Bugfix: Correctly recognize duplicate workspace assignments (Thanks Moredread)

Example of a faulty config:

    workspace 5 VGA1
    workspace 5 LVDS1

Fixes #498, #499
This commit is contained in:
Michael Stapelberg 2011-08-26 12:35:42 +02:00
parent a96a2d243c
commit 12e15609ef
1 changed files with 19 additions and 4 deletions

View File

@ -941,12 +941,27 @@ workspace:
} }
DLOG("Should assign workspace %s to output %s\n", ws_name, $4); DLOG("Should assign workspace %s to output %s\n", ws_name, $4);
struct Workspace_Assignment *assignment = scalloc(sizeof(struct Workspace_Assignment)); /* Check for earlier assignments of the same workspace so that we
* dont have assignments of a single workspace to different
* outputs */
struct Workspace_Assignment *assignment;
bool duplicate = false;
TAILQ_FOREACH(assignment, &ws_assignments, ws_assignments) {
if (strcasecmp(assignment->name, ws_name) == 0) {
ELOG("You have a duplicate workspace assignment for workspace \"%s\"\n",
ws_name);
assignment->output = $4;
duplicate = true;
}
}
if (!duplicate) {
assignment = scalloc(sizeof(struct Workspace_Assignment));
assignment->name = ws_name; assignment->name = ws_name;
assignment->output = $4; assignment->output = $4;
TAILQ_INSERT_TAIL(&ws_assignments, assignment, ws_assignments); TAILQ_INSERT_TAIL(&ws_assignments, assignment, ws_assignments);
} }
} }
}
| TOKWORKSPACE NUMBER workspace_name | TOKWORKSPACE NUMBER workspace_name
{ {
int ws_num = $2; int ws_num = $2;