Skip to content

workspace: match i3's depth-first workspace-output assignment#8993

Closed
mil-ad wants to merge 1 commit intoswaywm:masterfrom
mil-ad:fix-workspace-output-assignment
Closed

workspace: match i3's depth-first workspace-output assignment#8993
mil-ad wants to merge 1 commit intoswaywm:masterfrom
mil-ad:fix-workspace-output-assignment

Conversation

@mil-ad
Copy link
Copy Markdown
Contributor

@mil-ad mil-ad commented Jan 6, 2026

Summary

When selecting which workspace to create on an output, i3 uses a "depth-first" approach: for each workspace, it checks if the current output is the first available choice in that workspace's output list. This allows configurations like:

workspace 1 output DP-1 eDP-1
workspace 9 output eDP-1

When only eDP-1 is connected, i3 would select workspace 1 (since eDP-1 is its first available output). Previously, sway would check if the output was anywhere in the workspace's list, which could lead to unexpected behavior.

For example, with the config above and only eDP-1 connected, sway would start on workspace 9 instead of workspace 1, because workspace 9 appeared to match eDP-1 based on config order rather than output priority.

Changes

  • Updated workspace_valid_on_output() to return true only if the output is the first available choice for that workspace
  • Updated workspace_next_name() to use the same "first available" logic when selecting which workspace to create

Test plan

  • With config workspace 1 output EXTERNAL eDP-1 and workspace 9 output eDP-1, starting sway with only eDP-1 connected should create workspace 1 (not 9)
  • When EXTERNAL monitor is connected, workspace 1 should prefer it over eDP-1
  • Workspaces without output assignments should continue to work normally

🤖 Generated with Claude Code

When selecting which workspace to create on an output, i3 uses a
"depth-first" approach: for each workspace, it checks if the current
output is the *first available* choice in that workspace's output list.
This allows configurations like:

    workspace 1 output DP-1 eDP-1
    workspace 9 output eDP-1

When only eDP-1 is connected, i3 would select workspace 1 (since eDP-1
is its first available output). Previously, sway would check if the
output was *anywhere* in the workspace's list, which could lead to
unexpected behavior depending on config order.

This change updates both workspace_valid_on_output() and
workspace_next_name() to use the same "first available" logic as i3,
making sway's workspace-output assignment behavior match i3 more
closely.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@mil-ad mil-ad marked this pull request as draft January 6, 2026 21:43
@mil-ad mil-ad closed this Jan 6, 2026
@mil-ad mil-ad reopened this Jan 6, 2026
@mil-ad mil-ad closed this Mar 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant