From 99e17d5efb28cf1017743a709aa28f2e0177f43f Mon Sep 17 00:00:00 2001 From: Milad Alizadeh Date: Wed, 18 Feb 2026 16:32:11 +0000 Subject: [PATCH] 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. --- sway/tree/workspace.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c index 733a002b4..9a8e53d25 100644 --- 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;