[mutter] keybindings: Grab buttons with any modifier combo on unfocused windows



commit 2b59b4c793f417e15a61df969e23920d6e608538
Author: Rui Matos <tiagomatos gmail com>
Date:   Wed Feb 10 20:17:49 2016 +0100

    keybindings: Grab buttons with any modifier combo on unfocused windows
    
    We currently only focus unfocused windows on button press if no
    modifiers (or just ignored modifiers) are in effect. This behavior
    seems surprising and counter-intuitive so let's do it for any modifier
    combination instead.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=746642

 src/core/keybindings.c |   14 ++++++++++++--
 src/core/window.c      |    7 ++++++-
 2 files changed, 18 insertions(+), 3 deletions(-)
---
diff --git a/src/core/keybindings.c b/src/core/keybindings.c
index 4821c09..59d3c40 100644
--- a/src/core/keybindings.c
+++ b/src/core/keybindings.c
@@ -902,6 +902,16 @@ calc_grab_modifiers (MetaKeyBindingManager *keys,
   XIGrabModifiers mods;
   GArray *mods_array = g_array_new (FALSE, TRUE, sizeof (XIGrabModifiers));
 
+  /* The X server crashes if XIAnyModifier gets passed in with any
+     other bits. It doesn't make sense to ask for a grab of
+     XIAnyModifier plus other bits anyway so we avoid that. */
+  if (modmask & XIAnyModifier)
+    {
+      mods = (XIGrabModifiers) { XIAnyModifier, 0 };
+      g_array_append_val (mods_array, mods);
+      return mods_array;
+    }
+
   mods = (XIGrabModifiers) { modmask, 0 };
   g_array_append_val (mods_array, mods);
 
@@ -1061,7 +1071,7 @@ meta_display_grab_focus_window_button (MetaDisplay *display,
    * XSync()
    */
 
-  meta_change_buttons_grab (keys, window->xwindow, TRUE, TRUE, 0);
+  meta_change_buttons_grab (keys, window->xwindow, TRUE, TRUE, XIAnyModifier);
   window->have_focus_click_grab = TRUE;
 }
 
@@ -1076,7 +1086,7 @@ meta_display_ungrab_focus_window_button (MetaDisplay *display,
   if (!window->have_focus_click_grab)
     return;
 
-  meta_change_buttons_grab (keys, window->xwindow, FALSE, FALSE, 0);
+  meta_change_buttons_grab (keys, window->xwindow, FALSE, FALSE, XIAnyModifier);
   window->have_focus_click_grab = FALSE;
 }
 
diff --git a/src/core/window.c b/src/core/window.c
index 21557f3..1ffd484 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -4816,7 +4816,12 @@ meta_window_set_focused_internal (MetaWindow *window,
        */
       if (meta_prefs_get_focus_mode () == G_DESKTOP_FOCUS_MODE_CLICK ||
           !meta_prefs_get_raise_on_click())
-        meta_display_ungrab_focus_window_button (window->display, window);
+        {
+          meta_display_ungrab_focus_window_button (window->display, window);
+          /* Since we ungrab with XIAnyModifier above, all button
+             grabs go way so we need to re-grab the window buttons. */
+          meta_display_grab_window_buttons (window->display, window->xwindow);
+        }
 
       g_signal_emit (window, window_signals[FOCUS], 0);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]