1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
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);
|