tDo not select any entry when moving outside the window - xmenu - drop-down menu for X11
(HTM) git clone git://git.z3bra.org/xmenu.git
(DIR) Log
(DIR) Files
(DIR) Refs
---
(DIR) commit 72ba8a895a8f50ca3cd6ce21688683d3e421114c
(DIR) parent 3d49be3451b8f2caa0e1df5ad23af9791fb5a5b3
(HTM) Author: Willy Goiffon <dev@z3bra.org>
Date: Wed, 20 Nov 2019 08:37:03 +0100
Do not select any entry when moving outside the window
Diffstat:
M xmenu.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
---
(DIR) diff --git a/xmenu.c b/xmenu.c
t@@ -111,10 +111,10 @@ main(int argc, char *argv[])
val[0] = background;
val[1] = XCB_EVENT_MASK_EXPOSURE
| XCB_EVENT_MASK_KEY_PRESS
+ | XCB_EVENT_MASK_ENTER_WINDOW
| XCB_EVENT_MASK_LEAVE_WINDOW
| XCB_EVENT_MASK_BUTTON_PRESS
| XCB_EVENT_MASK_BUTTON_RELEASE
- | XCB_EVENT_MASK_BUTTON_MOTION
| XCB_EVENT_MASK_POINTER_MOTION
| XCB_EVENT_MASK_STRUCTURE_NOTIFY;
t@@ -166,6 +166,20 @@ main(int argc, char *argv[])
current = last = -1;
break;
case XCB_MOTION_NOTIFY:
+ /*
+ * in some special cases, MOTION events can be
+ * reported in the window when the pointer is
+ * actually outside. For example when pressing
+ * mouse button inside the window and the moving
+ * out while holding it.
+ * When don't want to select an entry in such
+ * cases, so we must check first that the pointer
+ * is actually inside the window
+ */
+ if (((xcb_motion_notify_event_t *)ev)->event_x > width
+ || ((xcb_motion_notify_event_t *)ev)->event_y > height)
+ break;
+
current = nent * (((xcb_motion_notify_event_t *)ev)->event_y * 1.0 / height);
hilight(wid, 0, (height/nent) * last, width, height/nent);
hilight(wid, 0, (height/nent) * current, width, height/nent);