Make the old 'assign' case-insensitive again (+test) (Thanks aksr)

This commit is contained in:
Michael Stapelberg 2011-09-11 21:16:45 +01:00
parent 67cf37ce66
commit b3e1fb1f3b
2 changed files with 54 additions and 2 deletions

View File

@ -1071,11 +1071,23 @@ assign:
char *separator = NULL; char *separator = NULL;
if ((separator = strchr(criteria, '/')) != NULL) { if ((separator = strchr(criteria, '/')) != NULL) {
*(separator++) = '\0'; *(separator++) = '\0';
match->title = regex_new(separator); char *pattern;
if (asprintf(&pattern, "(?i)%s", separator) == -1) {
ELOG("asprintf failed\n");
break;
}
match->title = regex_new(pattern);
free(pattern);
printf(" title = %s\n", separator); printf(" title = %s\n", separator);
} }
if (*criteria != '\0') { if (*criteria != '\0') {
match->class = regex_new(criteria); char *pattern;
if (asprintf(&pattern, "(?i)%s", criteria) == -1) {
ELOG("asprintf failed\n");
break;
}
match->class = regex_new(pattern);
free(pattern);
printf(" class = %s\n", criteria); printf(" class = %s\n", criteria);
} }
free(criteria); free(criteria);

View File

@ -182,6 +182,46 @@ exit_gracefully($process->pid);
sleep 0.25; sleep 0.25;
#####################################################################
# make sure that assignments are case-insensitive in the old syntax.
#####################################################################
$config = <<EOT;
# i3 config file (v4)
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
assign "special" ~
EOT
$process = launch_with_config($config);
$tmp = fresh_workspace;
ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
my $workspaces = get_workspace_names;
ok(!("targetws" ~~ @{$workspaces}), 'targetws does not exist yet');
my $window = $x->root->create_child(
class => WINDOW_CLASS_INPUT_OUTPUT,
rect => [ 0, 0, 30, 30 ],
background_color => '#0000ff',
);
$window->_create;
set_wm_class($window->id, 'SPEcial', 'SPEcial');
$window->name('special window');
$window->map;
sleep 0.25;
my $content = get_ws($tmp);
ok(@{$content->{nodes}} == 0, 'no tiling cons');
ok(@{$content->{floating_nodes}} == 1, 'one floating con');
$window->destroy;
exit_gracefully($process->pid);
sleep 0.25;
##################################################################### #####################################################################
# regression test: dock clients with floating assignments should not crash # regression test: dock clients with floating assignments should not crash
# (instead, nothing should happen - dock clients cant float) # (instead, nothing should happen - dock clients cant float)