From 1f708f8aa09bf8bbce82314a76b7f34def90b798 Mon Sep 17 00:00:00 2001 From: srdusr <99972264+srdusr@users.noreply.github.com> Date: Sat, 31 Jan 2026 14:34:00 +0200 Subject: Fix desktop-icon deselection and workspace-teleport-on-close; document a shadow limit Desktop icons stayed highlighted after clicking a window: select_desktop_icon(None) was only ever called from start_desktop_marquee, never from the one place every focus path (click, Alt-Tab, dock IPC, scratchpad show, snap flyout) already funnels through. Added the deselect there instead of per-caller. Closing a focused window could silently switch the user's active workspace: remove_window's fallback picked self.order.last(), but that list is global, not per-workspace, so it could land on a background window elsewhere - and focus_window already switches workspace to match whatever it's given (a real, separate feature for a deliberate srd dispatch focus). Fixed by preferring a same-workspace window first. New general.close_focus_follows_workspace (default false, live-settable) controls what happens only when nothing is left on the current workspace at all: off leaves focus at nothing, matching Windows/GNOME/macOS; on restores the old always-follow-the-global-fallback behaviour. Three new tests. Also documented, not fixed: shadows can still bleed onto a neighbouring *monitor* near a multi-output seam (shadow_rect has no monitor-boundary awareness), found via a live cross-monitor screenshot. Moot for this session since general.shadows is already off in the live config, but a real, open gap for anyone who re-enables shadows on a multi-monitor setup. --- crates/wayland/src/input/focus.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'crates/wayland/src/input') diff --git a/crates/wayland/src/input/focus.rs b/crates/wayland/src/input/focus.rs index ade0759..3fcff58 100644 --- a/crates/wayland/src/input/focus.rs +++ b/crates/wayland/src/input/focus.rs @@ -53,6 +53,18 @@ pub(crate) fn close_dwindow(w: &DWindow) { /// Wayland/X11 keyboard focus - without this, a window can be raised and /// tiled correctly yet never receive a single keystroke. pub(crate) fn focus_window(state: &mut CompState, id: WindowId) { + // Real desktop convention (Windows/GNOME/macOS all do this): a + // selected desktop icon stays highlighted only until something else + // takes focus. Reported live as "highlighted desktop icons don't + // become not highlighted anymore" when clicking a window - `select_ + // desktop_icon(None)` (clearing selection) was only ever called from + // `start_desktop_marquee` (a new marquee-select on bare desktop), never + // from the one place every focus path already funnels through + // regardless of how it got triggered (a click, Alt-Tab, a dock's IPC + // focus dispatch, scratchpad show, ...) - see this function's own + // doc comment on why that funnel already exists for raising. A no-op, + // cheap, when nothing was selected to begin with. + state.select_desktop_icon(None); state.wm.borrow_mut().focus_window(id); // Raises the window in smithay's own `Space` too, not just core's // `order` - `Space` keeps a completely independent stacking order of -- cgit v1.2.3