Adding configurable minimum width when using the center patch #1

This commit is contained in:
bakkeby 2020-01-27 09:43:10 +01:00
parent 9d3c424dea
commit d7f418468d
3 changed files with 8 additions and 7 deletions

2
.gitignore vendored
View File

@ -1,3 +1,5 @@
*.o
config.h
patches.h
dmenu
stest

View File

@ -13,6 +13,7 @@ static int instant = 0; /* -n option; if 1, selects matchin
#endif // INSTANT_PATCH
#if CENTER_PATCH
static int center = 1; /* -c option; if 0, dmenu won't be centered on the screen */
static int min_width = 500; /* minimum width when centered */
#endif // CENTER_PATCH
/* -fn option overrides fonts[0]; default X11 font or font set */
static const char *fonts[] = {

View File

@ -880,7 +880,6 @@ setup(void)
lines = MAX(lines, 0);
mh = (lines + 1) * bh;
#if CENTER_PATCH
if (center)
promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0;
#endif // CENTER_PATCH
#ifdef XINERAMA
@ -911,7 +910,7 @@ setup(void)
#if CENTER_PATCH
if (center) {
mw = MIN(MAX(max_textw() + promptw, 100), info[i].width);
mw = MIN(MAX(max_textw() + promptw, min_width), info[i].width);
x = info[i].x_org + ((info[i].width - mw) / 2);
y = info[i].y_org + ((info[i].height - mh) / 2);
} else {
@ -943,7 +942,7 @@ setup(void)
parentwin);
#if CENTER_PATCH
if (center) {
mw = MIN(MAX(max_textw() + promptw, 100), wa.width);
mw = MIN(MAX(max_textw() + promptw, min_width), wa.width);
x = (wa.width - mw) / 2;
y = (wa.height - mh) / 2;
} else {
@ -967,8 +966,7 @@ setup(void)
mw = wa.width;
#endif // CENTER_PATCH / XYW_PATCH
}
#if CENTER_PATCH
if (!center)
#if !CENTER_PATCH
promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0;
#endif // CENTER_PATCH
inputw = MIN(inputw, mw/3);