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.
This commit is contained in:
Milad Alizadeh 2026-02-18 16:32:11 +00:00 committed by Kenny Levinsen
parent fa497964fd
commit 99e17d5efb

View file

@ -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;