perhaps fix problems of being left in menus without being able to control openbox
This commit is contained in:
parent
ff04a81e62
commit
b8ba1cff1f
2 changed files with 22 additions and 12 deletions
|
@ -50,11 +50,13 @@ gboolean grab_keyboard(gboolean grab)
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
|
|
||||||
if (grab) {
|
if (grab) {
|
||||||
if (kgrabs++ == 0)
|
if (kgrabs++ == 0) {
|
||||||
ret = XGrabKeyboard(ob_display, RootWindow(ob_display, ob_screen),
|
ret = XGrabKeyboard(ob_display, RootWindow(ob_display, ob_screen),
|
||||||
FALSE, GrabModeAsync, GrabModeAsync,
|
FALSE, GrabModeAsync, GrabModeAsync,
|
||||||
event_lasttime) == Success;
|
event_lasttime) == Success;
|
||||||
else
|
if (!ret)
|
||||||
|
--kgrabs;
|
||||||
|
} else
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
} else if (kgrabs > 0) {
|
} else if (kgrabs > 0) {
|
||||||
if (--kgrabs == 0)
|
if (--kgrabs == 0)
|
||||||
|
@ -70,12 +72,14 @@ gboolean grab_pointer(gboolean grab, ObCursor cur)
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
|
|
||||||
if (grab) {
|
if (grab) {
|
||||||
if (pgrabs++ == 0)
|
if (pgrabs++ == 0) {
|
||||||
ret = XGrabPointer(ob_display, screen_support_win,
|
ret = XGrabPointer(ob_display, screen_support_win,
|
||||||
False, GRAB_PTR_MASK, GrabModeAsync,
|
False, GRAB_PTR_MASK, GrabModeAsync,
|
||||||
GrabModeAsync, FALSE,
|
GrabModeAsync, FALSE,
|
||||||
ob_cursor(cur), event_lasttime) == Success;
|
ob_cursor(cur), event_lasttime) == Success;
|
||||||
else
|
if (!ret)
|
||||||
|
--pgrabs;
|
||||||
|
} else
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
} else if (pgrabs > 0) {
|
} else if (pgrabs > 0) {
|
||||||
if (--pgrabs == 0) {
|
if (--pgrabs == 0) {
|
||||||
|
@ -91,12 +95,14 @@ gboolean grab_pointer_window(gboolean grab, ObCursor cur, Window win)
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
|
|
||||||
if (grab) {
|
if (grab) {
|
||||||
if (pgrabs++ == 0)
|
if (pgrabs++ == 0) {
|
||||||
ret = XGrabPointer(ob_display, win, False, GRAB_PTR_MASK,
|
ret = XGrabPointer(ob_display, win, False, GRAB_PTR_MASK,
|
||||||
GrabModeAsync, GrabModeAsync, TRUE,
|
GrabModeAsync, GrabModeAsync, TRUE,
|
||||||
ob_cursor(cur),
|
ob_cursor(cur),
|
||||||
event_lasttime) == Success;
|
event_lasttime) == Success;
|
||||||
else
|
if (!ret)
|
||||||
|
--pgrabs;
|
||||||
|
} else
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
} else if (pgrabs > 0) {
|
} else if (pgrabs > 0) {
|
||||||
if (--pgrabs == 0) {
|
if (--pgrabs == 0) {
|
||||||
|
|
|
@ -591,6 +591,16 @@ void menu_frame_show(ObMenuFrame *self, ObMenuFrame *parent)
|
||||||
if (g_list_find(menu_frame_visible, self))
|
if (g_list_find(menu_frame_visible, self))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (menu_frame_visible == NULL) {
|
||||||
|
/* no menus shown yet */
|
||||||
|
if (!grab_pointer(TRUE, OB_CURSOR_NONE))
|
||||||
|
return;
|
||||||
|
if (!grab_keyboard(TRUE)) {
|
||||||
|
grab_pointer(FALSE, OB_CURSOR_NONE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (parent) {
|
if (parent) {
|
||||||
if (parent->child)
|
if (parent->child)
|
||||||
menu_frame_hide(parent->child);
|
menu_frame_hide(parent->child);
|
||||||
|
@ -598,12 +608,6 @@ void menu_frame_show(ObMenuFrame *self, ObMenuFrame *parent)
|
||||||
}
|
}
|
||||||
self->parent = parent;
|
self->parent = parent;
|
||||||
|
|
||||||
if (menu_frame_visible == NULL) {
|
|
||||||
/* no menus shown yet */
|
|
||||||
grab_pointer(TRUE, OB_CURSOR_NONE);
|
|
||||||
grab_keyboard(TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* determine if the underlying menu is already visible */
|
/* determine if the underlying menu is already visible */
|
||||||
for (it = menu_frame_visible; it; it = g_list_next(it)) {
|
for (it = menu_frame_visible; it; it = g_list_next(it)) {
|
||||||
ObMenuFrame *f = it->data;
|
ObMenuFrame *f = it->data;
|
||||||
|
|
Loading…
Reference in a new issue