neodotfiles/source/dmenu/patches/dmenu-mousesupport-motion-5.2.diff

54 lines
1.3 KiB
Diff
Raw Normal View History

2024-03-28 21:40:01 +00:00
diff --git a/dmenu.c b/dmenu.c
index 48d4980..7677401 100644
--- a/dmenu.c
+++ b/dmenu.c
@@ -641,6 +641,29 @@ buttonpress(XEvent *e)
}
}
+static void
+motionevent(XButtonEvent *ev)
+{
+ struct item *it;
+ int xy, ev_xy;
+
+ if (ev->window != win || matches == 0)
+ return;
+
+ xy = lines > 0 ? bh : inputw + promptw + TEXTW("<");
+ ev_xy = lines > 0 ? ev->y : ev->x;
+ for (it = curr; it && it != next; it = it->right) {
+ int wh = lines > 0 ? bh : textw_clamp(it->text, mw - xy - TEXTW(">"));
+ if (ev_xy >= xy && ev_xy < (xy + wh)) {
+ sel = it;
+ calcoffsets();
+ drawmenu();
+ break;
+ }
+ xy += wh;
+ }
+}
+
static void
paste(void)
{
@@ -702,6 +725,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);
@@ -800,7 +826,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);