Skip to content

Add option to restrict swap and focus to the current workspace#2

Open
trftky wants to merge 1 commit intoctadel:masterfrom
trftky:feature/current-workspace-only
Open

Add option to restrict swap and focus to the current workspace#2
trftky wants to merge 1 commit intoctadel:masterfrom
trftky:feature/current-workspace-only

Conversation

@trftky
Copy link
Copy Markdown

@trftky trftky commented Apr 25, 2026

Problem

swap-* shortcuts currently move every window on the two monitors,
including windows on inactive workspaces, because swapWindowsWith
only filters by monitor (monitor.js L72-74). After a swap or any
monitor-* navigation, focus also sometimes jumps to a different
workspace, because _focusMostRecentWindowOnMonitor calls
get_tab_list(0, null), which scans all workspaces.

Reproduce

  1. Two monitors, two or more workspaces.
  2. Different windows on monitors A and B on workspace 1.
  3. Different windows on monitors A and B on workspace 2.
  4. On workspace 1, trigger e.g. swap-0.

→ Workspace 2's A/B windows are also swapped; the active workspace
itself sometimes changes after the action.

Solution

Add a new boolean current-workspace-only preference (default true,
which matches the most common user expectation; can be flipped to
false to preserve the original behavior).

When enabled:

  • swapWindowsWith only swaps windows that live on the active workspace.
  • _focusMostRecentWindowOnMonitor (used by both swap and navigate)
    only looks at windows on the active workspace, so the desktop no
    longer pulls the user out of their current workspace.

Files changed

  • schemas/org.gnome.shell.extensions.binu.gschema.xml — new boolean key
  • schemas/gschemas.compiled — regenerated
  • utils.jsPreferences.isCurrentWorkspaceOnlyEnabled() getter
  • monitor.js — guard the two affected blocks behind the new setting
  • prefs.js — new toggle in Preferences → Window Focus Settings

Test plan

  • Verified locally on GNOME 46 (X11): with the toggle on, swap is
    confined to the current workspace and focus stays put; with the
    toggle off, the original cross-workspace behavior is preserved.
  • Wayland not personally tested, but the changed APIs
    (workspace_manager.get_active_workspace, meta_window.get_workspace,
    display.get_tab_list) are session-agnostic.

`swap-*` shortcuts currently move every window on the two monitors,
including windows on inactive workspaces, because `swapWindowsWith`
only filters by monitor. After a swap or `monitor-*` navigation,
focus can also jump to a different workspace because
`_focusMostRecentWindowOnMonitor` calls `get_tab_list(0, null)`,
which scans all workspaces.

Add a new boolean `current-workspace-only` preference (default `true`)
exposed in Preferences -> Window Focus Settings. When enabled,
`swapWindowsWith` and `_focusMostRecentWindowOnMonitor` only consider
windows on the currently active workspace; disabling it preserves the
original behavior.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

1 participant