From 22a7ba18aee07963f3e25047b6b1d0f49426c6142c15c22659c472297fc2af38 Mon Sep 17 00:00:00 2001 From: Dominique Leuenberger Date: Mon, 18 Dec 2023 09:18:55 +0000 Subject: [PATCH] Accepting request 1133802 from home:AZhou:branches:GNOME:Factory - Add mutter-fix-x11-restart.patch: glgo#GNOME/mutter!2445 breaks restarting under x11 accidentally because it redirects subwindows after redirecting windows, this patch fix it by redirecting subwindows first (glgo#GNOME/gnome-shell#7050, glgo#GNOME/mutter!3329). OBS-URL: https://build.opensuse.org/request/show/1133802 OBS-URL: https://build.opensuse.org/package/show/GNOME:Factory/mutter?expand=0&rev=483 --- mutter-fix-x11-restart.patch | 251 +++++++++++++++++++++++++++++++++++ mutter.changes | 9 ++ mutter.spec | 3 + 3 files changed, 263 insertions(+) create mode 100644 mutter-fix-x11-restart.patch diff --git a/mutter-fix-x11-restart.patch b/mutter-fix-x11-restart.patch new file mode 100644 index 0000000..82a49de --- /dev/null +++ b/mutter-fix-x11-restart.patch @@ -0,0 +1,251 @@ +From b7a1159a1ecd08b5e6aa1279fea84accf846b411 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Jonas=20=C3=85dahl?= +Date: Fri, 20 Oct 2023 15:44:29 +0800 +Subject: [PATCH 1/4] x11-display: Make subwindow redirection call mode + specific + +This means that for X11 sessions we'll do it before any windows are +mapped, and before any plugin implementation is started. Doing it before +a plugin is started is important, because things that the plugin does +during startup can have consequences on how compositing on Xorg works. + +For the Xwayland case, we'll do it relatively in the setup phase. It +appears to have been harmless to do it later in the post-opened signal, +but there is no harm in doing it as one of the earlier steps. + +Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3089 +--- + src/compositor/meta-compositor-x11.c | 2 ++ + src/wayland/meta-xwayland.c | 1 + + src/x11/meta-x11-display.c | 1 - + 3 files changed, 3 insertions(+), 1 deletion(-) + +diff --git a/src/compositor/meta-compositor-x11.c b/src/compositor/meta-compositor-x11.c +index 1ad3327ddf6..ce7bc1945ce 100644 +--- a/src/compositor/meta-compositor-x11.c ++++ b/src/compositor/meta-compositor-x11.c +@@ -188,6 +188,8 @@ meta_compositor_x11_manage (MetaCompositor *compositor, + + compositor_x11->have_x11_sync_object = meta_sync_ring_init (xdisplay); + ++ meta_x11_display_redirect_windows (x11_display, display); ++ + return TRUE; + } + +diff --git a/src/wayland/meta-xwayland.c b/src/wayland/meta-xwayland.c +index e95ca564010..83f2fcb25d9 100644 +--- a/src/wayland/meta-xwayland.c ++++ b/src/wayland/meta-xwayland.c +@@ -1170,6 +1170,7 @@ on_x11_display_setup (MetaDisplay *display, + { + MetaX11Display *x11_display = meta_display_get_x11_display (display); + ++ meta_x11_display_redirect_windows (x11_display, display); + meta_xwayland_init_dnd (x11_display); + meta_xwayland_init_xrandr (manager, x11_display); + } +diff --git a/src/x11/meta-x11-display.c b/src/x11/meta-x11-display.c +index 4e98203dd25..c634a71fb2a 100644 +--- a/src/x11/meta-x11-display.c ++++ b/src/x11/meta-x11-display.c +@@ -301,7 +301,6 @@ on_x11_display_opened (MetaX11Display *x11_display, + MetaDisplay *display) + { + meta_display_manage_all_xwindows (display); +- meta_x11_display_redirect_windows (x11_display, display); + } + + static void +-- +GitLab + + +From 77fc07943c3171a5e7a047ca34af46feeca347c2 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Jonas=20=C3=85dahl?= +Date: Fri, 20 Oct 2023 17:03:31 +0800 +Subject: [PATCH 2/4] display: Move X11 initial focus handling to + MetaX11Display + +It's X11 specific, so put it in the X11 display manager object. +--- + src/core/display.c | 34 ---------------------------------- + src/x11/meta-x11-display.c | 25 +++++++++++++++++++++++++ + 2 files changed, 25 insertions(+), 34 deletions(-) + +diff --git a/src/core/display.c b/src/core/display.c +index 0a191c0fbca..b16e50e21de 100644 +--- a/src/core/display.c ++++ b/src/core/display.c +@@ -930,9 +930,6 @@ meta_display_new (MetaContext *context, + MetaDisplay *display; + MetaDisplayPrivate *priv; + guint32 timestamp; +-#ifdef HAVE_X11_CLIENT +- Window old_active_xwindow = None; +-#endif + MetaMonitorManager *monitor_manager; + MetaSettings *settings; + MetaInputCapture *input_capture; +@@ -1048,14 +1045,6 @@ meta_display_new (MetaContext *context, + display->last_focus_time = timestamp; + display->last_user_time = timestamp; + +-#ifdef HAVE_X11 +- if (!meta_is_wayland_compositor ()) +- meta_prop_get_window (display->x11_display, +- display->x11_display->xroot, +- display->x11_display->atom__NET_ACTIVE_WINDOW, +- &old_active_xwindow); +-#endif +- + if (!meta_compositor_manage (display->compositor, error)) + { + g_object_unref (display); +@@ -1076,30 +1065,7 @@ meta_display_new (MetaContext *context, + g_signal_connect (display->gesture_tracker, "state-changed", + G_CALLBACK (gesture_tracker_state_changed), display); + +- /* We know that if mutter is running as a Wayland compositor, +- * we start out with no windows. +- */ +-#ifdef HAVE_X11_CLIENT +- if (!meta_is_wayland_compositor ()) +- meta_display_manage_all_xwindows (display); +- +- if (old_active_xwindow != None) +- { +- MetaWindow *old_active_window; +- old_active_window = meta_x11_display_lookup_x_window (display->x11_display, +- old_active_xwindow); +- if (old_active_window) +- meta_window_focus (old_active_window, timestamp); +- else +- meta_display_unset_input_focus (display, timestamp); +- } +- else +- { +- meta_display_unset_input_focus (display, timestamp); +- } +-#else + meta_display_unset_input_focus (display, timestamp); +-#endif + + g_signal_connect (stage, "notify::is-grabbed", + G_CALLBACK (on_is_grabbed_changed), display); +diff --git a/src/x11/meta-x11-display.c b/src/x11/meta-x11-display.c +index c634a71fb2a..599968a363b 100644 +--- a/src/x11/meta-x11-display.c ++++ b/src/x11/meta-x11-display.c +@@ -300,7 +300,32 @@ static void + on_x11_display_opened (MetaX11Display *x11_display, + MetaDisplay *display) + { ++ Window old_active_xwindow = None; ++ ++ if (!meta_is_wayland_compositor ()) ++ { ++ meta_prop_get_window (display->x11_display, ++ display->x11_display->xroot, ++ display->x11_display->atom__NET_ACTIVE_WINDOW, ++ &old_active_xwindow); ++ } ++ + meta_display_manage_all_xwindows (display); ++ ++ if (old_active_xwindow != None) ++ { ++ MetaWindow *old_active_window; ++ ++ old_active_window = meta_x11_display_lookup_x_window (x11_display, ++ old_active_xwindow); ++ if (old_active_window) ++ { ++ uint32_t timestamp; ++ ++ timestamp = display->x11_display->timestamp; ++ meta_window_focus (old_active_window, timestamp); ++ } ++ } + } + + static void +-- +GitLab + + +From 668eb0d198dba58c7833b09926dce2f043889155 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Jonas=20=C3=85dahl?= +Date: Tue, 17 Oct 2023 15:46:00 +0800 +Subject: [PATCH 3/4] tests/x11: Fix replace test to catch the second instance + failing + +The test never noticed that the second instance never actually managed +to load; it was looping a multi second retry session trying to redirect +windows, meaning it failed to catch https://gitlab.gnome.org/GNOME/mutter/-/issues/3089. + +Fix the test so that it always waits for mutter to finish loading +successfully, just like it waits fro the first. +--- + src/tests/x11-test.sh | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/src/tests/x11-test.sh b/src/tests/x11-test.sh +index 59e460fc336..d95b2460f6e 100755 +--- a/src/tests/x11-test.sh ++++ b/src/tests/x11-test.sh +@@ -34,6 +34,9 @@ echo \# Launched with pid $MUTTER2_PID + MUTTER2_PID=$! + wait $MUTTER1_PID + ++echo \# Waiting for the second mutter to finish loading ++gdbus wait --session org.gnome.Mutter.IdleMonitor ++ + sleep 2 + + echo \# Terminating clients > /dev/stderr +-- +GitLab + + +From 8e6f18fcaf63968b0a75bf65da0c00473d71acb3 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Jonas=20=C3=85dahl?= +Date: Mon, 23 Oct 2023 14:47:33 +0800 +Subject: [PATCH 4/4] display: Rename mandatory X11 initialization function + +Simply to make it clear that the renamed function is specific to a +particular X11 initialization mode (mandatory Xwayland), put that in the +name, so that it's easier to understand when this function is relevant. +--- + src/core/display.c | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/src/core/display.c b/src/core/display.c +index b16e50e21de..f851f1be372 100644 +--- a/src/core/display.c ++++ b/src/core/display.c +@@ -897,9 +897,9 @@ meta_display_init_x11 (MetaDisplay *display, + } + + static void +-on_x11_initialized (MetaDisplay *display, +- GAsyncResult *result, +- gpointer user_data) ++on_mandatory_x11_initialized (MetaDisplay *display, ++ GAsyncResult *result, ++ gpointer user_data) + { + g_autoptr (GError) error = NULL; + +@@ -1018,7 +1018,7 @@ meta_display_new (MetaContext *context, + if (x11_display_policy == META_X11_DISPLAY_POLICY_MANDATORY) + { + meta_display_init_x11 (display, NULL, +- (GAsyncReadyCallback) on_x11_initialized, ++ (GAsyncReadyCallback) on_mandatory_x11_initialized, + NULL); + } + #endif /* HAVE_XWAYLAND */ +-- +GitLab + diff --git a/mutter.changes b/mutter.changes index 038aa80..5bdebe1 100644 --- a/mutter.changes +++ b/mutter.changes @@ -1,3 +1,12 @@ +------------------------------------------------------------------- +Mon Dec 18 06:47:32 UTC 2023 - Alynx Zhou + +- Add mutter-fix-x11-restart.patch: glgo#GNOME/mutter!2445 breaks + restarting under x11 accidentally because it redirects subwindows + after redirecting windows, this patch fix it by redirecting + subwindows first (glgo#GNOME/gnome-shell#7050, + glgo#GNOME/mutter!3329). + ------------------------------------------------------------------- Thu Dec 7 15:09:40 UTC 2023 - Dominique Leuenberger diff --git a/mutter.spec b/mutter.spec index 6f07483..12e9e3c 100644 --- a/mutter.spec +++ b/mutter.spec @@ -34,6 +34,8 @@ Source0: %{name}-%{version}.tar.zst Patch1: mutter-disable-cvt-s390x.patch # PATCH-FIX-OPENSUSE mutter-window-actor-Special-case-shaped-Java-windows.patch -- window-actor: Special-case shaped Java windows Patch2: mutter-window-actor-Special-case-shaped-Java-windows.patch +# PATCH-FIX-UPSTREAM mutter-fix-x11-restart.patch glgo#GNOME/gnome-shell#7050 glgo#GNOME/mutter!3329 alynx.zhou@suse.com -- Fix crash on restarting mutter under x11 +Patch3: mutter-fix-x11-restart.patch ## SLE-only patches start at 1000 # PATCH-FEATURE-SLE mutter-SLE-bell.patch FATE#316042 bnc#889218 idonmez@suse.com -- make audible bell work out of the box. @@ -145,6 +147,7 @@ applications that want to make use of the mutter library. %else %patch -P 1 -p1 %patch -P 2 -p1 +%patch -P 3 -p1 %endif # SLE-only patches and translations. %if 0%{?sle_version}