diff options
| author | srdusr <[email protected]> | 2025-02-14 21:36:00 +0200 |
|---|---|---|
| committer | srdusr <[email protected]> | 2025-02-14 21:36:00 +0200 |
| commit | 413daa7ba2ea0ebd1424c024fd0566423aaea3f8 (patch) | |
| tree | 90c1de1b29052201af7b499ce6a9f60e72ec2598 /crates/core/src/manager/workspaces.rs | |
| parent | ed0b8ecf6c08d920ffd1b52c9dc6a24a436ce977 (diff) | |
| download | srdwm-413daa7ba2ea0ebd1424c024fd0566423aaea3f8.tar.gz srdwm-413daa7ba2ea0ebd1424c024fd0566423aaea3f8.zip | |
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.
Diffstat (limited to 'crates/core/src/manager/workspaces.rs')
| -rw-r--r-- | crates/core/src/manager/workspaces.rs | 9 |
1 files changed, 1 insertions, 8 deletions
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; } |