diff options
author | Manuel Palenzuela <manuelpalenzuelamerino@gmail.com> | 2019-06-11 21:45:59 +0200 |
---|---|---|
committer | Manuel Palenzuela <manuelpalenzuelamerino@gmail.com> | 2019-06-11 21:45:59 +0200 |
commit | 6c00acacf99fed5a4cef1e274dcf1080f3683bb6 (patch) | |
tree | fbf32ba48418d9d47345593c2eb169a2b04e7a31 | |
parent | First compile (diff) | |
download | dmenu-6c00acacf99fed5a4cef1e274dcf1080f3683bb6.tar.gz dmenu-6c00acacf99fed5a4cef1e274dcf1080f3683bb6.tar.bz2 dmenu-6c00acacf99fed5a4cef1e274dcf1080f3683bb6.zip |
Added patch list
-rw-r--r-- | patches/dmenu-lineheight-4.9.diff | 94 | ||||
-rw-r--r-- | patches/dmenu-mousesupport-4.7.diff | 156 | ||||
-rw-r--r-- | patches/dmenu-prefixcompletion-flag-4.9.diff | 133 |
3 files changed, 383 insertions, 0 deletions
diff --git a/patches/dmenu-lineheight-4.9.diff b/patches/dmenu-lineheight-4.9.diff new file mode 100644 index 0000000..d12c77a --- /dev/null +++ b/patches/dmenu-lineheight-4.9.diff @@ -0,0 +1,94 @@ +From 87f92a561c31246f6f9effc0e89ef92677c87746 Mon Sep 17 00:00:00 2001 +From: astier <aleksandrs.stier@uni-bielefeld.de> +Date: Wed, 27 Feb 2019 21:44:55 +0100 +Subject: [PATCH] Add an option which defines the lineheight + +Despite both the panel and dmenu using the same font (a Terminus 12), +dmenu is shorter and the panel is visible from under the dmenu bar. +The appearance can be even more distracting when using similar colors +for background and selections. With the option added by this patch, +dmenu can be launched with a '-h 24', thus completely covering the panel. +--- + config.def.h | 1 + + dmenu.1 | 3 +++ + dmenu.c | 10 ++++++++-- + 3 files changed, 12 insertions(+), 2 deletions(-) + +diff --git a/config.def.h b/config.def.h +index 1edb647..317fa2f 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -15,6 +15,7 @@ static const char *colors[SchemeLast][2] = { + }; + /* -l option; if nonzero, dmenu uses vertical list with given number of lines */ + static unsigned int lines = 0; ++static unsigned int lineheight = 0; /* -h option; minimum height of a menu line */ + + /* + * Characters not considered part of a word while deleting words +diff --git a/dmenu.1 b/dmenu.1 +index 323f93c..7ef34d2 100644 +--- a/dmenu.1 ++++ b/dmenu.1 +@@ -50,6 +50,9 @@ dmenu matches menu items case insensitively. + .BI \-l " lines" + dmenu lists items vertically, with the given number of lines. + .TP ++.BI \-h " height" ++dmenu uses a menu line of at least 'height' pixels tall, but no less than 8. ++.TP + .BI \-m " monitor" + dmenu is displayed on the monitor number supplied. Monitor numbers are starting + from 0. +diff --git a/dmenu.c b/dmenu.c +index 6b8f51b..45d1946 100644 +--- a/dmenu.c ++++ b/dmenu.c +@@ -131,7 +131,7 @@ drawmenu(void) + { + unsigned int curpos; + struct item *item; +- int x = 0, y = 0, w; ++ int x = 0, y = 0, fh = drw->fonts->h, w; + + drw_setscheme(drw, scheme[SchemeNorm]); + drw_rect(drw, 0, 0, mw, mh, 1, 1); +@@ -148,7 +148,7 @@ drawmenu(void) + curpos = TEXTW(text) - TEXTW(&text[cursor]); + if ((curpos += lrpad / 2 - 1) < w) { + drw_setscheme(drw, scheme[SchemeNorm]); +- drw_rect(drw, x + curpos, 2, 2, bh - 4, 1, 0); ++ drw_rect(drw, x + curpos, 2 + (bh-fh)/2, 2, fh - 4, 1, 0); + } + + if (lines > 0) { +@@ -604,6 +604,7 @@ setup(void) + + /* calculate menu geometry */ + bh = drw->fonts->h + 2; ++ bh = MAX(bh,lineheight); /* make a menu line AT LEAST 'lineheight' tall */ + lines = MAX(lines, 0); + mh = (lines + 1) * bh; + #ifdef XINERAMA +@@ -683,6 +684,7 @@ static void + usage(void) + { + fputs("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n" ++ " [-h height]\n" + " [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]\n", stderr); + exit(1); + } +@@ -716,6 +718,10 @@ main(int argc, char *argv[]) + prompt = argv[++i]; + else if (!strcmp(argv[i], "-fn")) /* font or font set */ + fonts[0] = argv[++i]; ++ else if(!strcmp(argv[i], "-h")) { /* minimum height of one menu line */ ++ lineheight = atoi(argv[++i]); ++ lineheight = MAX(lineheight,8); /* reasonable default in case of value too small/negative */ ++ } + else if (!strcmp(argv[i], "-nb")) /* normal background color */ + colors[SchemeNorm][ColBg] = argv[++i]; + else if (!strcmp(argv[i], "-nf")) /* normal foreground color */ +-- +2.21.0 + diff --git a/patches/dmenu-mousesupport-4.7.diff b/patches/dmenu-mousesupport-4.7.diff new file mode 100644 index 0000000..b72bd86 --- /dev/null +++ b/patches/dmenu-mousesupport-4.7.diff @@ -0,0 +1,156 @@ +From 27f62488ceb466f73f682f5104825c60712bb5ff Mon Sep 17 00:00:00 2001 +From: Hiltjo Posthuma <hiltjo@codemadness.org> +Date: Fri, 9 Jun 2017 13:00:06 +0200 +Subject: [PATCH] dmenu mouse support + +--- + dmenu.c | 119 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- + 1 file changed, 118 insertions(+), 1 deletion(-) + +diff --git a/dmenu.c b/dmenu.c +index d605ab4..0c8500b 100644 +--- a/dmenu.c ++++ b/dmenu.c +@@ -459,6 +459,119 @@ keypress(XKeyEvent *ev) + } + + static void ++buttonpress(XEvent *e) ++{ ++ struct item *item; ++ XButtonPressedEvent *ev = &e->xbutton; ++ int x = 0, y = 0, h = bh, w; ++ ++ if (ev->window != win) ++ return; ++ ++ /* right-click: exit */ ++ if (ev->button == Button3) ++ exit(1); ++ ++ if (prompt && *prompt) ++ x += promptw; ++ ++ /* input field */ ++ w = (lines > 0 || !matches) ? mw - x : inputw; ++ ++ /* left-click on input: clear input, ++ * NOTE: if there is no left-arrow the space for < is reserved so ++ * add that to the input width */ ++ if (ev->button == Button1 && ++ ((lines <= 0 && ev->x >= 0 && ev->x <= x + w + ++ ((!prev || !curr->left) ? TEXTW("<") : 0)) || ++ (lines > 0 && ev->y >= y && ev->y <= y + h))) { ++ insert(NULL, -cursor); ++ drawmenu(); ++ return; ++ } ++ /* middle-mouse click: paste selection */ ++ if (ev->button == Button2) { ++ XConvertSelection(dpy, (ev->state & ShiftMask) ? clip : XA_PRIMARY, ++ utf8, utf8, win, CurrentTime); ++ drawmenu(); ++ return; ++ } ++ /* scroll up */ ++ if (ev->button == Button4 && prev) { ++ sel = curr = prev; ++ calcoffsets(); ++ drawmenu(); ++ return; ++ } ++ /* scroll down */ ++ if (ev->button == Button5 && next) { ++ sel = curr = next; ++ calcoffsets(); ++ drawmenu(); ++ return; ++ } ++ if (ev->button != Button1) ++ return; ++ if (ev->state & ~ControlMask) ++ return; ++ if (lines > 0) { ++ /* vertical list: (ctrl)left-click on item */ ++ w = mw - x; ++ for (item = curr; item != next; item = item->right) { ++ y += h; ++ if (ev->y >= y && ev->y <= (y + h)) { ++ puts(item->text); ++ if (!(ev->state & ControlMask)) ++ exit(0); ++ sel = item; ++ if (sel) { ++ sel->out = 1; ++ drawmenu(); ++ } ++ return; ++ } ++ } ++ } else if (matches) { ++ /* left-click on left arrow */ ++ x += inputw; ++ w = TEXTW("<"); ++ if (prev && curr->left) { ++ if (ev->x >= x && ev->x <= x + w) { ++ sel = curr = prev; ++ calcoffsets(); ++ drawmenu(); ++ return; ++ } ++ } ++ /* horizontal list: (ctrl)left-click on item */ ++ for (item = curr; item != next; item = item->right) { ++ x += w; ++ w = MIN(TEXTW(item->text), mw - x - TEXTW(">")); ++ if (ev->x >= x && ev->x <= x + w) { ++ puts(item->text); ++ if (!(ev->state & ControlMask)) ++ exit(0); ++ sel = item; ++ if (sel) { ++ sel->out = 1; ++ drawmenu(); ++ } ++ return; ++ } ++ } ++ /* left-click on right arrow */ ++ w = TEXTW(">"); ++ x = mw - w; ++ if (next && ev->x >= x && ev->x <= x + w) { ++ sel = curr = next; ++ calcoffsets(); ++ drawmenu(); ++ return; ++ } ++ } ++} ++ ++static void + paste(void) + { + char *p, *q; +@@ -512,6 +625,9 @@ run(void) + if (XFilterEvent(&ev, win)) + continue; + switch(ev.type) { ++ case ButtonPress: ++ buttonpress(&ev); ++ break; + case Expose: + if (ev.xexpose.count == 0) + drw_map(drw, win, 0, 0, mw, mh); +@@ -609,7 +725,8 @@ setup(void) + /* create menu window */ + swa.override_redirect = True; + swa.background_pixel = scheme[SchemeNorm][ColBg].pixel; +- swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask; ++ swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask | ++ ButtonPressMask; + win = XCreateWindow(dpy, parentwin, x, y, mw, mh, 0, + CopyFromParent, CopyFromParent, CopyFromParent, + CWOverrideRedirect | CWBackPixel | CWEventMask, &swa); +-- +2.12.2 + diff --git a/patches/dmenu-prefixcompletion-flag-4.9.diff b/patches/dmenu-prefixcompletion-flag-4.9.diff new file mode 100644 index 0000000..45c3b29 --- /dev/null +++ b/patches/dmenu-prefixcompletion-flag-4.9.diff @@ -0,0 +1,133 @@ +diff --git i/config.def.h w/config.def.h +index 1edb647..5d312d2 100644 +--- i/config.def.h ++++ w/config.def.h +@@ -21,3 +21,8 @@ static unsigned int lines = 0; + * for example: " /?\"&[]" + */ + static const char worddelimiters[] = " "; ++ ++/* ++ * Use prefix matching by default; can be inverted with the -x flag. ++ */ ++static int use_prefix = 1; +diff --git i/dmenu.1 w/dmenu.1 +index 323f93c..429fdfa 100644 +--- i/dmenu.1 ++++ w/dmenu.1 +@@ -3,7 +3,7 @@ + dmenu \- dynamic menu + .SH SYNOPSIS + .B dmenu +-.RB [ \-bfiv ] ++.RB [ \-bfivx ] + .RB [ \-l + .IR lines ] + .RB [ \-m +@@ -78,6 +78,9 @@ defines the selected foreground color. + .B \-v + prints version information to stdout, then exits. + .TP ++.B \-x ++Invert prefix matching setting. ++.TP + .BI \-w " windowid" + embed into windowid. + .SH USAGE +diff --git i/dmenu.c w/dmenu.c +index 6b8f51b..3cef454 100644 +--- i/dmenu.c ++++ w/dmenu.c +@@ -228,8 +228,13 @@ match(void) + die("cannot realloc %u bytes:", tokn * sizeof *tokv); + len = tokc ? strlen(tokv[0]) : 0; + +- matches = lprefix = lsubstr = matchend = prefixend = substrend = NULL; +- textsize = strlen(text) + 1; ++ if (use_prefix) { ++ matches = lprefix = matchend = prefixend = NULL; ++ textsize = strlen(text); ++ } else { ++ matches = lprefix = lsubstr = matchend = prefixend = substrend = NULL; ++ textsize = strlen(text) + 1; ++ } + for (item = items; item && item->text; item++) { + for (i = 0; i < tokc; i++) + if (!fstrstr(item->text, tokv[i])) +@@ -241,7 +246,7 @@ match(void) + appenditem(item, &matches, &matchend); + else if (!fstrncmp(tokv[0], item->text, len)) + appenditem(item, &lprefix, &prefixend); +- else ++ else if (!use_prefix) + appenditem(item, &lsubstr, &substrend); + } + if (lprefix) { +@@ -252,7 +257,7 @@ match(void) + matches = lprefix; + matchend = prefixend; + } +- if (lsubstr) { ++ if (!use_prefix && lsubstr) { + if (matches) { + matchend->right = lsubstr; + lsubstr->left = matchend; +@@ -260,6 +265,7 @@ match(void) + matches = lsubstr; + matchend = substrend; + } ++ + curr = sel = matches; + calcoffsets(); + } +@@ -309,6 +315,7 @@ keypress(XKeyEvent *ev) + { + char buf[32]; + int len; ++ struct item * item; + KeySym ksym; + Status status; + +@@ -487,12 +494,17 @@ insert: + } + break; + case XK_Tab: +- if (!sel) +- return; +- strncpy(text, sel->text, sizeof text - 1); ++ if (!matches) break; /* cannot complete no matches */ ++ strncpy(text, matches->text, sizeof text - 1); + text[sizeof text - 1] = '\0'; +- cursor = strlen(text); +- match(); ++ len = cursor = strlen(text); /* length of longest common prefix */ ++ for (item = matches; item && item->text; item = item->right) { ++ cursor = 0; ++ while (cursor < len && text[cursor] == item->text[cursor]) ++ cursor++; ++ len = cursor; ++ } ++ memset(text + len, '\0', strlen(text) - len); + break; + } + +@@ -682,7 +694,7 @@ setup(void) + static void + usage(void) + { +- fputs("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n" ++ fputs("usage: dmenu [-bfivx] [-l lines] [-p prompt] [-fn font] [-m monitor]\n" + " [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]\n", stderr); + exit(1); + } +@@ -705,7 +717,9 @@ main(int argc, char *argv[]) + else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */ + fstrncmp = strncasecmp; + fstrstr = cistrstr; +- } else if (i + 1 == argc) ++ } else if (!strcmp(argv[i], "-x")) /* invert use_prefix */ ++ use_prefix = !use_prefix; ++ else if (i + 1 == argc) + usage(); + /* these options take one argument */ + else if (!strcmp(argv[i], "-l")) /* number of lines in vertical list */ |