sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

commit e9fdf2b08316ffd43e9b6cde071b8f1ff9ed63d4
parent 5fc328d488334f26b79c98fead86041bb6c1e616
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Sat, 29 Feb 2020 19:40:48 +0100

update dmenu mouse support patch

The 4.7 patch works fine, but applies with fuzzy offset matching.
This patch applies 100% clean to 4.9.

Update and reword some things on my page and add a gopherhole link.

Diffstat:
Msuckless.org/people/hiltjo/index.md | 11+++++++----
Atools.suckless.org/dmenu/patches/mouse-support/dmenu-mousesupport-4.9.diff | 144+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mtools.suckless.org/dmenu/patches/mouse-support/index.md | 1+
3 files changed, 152 insertions(+), 4 deletions(-)

diff --git a/suckless.org/people/hiltjo/index.md b/suckless.org/people/hiltjo/index.md @@ -3,9 +3,12 @@ hiltjo Greetings traveler, -I'm the maintainer of some suckless projects and have contributed some -patches to various suckless projects. +I'm the current maintainer of some suckless projects (dmenu, ii, st) and have +contributed patches to various suckless projects. -Some of my other projects are hosted at [2f30](https://git.2f30.org). +Website: <https://codemadness.org/>. +Gopherhole: <gopher://codemadness.org>. +Projects: <https://git.codemadness.org/>. -My (personal) projects are available at [codemadness](https://git.codemadness.org). +Some of my projects are mirrored at [2f30](https://git.2f30.org) and +[bitreich](gopher://bitreich.org/1/scm). diff --git a/tools.suckless.org/dmenu/patches/mouse-support/dmenu-mousesupport-4.9.diff b/tools.suckless.org/dmenu/patches/mouse-support/dmenu-mousesupport-4.9.diff @@ -0,0 +1,144 @@ +diff --git a/dmenu.c b/dmenu.c +index 6b8f51b..8c663a9 100644 +--- a/dmenu.c ++++ b/dmenu.c +@@ -500,6 +500,119 @@ draw: + drawmenu(); + } + ++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) + { +@@ -556,6 +669,9 @@ run(void) + if (XFilterEvent(&ev, None)) + continue; + switch(ev.type) { ++ case ButtonPress: ++ buttonpress(&ev); ++ break; + case Expose: + if (ev.xexpose.count == 0) + drw_map(drw, win, 0, 0, mw, mh); +@@ -653,7 +769,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); diff --git a/tools.suckless.org/dmenu/patches/mouse-support/index.md b/tools.suckless.org/dmenu/patches/mouse-support/index.md @@ -24,6 +24,7 @@ Mouse actions supported: Download -------- +* [dmenu-mousesupport-4.9.diff](dmenu-mousesupport-4.9.diff) * [dmenu-mousesupport-4.7.diff](dmenu-mousesupport-4.7.diff) * [dmenu-mousesupport-4.6.diff](dmenu-mousesupport-4.6.diff) * [dmenu-mousesupport-20160702-3c91eed.diff](dmenu-mousesupport-20160702-3c91eed.diff)