Merge pull request #3799 from xzfc/3527-workspace-number

extract_workspace_names_from_bindings: handle optional flags
next
Orestis 2019-09-28 08:41:27 +03:00 committed by GitHub
commit 94fdb92d7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 5 deletions

View File

@ -197,18 +197,27 @@ void extract_workspace_names_from_bindings(void) {
while (*target == ' ' || *target == '\t')
target++;
/* We check if this is the workspace
* next/prev/next_on_output/prev_on_output/back_and_forth/number command.
* next/prev/next_on_output/prev_on_output/back_and_forth command.
* Beware: The workspace names "next", "prev", "next_on_output",
* "prev_on_output", "number", "back_and_forth" and "current" are OK,
* "prev_on_output", "back_and_forth" and "current" are OK,
* so we check before stripping the double quotes */
if (strncasecmp(target, "next", strlen("next")) == 0 ||
strncasecmp(target, "prev", strlen("prev")) == 0 ||
strncasecmp(target, "next_on_output", strlen("next_on_output")) == 0 ||
strncasecmp(target, "prev_on_output", strlen("prev_on_output")) == 0 ||
strncasecmp(target, "number", strlen("number")) == 0 ||
strncasecmp(target, "back_and_forth", strlen("back_and_forth")) == 0 ||
strncasecmp(target, "current", strlen("current")) == 0)
continue;
if (strncasecmp(target, "--no-auto-back-and-forth", strlen("--no-auto-back-and-forth")) == 0) {
target += strlen("--no-auto-back-and-forth");
while (*target == ' ' || *target == '\t')
target++;
}
if (strncasecmp(target, "number", strlen("number")) == 0) {
target += strlen("number");
while (*target == ' ' || *target == '\t')
target++;
}
char *target_name = parse_string(&target, false);
if (target_name == NULL)
continue;

View File

@ -125,4 +125,22 @@ is_deeply(\@names, [ '3' ], 'i3 starts on workspace 3');
exit_gracefully($pid);
##############################################################
# 7: verify optional flags do not affect startup workspace
##############################################################
$config = <<EOT;
# i3 config file (v4)
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
bindsym Mod1+1 workspace --no-auto-back-and-forth number 3:three
EOT
$pid = launch_with_config($config);
@names = @{get_workspace_names()};
is_deeply(\@names, [ '3:three' ], 'i3 starts on named workspace 3:three');
exit_gracefully($pid);
done_testing;

View File

@ -19,10 +19,9 @@
use i3test i3_autostart => 0;
my $first_lines = <<'EOT';
set $workspace1 workspace number 1
set $workspace0 workspace eggs
bindsym Mod4+1 $workspace1
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
EOT
# Intentionally don't add a trailing newline for the last line since this is