From 413daa7ba2ea0ebd1424c024fd0566423aaea3f8 Mon Sep 17 00:00:00 2001 From: srdusr <99972264+srdusr@users.noreply.github.com> Date: Fri, 14 Feb 2025 21:36:00 +0200 Subject: Fix workspace switches undoing themselves within milliseconds sync()'s per-tick platform.focus(id) re-assertion (added to keep real Wayland/X11 keyboard focus following core's own bookkeeping) ran unconditionally on every dirty tick, including when nothing about focus had actually changed. focus_window (core) has its own, separate side effect of switching to the focused window's workspace when it differs from the current one - correct when focus genuinely moves to a window on another workspace, but this call was never gated on focus having changed at all: switching workspace via activate_workspace left the still-focused window's own workspace field untouched, so the very next dirty tick's blind re-assertion of that same focus saw a mismatch against the just-changed current_workspace and switched straight back. Confirmed live via temporary core-side logging: two switch_workspace calls a few milliseconds apart, the second one undoing the first every single time, for every workspace switch that didn't also change which window was focused. Gated the re-assertion on the focused id actually changing since the last sync() call. Real focus-follows-real-platform-focus still happens on every genuine change, which is all the original fix needed. --- crates/core/src/manager/workspaces.rs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'crates/core') diff --git a/crates/core/src/manager/workspaces.rs b/crates/core/src/manager/workspaces.rs index ddc8341..6ffb21b 100644 --- a/crates/core/src/manager/workspaces.rs +++ b/crates/core/src/manager/workspaces.rs @@ -50,14 +50,7 @@ impl WindowManager { /// doesn't need its own separate bookkeeping. pub fn switch_workspace(&mut self, id: WorkspaceId) { let target = if self.auto_back_and_forth && id == self.current_workspace { self.previous_workspace } else { id }; - let exists = self.workspaces.iter().any(|w| w.id == target); - log::warn!( - "SWITCH-WS-DIAG requested_id={id} auto_back_and_forth={} current={} previous={} target={target} exists={exists}", - self.auto_back_and_forth, - self.current_workspace, - self.previous_workspace - ); - if exists && target != self.current_workspace { + if self.workspaces.iter().any(|w| w.id == target) && target != self.current_workspace { self.previous_workspace = self.current_workspace; self.current_workspace = target; } -- cgit v1.2.3