i3 - improved tiling WM


Fix handling of new windows with WM_STATE_FULLSCREEN

Patch status: superseded

Patch by jj

Long description:

If the currently focused window is in fullscreen mode, and a new window
is opened with WM_STATE_FULLSCREEN set, the new window now becomes the
new fullscreen window and gains focus.

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

b/src/manage.c

16
@@ -321,11 +321,20 @@ void manage_window(xcb_window_t window, xcb_get_window_attributes_cookie_t cooki
17
     x_set_name(nc, name);
18
     free(name);
19
 
20
+    /* handle fullscreen containers */
21
     Con *ws = con_get_workspace(nc);
22
     Con *fs = (ws ? con_get_fullscreen_con(ws, CF_OUTPUT) : NULL);
23
     if (fs == NULL)
24
         fs = con_get_fullscreen_con(croot, CF_GLOBAL);
25
 
26
+    xcb_get_property_reply_t *state_reply = xcb_get_property_reply(conn, state_cookie, NULL);
27
+    if (xcb_reply_contains_atom(state_reply, A__NET_WM_STATE_FULLSCREEN)) {
28
+        fs = NULL;
29
+        con_toggle_fullscreen(nc, CF_OUTPUT);
30
+    }
31
+
32
+    FREE(state_reply);
33
+
34
     if (fs == NULL) {
35
         DLOG("Not in fullscreen mode, focusing\n");
36
         if (!cwindow->dock) {
37
@@ -429,12 +438,6 @@ void manage_window(xcb_window_t window, xcb_get_window_attributes_cookie_t cooki
38
     xcb_change_window_attributes(conn, window, XCB_CW_EVENT_MASK, values);
39
     xcb_flush(conn);
40
 
41
-    reply = xcb_get_property_reply(conn, state_cookie, NULL);
42
-    if (xcb_reply_contains_atom(reply, A__NET_WM_STATE_FULLSCREEN))
43
-        con_toggle_fullscreen(nc, CF_OUTPUT);
44
-
45
-    FREE(reply);
46
-
47
     /* Put the client inside the save set. Upon termination (whether killed or
48
      * normal exit does not matter) of the window manager, these clients will
49
      * be correctly reparented to their most closest living ancestor (=