[wiki] [sites] [dmenu][mouse-support]: fix bug and update description || NRK
commit a14388cffa89b04540bab8dbee80a5dbc9347d53
Author: NRK <nrk_AT_disroot.org>
Date: Sun Nov 20 02:29:56 2022 +0600
[dmenu][mouse-support]: fix bug and update description
Looks like I unknowningly reinvented the "hover-bg" version of the
patch. I hadn't noticed it since it was at the bottom of the list where
outdated patches typically are.
Looking at the "hover-bg" variant revealed a bug in the new patch where
promptw wasn't being accounted for.
But in any case, doesn't seem like there's any reason to have two
separate versions. If there are some reason for the separation then feel
free to pull the motionevent() into a separate diff.
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 bf071a0a..ee52488b 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 27b7a30..c9bc84f 100644
+index 27b7a30..5363aa1 100644
--- a/dmenu.c
+++ b/dmenu.c
-_AT_@ -528,6 +528,151 @@ draw:
+_AT_@ -528,6 +528,153 @@ draw:
drawmenu();
}
_AT_@ -122,7 +122,7 @@ index 27b7a30..c9bc84f 100644
+static void
+motionevent(XButtonEvent *ev)
+{
-+ struct item *it;
++ struct item *it, *psel = sel;
+
+ if (ev->window != win)
+ return;
_AT_@ -132,29 +132,31 @@ index 27b7a30..c9bc84f 100644
+ 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("<");
++ 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;
-+ drawmenu();
+ break;
+ }
+ x += w;
+ }
+ }
++ if (psel != sel) {
++ calcoffsets();
++ drawmenu();
++ }
+}
+
static void
paste(void)
{
-_AT_@ -586,6 +731,12 @@ run(void)
+_AT_@ -586,6 +733,12 @@ run(void)
break;
cleanup();
exit(1);
_AT_@ -167,7 +169,7 @@ index 27b7a30..c9bc84f 100644
case Expose:
if (ev.xexpose.count == 0)
drw_map(drw, win, 0, 0, mw, mh);
-_AT_@ -683,7 +834,8 @@ setup(void)
+_AT_@ -683,7 +836,8 @@ setup(void)
/* create menu window */
swa.override_redirect = True;
swa.background_pixel = scheme[SchemeNorm][ColBg].pixel;
diff --git a/tools.suckless.org/dmenu/patches/mouse-support/index.md b/tools.suckless.org/dmenu/patches/mouse-support/index.md
index e035a578..645a5bcf 100644
--- a/tools.suckless.org/dmenu/patches/mouse-support/index.md
+++ b/tools.suckless.org/dmenu/patches/mouse-support/index.md
_AT_@ -22,7 +22,7 @@ Mouse actions supported:
* In horizontal mode: same as left-clicking on right arrow.
* In vertical mode: show items below.
* Motion:
- * Will select stuff.
+ * Will select the hovered item.
Download
--------
Received on Sat Nov 19 2022 - 21:36:10 CET
This archive was generated by hypermail 2.3.0
: Sat Nov 19 2022 - 21:36:45 CET