diff --git a/mutter-prevent-newly-focused-windows-to-steal-focus-from-shell.patch b/mutter-prevent-newly-focused-windows-to-steal-focus-from-shell.patch new file mode 100644 index 0000000..eff8954 --- /dev/null +++ b/mutter-prevent-newly-focused-windows-to-steal-focus-from-shell.patch @@ -0,0 +1,125 @@ +diff --unified --recursive --text --new-file --color mutter-43.3+4.old/src/core/events.c mutter-43.3+4.new/src/core/events.c +--- mutter-43.3+4.old/src/core/events.c 2023-03-13 16:20:18.953566837 +0800 ++++ mutter-43.3+4.new/src/core/events.c 2023-03-13 16:21:25.375564893 +0800 +@@ -34,7 +34,6 @@ + #include "core/display-private.h" + #include "core/window-private.h" + #include "meta/meta-backend.h" +-#include "x11/meta-x11-display-private.h" + + #ifdef HAVE_NATIVE_BACKEND + #include "backends/native/meta-backend-native.h" +@@ -261,9 +260,6 @@ + display->grabbed_in_clutter = FALSE; + meta_compositor_grab_end (compositor); + } +- +- if (display->x11_display) +- meta_x11_display_sync_input_focus (display->x11_display); + } + + device = clutter_event_get_device (event); +diff --unified --recursive --text --new-file --color mutter-43.3+4.old/src/core/window.c mutter-43.3+4.new/src/core/window.c +--- mutter-43.3+4.old/src/core/window.c 2023-03-13 16:20:18.956900099 +0800 ++++ mutter-43.3+4.new/src/core/window.c 2023-03-13 16:21:25.382231433 +0800 +@@ -1988,6 +1988,15 @@ + return; + } + ++ /* Do not focus window on map if input is already taken by the ++ * compositor. ++ */ ++ if (!meta_display_windows_are_interactable (window->display)) ++ { ++ *takes_focus = FALSE; ++ return; ++ } ++ + /* Terminal usage may be different; some users intend to launch + * many apps in quick succession or to just view things in the new + * window while still interacting with the terminal. In that case, +diff --unified --recursive --text --new-file --color mutter-43.3+4.old/src/x11/events.c mutter-43.3+4.new/src/x11/events.c +--- mutter-43.3+4.old/src/x11/events.c 2023-03-13 16:20:18.990232717 +0800 ++++ mutter-43.3+4.new/src/x11/events.c 2023-03-13 16:21:25.382231433 +0800 +@@ -1009,9 +1009,6 @@ + break; + case XI_FocusIn: + case XI_FocusOut: +- if (clutter_stage_get_grab_actor (stage) != NULL) +- break; +- + if (handle_window_focus_event (x11_display, window, enter_event, serial) && + enter_event->event == enter_event->root) + { +@@ -1933,8 +1930,7 @@ + event->xany.serial > x11_display->focus_serial && + display->focus_window && + display->focus_window->client_type == META_WINDOW_CLIENT_TYPE_X11 && +- !window_has_xwindow (display->focus_window, x11_display->server_focus_window) && +- meta_display_windows_are_interactable (display)) ++ !window_has_xwindow (display->focus_window, x11_display->server_focus_window)) + { + meta_topic (META_DEBUG_FOCUS, "Earlier attempt to focus %s failed", + display->focus_window->desc); +diff --unified --recursive --text --new-file --color mutter-43.3+4.old/src/x11/meta-x11-display.c mutter-43.3+4.new/src/x11/meta-x11-display.c +--- mutter-43.3+4.old/src/x11/meta-x11-display.c 2023-03-13 16:20:18.990232717 +0800 ++++ mutter-43.3+4.new/src/x11/meta-x11-display.c 2023-03-13 16:21:25.375564893 +0800 +@@ -1944,10 +1944,6 @@ + Window xwindow, + uint32_t timestamp) + { +- if (xwindow != None && +- !meta_display_windows_are_interactable (x11_display->display)) +- return; +- + meta_x11_error_trap_push (x11_display); + + /* In order for mutter to know that the focus request succeeded, we track +@@ -2020,22 +2016,6 @@ + x11_display->display->last_focus_time = timestamp; + } + +-void +-meta_x11_display_sync_input_focus (MetaX11Display *x11_display) +-{ +- guint timestamp; +- +- if (!meta_display_windows_are_interactable (x11_display->display)) +- return; +- +- meta_x11_error_trap_push (x11_display); +- timestamp = meta_display_get_current_time (x11_display->display); +- meta_x11_display_set_input_focus_internal (x11_display, +- x11_display->focus_xwindow, +- timestamp); +- meta_x11_error_trap_pop (x11_display); +-} +- + static MetaX11DisplayLogicalMonitorData * + get_x11_display_logical_monitor_data (MetaLogicalMonitor *logical_monitor) + { +diff --unified --recursive --text --new-file --color mutter-43.3+4.old/src/x11/meta-x11-display-private.h mutter-43.3+4.new/src/x11/meta-x11-display-private.h +--- mutter-43.3+4.old/src/x11/meta-x11-display-private.h 2023-03-13 16:20:18.990232717 +0800 ++++ mutter-43.3+4.new/src/x11/meta-x11-display-private.h 2023-03-13 16:21:25.375564893 +0800 +@@ -258,8 +258,6 @@ + gboolean focus_frame, + uint32_t timestamp); + +-void meta_x11_display_sync_input_focus (MetaX11Display *x11_display); +- + MetaDisplay * meta_x11_display_get_display (MetaX11Display *x11_display); + + #endif /* META_X11_DISPLAY_PRIVATE_H */ +diff --unified --recursive --text --new-file --color mutter-43.3+4.old/src/x11/window-x11.c mutter-43.3+4.new/src/x11/window-x11.c +--- mutter-43.3+4.old/src/x11/window-x11.c 2023-03-13 16:20:18.993565979 +0800 ++++ mutter-43.3+4.new/src/x11/window-x11.c 2023-03-13 16:21:25.382231433 +0800 +@@ -3382,7 +3382,8 @@ + event->xclient.data.l[4]); /* height */ + } + else if (event->xclient.message_type == +- x11_display->atom__NET_ACTIVE_WINDOW) ++ x11_display->atom__NET_ACTIVE_WINDOW && ++ meta_display_windows_are_interactable (window->display)) + { + MetaClientType source_indication; + guint32 timestamp; diff --git a/mutter.changes b/mutter.changes index 098fa8e..0013bb0 100644 --- a/mutter.changes +++ b/mutter.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Mon Mar 13 08:25:25 UTC 2023 - Alynx Zhou + +- Add mutter-prevent-newly-focused-windows-to-steal-focus-from-shell.patch: + Revert wrong commit and try a third approach to fix focus + (bsc#1208494). + ------------------------------------------------------------------- Mon Feb 20 14:38:43 UTC 2023 - Dominique Leuenberger diff --git a/mutter.spec b/mutter.spec index 4a72692..e35c2ea 100644 --- a/mutter.spec +++ b/mutter.spec @@ -40,6 +40,8 @@ Patch1: mutter-disable-cvt-s390x.patch Patch2: mutter-window-actor-Special-case-shaped-Java-windows.patch # PATCH-FIX-UPSTREAM mutter-crash-meta_context_terminate.patch bsc#1199382 glgo#GNOME/mutter#2267 xwang@suse.com -- Fix SIGSEGV in meta_context_terminate Patch3: mutter-crash-meta_context_terminate.patch +# PATCH-FIX-UPSTREAM mutter-prevent-newly-focused-windows-to-steal-focus-from-shell.patch bsc#1208494, glgo#GNOME/mutter!2878 alynx.zhou@suse.com -- Fix broken window focus +Patch4: mutter-prevent-newly-focused-windows-to-steal-focus-from-shell.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. @@ -148,6 +150,7 @@ applications that want to make use of the mutter library. %patch1 -p1 %patch2 -p1 %patch3 -p1 +%patch4 -p1 # SLE-only patches and translations. %if 0%{?sle_version}