i3 - improved tiling WM


added testcase for the workspace-focus ipc event when switching focus between two outputs

Patch status: merged

Patch by jj

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

b/testcases/t/514-ipc-workspace-multi-monitor.t

16
@@ -0,0 +1,72 @@
17
+#!perl
18
+# vim:ts=4:sw=4:expandtab
19
+#
20
+# Please read the following documents before working on tests:
21
+# • http://build.i3wm.org/docs/testsuite.html
22
+#   (or docs/testsuite)
23
+#
24
+# • http://build.i3wm.org/docs/lib-i3test.html
25
+#   (alternatively: perldoc ./testcases/lib/i3test.pm)
26
+#
27
+# • http://build.i3wm.org/docs/ipc.html
28
+#   (or docs/ipc)
29
+#
30
+# • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
31
+#   (unless you are already familiar with Perl)
32
+# 
33
+# Ticket: #990
34
+# Bug still in: 4.5.1-23-g82b5978
35
+
36
+use i3test i3_autostart => 0;
37
+
38
+my $config = <<EOT;
39
+# i3 config file (v4)
40
+font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
41
+fake-outputs 1024x768+0+0,1024x768+1024+0
42
+EOT
43
+
44
+my $pid = launch_with_config($config);
45
+
46
+my $i3 = i3(get_socket_path());
47
+
48
+$i3->connect()->recv;
49
+
50
+################################
51
+# Workspaces requests and events
52
+################################
53
+
54
+my $focused = get_ws(focused_ws());
55
+
56
+# Events
57
+
58
+# We are switching to an empty workpspace on the output to the right from an empty workspace on the output on the left, so we expect
59
+# to receive "init", "focus", and "empty".
60
+my $focus = AnyEvent->condvar;
61
+$i3->subscribe({
62
+    workspace => sub {
63
+        my ($event) = @_;
64
+        if ($event->{change} eq 'focus') {
65
+            # Check that we have the old and new workspace
66
+            $focus->send(
67
+                $event->{current}->{name} == '2' &&
68
+                $event->{old}->{name} == $focused->{name}
69
+            );
70
+        }
71
+    }
72
+})->recv;
73
+
74
+cmd 'focus output right';
75
+
76
+my $t;
77
+$t = AnyEvent->timer(
78
+    after => 0.5,
79
+    cb => sub {
80
+        $focus->send(0);
81
+    }
82
+);
83
+
84
+ok($focus->recv, 'Workspace "focus" event received');
85
+
86
+exit_gracefully($pid);
87
+
88
+done_testing;