2 # vim:ts=4:sw=4:expandtab
3 # !NO_I3_INSTANCE! will prevent complete-run.pl from starting i3
5 # Tests if assignments work
9 use X11::XCB::Connection;
12 my $x = X11::XCB::Connection->new;
14 # TODO: move to X11::XCB
16 my ($id, $class, $instance) = @_;
18 # Add a _NET_WM_STRUT_PARTIAL hint
19 my $atomname = $x->atom(name => 'WM_CLASS');
20 my $atomtype = $x->atom(name => 'STRING');
28 length($class) + length($instance) + 2,
29 "$instance\x00$class\x00"
34 #####################################################################
35 # start a window and see that it does not get assigned with an empty config
36 #####################################################################
40 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
43 my $process = launch_with_config($config);
45 my $tmp = fresh_workspace;
47 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
49 my $window = $x->root->create_child(
50 class => WINDOW_CLASS_INPUT_OUTPUT,
51 rect => [ 0, 0, 30, 30 ],
52 background_color => '#0000ff',
56 set_wm_class($window->id, 'special', 'special');
57 $window->name('special window');
61 ok(@{get_ws_content($tmp)} == 1, 'special window got managed to current (random) workspace');
63 exit_gracefully($process->pid);
69 #####################################################################
70 # start a window and see that it gets assigned to a formerly unused
72 #####################################################################
76 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
77 assign "special" → targetws
80 $process = launch_with_config($config);
82 $tmp = fresh_workspace;
84 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
85 my $workspaces = get_workspace_names;
86 ok(!("targetws" ~~ @{$workspaces}), 'targetws does not exist yet');
88 my $window = $x->root->create_child(
89 class => WINDOW_CLASS_INPUT_OUTPUT,
90 rect => [ 0, 0, 30, 30 ],
91 background_color => '#0000ff',
95 set_wm_class($window->id, 'special', 'special');
96 $window->name('special window');
100 ok(@{get_ws_content($tmp)} == 0, 'still no containers');
101 ok("targetws" ~~ @{get_workspace_names()}, 'targetws exists');
105 exit_gracefully($process->pid);
109 #####################################################################
110 # start a window and see that it gets assigned to a workspace which has content
111 # already, next to the existing node.
112 #####################################################################
114 $process = launch_with_config($config);
116 # initialize the target workspace, then go to a fresh one
117 ok(!("targetws" ~~ @{get_workspace_names()}), 'targetws does not exist yet');
118 cmd 'workspace targetws';
119 cmp_ok(@{get_ws_content('targetws')}, '==', 0, 'no containers on targetws yet');
121 cmp_ok(@{get_ws_content('targetws')}, '==', 1, 'one container on targetws');
122 $tmp = fresh_workspace;
124 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
125 ok("targetws" ~~ @{get_workspace_names()}, 'targetws does not exist yet');
127 my $window = $x->root->create_child(
128 class => WINDOW_CLASS_INPUT_OUTPUT,
129 rect => [ 0, 0, 30, 30 ],
130 background_color => '#0000ff',
134 set_wm_class($window->id, 'special', 'special');
135 $window->name('special window');
139 ok(@{get_ws_content($tmp)} == 0, 'still no containers');
140 ok(@{get_ws_content('targetws')} == 2, 'two containers on targetws');
142 exit_gracefully($process->pid);
144 #####################################################################
145 # start a window and see that it gets assigned to a workspace which has content
146 # already, next to the existing node.
147 #####################################################################
150 # i3 config file (v4)
151 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
155 $process = launch_with_config($config);
157 $tmp = fresh_workspace;
159 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
160 my $workspaces = get_workspace_names;
161 ok(!("targetws" ~~ @{$workspaces}), 'targetws does not exist yet');
163 my $window = $x->root->create_child(
164 class => WINDOW_CLASS_INPUT_OUTPUT,
165 rect => [ 0, 0, 30, 30 ],
166 background_color => '#0000ff',
170 set_wm_class($window->id, 'special', 'special');
171 $window->name('special window');
175 my $content = get_ws($tmp);
176 ok(@{$content->{nodes}} == 0, 'no tiling cons');
177 ok(@{$content->{floating_nodes}} == 1, 'one floating con');
181 exit_gracefully($process->pid);