Skip to content

core: Make sure focus_default_window() worked

The function focus_default_window() optionally takes a MetaWindow argument denoting a window that should not be focused.

That function calls focus_ancestor_or_top_window() which in turn calls meta_window_focus() to pass focus to another window.

However meta_window_focus() gives no guarantee that the given window will end up being the one focused, and can fail in various and creative ways.

If that fails, we could possibly end up with the focus window remaining the same, while the caller assumes focus was changed, going as far as asserting that fact like meta_window_unmanage() does.

As a result, mutter may abort simply because meta_window_focus() failed to set focus on the expected window.

To avoid that issue, check that the focus did not end up on the window that we explicitly did not want, and if that's the case, simply fallback to the default focus window.

Closes: #862 (closed)

Merge request reports