From 43081fc8bd6639464aa7bedb9e80e99837086899 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Thu, 29 Sep 2022 17:00:20 +0200 Subject: [PATCH] core: Simplify handling of ungrabbing condition Unlike the comment suggests, this piece of event handling manages the ungrabbing of a window on button press in the following 2 conditions: - If a keyboard grab operation was triggered, the window does additionally follow the pointer, and first button press ends the grab. - If a button-press grab is ongoing on the window, but more buttons are pressed. We can simplify this to just happen every time a button press event is received while a window grab op is ongoing. The only case where this might diverge a bit is same button presses from different pointer devices, and it's not a big stretch to also undo the grab in that situation. This also happens to make the "button" argument in meta_display_begin_grab_op() completely unused. Part-of: --- src/core/window.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/core/window.c b/src/core/window.c index 76a6c1a9b..3385be8fd 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -6300,21 +6300,13 @@ meta_window_handle_mouse_grab_op_event (MetaWindow *window, case CLUTTER_BUTTON_PRESS: { - ClutterModifierType grab_mods = meta_display_get_compositor_modifiers (window->display); - /* This is the keybinding or menu case where we've * been dragging around the window without the button - * pressed. */ - - if ((meta_grab_op_is_mouse (window->display->grab_op) && - (event->button.modifier_state & grab_mods) == grab_mods && - window->display->grab_button != (int) event->button.button) || - meta_grab_op_is_keyboard (window->display->grab_op)) - { - end_grab_op (window, event); - return FALSE; - } - return TRUE; + * pressed, or the case of pressing extra mouse buttons + * while a grab op is ongoing. + */ + end_grab_op (window, event); + return FALSE; } case CLUTTER_TOUCH_END: