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;
|
MetaDisplay *display;
|
||||||
Window modified;
|
Window modified;
|
||||||
gboolean frame_was_receiver;
|
gboolean frame_was_receiver;
|
||||||
|
gboolean bypass_compositor;
|
||||||
gboolean filter_out_event;
|
gboolean filter_out_event;
|
||||||
|
|
||||||
display = data;
|
display = data;
|
||||||
@ -1522,6 +1523,7 @@ event_callback (XEvent *event,
|
|||||||
sn_display_process_event (display->sn_display, event);
|
sn_display_process_event (display->sn_display, event);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
bypass_compositor = FALSE;
|
||||||
filter_out_event = FALSE;
|
filter_out_event = FALSE;
|
||||||
display->current_time = event_get_time (display, event);
|
display->current_time = event_get_time (display, event);
|
||||||
display->xinerama_cache_invalidated = TRUE;
|
display->xinerama_cache_invalidated = TRUE;
|
||||||
@ -1668,7 +1670,13 @@ event_callback (XEvent *event,
|
|||||||
{
|
{
|
||||||
case KeyPress:
|
case KeyPress:
|
||||||
case KeyRelease:
|
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;
|
break;
|
||||||
case ButtonPress:
|
case ButtonPress:
|
||||||
if (event->xbutton.button == 4 || event->xbutton.button == 5)
|
if (event->xbutton.button == 4 || event->xbutton.button == 5)
|
||||||
@ -2534,7 +2542,7 @@ event_callback (XEvent *event,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (display->compositor)
|
if (display->compositor && !bypass_compositor)
|
||||||
{
|
{
|
||||||
if (meta_compositor_process_event (display->compositor,
|
if (meta_compositor_process_event (display->compositor,
|
||||||
event,
|
event,
|
||||||
|
@ -45,7 +45,7 @@ gboolean meta_window_grab_all_keys (MetaWindow *window,
|
|||||||
guint32 timestamp);
|
guint32 timestamp);
|
||||||
void meta_window_ungrab_all_keys (MetaWindow *window,
|
void meta_window_ungrab_all_keys (MetaWindow *window,
|
||||||
guint32 timestamp);
|
guint32 timestamp);
|
||||||
void meta_display_process_key_event (MetaDisplay *display,
|
gboolean meta_display_process_key_event (MetaDisplay *display,
|
||||||
MetaWindow *window,
|
MetaWindow *window,
|
||||||
XEvent *event);
|
XEvent *event);
|
||||||
void meta_set_keybindings_disabled (gboolean setting);
|
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
|
* right. This cannot cause infinite recursion because we never call
|
||||||
* ourselves when there wasn't a grab, and we always clear the grab
|
* ourselves when there wasn't a grab, and we always clear the grab
|
||||||
* first; the invariant is enforced using an assertion. See #112560.
|
* 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: We need to prove there are no race conditions here.
|
||||||
* FIXME: Does it correctly handle alt-Tab being followed by another
|
* FIXME: Does it correctly handle alt-Tab being followed by another
|
||||||
* grabbing keypress without letting go of alt?
|
* grabbing keypress without letting go of alt?
|
||||||
* FIXME: An iterative solution would probably be simpler to understand
|
* FIXME: An iterative solution would probably be simpler to understand
|
||||||
* (and help us solve the other fixmes).
|
* (and help us solve the other fixmes).
|
||||||
*/
|
*/
|
||||||
void
|
gboolean
|
||||||
meta_display_process_key_event (MetaDisplay *display,
|
meta_display_process_key_event (MetaDisplay *display,
|
||||||
MetaWindow *window,
|
MetaWindow *window,
|
||||||
XEvent *event)
|
XEvent *event)
|
||||||
@ -1303,7 +1306,7 @@ meta_display_process_key_event (MetaDisplay *display,
|
|||||||
all_bindings_disabled ? ReplayKeyboard : AsyncKeyboard,
|
all_bindings_disabled ? ReplayKeyboard : AsyncKeyboard,
|
||||||
event->xkey.time);
|
event->xkey.time);
|
||||||
if (all_bindings_disabled)
|
if (all_bindings_disabled)
|
||||||
return;
|
return FALSE;
|
||||||
|
|
||||||
/* if key event was on root window, we have a shortcut */
|
/* if key event was on root window, we have a shortcut */
|
||||||
screen = meta_display_screen_for_root (display, event->xkey.window);
|
screen = meta_display_screen_for_root (display, event->xkey.window);
|
||||||
@ -1314,12 +1317,12 @@ meta_display_process_key_event (MetaDisplay *display,
|
|||||||
event->xany.window);
|
event->xany.window);
|
||||||
|
|
||||||
if (screen == NULL)
|
if (screen == NULL)
|
||||||
return; /* event window is destroyed */
|
return FALSE; /* event window is destroyed */
|
||||||
|
|
||||||
/* ignore key events on popup menus and such. */
|
/* ignore key events on popup menus and such. */
|
||||||
if (window == NULL &&
|
if (window == NULL &&
|
||||||
meta_ui_window_is_widget (screen->ui, event->xany.window))
|
meta_ui_window_is_widget (screen->ui, event->xany.window))
|
||||||
return;
|
return FALSE;
|
||||||
|
|
||||||
/* window may be NULL */
|
/* window may be NULL */
|
||||||
|
|
||||||
@ -1339,7 +1342,7 @@ meta_display_process_key_event (MetaDisplay *display,
|
|||||||
if (all_keys_grabbed)
|
if (all_keys_grabbed)
|
||||||
{
|
{
|
||||||
if (display->grab_op == META_GRAB_OP_NONE)
|
if (display->grab_op == META_GRAB_OP_NONE)
|
||||||
return;
|
return TRUE;
|
||||||
/* If we get here we have a global grab, because
|
/* If we get here we have a global grab, because
|
||||||
* we're in some special keyboard mode such as window move
|
* we're in some special keyboard mode such as window move
|
||||||
* mode.
|
* mode.
|
||||||
@ -1416,18 +1419,20 @@ meta_display_process_key_event (MetaDisplay *display,
|
|||||||
"Ending grab op %u on key event sym %s\n",
|
"Ending grab op %u on key event sym %s\n",
|
||||||
display->grab_op, XKeysymToString (keysym));
|
display->grab_op, XKeysymToString (keysym));
|
||||||
meta_display_end_grab_op (display, event->xkey.time);
|
meta_display_end_grab_op (display, event->xkey.time);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
handled = process_overlay_key (display, screen, event, keysym);
|
handled = process_overlay_key (display, screen, event, keysym);
|
||||||
|
if (handled)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
/* Do the normal keybindings */
|
/* Do the normal keybindings */
|
||||||
if (!handled)
|
return process_event (display->key_bindings,
|
||||||
process_event (display->key_bindings,
|
display->n_key_bindings,
|
||||||
display->n_key_bindings,
|
display, screen, window, event, keysym,
|
||||||
display, screen, window, event, keysym,
|
!all_keys_grabbed && window);
|
||||||
!all_keys_grabbed && window);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
Loading…
Reference in New Issue
Block a user