Implement the window::close event
Patch status: merged
Patch by Tony Crisci
Long description:
The window::close event should be emitted when a window closes.
To apply this patch, use:
curl http://cr.i3wm.org/patch/591/raw.patch | git am
b/docs/ipc
17 |
@@ -717,6 +717,7 @@ This event consists of a single serialized map containing a property |
18 |
+change (string)+ which indicates the type of the change |
19 |
|
20 |
* +new+ - the window has become managed by i3 |
21 |
+* +close+ - the window has closed |
22 |
* +focus+ - the window has received input focus |
23 |
* +title+ - the window's title has changed |
24 |
* +fullscreen_mode+ - the window has entered or exited fullscreen mode |
b/src/tree.c
29 |
@@ -255,6 +255,7 @@ bool tree_close(Con *con, kill_window_t kill_window, bool dont_kill_parent, bool |
30 |
* X11 Errors are returned when the window was already destroyed */ |
31 |
add_ignore_event(cookie.sequence, 0); |
32 |
} |
33 |
+ ipc_send_window_event("close", con); |
34 |
FREE(con->window->class_class); |
35 |
FREE(con->window->class_instance); |
36 |
i3string_free(con->window->name); |
b/testcases/t/231-ipc-window-close.t
42 |
@@ -0,0 +1,52 @@ |
43 |
+#!perl |
44 |
+# vim:ts=4:sw=4:expandtab |
45 |
+# |
46 |
+# Please read the following documents before working on tests: |
47 |
+# • http://build.i3wm.org/docs/testsuite.html |
48 |
+# (or docs/testsuite) |
49 |
+# |
50 |
+# • http://build.i3wm.org/docs/lib-i3test.html |
51 |
+# (alternatively: perldoc ./testcases/lib/i3test.pm) |
52 |
+# |
53 |
+# • http://build.i3wm.org/docs/ipc.html |
54 |
+# (or docs/ipc) |
55 |
+# |
56 |
+# • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf |
57 |
+# (unless you are already familiar with Perl) |
58 |
+# |
59 |
+# Tests that the ipc close event works properly |
60 |
+# |
61 |
+# Bug still in: 4.8-7-gf4a8253 |
62 |
+use i3test; |
63 |
+ |
64 |
+my $i3 = i3(get_socket_path()); |
65 |
+$i3->connect()->recv; |
66 |
+ |
67 |
+my $cv; |
68 |
+my $t; |
69 |
+ |
70 |
+sub reset_test { |
71 |
+ $cv = AE::cv; |
72 |
+ $t = AE::timer(0.5, 0, sub { $cv->send(0); }); |
73 |
+} |
74 |
+ |
75 |
+reset_test; |
76 |
+ |
77 |
+$i3->subscribe({ |
78 |
+ window => sub { |
79 |
+ my ($e) = @_; |
80 |
+ if ($e->{change} eq 'close') { |
81 |
+ $cv->send($e->{container}); |
82 |
+ } |
83 |
+ }, |
84 |
+ })->recv; |
85 |
+ |
86 |
+my $window = open_window; |
87 |
+ |
88 |
+cmd 'kill'; |
89 |
+my $con = $cv->recv; |
90 |
+ |
91 |
+ok($con, 'closing a window should send the window::close event'); |
92 |
+is($con->{window}, $window->{id}, 'the event should contain information about the window'); |
93 |
+ |
94 |
+done_testing; |