cfg_workspace: Accept outputs with spaces again
This is a regression from bce088679
.
An other way to fix this would be to concatenate strings inside the
strtok loop when an output starts with a double quote but I'd rather
let the parser do the word splitting.
Fixes #3646
This commit is contained in:
parent
3aa42cf795
commit
8ce99cdacb
|
@ -277,11 +277,13 @@ state WORKSPACE:
|
||||||
|
|
||||||
state WORKSPACE_OUTPUT:
|
state WORKSPACE_OUTPUT:
|
||||||
'output'
|
'output'
|
||||||
-> WORKSPACE_OUTPUT_STR
|
-> WORKSPACE_OUTPUT_WORD
|
||||||
|
|
||||||
state WORKSPACE_OUTPUT_STR:
|
state WORKSPACE_OUTPUT_WORD:
|
||||||
output = string
|
output = word
|
||||||
-> call cfg_workspace($workspace, $output)
|
-> call cfg_workspace($workspace, $output); WORKSPACE_OUTPUT_WORD
|
||||||
|
end
|
||||||
|
-> INITIAL
|
||||||
|
|
||||||
# ipc-socket <path>
|
# ipc-socket <path>
|
||||||
state IPC_SOCKET:
|
state IPC_SOCKET:
|
||||||
|
|
|
@ -334,12 +334,18 @@ CFGFUN(show_marks, const char *value) {
|
||||||
config.show_marks = eval_boolstr(value);
|
config.show_marks = eval_boolstr(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
CFGFUN(workspace, const char *workspace, const char *outputs) {
|
static char *current_workspace = NULL;
|
||||||
DLOG("Assigning workspace \"%s\" to outputs \"%s\"\n", workspace, outputs);
|
|
||||||
/* Check for earlier assignments of the same workspace so that we
|
CFGFUN(workspace, const char *workspace, const char *output) {
|
||||||
* don’t have assignments of a single workspace to different
|
|
||||||
* outputs */
|
|
||||||
struct Workspace_Assignment *assignment;
|
struct Workspace_Assignment *assignment;
|
||||||
|
|
||||||
|
/* When a new workspace line is encountered, for the first output word,
|
||||||
|
* $workspace from the config.spec is non-NULL. Afterwards, the parser calls
|
||||||
|
* clear_stack() because of the call line. Thus, we have to preserve the
|
||||||
|
* workspace string. */
|
||||||
|
if (workspace) {
|
||||||
|
FREE(current_workspace);
|
||||||
|
|
||||||
TAILQ_FOREACH(assignment, &ws_assignments, ws_assignments) {
|
TAILQ_FOREACH(assignment, &ws_assignments, ws_assignments) {
|
||||||
if (strcasecmp(assignment->name, workspace) == 0) {
|
if (strcasecmp(assignment->name, workspace) == 0) {
|
||||||
ELOG("You have a duplicate workspace assignment for workspace \"%s\"\n",
|
ELOG("You have a duplicate workspace assignment for workspace \"%s\"\n",
|
||||||
|
@ -348,16 +354,21 @@ CFGFUN(workspace, const char *workspace, const char *outputs) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char *buf = sstrdup(outputs);
|
current_workspace = sstrdup(workspace);
|
||||||
char *output = strtok(buf, " ");
|
} else {
|
||||||
while (output != NULL) {
|
if (!current_workspace) {
|
||||||
|
DLOG("Both workspace and current_workspace are NULL, assuming we had an error before\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
workspace = current_workspace;
|
||||||
|
}
|
||||||
|
|
||||||
|
DLOG("Assigning workspace \"%s\" to output \"%s\"\n", workspace, output);
|
||||||
|
|
||||||
assignment = scalloc(1, sizeof(struct Workspace_Assignment));
|
assignment = scalloc(1, sizeof(struct Workspace_Assignment));
|
||||||
assignment->name = sstrdup(workspace);
|
assignment->name = sstrdup(workspace);
|
||||||
assignment->output = sstrdup(output);
|
assignment->output = sstrdup(output);
|
||||||
TAILQ_INSERT_TAIL(&ws_assignments, assignment, ws_assignments);
|
TAILQ_INSERT_TAIL(&ws_assignments, assignment, ws_assignments);
|
||||||
output = strtok(NULL, " ");
|
|
||||||
}
|
|
||||||
free(buf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CFGFUN(ipc_socket, const char *path) {
|
CFGFUN(ipc_socket, const char *path) {
|
||||||
|
|
|
@ -400,12 +400,18 @@ $config = <<'EOT';
|
||||||
workspace 3 output VGA-1
|
workspace 3 output VGA-1
|
||||||
workspace "4: output" output VGA-2
|
workspace "4: output" output VGA-2
|
||||||
workspace bleh output LVDS1/I_1
|
workspace bleh output LVDS1/I_1
|
||||||
|
# See #3646
|
||||||
|
workspace foo output a b c "a b c"
|
||||||
EOT
|
EOT
|
||||||
|
|
||||||
$expected = <<'EOT';
|
$expected = <<'EOT';
|
||||||
cfg_workspace(3, VGA-1)
|
cfg_workspace(3, VGA-1)
|
||||||
cfg_workspace(4: output, VGA-2)
|
cfg_workspace(4: output, VGA-2)
|
||||||
cfg_workspace(bleh, LVDS1/I_1)
|
cfg_workspace(bleh, LVDS1/I_1)
|
||||||
|
cfg_workspace(foo, a)
|
||||||
|
cfg_workspace((null), b)
|
||||||
|
cfg_workspace((null), c)
|
||||||
|
cfg_workspace((null), a b c)
|
||||||
EOT
|
EOT
|
||||||
|
|
||||||
is(parser_calls($config),
|
is(parser_calls($config),
|
||||||
|
|
|
@ -79,7 +79,9 @@ workspace 1 output fake-1 fake-2
|
||||||
workspace 2 output fake-3 fake-4 fake-0 fake-1
|
workspace 2 output fake-3 fake-4 fake-0 fake-1
|
||||||
workspace 3 output these outputs do not exist but these do: fake-0 fake-3
|
workspace 3 output these outputs do not exist but these do: fake-0 fake-3
|
||||||
workspace 4 output whitespace fake-0
|
workspace 4 output whitespace fake-0
|
||||||
workspace special output doesnotexist1 doesnotexist2 doesnotexist3
|
workspace foo output doesnotexist1 doesnotexist2 doesnotexist3
|
||||||
|
workspace bar output doesnotexist
|
||||||
|
workspace bar output fake-0
|
||||||
EOT
|
EOT
|
||||||
|
|
||||||
$pid = launch_with_config($config);
|
$pid = launch_with_config($config);
|
||||||
|
@ -91,8 +93,11 @@ do_test('4', 'fake-0', 'Excessive whitespace is ok');
|
||||||
do_test('5', 'fake-1', 'Numbered initialization for fake-1');
|
do_test('5', 'fake-1', 'Numbered initialization for fake-1');
|
||||||
do_test('6', 'fake-2', 'Numbered initialization for fake-2');
|
do_test('6', 'fake-2', 'Numbered initialization for fake-2');
|
||||||
|
|
||||||
cmd 'focus output fake-0, workspace special';
|
cmd 'focus output fake-0, workspace foo';
|
||||||
check_output('special', 'fake-0', 'Workspace with only non-existing assigned outputs opened in current output.');
|
check_output('foo', 'fake-0', 'Workspace with only non-existing assigned outputs opened in current output');
|
||||||
|
|
||||||
|
cmd 'focus output fake-0, workspace bar';
|
||||||
|
check_output('bar', 'fake-0', 'Second workspace assignment line ignored');
|
||||||
|
|
||||||
# Moving assigned workspaces.
|
# Moving assigned workspaces.
|
||||||
cmd 'workspace 2, move workspace to output left';
|
cmd 'workspace 2, move workspace to output left';
|
||||||
|
|
Loading…
Reference in New Issue