i3 - improved tiling WM


Bugfix: cross-output focus should focus floating

Patch status: needinfo

Patch by Tony Crisci

Long description:

Focusing across outputs with `focus [direction]` should focus an
existing floating con when no tiling con exists on the output in
[direction].

To apply this patch, use:
curl http://cr.i3wm.org/patch/579/raw.patch | git am

b/src/commands.c

18
@@ -1379,6 +1379,12 @@ void cmd_focus_direction(I3_CMD, char *direction) {
19
         return;
20
     }
21
 
22
+    /* XXX: if tree_next() focused a workspace, we may have to descend into the
23
+     * floating cons on this workspace to find the correct con to focus, but we
24
+     * shouldn't have to do this. */
25
+    if (focused->type == CT_WORKSPACE && !TAILQ_EMPTY(&focused->floating_head))
26
+        con_focus(con_descend_focused(TAILQ_FIRST(&focused->floating_head)));
27
+
28
     cmd_output->needs_tree_render = true;
29
     // XXX: default reply for now, make this a better reply
30
     ysuccess(true);

b/testcases/t/520-regress-focus-direction-floating.t

36
@@ -0,0 +1,48 @@
37
+#!perl
38
+# vim:ts=4:sw=4:expandtab
39
+#
40
+# Please read the following documents before working on tests:
41
+# • http://build.i3wm.org/docs/testsuite.html
42
+#   (or docs/testsuite)
43
+#
44
+# • http://build.i3wm.org/docs/lib-i3test.html
45
+#   (alternatively: perldoc ./testcases/lib/i3test.pm)
46
+#
47
+# • http://build.i3wm.org/docs/ipc.html
48
+#   (or docs/ipc)
49
+#
50
+# • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
51
+#   (unless you are already familiar with Perl)
52
+#
53
+# Ensure that `focus [direction]` will focus an existing floating con when no
54
+# tiling con exists on the output in [direction] when focusing across outputs
55
+# Bug still in: 4.7.2-204-g893dbae
56
+use i3test i3_autostart => 0;
57
+
58
+my $config = <<EOT;
59
+# i3 config file (v4)
60
+font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
61
+
62
+workspace ws_left output fake-0
63
+workspace ws_right output fake-1
64
+
65
+mouse_warping none
66
+
67
+fake-outputs 1024x768+0+0,1024x768+1024+0
68
+EOT
69
+
70
+my $pid = launch_with_config($config);
71
+
72
+cmd 'workspace ws_left';
73
+my $win = open_window();
74
+
75
+cmd 'floating enable';
76
+cmd 'focus output right';
77
+cmd 'focus left';
78
+
79
+is($x->input_focus, $win->id,
80
+    'Focusing across outputs with `focus [direction]` should focus an existing floating con when no tiling con exists on the output in [direction].');
81
+
82
+exit_gracefully($pid);
83
+
84
+done_testing;