i3 - improved tiling WM


Implement the window::fullscreen event

Patch status: needinfo

Patch by Tony Crisci

Long description:

The fullscreen event is a window with the "change" property set to
"fullscreen". This event should be emitted whenever a window becomes
fullscreen and whenever the window becomes non-fullscreen.

This event can be used to turn off dpms off when a window is fullscreen
or display the fullscreen container name in the status line for instance.

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

b/src/con.c

21
@@ -609,6 +609,9 @@ void con_toggle_fullscreen(Con *con, int fullscreen_mode) {
22
 
23
     DLOG("mode now: %d\n", con->fullscreen_mode);
24
 
25
+    /* Send an ipc window "fullscreen" event */
26
+    ipc_send_window_event("fullscreen", con);
27
+
28
     /* update _NET_WM_STATE if this container has a window */
29
     /* TODO: when a window is assigned to a container which is already
30
      * fullscreened, this state needs to be pushed to the client, too */

b/testcases/t/224-ipc-window-fullscreen.t

36
@@ -0,0 +1,59 @@
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
+# Tests that the ipc window::fullscreen event works properly
54
+#
55
+# Bug still in: 4.7.2-135-g7deb23c
56
+use i3test;
57
+
58
+my $i3 = i3(get_socket_path());
59
+$i3->connect()->recv;
60
+
61
+my $cv;
62
+my $t;
63
+
64
+sub reset_test {
65
+    $cv = AE::cv;
66
+    $t = AE::timer(0.5, 0, sub { $cv->send(0); });
67
+}
68
+
69
+reset_test;
70
+
71
+$i3->subscribe({
72
+        window => sub {
73
+            my ($e) = @_;
74
+            if ($e->{change} eq 'fullscreen') {
75
+                $cv->send($e->{container});
76
+            }
77
+        },
78
+    })->recv;
79
+
80
+my $window = open_window;
81
+
82
+cmd 'fullscreen';
83
+my $con = $cv->recv;
84
+
85
+ok($con, 'got fullscreen window event (on)');
86
+is($con->{fullscreen_mode}, 1, 'window is fullscreen');
87
+
88
+reset_test;
89
+cmd 'fullscreen';
90
+$con = $cv->recv;
91
+
92
+ok($con, 'got fullscreen window event (off)');
93
+is($con->{fullscreen_mode}, 0, 'window is not fullscreen');
94
+
95
+done_testing;