[wiki] [sites] [dmenu][mouse-support]: add separate motion patch || NRK
commit 6b6a3370e0e2488e5dc5f862fceba9f9cff68b74
Author: NRK <nrk_AT_disroot.org>
Date: Sun Nov 20 16:50:27 2022 +0600
[dmenu][mouse-support]: add separate motion patch
also add a separate section for the motion patches so they are more
easily visible.
diff --git a/tools.suckless.org/dmenu/patches/mouse-support/dmenu-mousesupport-motion-5.2.diff b/tools.suckless.org/dmenu/patches/mouse-support/dmenu-mousesupport-motion-5.2.diff
new file mode 100644
index 00000000..ec15a72a
--- /dev/null
+++ b/tools.suckless.org/dmenu/patches/mouse-support/dmenu-mousesupport-motion-5.2.diff
_AT_@ -0,0 +1,64 @@
+diff --git a/dmenu.c b/dmenu.c
+index 48d4980..5363aa1 100644
+--- a/dmenu.c
++++ b/dmenu.c
+_AT_@ -641,6 +641,40 @@ buttonpress(XEvent *e)
+ }
+ }
+
++static void
++motionevent(XButtonEvent *ev)
++{
++ struct item *it, *psel = sel;
++
++ if (ev->window != win)
++ return;
++
++ if (lines > 0) { /* vertical list */
++ int y = bh;
++ for (it = curr; it && it != next; it = it->right) {
++ if (ev->y >= y && ev->y < (y + bh)) {
++ sel = it;
++ break;
++ }
++ y += bh;
++ }
++ } else if (matches) {
++ int x = inputw + promptw + TEXTW("<");
++ for (it = curr; it && it != next; it = it->right) {
++ int w = textw_clamp(it->text, mw - x - TEXTW(">"));
++ if (ev->x >= x && ev->x < (x + w)) {
++ sel = it;
++ break;
++ }
++ x += w;
++ }
++ }
++ if (psel != sel) {
++ calcoffsets();
++ drawmenu();
++ }
++}
++
+ static void
+ paste(void)
+ {
+_AT_@ -702,6 +736,9 @@ run(void)
+ case ButtonPress:
+ buttonpress(&ev);
+ break;
++ case MotionNotify:
++ motionevent(&ev.xbutton);
++ break;
+ case Expose:
+ if (ev.xexpose.count == 0)
+ drw_map(drw, win, 0, 0, mw, mh);
+_AT_@ -800,7 +837,7 @@ setup(void)
+ swa.override_redirect = True;
+ swa.background_pixel = scheme[SchemeNorm][ColBg].pixel;
+ swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask |
+- ButtonPressMask;
++ ButtonPressMask | PointerMotionMask;
+ 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
index 90f28a69..09626074 100644
--- a/tools.suckless.org/dmenu/patches/mouse-support/index.md
+++ b/tools.suckless.org/dmenu/patches/mouse-support/index.md
_AT_@ -21,6 +21,8 @@ Mouse actions supported:
* Scroll down:
* In horizontal mode: same as left-clicking on right arrow.
* In vertical mode: show items below.
+* Motion (needs motion-support patch):
+ * Selects the hovered item.
Download
--------
_AT_@ -31,6 +33,11 @@ Download
* [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)
+
+Motion Support
+--------------
+* [dmenu-mousesupport-motion-5.2.diff](dmenu-mousesupport-motion-5.2.diff)
+ (Applies on top of the original mouse-support patch).
* [dmenu-mousesupporthoverbgcol-20210123-1a13d04.diff](dmenu-mousesupporthoverbgcol-20210123-1a13d04.diff)
set selectbg color on hovered item.
* [dmenu-mousesupporthoverbgcol-5.0.diff](dmenu-mousesupporthoverbgcol-5.0.diff)
_AT_@ -44,3 +51,4 @@ Author
* Xarchus (for multisel support).
* prx (for selectbg color on hovered item)
* Nathan Sketch (for grid compatibility) - <sketchn98_AT_gmail.com>
+* NRK <nrk_AT_disroot.org> - Motion support for v5.2
Received on Sun Nov 20 2022 - 11:56:01 CET
This archive was generated by hypermail 2.3.0
: Sun Nov 20 2022 - 12:00:44 CET