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