From f4f873aaceddb2cb256124da169f19096fe9c960 Mon Sep 17 00:00:00 2001 From: Valentin Gehrke Date: Tue, 1 Sep 2015 18:42:07 +0200 Subject: [PATCH] dmenu2 centered patch --- patches/dmenu2-centered.patch | 47 +++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 patches/dmenu2-centered.patch diff --git a/patches/dmenu2-centered.patch b/patches/dmenu2-centered.patch new file mode 100644 index 0000000..30d871a --- /dev/null +++ b/patches/dmenu2-centered.patch @@ -0,0 +1,47 @@ +--- src/dmenu2-0.2/dmenu.c 2013-11-26 09:15:04.000000000 +0100 ++++ dmenu_patched.c 2015-03-22 16:52:28.983695802 +0100 +@@ -77,6 +77,8 @@ + static Bool filter = False; + static Bool maskin = False; + static Bool noinput = False; ++static Bool centered_horiz = False; ++static Bool centered_vert = False; + static int ret = 0; + static Bool quiet = False; + static DC *dc; +@@ -108,6 +110,14 @@ + } + else if(!strcmp(argv[i], "-b")) /* appears at the bottom of the screen */ + topbar = False; ++ else if(!strcmp(argv[i], "-c")) { ++ centered_horiz = True; ++ centered_vert = True; ++ } ++ else if(!strcmp(argv[i], "-ch")) ++ centered_horiz = True; ++ else if(!strcmp(argv[i], "-cv")) ++ centered_vert = True; + else if(!strcmp(argv[i], "-q")) + quiet = True; + else if(!strcmp(argv[i], "-f")) /* grabs keyboard before reading stdin */ +@@ -879,7 +889,10 @@ + promptw = (prompt && *prompt) ? textw(dc, prompt) : 0; + inputw = MIN(inputw, mw/3); + match(); +- ++ ++ if(centered_horiz) x = (dimx + dimw/2 - mw/2); ++ if(centered_vert) y = (dimy + dimh/2 - mh/2); ++ + swa.override_redirect = True; + + /* create dim window */ +@@ -930,7 +943,7 @@ + + void + usage(void) { +- fputs("usage: dmenu [-b] [-q] [-f] [-r] [-i] [-z] [-t] [-mask] [-noinput]\n" ++ fputs("usage: dmenu [-b] [-c] [-ch] [-cv] [-q] [-f] [-r] [-i] [-z] [-t] [-mask] [-noinput]\n" + " [-s screen] [-name name] [-class class] [ -o opacity]\n" + " [-dim opcity] [-dc color] [-l lines] [-p prompt] [-fn font]\n" + " [-x xoffset] [-y yoffset] [-h height] [-w width]\n"