]> git.sur5r.net Git - i3/i3/blob - testcases/t/288-i3-floating-window-atom.t
Merge branch 'release-4.16.1'
[i3/i3] / testcases / t / 288-i3-floating-window-atom.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3 #
4 # Please read the following documents before working on tests:
5 # • https://build.i3wm.org/docs/testsuite.html
6 #   (or docs/testsuite)
7 #
8 # • https://build.i3wm.org/docs/lib-i3test.html
9 #   (alternatively: perldoc ./testcases/lib/i3test.pm)
10 #
11 # • https://build.i3wm.org/docs/ipc.html
12 #   (or docs/ipc)
13 #
14 # • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
15 #   (unless you are already familiar with Perl)
16 #
17 # Tests for our proprietary atom I3_FLOATING_WINDOW to allow
18 # identifying floating windows.
19 # Ticket: #2223
20 use i3test;
21 use X11::XCB qw(:all);
22
23 my ($con);
24
25 sub has_i3_floating_window {
26     sync_with_i3;
27
28     my ($con) = @_;
29     my $cookie = $x->get_property(
30         0,
31         $con->{id},
32         $x->atom(name => 'I3_FLOATING_WINDOW')->id,
33         $x->atom(name => 'CARDINAL')->id,
34         0,
35         1
36     );
37
38     my $reply = $x->get_property_reply($cookie->{sequence});
39     return 0 if $reply->{length} != 1;
40
41     return unpack("L", $reply->{value});
42 }
43
44 ###############################################################################
45 # Toggling floating on a container adds / removes I3_FLOATING_WINDOW.
46 ###############################################################################
47
48 fresh_workspace;
49
50 $con = open_window;
51 is(has_i3_floating_window($con), 0, 'I3_FLOATING_WINDOW is not set');
52
53 cmd 'floating enable';
54 is(has_i3_floating_window($con), 1, 'I3_FLOATING_WINDOW is set');
55
56 cmd 'floating disable';
57 is(has_i3_floating_window($con), 0, 'I3_FLOATING_WINDOW is not set');
58
59 ###############################################################################
60 # A window that is floated when managed has I3_FLOATING_WINDOW set.
61 ###############################################################################
62 #
63 fresh_workspace;
64
65 $con = open_floating_window;
66 is(has_i3_floating_window($con), 1, 'I3_FLOATING_WINDOW is set');
67
68 ###############################################################################
69
70 done_testing;