Skip to content

Fix focus loss when destroying a standalone toplevel#41

Merged
malbiruk merged 1 commit intomalbiruk:mainfrom
nico4348:fix/refocus-history-on-destroy
Apr 18, 2026
Merged

Fix focus loss when destroying a standalone toplevel#41
malbiruk merged 1 commit intomalbiruk:mainfrom
nico4348:fix/refocus-history-on-destroy

Conversation

@nico4348
Copy link
Copy Markdown
Contributor

Changes

In toplevel_destroyed, when the destroyed xdg-toplevel has no parent surface, fall back to the most recent previous window from focus_history instead of calling set_focus(None).

Purpose

With focus_follows_mouse = true, closing a standalone picker window (clipboard manager, launcher wrapped in a terminal, etc.) leaves keyboard focus empty until the pointer crosses another surface. The XWayland path already has this fallback; this brings xdg_shell in line.

Fixes #40

When a focused xdg-toplevel without a parent surface is destroyed,
keyboard focus was cleared with set_focus(None) instead of falling
back to focus_history. With focus_follows_mouse enabled and the
pointer over empty canvas, this leaves the session with no focused
window until the user crosses the pointer onto another surface.

Mirror the fallback already used by the XWayland widget path: prefer
parent focus, otherwise pick the most recent previous window from
focus_history.

Fixes malbiruk#40
@malbiruk malbiruk merged commit e084d01 into malbiruk:main Apr 18, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Focus is lost when a focused window without parent is closed

2 participants