From: Orestis Floros Date: Wed, 28 Mar 2018 01:05:48 +0000 (+0300) Subject: Use get_assigned_output for numbers X-Git-Tag: 4.16~68^2~1 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=d525eb80aefcd596c5c40750eb9fa3570e5c55ed;p=i3%2Fi3 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. --- diff --git a/src/workspace.c b/src/workspace.c index 9441042e..a27c6f4b 100644 --- a/src/workspace.c +++ b/src/workspace.c @@ -248,7 +248,9 @@ Con *create_workspace_on_output(Output *output, Con *content) { DLOG("Getting next unused workspace by number\n"); int c = 0; 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); } ws->num = c; diff --git a/testcases/t/297-assign-workspace-to-output.t b/testcases/t/297-assign-workspace-to-output.t new file mode 100644 index 00000000..650efa12 --- /dev/null +++ b/testcases/t/297-assign-workspace-to-output.t @@ -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 = <