From: Michael Stapelberg Date: Fri, 26 Aug 2011 10:35:42 +0000 (+0200) Subject: Bugfix: Correctly recognize duplicate workspace assignments (Thanks Moredread) X-Git-Tag: 4.0.2~15^2 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=12e15609ef04d6934b85086176ac3d6b707d03ca;p=i3%2Fi3 Bugfix: Correctly recognize duplicate workspace assignments (Thanks Moredread) Example of a faulty config: workspace 5 VGA1 workspace 5 LVDS1 Fixes #498, #499 --- diff --git a/src/cfgparse.y b/src/cfgparse.y index a80e25af..c0bf92af 100644 --- a/src/cfgparse.y +++ b/src/cfgparse.y @@ -941,10 +941,25 @@ workspace: } DLOG("Should assign workspace %s to output %s\n", ws_name, $4); - struct Workspace_Assignment *assignment = scalloc(sizeof(struct Workspace_Assignment)); - assignment->name = ws_name; - assignment->output = $4; - TAILQ_INSERT_TAIL(&ws_assignments, assignment, ws_assignments); + /* Check for earlier assignments of the same workspace so that we + * don’t 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->output = $4; + TAILQ_INSERT_TAIL(&ws_assignments, assignment, ws_assignments); + } } } | TOKWORKSPACE NUMBER workspace_name