1
0
Fork 0

display: Move X11 initial focus handling to MetaX11Display

It's X11 specific, so put it in the X11 display manager object.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3329>
This commit is contained in:
Jonas Ådahl 2023-10-20 17:03:31 +08:00 committed by Florian Müllner
parent de31822ecc
commit 827adc898e
2 changed files with 25 additions and 34 deletions

View file

@ -941,9 +941,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;
@ -1059,14 +1056,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);
@ -1087,30 +1076,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);

View file

@ -306,7 +306,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