mirror of
https://github.com/mintycube/dmenu.git
synced 2024-10-22 14:05:48 +02:00
Adding configurable minimum width when using the center patch #1
This commit is contained in:
parent
9d3c424dea
commit
d7f418468d
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,3 +1,5 @@
|
|||||||
*.o
|
*.o
|
||||||
config.h
|
config.h
|
||||||
patches.h
|
patches.h
|
||||||
|
dmenu
|
||||||
|
stest
|
||||||
|
@ -13,6 +13,7 @@ static int instant = 0; /* -n option; if 1, selects matchin
|
|||||||
#endif // INSTANT_PATCH
|
#endif // INSTANT_PATCH
|
||||||
#if CENTER_PATCH
|
#if CENTER_PATCH
|
||||||
static int center = 1; /* -c option; if 0, dmenu won't be centered on the screen */
|
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
|
#endif // CENTER_PATCH
|
||||||
/* -fn option overrides fonts[0]; default X11 font or font set */
|
/* -fn option overrides fonts[0]; default X11 font or font set */
|
||||||
static const char *fonts[] = {
|
static const char *fonts[] = {
|
||||||
|
12
dmenu.c
12
dmenu.c
@ -880,8 +880,7 @@ setup(void)
|
|||||||
lines = MAX(lines, 0);
|
lines = MAX(lines, 0);
|
||||||
mh = (lines + 1) * bh;
|
mh = (lines + 1) * bh;
|
||||||
#if CENTER_PATCH
|
#if CENTER_PATCH
|
||||||
if (center)
|
promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0;
|
||||||
promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0;
|
|
||||||
#endif // CENTER_PATCH
|
#endif // CENTER_PATCH
|
||||||
#ifdef XINERAMA
|
#ifdef XINERAMA
|
||||||
i = 0;
|
i = 0;
|
||||||
@ -911,7 +910,7 @@ setup(void)
|
|||||||
|
|
||||||
#if CENTER_PATCH
|
#if CENTER_PATCH
|
||||||
if (center) {
|
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);
|
x = info[i].x_org + ((info[i].width - mw) / 2);
|
||||||
y = info[i].y_org + ((info[i].height - mh) / 2);
|
y = info[i].y_org + ((info[i].height - mh) / 2);
|
||||||
} else {
|
} else {
|
||||||
@ -943,7 +942,7 @@ setup(void)
|
|||||||
parentwin);
|
parentwin);
|
||||||
#if CENTER_PATCH
|
#if CENTER_PATCH
|
||||||
if (center) {
|
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;
|
x = (wa.width - mw) / 2;
|
||||||
y = (wa.height - mh) / 2;
|
y = (wa.height - mh) / 2;
|
||||||
} else {
|
} else {
|
||||||
@ -967,9 +966,8 @@ setup(void)
|
|||||||
mw = wa.width;
|
mw = wa.width;
|
||||||
#endif // CENTER_PATCH / XYW_PATCH
|
#endif // CENTER_PATCH / XYW_PATCH
|
||||||
}
|
}
|
||||||
#if CENTER_PATCH
|
#if !CENTER_PATCH
|
||||||
if (!center)
|
promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0;
|
||||||
promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0;
|
|
||||||
#endif // CENTER_PATCH
|
#endif // CENTER_PATCH
|
||||||
inputw = MIN(inputw, mw/3);
|
inputw = MIN(inputw, mw/3);
|
||||||
match();
|
match();
|
||||||
|
Loading…
Reference in New Issue
Block a user