Use get_assigned_output for numbers
This prohibits the usage of workspaces assigned to other outputs in create_workspace_on_output. Eg, with config: workspace 1 output fake-0 workspace 2 output fake-0 and 2 screens workspace 2 would be used for the second screen even though it is assigned to the first one. Also introduces a test for workspace assignments that includes the case described above and some tests that don't fail in the next branch.
This commit is contained in:
parent
1d5b43c18f
commit
d525eb80ae
|
@ -248,7 +248,9 @@ Con *create_workspace_on_output(Output *output, Con *content) {
|
||||||
DLOG("Getting next unused workspace by number\n");
|
DLOG("Getting next unused workspace by number\n");
|
||||||
int c = 0;
|
int c = 0;
|
||||||
while (exists) {
|
while (exists) {
|
||||||
exists = (get_existing_workspace_by_num(++c) != NULL);
|
c++;
|
||||||
|
Con *assigned = get_assigned_output(NULL, c);
|
||||||
|
exists = (get_existing_workspace_by_num(c) || (assigned && assigned != output->con));
|
||||||
DLOG("result for ws %d: exists = %d\n", c, exists);
|
DLOG("result for ws %d: exists = %d\n", c, exists);
|
||||||
}
|
}
|
||||||
ws->num = c;
|
ws->num = c;
|
||||||
|
|
|
@ -0,0 +1,60 @@
|
||||||
|
#!perl
|
||||||
|
# vim:ts=4:sw=4:expandtab
|
||||||
|
#
|
||||||
|
# Please read the following documents before working on tests:
|
||||||
|
# • https://build.i3wm.org/docs/testsuite.html
|
||||||
|
# (or docs/testsuite)
|
||||||
|
#
|
||||||
|
# • https://build.i3wm.org/docs/lib-i3test.html
|
||||||
|
# (alternatively: perldoc ./testcases/lib/i3test.pm)
|
||||||
|
#
|
||||||
|
# • https://build.i3wm.org/docs/ipc.html
|
||||||
|
# (or docs/ipc)
|
||||||
|
#
|
||||||
|
# • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
|
||||||
|
# (unless you are already familiar with Perl)
|
||||||
|
#
|
||||||
|
# Test assignments of workspaces to outputs.
|
||||||
|
use i3test i3_autostart => 0;
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# Test initial workspaces.
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
my $config = <<EOT;
|
||||||
|
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
|
||||||
|
|
||||||
|
fake-outputs 1024x768+0+0,1024x768+1024+0,1024x768+1024+768,1024x768+0+768
|
||||||
|
|
||||||
|
bindsym Mod1+x workspace bindingname
|
||||||
|
|
||||||
|
workspace 9 output doesnotexist
|
||||||
|
workspace special output fake-0
|
||||||
|
workspace 1 output doesnotexist
|
||||||
|
workspace dontusethisname output doesnotexist
|
||||||
|
workspace donotoverride output fake-0
|
||||||
|
workspace 2 output fake-0
|
||||||
|
workspace 3 output fake-0
|
||||||
|
EOT
|
||||||
|
|
||||||
|
my $pid = launch_with_config($config);
|
||||||
|
|
||||||
|
sub check_output {
|
||||||
|
my ($workspace, $output, $msg) = @_;
|
||||||
|
is(get_output_for_workspace($workspace), $output, $msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
check_output('9', '', 'Numbered workspace with a big number that is assigned to output that does not exist is not used');
|
||||||
|
check_output('special', 'fake-0', 'Output gets special workspace because of assignment');
|
||||||
|
check_output('bindingname', 'fake-1', 'Bindings give workspace names');
|
||||||
|
check_output('1', 'fake-2', 'Numbered workspace that is assigned to output that does not exist is used');
|
||||||
|
check_output('2', '', 'Numbered workspace assigned to output with existing workspace is not used');
|
||||||
|
check_output('3', '', 'Numbered workspace assigned to output with existing workspace is not used');
|
||||||
|
check_output('4', 'fake-3', 'First available number that is not assigned to existing output is used');
|
||||||
|
check_output('dontusethisname', '', 'Named workspace that is assigned to output that does not exist is not used');
|
||||||
|
check_output('donotoverride', '', 'Named workspace assigned to already occupied output is not used');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
exit_gracefully($pid);
|
||||||
|
done_testing;
|
Loading…
Reference in New Issue