From f5c8e0d96dc952f0e6fb37d91c82d344473c77d4 Mon Sep 17 00:00:00 2001 From: Sebastian Keller Date: Sun, 21 Jun 2020 00:46:38 +0200 Subject: [PATCH] window/x11: Don't stop early when trying to find default focus window When trying to find a default focus window, the code iterates through a queue of candidates with a timeout between each candidate. If the window the current timeout is waiting for gets destroyed, this process just stops instead of trying the next window in the queue. This issue was made more likely to be triggered with the previous change to the closed-transient-no-input-parents-queued-default-focus-destroyed test due to the introduction of a wait, which can introduce a delay between the two destroy commands. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1325 --- src/x11/window-x11.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/x11/window-x11.c b/src/x11/window-x11.c index db3fae2f0..ff8361540 100644 --- a/src/x11/window-x11.c +++ b/src/x11/window-x11.c @@ -833,6 +833,18 @@ focus_candidates_maybe_take_and_focus_next (GQueue **focus_candidates_ptr, meta_window_x11_maybe_focus_delayed (focus_window, focus_candidates, timestamp); } +static void +focus_window_delayed_unmanaged (gpointer user_data) +{ + MetaWindowX11DelayedFocusData *data = user_data; + uint32_t timestamp = data->timestamp; + + focus_candidates_maybe_take_and_focus_next (&data->pending_focus_candidates, + timestamp); + + meta_window_x11_delayed_focus_data_free (data); +} + static gboolean focus_window_delayed_timeout (gpointer user_data) { @@ -868,7 +880,7 @@ meta_window_x11_maybe_focus_delayed (MetaWindow *window, data->unmanaged_id = g_signal_connect_swapped (window, "unmanaged", - G_CALLBACK (meta_window_x11_delayed_focus_data_free), + G_CALLBACK (focus_window_delayed_unmanaged), data); data->focused_changed_id =