workspace: match i3's depth-first workspace-output assignment#8993
Closed
mil-ad wants to merge 1 commit intoswaywm:masterfrom
Closed
workspace: match i3's depth-first workspace-output assignment#8993mil-ad wants to merge 1 commit intoswaywm:masterfrom
mil-ad wants to merge 1 commit intoswaywm:masterfrom
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
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
workspace_valid_on_output()to return true only if the output is the first available choice for that workspaceworkspace_next_name()to use the same "first available" logic when selecting which workspace to createTest plan
workspace 1 output EXTERNAL eDP-1andworkspace 9 output eDP-1, starting sway with only eDP-1 connected should create workspace 1 (not 9)🤖 Generated with Claude Code