tImprove behavior when root window is grabbed - xmenu - drop-down menu for X11
HTML git clone git://git.z3bra.org/xmenu.git
DIR Log
DIR Files
DIR Refs
---
DIR commit 2887ba0d41f031f54f256aa5adbfacaa421ab2a4
DIR parent bf59d1b7d425a118abedc02bd29fd04a55460bfd
HTML Author: Willy Goiffon <dev@z3bra.org>
Date: Sat, 23 Nov 2019 11:36:10 +0100
Improve behavior when root window is grabbed
* only respond to a single mouse button (hardcoded)
* clear selection when moving outside the menu
Diffstat:
M config.def.h | 4 ++++
M xmenu.c | 13 ++++++++++---
2 files changed, 14 insertions(+), 3 deletions(-)
---
DIR diff --git a/config.def.h b/config.def.h
t@@ -4,3 +4,7 @@ uint32_t foreground = 0xc1eafe;
/* font used for entries */
char *font = "monospace:pixelsize=16";
+
+/* mouse buttons to react to when using the menu */
+int mousebutton = XCB_BUTTON_INDEX_1;
+
DIR diff --git a/xmenu.c b/xmenu.c
t@@ -138,6 +138,8 @@ eventloop()
* only to avoid popup loops
*/
case XCB_BUTTON_PRESS:
+ if (((xcb_button_press_event_t *)ev)->detail != mousebutton)
+ break;
menu.x = ((xcb_button_press_event_t *)ev)->root_x;
menu.y = ((xcb_button_press_event_t *)ev)->root_y;
popwindow(menu.x, menu.y, menu.w, menu.h);
t@@ -149,8 +151,9 @@ eventloop()
* it validates the current selection (if any)
*/
case XCB_BUTTON_RELEASE:
- return 0;
- break; /* NOTREACHED */
+ if (((xcb_button_press_event_t *)ev)->detail == mousebutton)
+ return 0;
+ break;
/*
* make sure to keep track of window geometry changes
t@@ -213,8 +216,12 @@ eventloop()
if (e->root_x > menu.x + menu.w
|| e->root_y > menu.y + menu.h
|| e->root_x < menu.x
- || e->root_y < menu.y)
+ || e->root_y < menu.y) {
+ if (current >= 0)
+ hilight(wid, 0, (menu.h/nent) * current, menu.w, menu.h/nent);
+ current = -1;
break;
+ }
current = nent * ((e->root_y - menu.y) * 1.0 / menu.h);