Handle WM_CHANGE_STATE requests for iconic state
Patch status: merged
Patch by Tony Crisci
Long description:
http://tronche.com/gui/x/icccm/sec-4.html#s-4.1.4 > IconicState - The client's top-level window is iconic (whatever that > means for this window manager). The client can assume that its > top-level window is not viewable, its icon_window (if any) will be > viewable and, failing that, its icon_pixmap (if any) or its > WM_ICON_NAME will be displayed. For these requests, we just close the window. fixes #1279
To apply this patch, use:
curl http://cr.i3wm.org/patch/588/raw.patch | git am
b/include/atoms.xmacro
| 27 |
@@ -34,3 +34,4 @@ xmacro(I3_PID) |
| 28 |
xmacro(_NET_REQUEST_FRAME_EXTENTS) |
| 29 |
xmacro(_NET_FRAME_EXTENTS) |
| 30 |
xmacro(_MOTIF_WM_HINTS) |
| 31 |
+xmacro(WM_CHANGE_STATE) |
b/src/handlers.c
| 36 |
@@ -791,6 +791,21 @@ static void handle_client_message(xcb_client_message_event_t *event) {
|
| 37 |
XCB_ATOM_CARDINAL, 32, 4, |
| 38 |
&r); |
| 39 |
xcb_flush(conn); |
| 40 |
+ } else if (event->type == A_WM_CHANGE_STATE) {
|
| 41 |
+ /* http://tronche.com/gui/x/icccm/sec-4.html#s-4.1.4 */ |
| 42 |
+ Con *con = con_by_window_id(event->window); |
| 43 |
+ |
| 44 |
+ if (con && event->data.data32[0] == 3) {
|
| 45 |
+ /* this request is so we can play some animiation showing the |
| 46 |
+ * window physically moving to the tray before we close it (I |
| 47 |
+ * think) */ |
| 48 |
+ DLOG("Client has requested iconic state. Closing this con. (con = %p)\n", con);
|
| 49 |
+ tree_close(con, DONT_KILL_WINDOW, false, false); |
| 50 |
+ tree_render(); |
| 51 |
+ } else {
|
| 52 |
+ DLOG("Not handling WM_CHANGE_STATE request. (window = %d, state = %d)\n", event->window, event->data.data32[0]);
|
| 53 |
+ } |
| 54 |
+ |
| 55 |
} else {
|
| 56 |
DLOG("unhandled clientmessage\n");
|
| 57 |
return; |
b/testcases/t/231-wm-change-state.t
| 63 |
@@ -0,0 +1,49 @@ |
| 64 |
+#!perl |
| 65 |
+# vim:ts=4:sw=4:expandtab |
| 66 |
+# |
| 67 |
+# Please read the following documents before working on tests: |
| 68 |
+# • http://build.i3wm.org/docs/testsuite.html |
| 69 |
+# (or docs/testsuite) |
| 70 |
+# |
| 71 |
+# • http://build.i3wm.org/docs/lib-i3test.html |
| 72 |
+# (alternatively: perldoc ./testcases/lib/i3test.pm) |
| 73 |
+# |
| 74 |
+# • http://build.i3wm.org/docs/ipc.html |
| 75 |
+# (or docs/ipc) |
| 76 |
+# |
| 77 |
+# • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf |
| 78 |
+# (unless you are already familiar with Perl) |
| 79 |
+# |
| 80 |
+# Correctly handle WM_CHANGE_STATE requests for the iconic state |
| 81 |
+# See http://tronche.com/gui/x/icccm/sec-4.html#s-4.1.4 |
| 82 |
+# Ticket: #1279 |
| 83 |
+# Bug still in: 4.8-7-gf4a8253 |
| 84 |
+use i3test; |
| 85 |
+ |
| 86 |
+sub send_iconic_state_request {
|
| 87 |
+ my ($win) = @_; |
| 88 |
+ |
| 89 |
+ my $msg = pack "CCSLLLLLL", |
| 90 |
+ X11::XCB::CLIENT_MESSAGE, # response_type |
| 91 |
+ 32, # format |
| 92 |
+ 0, # sequence |
| 93 |
+ $win->id, # window |
| 94 |
+ $x->atom(name => 'WM_CHANGE_STATE')->id, # message type |
| 95 |
+ 3, # data32[0] |
| 96 |
+ 0, # data32[1] |
| 97 |
+ 0, # data32[2] |
| 98 |
+ 0, # data32[3] |
| 99 |
+ 0; # data32[4] |
| 100 |
+ |
| 101 |
+ $x->send_event(0, $x->get_root_window(), X11::XCB::EVENT_MASK_SUBSTRUCTURE_REDIRECT, $msg); |
| 102 |
+} |
| 103 |
+ |
| 104 |
+my $ws = fresh_workspace; |
| 105 |
+my $win = open_window; |
| 106 |
+ |
| 107 |
+send_iconic_state_request($win); |
| 108 |
+sync_with_i3; |
| 109 |
+ |
| 110 |
+is(@{get_ws($ws)->{nodes}}, 0, 'When a window requests the iconic state, the container should be closed');
|
| 111 |
+ |
| 112 |
+done_testing; |