Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/handlers/xdg_shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,16 @@ impl XdgShellHandler for DriftWm {
.is_some_and(|f| f.0 == wl_surface)
{
let serial = smithay::utils::SERIAL_COUNTER.next_serial();
keyboard.set_focus(self, parent_focus, serial);
// Standalone toplevels have no parent — fall back to the most
// recent previous window so focus does not vanish (important
// with focus_follows_mouse when the pointer is over empty canvas).
let fallback = parent_focus.or_else(|| {
self.focus_history
.iter()
.find(|w| w != &window)
.and_then(|w| w.wl_surface().map(|s| FocusTarget(s.into_owned())))
});
keyboard.set_focus(self, fallback, serial);
}
// If the destroyed window was fullscreen, restore viewport
let fs_output = self.fullscreen.iter()
Expand Down