2 # vim:ts=4:sw=4:expandtab
4 # Please read the following documents before working on tests:
5 # • http://build.i3wm.org/docs/testsuite.html
8 # • http://build.i3wm.org/docs/lib-i3test.html
9 # (alternatively: perldoc ./testcases/lib/i3test.pm)
11 # • http://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 # Ensure that hovering over the window decoration of a window causes it to focus
20 # Bug still in: 4.10.2-174-g8029ff0
23 my ($ws, $A, $B, $C, $target, $y);
26 # ==================================================================================
27 # Given the following layout (= denotes the window decoration),
28 # when moving the mouse from 1 to 2,
29 # then the C should be focused.
31 # This should especially be the case if B is the focus head of its vertically split parent container.
39 # ==================================================================================
41 $ws = fresh_workspace;
47 $target = get_focused($ws);
49 @cons = @{get_ws($ws)->{nodes}};
51 $C = $cons[1]->{nodes}[1];
53 $y = $C->{rect}->{y} - 0.5 * $C->{deco_rect}->{height};
55 # make sure that B is the focus head of its parent
56 cmd '[id="' . $B->{id} . '"] focus';
58 # move pointer to position 1
59 $x->root->warp_pointer($C->{rect}->{x} - 0.5 * $A->{rect}->{width}, $y);
62 # move pointer to position 2
63 $x->root->warp_pointer($C->{rect}->{x} + 0.5 * $C->{rect}->{width}, $y);
66 is(get_focused($ws), $target, 'focus switched to container C');
68 # ==================================================================================
69 # Given a tabbed container when the mouse is moved onto the window decoration
70 # then the focus head of the tabbed container is focused regardless of which particular
71 # tab's decoration the mouse is on.
73 # +=========+=========+
75 # | 1 +=2==|****| <- tab to the right is focus head of tabbed container
77 # +---------+---------+
79 # ==================================================================================
81 $ws = fresh_workspace;
89 $target = get_focused($ws);
92 @cons = @{get_ws($ws)->{nodes}};
94 $B = $cons[1]->{nodes}[1]->{nodes}[1];
96 $y = $B->{rect}->{y} - 0.5 * $B->{deco_rect}->{height};
98 $x->root->warp_pointer($B->{rect}->{x} - 0.5 * $A->{rect}->{width}, $y);
101 $x->root->warp_pointer($B->{rect}->{x} + 0.2 * $B->{rect}->{width}, $y);
104 is(get_focused($ws), $target, 'focus switched to the focus head of the tabbed container');
106 # ==================================================================================
107 # Given a stacked container when the mouse is moved onto the window decoration
108 # then the focus head of the stacked container is focused regardless of which particular
109 # tab's decoration the mouse is on.
111 # +=========+=========+
114 # | +*********+ <- the lower tab is the focus head of the stacked container
116 # +---------+---------+
118 # ==================================================================================
120 $ws = fresh_workspace;
128 $target = get_focused($ws);
129 cmd 'layout stacked';
131 @cons = @{get_ws($ws)->{nodes}};
133 $B = $cons[1]->{nodes}[1]->{nodes}[0];
134 $C = $cons[1]->{nodes}[1]->{nodes}[1];
136 $y = $B->{rect}->{y} - 1.5 * $B->{deco_rect}->{height};
138 $x->root->warp_pointer($B->{rect}->{x} - 0.5 * $A->{rect}->{width}, $y);
141 $x->root->warp_pointer($B->{rect}->{x} + 0.5 * $B->{rect}->{width}, $y);
144 is(get_focused($ws), $target, 'focus switched to the focus head of the stacked container');
146 # ==================================================================================