Skip to content

display: Use existing focus_window when asked to focus default window

We use meta_display_focus_default_window() to sync the input focus back to a window after it was on shell UI, this is not really necessary on Wayland, but it is on X11. What this function does internally is ask MetaWindowStack about the topmost window and focus+raise that window.

In gnome-shell we set the input focus to the default window every time the key-focus changes to NULL (see shell-global.c -> sync_stage_window_focus()). Now when closing the alt-tab switcher and activating a window while there's an always-on-top window on the workspace, meta_display_focus_default_window() will focus that always-on-top window right after closing the alt-tab switcher, making it impossible to focus another window using alt-tab.

To fix this, make meta_display_focus_default_window() check if there's an existing focus_window first, if there is, use that, and if there isn't, resort to asking the MetaWorkspace, which will then ask the MetaWindowStack.

Fixes: gnome-shell#5162 (closed)

Merge request reports