diff --git a/include/client.h b/include/client.h index 9da3a5ec..41bd5db3 100644 --- a/include/client.h +++ b/include/client.h @@ -53,6 +53,12 @@ bool client_matches_class_name(Client *client, char *to_class, char *to_title, */ void client_enter_fullscreen(xcb_connection_t *conn, Client *client); +/** + * Leaves fullscreen mode for the current client. This is called by toggle_fullscreen. + * + */ +void client_leave_fullscreen(xcb_connection_t *conn, Client *client); + /** * Toggles fullscreen mode for the given client. It updates the data * structures and reconfigures (= resizes/moves) the client and its frame to diff --git a/src/client.c b/src/client.c index dd88acc1..f8303ea4 100644 --- a/src/client.c +++ b/src/client.c @@ -192,6 +192,38 @@ void client_enter_fullscreen(xcb_connection_t *conn, Client *client) { xcb_flush(conn); } +/* + * Leaves fullscreen mode for the current client. This is called by toggle_fullscreen. + * + */ +void client_leave_fullscreen(xcb_connection_t *conn, Client *client) { + LOG("leaving fullscreen mode\n"); + client->fullscreen = false; + Workspace *ws; + TAILQ_FOREACH(ws, workspaces, workspaces) + if (ws->fullscreen_client == client) + ws->fullscreen_client = NULL; + + if (client_is_floating(client)) { + /* For floating clients it’s enough if we just reconfigure that window (in fact, + * re-rendering the layout will not update the client.) */ + reposition_client(conn, client); + resize_client(conn, client); + /* redecorate_window flushes */ + redecorate_window(conn, client); + } else { + client_set_below_floating(conn, client); + + /* Because the coordinates of the window haven’t changed, it would not be + re-configured if we don’t set the following flag */ + client->force_reconfigure = true; + /* We left fullscreen mode, redraw the whole layout to ensure enternotify events are disabled */ + render_layout(conn); + } + + xcb_flush(conn); +} + /* * Toggles fullscreen mode for the given client. It updates the data structures and * reconfigures (= resizes/moves) the client and its frame to the full size of the