You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mutter/SOURCES/0002-display-Move-X11-initi...

113 lines
3.7 KiB

From c6a74d8f4161440a530bea5ca3b5cf199beb046b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
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 bd09082ed2..ddd475f457 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -945,9 +945,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;
@@ -1065,14 +1062,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);
@@ -1093,30 +1082,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 6de0511dc6..267fa1b835 100644
--- a/src/x11/meta-x11-display.c
+++ b/src/x11/meta-x11-display.c
@@ -307,7 +307,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
--
2.44.0.501.g19981daefd.dirty