window: Be better at filtering window grab mods

It turns out that Clutter doesn't actually filter NumLock / ScrollLock /
CapsLock from button events due to its terrible event translation code.

Check only the grab mods to check if it's unmodified.
This commit is contained in:
Jasper St. Pierre 2014-08-15 16:03:50 -04:00
parent 71a4fe746e
commit d233238c64

View File

@ -6108,16 +6108,6 @@ end_grab_op (MetaWindow *window,
meta_display_end_grab_op (window->display, clutter_event_get_time (event)); meta_display_end_grab_op (window->display, clutter_event_get_time (event));
} }
static gboolean
button_event_is_window_grab (MetaDisplay *display,
const ClutterEvent *event)
{
ClutterModifierType mods = event->button.modifier_state;
ClutterModifierType grab_mods = meta_display_get_window_grab_modifiers (display);
return (mods & grab_mods) == grab_mods;
}
gboolean gboolean
meta_window_handle_mouse_grab_op_event (MetaWindow *window, meta_window_handle_mouse_grab_op_event (MetaWindow *window,
const ClutterEvent *event) const ClutterEvent *event)
@ -6129,12 +6119,15 @@ meta_window_handle_mouse_grab_op_event (MetaWindow *window,
switch (event->type) switch (event->type)
{ {
case CLUTTER_BUTTON_PRESS: case CLUTTER_BUTTON_PRESS:
{
ClutterModifierType grab_mods = meta_display_get_window_grab_modifiers (display);
/* This is the keybinding or menu case where we've /* This is the keybinding or menu case where we've
* been dragging around the window without the button * been dragging around the window without the button
* pressed. */ * pressed. */
if ((meta_grab_op_is_mouse (window->display->grab_op) && if ((meta_grab_op_is_mouse (window->display->grab_op) &&
button_event_is_window_grab (window->display, event) && (event->button.modifier_state & grab_mods) == grab_mods &&
window->display->grab_button != (int) event->button.button) || window->display->grab_button != (int) event->button.button) ||
meta_grab_op_is_keyboard (window->display->grab_op)) meta_grab_op_is_keyboard (window->display->grab_op))
{ {
@ -6142,6 +6135,7 @@ meta_window_handle_mouse_grab_op_event (MetaWindow *window,
return FALSE; return FALSE;
} }
return TRUE; return TRUE;
}
case CLUTTER_TOUCH_END: case CLUTTER_TOUCH_END:
if (meta_display_is_pointer_emulating_sequence (window->display, sequence)) if (meta_display_is_pointer_emulating_sequence (window->display, sequence))
@ -7912,12 +7906,9 @@ meta_window_handle_ungrabbed_event (MetaWindow *window,
* care about. Just let the event through. * care about. Just let the event through.
*/ */
const int CLUTTER_BUTTON_MASK = (CLUTTER_BUTTON1_MASK | CLUTTER_BUTTON2_MASK | ClutterModifierType grab_mods = meta_display_get_window_grab_modifiers (display);
CLUTTER_BUTTON3_MASK | CLUTTER_BUTTON4_MASK | unmodified = (event->button.modifier_state & grab_mods) == 0;
CLUTTER_BUTTON5_MASK); is_window_grab = (event->button.modifier_state & grab_mods) == grab_mods;
unmodified = (event->button.modifier_state & ~CLUTTER_BUTTON_MASK) == 0;
is_window_grab = button_event_is_window_grab (display, event);
if (unmodified) if (unmodified)
{ {