[wiki] [sites] [dmenu][mouse-support]: add motion support || NRK

From: <git_AT_suckless.org>
Date: Sat, 19 Nov 2022 17:13:26 +0100

commit b28ae177223c4eba99b844562e103915c01cdb22
Author: NRK <nrk_AT_disroot.org>
Date: Sat Nov 19 21:30:22 2022 +0600

    [dmenu][mouse-support]: add motion support

diff --git a/tools.suckless.org/dmenu/patches/mouse-support/dmenu-mousesupport-5.2.diff b/tools.suckless.org/dmenu/patches/mouse-support/dmenu-mousesupport-5.2.diff
index eaacea42..bf071a0a 100644
--- a/tools.suckless.org/dmenu/patches/mouse-support/dmenu-mousesupport-5.2.diff
+++ b/tools.suckless.org/dmenu/patches/mouse-support/dmenu-mousesupport-5.2.diff
_AT_@ -1,8 +1,8 @@
 diff --git a/dmenu.c b/dmenu.c
-index 7cf253b..d276a94 100644
+index 27b7a30..c9bc84f 100644
 --- a/dmenu.c
 +++ b/dmenu.c
-_AT_@ -528,6 +528,119 @@ draw:
+_AT_@ -528,6 +528,151 @@ draw:
          drawmenu();
  }
  
_AT_@ -118,27 +118,62 @@ index 7cf253b..d276a94 100644
 + }
 + }
 +}
++
++static void
++motionevent(XButtonEvent *ev)
++{
++ struct item *it;
++
++ 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;
++ drawmenu();
++ break;
++ }
++ y += bh;
++ }
++ } else if (matches) {
++ int x = inputw + 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;
++ drawmenu();
++ break;
++ }
++ x += w;
++ }
++ }
++}
 +
  static void
  paste(void)
  {
-_AT_@ -582,6 +695,9 @@ run(void)
+_AT_@ -586,6 +731,12 @@ run(void)
                                  break;
                          cleanup();
                          exit(1);
 + 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_@ -679,7 +795,8 @@ setup(void)
+_AT_@ -683,7 +834,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;
++ 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..e035a578 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:
+ * Will select stuff.
 
 Download
 --------
_AT_@ -44,3 +46,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
Received on Sat Nov 19 2022 - 17:13:26 CET

This archive was generated by hypermail 2.3.0 : Sat Nov 19 2022 - 17:24:42 CET