]> git.sur5r.net Git - i3/i3/blob - testcases/t/259-net-wm-user-time.t
Merge pull request #2953 from CyberShadow/focus_wrapping
[i3/i3] / testcases / t / 259-net-wm-user-time.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 # Test for _NET_WM_USER_TIME.
18 # Ticket: #2064
19 use i3test;
20 use X11::XCB 'PROP_MODE_REPLACE';
21
22 my ($ws, $other, $con);
23
24 sub open_window_with_user_time {
25     my $wm_user_time = shift;
26
27     my $window = open_window(
28         before_map => sub {
29             my ($window) = @_;
30
31             my $atomname = $x->atom(name => '_NET_WM_USER_TIME');
32             my $atomtype = $x->atom(name => 'CARDINAL');
33             $x->change_property(
34                 PROP_MODE_REPLACE,
35                 $window->id,
36                 $atomname->id,
37                 $atomtype->id,
38                 32,
39                 1,
40                 pack('L1', $wm_user_time),
41             );
42         },
43     );
44
45     return $window;
46 }
47
48 #####################################################################
49 # 1: if _NET_WM_USER_TIME is set to 0, the window is not focused
50 #    initially.
51 #####################################################################
52
53 $ws = fresh_workspace;
54
55 open_window;
56 $other = get_focused($ws);
57 open_window_with_user_time(0);
58
59 is(get_focused($ws), $other, 'new window is not focused');
60
61 #####################################################################
62 # 2: if _NET_WM_USER_TIME is set to something other than 0, the
63 #    window is focused anyway.
64 #####################################################################
65
66 $ws = fresh_workspace;
67
68 open_window;
69 $other = get_focused($ws);
70 open_window_with_user_time(42);
71
72 isnt(get_focused($ws), $other, 'new window is focused');
73
74 done_testing;