mutter/2954.patch

305 lines
12 KiB
Diff

From e30abee5a27072f9297117d49ff0ac6cc99c22fb Mon Sep 17 00:00:00 2001
From: Carlos Garnacho <carlosg@gnome.org>
Date: Wed, 12 Apr 2023 10:20:25 +0200
Subject: [PATCH 1/3] core: Minor refactor
Do not make code live before variable declarations.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2954>
---
src/core/keybindings.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/src/core/keybindings.c b/src/core/keybindings.c
index 9873c1c73c..7dc7ccc08f 100644
--- a/src/core/keybindings.c
+++ b/src/core/keybindings.c
@@ -1182,16 +1182,18 @@ meta_change_button_grab (MetaKeyBindingManager *keys,
int button,
int modmask)
{
- if (meta_is_wayland_compositor ())
- return;
-
- MetaBackendX11 *backend = META_BACKEND_X11 (keys->backend);
- Display *xdisplay = meta_backend_x11_get_xdisplay (backend);
-
+ MetaBackendX11 *backend;
+ Display *xdisplay;
unsigned char mask_bits[XIMaskLen (XI_LASTEVENT)] = { 0 };
XIEventMask mask = { XIAllMasterDevices, sizeof (mask_bits), mask_bits };
GArray *mods;
+ if (meta_is_wayland_compositor ())
+ return;
+
+ backend = META_BACKEND_X11 (keys->backend);
+ xdisplay = meta_backend_x11_get_xdisplay (backend);
+
XISetMask (mask.mask, XI_ButtonPress);
XISetMask (mask.mask, XI_ButtonRelease);
XISetMask (mask.mask, XI_Motion);
--
GitLab
From a42bc34e4d40e73ef0e7b2f9f3b1360cf066acba Mon Sep 17 00:00:00 2001
From: Carlos Garnacho <carlosg@gnome.org>
Date: Wed, 12 Apr 2023 10:21:54 +0200
Subject: [PATCH 2/3] core: Pass MetaWindow on passive button grab machinery
In practical effects the passed Window is always window->xwindow,
so pass the MetaWindow and get the better X11 Window deep in the
call stack.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2954>
---
src/core/display-private.h | 4 ++--
src/core/keybindings.c | 39 +++++++++++++++++++++-----------------
src/core/window.c | 2 +-
src/x11/window-x11.c | 4 ++--
4 files changed, 27 insertions(+), 22 deletions(-)
diff --git a/src/core/display-private.h b/src/core/display-private.h
index efd92a4ac1..4eff0b7cbd 100644
--- a/src/core/display-private.h
+++ b/src/core/display-private.h
@@ -237,9 +237,9 @@ GSList* meta_display_list_windows (MetaDisplay *display,
void meta_display_reload_cursor (MetaDisplay *display);
void meta_display_grab_window_buttons (MetaDisplay *display,
- Window xwindow);
+ MetaWindow *window);
void meta_display_ungrab_window_buttons (MetaDisplay *display,
- Window xwindow);
+ MetaWindow *window);
void meta_display_grab_focus_window_button (MetaDisplay *display,
MetaWindow *window);
diff --git a/src/core/keybindings.c b/src/core/keybindings.c
index 7dc7ccc08f..d08e9619bd 100644
--- a/src/core/keybindings.c
+++ b/src/core/keybindings.c
@@ -1176,20 +1176,23 @@ calc_grab_modifiers (MetaKeyBindingManager *keys,
static void
meta_change_button_grab (MetaKeyBindingManager *keys,
- Window xwindow,
- gboolean grab,
- gboolean sync,
- int button,
- int modmask)
+ MetaWindow *window,
+ gboolean grab,
+ gboolean sync,
+ int button,
+ int modmask)
{
MetaBackendX11 *backend;
Display *xdisplay;
unsigned char mask_bits[XIMaskLen (XI_LASTEVENT)] = { 0 };
XIEventMask mask = { XIAllMasterDevices, sizeof (mask_bits), mask_bits };
+ Window xwindow;
GArray *mods;
if (meta_is_wayland_compositor ())
return;
+ if (window->client_type != META_WINDOW_CLIENT_TYPE_X11)
+ return;
backend = META_BACKEND_X11 (keys->backend);
xdisplay = meta_backend_x11_get_xdisplay (backend);
@@ -1202,6 +1205,8 @@ meta_change_button_grab (MetaKeyBindingManager *keys,
meta_clutter_x11_trap_x_errors ();
+ xwindow = window->xwindow;
+
/* GrabModeSync means freeze until XAllowEvents */
if (grab)
XIGrabButton (xdisplay,
@@ -1231,7 +1236,7 @@ meta_display_get_compositor_modifiers (MetaDisplay *display)
static void
meta_change_buttons_grab (MetaKeyBindingManager *keys,
- Window xwindow,
+ MetaWindow *window,
gboolean grab,
gboolean sync,
int modmask)
@@ -1240,12 +1245,12 @@ meta_change_buttons_grab (MetaKeyBindingManager *keys,
int i;
for (i = 1; i <= MAX_BUTTON; i++)
- meta_change_button_grab (keys, xwindow, grab, sync, i, modmask);
+ meta_change_button_grab (keys, window, grab, sync, i, modmask);
}
void
meta_display_grab_window_buttons (MetaDisplay *display,
- Window xwindow)
+ MetaWindow *window)
{
MetaKeyBindingManager *keys = &display->key_binding_manager;
@@ -1254,7 +1259,7 @@ meta_display_grab_window_buttons (MetaDisplay *display,
* Grab Alt + button3 for popping up window menu.
* Grab Alt + Shift + button1 for snap-moving window.
*/
- meta_verbose ("Grabbing window buttons for 0x%lx", xwindow);
+ meta_verbose ("Grabbing window buttons for %s", window->desc);
/* FIXME If we ignored errors here instead of spewing, we could
* put one big error trap around the loop and avoid a bunch of
@@ -1263,7 +1268,7 @@ meta_display_grab_window_buttons (MetaDisplay *display,
if (keys->window_grab_modifiers != 0)
{
- meta_change_buttons_grab (keys, xwindow, TRUE, FALSE,
+ meta_change_buttons_grab (keys, window, TRUE, FALSE,
keys->window_grab_modifiers);
/* In addition to grabbing Alt+Button1 for moving the window,
@@ -1272,7 +1277,7 @@ meta_display_grab_window_buttons (MetaDisplay *display,
* Shift+Alt+Button1 for some reason; so at least part of the
* order still matters, which sucks (please FIXME).
*/
- meta_change_button_grab (keys, xwindow,
+ meta_change_button_grab (keys, window,
TRUE,
FALSE,
1, keys->window_grab_modifiers | ShiftMask);
@@ -1281,14 +1286,14 @@ meta_display_grab_window_buttons (MetaDisplay *display,
void
meta_display_ungrab_window_buttons (MetaDisplay *display,
- Window xwindow)
+ MetaWindow *window)
{
MetaKeyBindingManager *keys = &display->key_binding_manager;
if (keys->window_grab_modifiers == 0)
return;
- meta_change_buttons_grab (keys, xwindow, FALSE, FALSE,
+ meta_change_buttons_grab (keys, window, FALSE, FALSE,
keys->window_grab_modifiers);
}
@@ -1329,7 +1334,7 @@ meta_display_grab_focus_window_button (MetaDisplay *display,
* XSync()
*/
- meta_change_buttons_grab (keys, window->xwindow, TRUE, TRUE, XIAnyModifier);
+ meta_change_buttons_grab (keys, window, TRUE, TRUE, XIAnyModifier);
window->have_focus_click_grab = TRUE;
}
@@ -1344,7 +1349,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, XIAnyModifier);
+ meta_change_buttons_grab (keys, window, FALSE, FALSE, XIAnyModifier);
window->have_focus_click_grab = FALSE;
}
@@ -1376,7 +1381,7 @@ prefs_changed_callback (MetaPreference pref,
for (l = windows; l; l = l->next)
{
MetaWindow *w = l->data;
- meta_display_ungrab_window_buttons (display, w->xwindow);
+ meta_display_ungrab_window_buttons (display, w);
}
update_window_grab_modifiers (display);
@@ -1385,7 +1390,7 @@ prefs_changed_callback (MetaPreference pref,
{
MetaWindow *w = l->data;
if (w->type != META_WINDOW_DOCK)
- meta_display_grab_window_buttons (display, w->xwindow);
+ meta_display_grab_window_buttons (display, w);
}
g_slist_free (windows);
diff --git a/src/core/window.c b/src/core/window.c
index 8e11ab7c88..2ce0b6687d 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -5194,7 +5194,7 @@ meta_window_set_focused_internal (MetaWindow *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);
+ meta_display_grab_window_buttons (window->display, window);
}
g_signal_emit (window, window_signals[FOCUS], 0);
diff --git a/src/x11/window-x11.c b/src/x11/window-x11.c
index e87037af83..ce9c204cdf 100644
--- a/src/x11/window-x11.c
+++ b/src/x11/window-x11.c
@@ -706,7 +706,7 @@ meta_window_x11_unmanage (MetaWindow *window)
XShapeSelectInput (x11_display->xdisplay, window->xwindow, NoEventMask);
meta_window_ungrab_keys (window);
- meta_display_ungrab_window_buttons (window->display, window->xwindow);
+ meta_display_ungrab_window_buttons (window->display, window);
meta_display_ungrab_focus_window_button (window->display, window);
meta_x11_error_trap_pop (x11_display);
@@ -3861,7 +3861,7 @@ meta_window_x11_new (MetaDisplay *display,
meta_window_grab_keys (window);
if (window->type != META_WINDOW_DOCK && !window->override_redirect)
{
- meta_display_grab_window_buttons (window->display, window->xwindow);
+ meta_display_grab_window_buttons (window->display, window);
meta_display_grab_focus_window_button (window->display, window);
}
--
GitLab
From f744acefee25bfb54ceb75e9a21cbcaeb58da40c Mon Sep 17 00:00:00 2001
From: Carlos Garnacho <carlosg@gnome.org>
Date: Wed, 12 Apr 2023 10:23:49 +0200
Subject: [PATCH 3/3] core: Create passive button grab on topmost Window
With the frames client, we do no longer handle events for the
frame window inside Mutter. This means we do not get events
"for free" to handle focus on a just clicked frame window.
This results in a background window not ending up focused if
clicked on its frame.
In order to fix this, make the passive button grab extend to
the frame window if a window has one. This brings back
focus-on-click behavior, while treating windows further as
a unitary surface.
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2727
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2954>
---
src/core/keybindings.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/core/keybindings.c b/src/core/keybindings.c
index d08e9619bd..63c7315ce8 100644
--- a/src/core/keybindings.c
+++ b/src/core/keybindings.c
@@ -1205,7 +1205,10 @@ meta_change_button_grab (MetaKeyBindingManager *keys,
meta_clutter_x11_trap_x_errors ();
- xwindow = window->xwindow;
+ if (window->frame)
+ xwindow = window->frame->xwindow;
+ else
+ xwindow = window->xwindow;
/* GrabModeSync means freeze until XAllowEvents */
if (grab)
--
GitLab