Fix handling of new windows with WM_STATE_FULLSCREEN
Patch status: merged
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/223/raw.patch | git am
b/src/manage.c
17 |
@@ -321,11 +321,20 @@ void manage_window(xcb_window_t window, xcb_get_window_attributes_cookie_t cooki |
18 |
x_set_name(nc, name); |
19 |
free(name); |
20 |
|
21 |
+ /* handle fullscreen containers */ |
22 |
Con *ws = con_get_workspace(nc); |
23 |
Con *fs = (ws ? con_get_fullscreen_con(ws, CF_OUTPUT) : NULL); |
24 |
if (fs == NULL) |
25 |
fs = con_get_fullscreen_con(croot, CF_GLOBAL); |
26 |
|
27 |
+ xcb_get_property_reply_t *state_reply = xcb_get_property_reply(conn, state_cookie, NULL); |
28 |
+ if (xcb_reply_contains_atom(state_reply, A__NET_WM_STATE_FULLSCREEN)) { |
29 |
+ fs = NULL; |
30 |
+ con_toggle_fullscreen(nc, CF_OUTPUT); |
31 |
+ } |
32 |
+ |
33 |
+ FREE(state_reply); |
34 |
+ |
35 |
if (fs == NULL) { |
36 |
DLOG("Not in fullscreen mode, focusing\n"); |
37 |
if (!cwindow->dock) { |
38 |
@@ -429,12 +438,6 @@ void manage_window(xcb_window_t window, xcb_get_window_attributes_cookie_t cooki |
39 |
xcb_change_window_attributes(conn, window, XCB_CW_EVENT_MASK, values); |
40 |
xcb_flush(conn); |
41 |
|
42 |
- reply = xcb_get_property_reply(conn, state_cookie, NULL); |
43 |
- if (xcb_reply_contains_atom(reply, A__NET_WM_STATE_FULLSCREEN)) |
44 |
- con_toggle_fullscreen(nc, CF_OUTPUT); |
45 |
- |
46 |
- FREE(reply); |
47 |
- |
48 |
/* Put the client inside the save set. Upon termination (whether killed or |
49 |
* normal exit does not matter) of the window manager, these clients will |
50 |
* be correctly reparented to their most closest living ancestor (= |
b/testcases/t/100-fullscreen.t
55 |
@@ -214,4 +214,25 @@ sync_with_i3; |
56 |
# Verify that $swindow was the one that initially remained fullscreen. |
57 |
is(fullscreen_windows($tmp), 0, 'no fullscreen windows on first ws'); |
58 |
|
59 |
+################################################################################ |
60 |
+# Verify that opening a window with _NET_WM_STATE_FULLSCREEN unfullscreens any |
61 |
+# existing container on the workspace and fullscreens the newly opened window. |
62 |
+################################################################################ |
63 |
+ |
64 |
+$tmp = fresh_workspace; |
65 |
+ |
66 |
+$window = open_window(); |
67 |
+ |
68 |
+cmd "fullscreen"; |
69 |
+ |
70 |
+is(fullscreen_windows($tmp), 1, 'one fullscreen window on ws'); |
71 |
+is($x->input_focus, $window->id, 'fullscreen window focused'); |
72 |
+ |
73 |
+$swindow = open_window({ |
74 |
+ fullscreen => 1 |
75 |
+}); |
76 |
+ |
77 |
+is(fullscreen_windows($tmp), 1, 'one fullscreen window on ws'); |
78 |
+is($x->input_focus, $swindow->id, 'fullscreen window focused'); |
79 |
+ |
80 |
done_testing; |