i3 - improved tiling WM


Implement the window::fullscreen_mode event

Patch status: merged

Patch by Tony Crisci

Long description:

The fullscreen_mode event is a window with the "change" property set to
"fullscreen_mode". This event should be emitted whenever a window enters
or exits fullscreen mode.

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/521/raw.patch | git am

b/docs/ipc

23
@@ -634,7 +634,7 @@ mode (2)::
24
 window (3)::
25
 	Sent when a client's window is successfully reparented (that is when i3
26
 	has finished fitting it into a container), when a window received input
27
-	focus or when a window title has been updated.
28
+	focus or when certain properties of the window have changed.
29
 barconfig_update (4)::
30
     Sent when the hidden_state or mode field in the barconfig of any bar
31
     instance was updated.
32
@@ -714,8 +714,12 @@ mode is simply named default.
33
 === window event
34
 
35
 This event consists of a single serialized map containing a property
36
-+change (string)+ which indicates the type of the change ("focus", "new",
37
-"title").
38
++change (string)+ which indicates the type of the change
39
+
40
+* +new+ - the window has become managed by i3
41
+* +focus+ - the window has received input focus
42
+* +title+ - the window's title has changed
43
+* +fullscreen_mode+ - the window has entered or exited fullscreen mode
44
 
45
 Additionally a +container (object)+ field will be present, which consists
46
 of the window's parent container. Be aware that for the "new" event, the

b/src/con.c

51
@@ -609,6 +609,9 @@ void con_toggle_fullscreen(Con *con, int fullscreen_mode) {
52
 
53
     DLOG("mode now: %d\n", con->fullscreen_mode);
54
 
55
+    /* Send an ipc window "fullscreen_mode" event */
56
+    ipc_send_window_event("fullscreen_mode", con);
57
+
58
     /* update _NET_WM_STATE if this container has a window */
59
     /* TODO: when a window is assigned to a container which is already
60
      * fullscreened, this state needs to be pushed to the client, too */

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

66
@@ -0,0 +1,59 @@
67
+#!perl
68
+# vim:ts=4:sw=4:expandtab
69
+#
70
+# Please read the following documents before working on tests:
71
+# • http://build.i3wm.org/docs/testsuite.html
72
+#   (or docs/testsuite)
73
+#
74
+# • http://build.i3wm.org/docs/lib-i3test.html
75
+#   (alternatively: perldoc ./testcases/lib/i3test.pm)
76
+#
77
+# • http://build.i3wm.org/docs/ipc.html
78
+#   (or docs/ipc)
79
+#
80
+# • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
81
+#   (unless you are already familiar with Perl)
82
+#
83
+# Tests that the ipc window::fullscreen_mode event works properly
84
+#
85
+# Bug still in: 4.7.2-135-g7deb23c
86
+use i3test;
87
+
88
+my $i3 = i3(get_socket_path());
89
+$i3->connect()->recv;
90
+
91
+my $cv;
92
+my $t;
93
+
94
+sub reset_test {
95
+    $cv = AE::cv;
96
+    $t = AE::timer(0.5, 0, sub { $cv->send(0); });
97
+}
98
+
99
+reset_test;
100
+
101
+$i3->subscribe({
102
+        window => sub {
103
+            my ($e) = @_;
104
+            if ($e->{change} eq 'fullscreen_mode') {
105
+                $cv->send($e->{container});
106
+            }
107
+        },
108
+    })->recv;
109
+
110
+my $window = open_window;
111
+
112
+cmd 'fullscreen';
113
+my $con = $cv->recv;
114
+
115
+ok($con, 'got fullscreen window event (on)');
116
+is($con->{fullscreen_mode}, 1, 'window is fullscreen');
117
+
118
+reset_test;
119
+cmd 'fullscreen';
120
+$con = $cv->recv;
121
+
122
+ok($con, 'got fullscreen window event (off)');
123
+is($con->{fullscreen_mode}, 0, 'window is not fullscreen');
124
+
125
+done_testing;