Fix findMenu: check brother menus and dock menus
The root menu uses a 'brother' copy for the live instance. findMenu was only checking the original, not the brother, so it returned NULL when the pointer was over the active menu copy. This caused the menu to close immediately on button release (closeCascade triggered by !smenu condition).
This commit is contained in:
parent
f2dfe4a4d0
commit
0dc38e4d79
46
src/menu.c
46
src/menu.c
|
|
@ -1117,39 +1117,35 @@ static WMenu *findMenu(WScreen * scr, int *x_ret, int *y_ret)
|
|||
|
||||
wm_backend->pointer_get_position(&x, &y);
|
||||
|
||||
/* Check root menu and its cascades */
|
||||
/* Helper: check if (x,y) is inside a mapped menu */
|
||||
#define CHECK_MENU(m) do { \
|
||||
if ((m) && (m)->flags.mapped && \
|
||||
x >= (m)->frame_x && x < (m)->frame_x + MENUW(m) && \
|
||||
y >= (m)->frame_y && y < (m)->frame_y + MENUH(m)) { \
|
||||
*x_ret = x - (m)->frame_x; \
|
||||
*y_ret = y - (m)->frame_y; \
|
||||
return (m); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
/* Check root menu, its brother, and cascades */
|
||||
menu = scr->root_menu;
|
||||
if (menu && menu->flags.mapped) {
|
||||
if (x >= menu->frame_x && x < menu->frame_x + MENUW(menu) &&
|
||||
y >= menu->frame_y && y < menu->frame_y + MENUH(menu)) {
|
||||
*x_ret = x - menu->frame_x;
|
||||
*y_ret = y - menu->frame_y;
|
||||
return menu;
|
||||
}
|
||||
/* Check cascades */
|
||||
if (menu) {
|
||||
CHECK_MENU(menu);
|
||||
CHECK_MENU(menu->brother);
|
||||
for (int i = 0; i < menu->cascade_no; i++) {
|
||||
WMenu *sub = menu->cascades[i];
|
||||
if (sub && sub->flags.mapped &&
|
||||
x >= sub->frame_x && x < sub->frame_x + MENUW(sub) &&
|
||||
y >= sub->frame_y && y < sub->frame_y + MENUH(sub)) {
|
||||
*x_ret = x - sub->frame_x;
|
||||
*y_ret = y - sub->frame_y;
|
||||
return sub;
|
||||
}
|
||||
CHECK_MENU(menu->cascades[i]);
|
||||
if (menu->cascades[i])
|
||||
CHECK_MENU(menu->cascades[i]->brother);
|
||||
}
|
||||
}
|
||||
|
||||
/* Check switch menu */
|
||||
menu = scr->switch_menu;
|
||||
if (menu && menu->flags.mapped) {
|
||||
if (x >= menu->frame_x && x < menu->frame_x + MENUW(menu) &&
|
||||
y >= menu->frame_y && y < menu->frame_y + MENUH(menu)) {
|
||||
*x_ret = x - menu->frame_x;
|
||||
*y_ret = y - menu->frame_y;
|
||||
return menu;
|
||||
}
|
||||
}
|
||||
CHECK_MENU(menu);
|
||||
if (menu) CHECK_MENU(menu->brother);
|
||||
|
||||
#undef CHECK_MENU
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue