diff options
| author | Shubham Saini <shubham6405@gmail.com> | 2020-05-16 17:43:31 +0000 | 
|---|---|---|
| committer | Shubham Saini <shubham6405@gmail.com> | 2020-05-16 17:43:31 +0000 | 
| commit | 16d45c32c20d7b3db8ba2533ca9d414d8cd308f2 (patch) | |
| tree | f829957546b740e6897eba24c8f49bb4c170044e /dmenu/patches | |
gone full suckless
Diffstat (limited to 'dmenu/patches')
| -rw-r--r-- | dmenu/patches/dmenu-center-4.8.diff | 56 | 
1 files changed, 56 insertions, 0 deletions
diff --git a/dmenu/patches/dmenu-center-4.8.diff b/dmenu/patches/dmenu-center-4.8.diff new file mode 100644 index 0000000..a970fcb --- /dev/null +++ b/dmenu/patches/dmenu-center-4.8.diff  | |||
| @@ -0,0 +1,56 @@ | |||
| 1 | diff --git a/dmenu.c b/dmenu.c | ||
| 2 | index 5e9c367..2268ea9 100644 | ||
| 3 | --- a/dmenu.c | ||
| 4 | +++ b/dmenu.c | ||
| 5 | @@ -88,6 +88,15 @@ calcoffsets(void) | ||
| 6 | break; | ||
| 7 | } | ||
| 8 | |||
| 9 | +static int | ||
| 10 | +max_textw(void) | ||
| 11 | +{ | ||
| 12 | + int len = 0; | ||
| 13 | + for (struct item *item = items; item && item->text; item++) | ||
| 14 | + len = MAX(TEXTW(item->text), len); | ||
| 15 | + return len; | ||
| 16 | +} | ||
| 17 | + | ||
| 18 | static void | ||
| 19 | cleanup(void) | ||
| 20 | { | ||
| 21 | @@ -598,6 +607,7 @@ setup(void) | ||
| 22 | bh = drw->fonts->h + 2; | ||
| 23 | lines = MAX(lines, 0); | ||
| 24 | mh = (lines + 1) * bh; | ||
| 25 | + promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0; | ||
| 26 | #ifdef XINERAMA | ||
| 27 | i = 0; | ||
| 28 | if (parentwin == root && (info = XineramaQueryScreens(dpy, &n))) { | ||
| 29 | @@ -624,9 +634,9 @@ setup(void) | ||
| 30 | if (INTERSECT(x, y, 1, 1, info[i])) | ||
| 31 | break; | ||
| 32 | |||
| 33 | - x = info[i].x_org; | ||
| 34 | - y = info[i].y_org + (topbar ? 0 : info[i].height - mh); | ||
| 35 | - mw = info[i].width; | ||
| 36 | + mw = MIN(MAX(max_textw() + promptw, 100), info[i].width); | ||
| 37 | + x = info[i].x_org + ((info[i].width - mw) / 2); | ||
| 38 | + y = info[i].y_org + ((info[i].height - mh) / 2); | ||
| 39 | XFree(info); | ||
| 40 | } else | ||
| 41 | #endif | ||
| 42 | @@ -634,11 +644,10 @@ setup(void) | ||
| 43 | if (!XGetWindowAttributes(dpy, parentwin, &wa)) | ||
| 44 | die("could not get embedding window attributes: 0x%lx", | ||
| 45 | parentwin); | ||
| 46 | - x = 0; | ||
| 47 | - y = topbar ? 0 : wa.height - mh; | ||
| 48 | - mw = wa.width; | ||
| 49 | + mw = MIN(MAX(max_textw() + promptw, 100), wa.width); | ||
| 50 | + x = (wa.width - mw) / 2; | ||
| 51 | + y = (wa.height - mh) / 2; | ||
| 52 | } | ||
| 53 | - promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0; | ||
| 54 | inputw = MIN(inputw, mw/3); | ||
| 55 | match(); | ||
| 56 | |||
