commit 99e17d5efb28cf1017743a709aa28f2e0177f43f
parent fa497964fd55632beacf5f425e964ae4893e25b9
Author: Milad Alizadeh <git@mil.ad>
Date: Wed, 18 Feb 2026 16:32:11 +0000
tree/workspace: fix output priority in workspace assignment
workspace_valid_on_output() and workspace_next_name() check whether an
output appears anywhere in a workspace's output list, ignoring priority
order. This allows a lower-priority output to claim a workspace even
when a higher-priority output is available.
Fix by stopping early when iterating the output list: if a different
available output is found before the current one, the workspace belongs
to that higher-priority output.
Diffstat:
1 file changed, 6 insertions(+), 0 deletions(-)
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c
@@ -205,6 +205,9 @@ static bool workspace_valid_on_output(const char *output_name,
if (output_match_name_or_id(output, wsc->outputs->items[i])) {
return true;
}
+ if (output_by_name_or_id(wsc->outputs->items[i])) {
+ return false; // a higher-priority output is available
+ }
}
return false;
@@ -326,6 +329,9 @@ char *workspace_next_name(const char *output_name) {
target = strdup(wsc->workspace);
break;
}
+ if (output_by_name_or_id(wsc->outputs->items[j])) {
+ break; // a higher-priority output is available
+ }
}
if (found) {
break;