update dmenu mouse support patch for 5.4 - sites - public wiki contents of suckless.org
 (HTM) git clone git://git.suckless.org/sites
 (DIR) Log
 (DIR) Files
 (DIR) Refs
       ---
 (DIR) commit 377c735e752c1f9a9807d939da685000d04a8f78
 (DIR) parent efff9c914169f78cce6c0ff8e32ae555fa56343a
 (HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
       Date:   Sat,  9 Aug 2025 15:34:50 +0200
       
       update dmenu mouse support patch for 5.4
       
       Note that almost nothing changed in dmenu.c from 5.3 to 5.4, so the 5.3 patch
       also applied cleanly.
       
       Diffstat:
         A tools.suckless.org/dmenu/patches/m… |     145 +++++++++++++++++++++++++++++++
         M tools.suckless.org/dmenu/patches/m… |       1 +
       
       2 files changed, 146 insertions(+), 0 deletions(-)
       ---
 (DIR) diff --git a/tools.suckless.org/dmenu/patches/mouse-support/dmenu-mousesupport-5.4.diff b/tools.suckless.org/dmenu/patches/mouse-support/dmenu-mousesupport-5.4.diff
       @@ -0,0 +1,145 @@
       +diff --git a/dmenu.c b/dmenu.c
       +index fd49549..5d0891a 100644
       +--- a/dmenu.c
       ++++ b/dmenu.c
       +@@ -527,6 +527,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)
       + {
       +@@ -586,6 +699,9 @@ run(void)
       +                                 break;
       +                         cleanup();
       +                         exit(1);
       ++                case ButtonPress:
       ++                        buttonpress(&ev);
       ++                        break;
       +                 case Expose:
       +                         if (ev.xexpose.count == 0)
       +                                 drw_map(drw, win, 0, 0, mw, mh);
       +@@ -683,7 +799,9 @@ 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, root, x, y, mw, mh, 0,
       +                             CopyFromParent, CopyFromParent, CopyFromParent,
       +                             CWOverrideRedirect | CWBackPixel | CWEventMask, &swa);
 (DIR) diff --git a/tools.suckless.org/dmenu/patches/mouse-support/index.md b/tools.suckless.org/dmenu/patches/mouse-support/index.md
       @@ -26,6 +26,7 @@ Mouse actions supported:
        
        Download
        --------
       +* [dmenu-mousesupport-5.4.diff](dmenu-mousesupport-5.4.diff)
        * [dmenu-mousesupport-5.3.diff](dmenu-mousesupport-5.3.diff)
        * [dmenu-mousesupport-5.2.diff](dmenu-mousesupport-5.2.diff)
        * [dmenu-mousesupport-5.1.diff](dmenu-mousesupport-5.1.diff)