move workspace to output: don’t create duplicatively numbered workspaces (#3746)

fixes #3745
This commit is contained in:
Antoine 2019-08-07 22:43:01 -07:00 committed by Michael Stapelberg
parent 840d9202d1
commit 3b88e41dd8
1 changed files with 6 additions and 2 deletions

View File

@ -983,11 +983,15 @@ void workspace_move_to_output(Con *ws, Output *output) {
bool used_assignment = false; bool used_assignment = false;
struct Workspace_Assignment *assignment; struct Workspace_Assignment *assignment;
TAILQ_FOREACH(assignment, &ws_assignments, ws_assignments) { TAILQ_FOREACH(assignment, &ws_assignments, ws_assignments) {
bool attached;
int num;
if (!output_triggers_assignment(current_output, assignment)) { if (!output_triggers_assignment(current_output, assignment)) {
continue; continue;
} }
/* check if this workspace is already attached to the tree */ /* check if this workspace's name or num is already attached to the tree */
if (get_existing_workspace_by_name(assignment->name) != NULL) { num = ws_name_to_number(assignment->name);
attached = ((num == -1) ? get_existing_workspace_by_name(assignment->name) : get_existing_workspace_by_num(num)) != NULL;
if (attached) {
continue; continue;
} }