diff --git a/src/core/display.c b/src/core/display.c index 8c0364621..5b8bb8216 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; @@ -1066,14 +1063,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); @@ -1094,30 +1083,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 6de0511dc..267fa1b83 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