Enforce a policy of single-handling of key events
Only process each key event once. If all keys are grabbed, then don't also look for handlers for a key shortcut after processing the grab op. If all keys are grabbed or we find a key shortcut, don't pass the event on to the compositing mananger. http://bugzilla.gnome.org/show_bug.cgi?id=590754
This commit is contained in:
parent
7a6968cb46
commit
b1776b5ae5
@ -1509,6 +1509,7 @@ event_callback (XEvent *event,
|
||||
MetaDisplay *display;
|
||||
Window modified;
|
||||
gboolean frame_was_receiver;
|
||||
gboolean bypass_compositor;
|
||||
gboolean filter_out_event;
|
||||
|
||||
display = data;
|
||||
@ -1522,6 +1523,7 @@ event_callback (XEvent *event,
|
||||
sn_display_process_event (display->sn_display, event);
|
||||
#endif
|
||||
|
||||
bypass_compositor = FALSE;
|
||||
filter_out_event = FALSE;
|
||||
display->current_time = event_get_time (display, event);
|
||||
display->xinerama_cache_invalidated = TRUE;
|
||||
@ -1668,7 +1670,13 @@ event_callback (XEvent *event,
|
||||
{
|
||||
case KeyPress:
|
||||
case KeyRelease:
|
||||
meta_display_process_key_event (display, window, event);
|
||||
/* For key events, it's important to enforce single-handling, or
|
||||
* we can get into a confused state. So if a keybinding is
|
||||
* handled (because it's one of our hot-keys, or because we are
|
||||
* in a keyboard-grabbed mode like moving a window, we don't
|
||||
* want to pass the key event to the compositor at all.
|
||||
*/
|
||||
bypass_compositor = meta_display_process_key_event (display, window, event);
|
||||
break;
|
||||
case ButtonPress:
|
||||
if (event->xbutton.button == 4 || event->xbutton.button == 5)
|
||||
@ -2534,7 +2542,7 @@ event_callback (XEvent *event,
|
||||
break;
|
||||
}
|
||||
|
||||
if (display->compositor)
|
||||
if (display->compositor && !bypass_compositor)
|
||||
{
|
||||
if (meta_compositor_process_event (display->compositor,
|
||||
event,
|
||||
|
@ -45,7 +45,7 @@ gboolean meta_window_grab_all_keys (MetaWindow *window,
|
||||
guint32 timestamp);
|
||||
void meta_window_ungrab_all_keys (MetaWindow *window,
|
||||
guint32 timestamp);
|
||||
void meta_display_process_key_event (MetaDisplay *display,
|
||||
gboolean meta_display_process_key_event (MetaDisplay *display,
|
||||
MetaWindow *window,
|
||||
XEvent *event);
|
||||
void meta_set_keybindings_disabled (gboolean setting);
|
||||
|
@ -1281,13 +1281,16 @@ process_event (MetaKeyBinding *bindings,
|
||||
* right. This cannot cause infinite recursion because we never call
|
||||
* ourselves when there wasn't a grab, and we always clear the grab
|
||||
* first; the invariant is enforced using an assertion. See #112560.
|
||||
*
|
||||
* The return value is whether we handled the key event.
|
||||
*
|
||||
* FIXME: We need to prove there are no race conditions here.
|
||||
* FIXME: Does it correctly handle alt-Tab being followed by another
|
||||
* grabbing keypress without letting go of alt?
|
||||
* FIXME: An iterative solution would probably be simpler to understand
|
||||
* (and help us solve the other fixmes).
|
||||
*/
|
||||
void
|
||||
gboolean
|
||||
meta_display_process_key_event (MetaDisplay *display,
|
||||
MetaWindow *window,
|
||||
XEvent *event)
|
||||
@ -1303,7 +1306,7 @@ meta_display_process_key_event (MetaDisplay *display,
|
||||
all_bindings_disabled ? ReplayKeyboard : AsyncKeyboard,
|
||||
event->xkey.time);
|
||||
if (all_bindings_disabled)
|
||||
return;
|
||||
return FALSE;
|
||||
|
||||
/* if key event was on root window, we have a shortcut */
|
||||
screen = meta_display_screen_for_root (display, event->xkey.window);
|
||||
@ -1314,12 +1317,12 @@ meta_display_process_key_event (MetaDisplay *display,
|
||||
event->xany.window);
|
||||
|
||||
if (screen == NULL)
|
||||
return; /* event window is destroyed */
|
||||
return FALSE; /* event window is destroyed */
|
||||
|
||||
/* ignore key events on popup menus and such. */
|
||||
if (window == NULL &&
|
||||
meta_ui_window_is_widget (screen->ui, event->xany.window))
|
||||
return;
|
||||
return FALSE;
|
||||
|
||||
/* window may be NULL */
|
||||
|
||||
@ -1339,7 +1342,7 @@ meta_display_process_key_event (MetaDisplay *display,
|
||||
if (all_keys_grabbed)
|
||||
{
|
||||
if (display->grab_op == META_GRAB_OP_NONE)
|
||||
return;
|
||||
return TRUE;
|
||||
/* If we get here we have a global grab, because
|
||||
* we're in some special keyboard mode such as window move
|
||||
* mode.
|
||||
@ -1416,18 +1419,20 @@ meta_display_process_key_event (MetaDisplay *display,
|
||||
"Ending grab op %u on key event sym %s\n",
|
||||
display->grab_op, XKeysymToString (keysym));
|
||||
meta_display_end_grab_op (display, event->xkey.time);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
handled = process_overlay_key (display, screen, event, keysym);
|
||||
if (handled)
|
||||
return TRUE;
|
||||
|
||||
/* Do the normal keybindings */
|
||||
if (!handled)
|
||||
process_event (display->key_bindings,
|
||||
display->n_key_bindings,
|
||||
display, screen, window, event, keysym,
|
||||
!all_keys_grabbed && window);
|
||||
return process_event (display->key_bindings,
|
||||
display->n_key_bindings,
|
||||
display, screen, window, event, keysym,
|
||||
!all_keys_grabbed && window);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
Loading…
Reference in New Issue
Block a user