2 # vim:ts=4:sw=4:expandtab
4 # Please read the following documents before working on tests:
5 # • https://build.i3wm.org/docs/testsuite.html
8 # • https://build.i3wm.org/docs/lib-i3test.html
9 # (alternatively: perldoc ./testcases/lib/i3test.pm)
11 # • https://build.i3wm.org/docs/ipc.html
14 # • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
15 # (unless you are already familiar with Perl)
17 # Tests for _NET_MOVERESIZE_WINDOW.
19 use i3test i3_autostart => 0;
21 sub moveresize_window {
22 my ($win, $pos_x, $pos_y, $width, $height) = @_;
25 $flags |= (1 << 8) if $pos_x >= 0;
26 $flags |= (1 << 9) if $pos_y >= 0;
27 $flags |= (1 << 10) if $width >= 0;
28 $flags |= (1 << 11) if $height >= 0;
30 my $msg = pack "CCSLLLLLLL",
31 X11::XCB::CLIENT_MESSAGE, # response_type
35 $x->atom(name => '_NET_MOVERESIZE_WINDOW')->id, # message type
36 $flags, # data32[0] (flags)
37 $pos_x, # data32[1] (x)
38 $pos_y, # data32[2] (y)
39 $width, # data32[3] (width)
40 $height; # data32[4] (height)
42 $x->send_event(0, $x->get_root_window(), X11::XCB::EVENT_MASK_SUBSTRUCTURE_REDIRECT, $msg);
48 font font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
54 my ($pid, $ws, $window, $content);
56 ###############################################################################
58 ###############################################################################
59 # A _NET_MOVERESIZE_WINDOW client message can change the position and size
60 # of a floating window.
61 ###############################################################################
63 $pid = launch_with_config($config);
64 $ws = fresh_workspace;
66 $window = open_floating_window(rect => [50, 50, 100, 100]);
67 moveresize_window($window, 0, 0, 555, 666);
69 $content = get_ws($ws);
70 is($content->{floating_nodes}->[0]->{rect}->{x}, 0, 'the x coordinate is correct');
71 is($content->{floating_nodes}->[0]->{rect}->{y}, 0, 'the y coordinate is correct');
72 is($content->{floating_nodes}->[0]->{rect}->{width}, 555, 'the width is correct');
73 is($content->{floating_nodes}->[0]->{rect}->{height}, 666, 'the height is correct');
75 exit_gracefully($pid);
77 ###############################################################################
78 # A _NET_MOVERESIZE_WINDOW client message can change only the position of a
80 ###############################################################################
82 $pid = launch_with_config($config);
83 $ws = fresh_workspace;
85 $window = open_floating_window(rect => [50, 50, 100, 100]);
86 moveresize_window($window, 100, 100, -1, -1);
88 $content = get_ws($ws);
89 is($content->{floating_nodes}->[0]->{rect}->{x}, 100, 'the x coordinate is correct');
90 is($content->{floating_nodes}->[0]->{rect}->{y}, 100, 'the y coordinate is correct');
91 is($content->{floating_nodes}->[0]->{rect}->{width}, 100, 'the width is unchanged');
92 is($content->{floating_nodes}->[0]->{rect}->{height}, 100, 'the height is unchanged');
94 exit_gracefully($pid);
96 ###############################################################################
97 # A _NET_MOVERESIZE_WINDOW client message can change only the size of a
99 ###############################################################################
101 $pid = launch_with_config($config);
102 $ws = fresh_workspace;
104 $window = open_floating_window(rect => [50, 50, 100, 100]);
105 moveresize_window($window, -1, -1, 200, 200);
107 $content = get_ws($ws);
108 is($content->{floating_nodes}->[0]->{rect}->{x}, 50, 'the x coordinate is unchanged');
109 is($content->{floating_nodes}->[0]->{rect}->{y}, 50, 'the y coordinate is unchanged');
110 is($content->{floating_nodes}->[0]->{rect}->{width}, 200, 'the width is correct');
111 is($content->{floating_nodes}->[0]->{rect}->{height}, 200, 'the height is correct');
113 exit_gracefully($pid);
115 ###############################################################################