From efc78de4eee704672c09b5652afce4739e1e54f1 Mon Sep 17 00:00:00 2001 From: Orestis Floros Date: Wed, 22 Aug 2018 14:02:27 +0300 Subject: [PATCH] Introduce con_get_fullscreen_covering_ws This commit will also fix the following bugs: 1. click.c: Users could drag global fullscreen floating containers. 2. render.c: Floating containers would get rendered with a global fullscreen container in another workspace. --- include/con.h | 8 ++++++++ src/click.c | 2 +- src/commands.c | 2 +- src/con.c | 17 +++++++++++++++++ src/handlers.c | 12 ++---------- src/manage.c | 4 +--- src/render.c | 2 +- 7 files changed, 31 insertions(+), 16 deletions(-) diff --git a/include/con.h b/include/con.h index 58123a87..672d80ac 100644 --- a/include/con.h +++ b/include/con.h @@ -120,6 +120,14 @@ Con *con_parent_with_orientation(Con *con, orientation_t orientation); */ Con *con_get_fullscreen_con(Con *con, fullscreen_mode_t fullscreen_mode); +/** + * Returns the fullscreen node that covers the given workspace if it exists. + * This is either a CF_GLOBAL fullscreen container anywhere or a CF_OUTPUT + * fullscreen container in the workspace. + * + */ +Con *con_get_fullscreen_covering_ws(Con *ws); + /** * Returns true if the container is internal, such as __i3_scratch * diff --git a/src/click.c b/src/click.c index 81e95dfa..1218a4c2 100644 --- a/src/click.c +++ b/src/click.c @@ -254,7 +254,7 @@ static int route_click(Con *con, xcb_button_press_event_t *event, const bool mod /* 3: For floating containers, we also want to raise them on click. * We will skip handling events on floating cons in fullscreen mode */ - Con *fs = (ws ? con_get_fullscreen_con(ws, CF_OUTPUT) : NULL); + Con *fs = con_get_fullscreen_covering_ws(ws); if (floatingcon != NULL && fs != con) { /* 4: floating_modifier plus left mouse button drags */ if (mod_pressed && event->detail == XCB_BUTTON_CLICK_LEFT) { diff --git a/src/commands.c b/src/commands.c index ad7d9770..22ec6c3f 100644 --- a/src/commands.c +++ b/src/commands.c @@ -1282,7 +1282,7 @@ void cmd_focus_direction(I3_CMD, const char *direction) { static void cmd_focus_force_focus(Con *con) { /* Disable fullscreen container in workspace with container to be focused. */ Con *ws = con_get_workspace(con); - Con *fullscreen_on_ws = (focused && focused->fullscreen_mode == CF_GLOBAL) ? focused : con_get_fullscreen_con(ws, CF_OUTPUT); + Con *fullscreen_on_ws = con_get_fullscreen_covering_ws(ws); if (fullscreen_on_ws && fullscreen_on_ws != con && !con_has_parent(con, fullscreen_on_ws)) { con_disable_fullscreen(fullscreen_on_ws); } diff --git a/src/con.c b/src/con.c index f20f7c35..844d9b68 100644 --- a/src/con.c +++ b/src/con.c @@ -509,6 +509,23 @@ Con *con_get_fullscreen_con(Con *con, fullscreen_mode_t fullscreen_mode) { return NULL; } +/* + * Returns the fullscreen node that covers the given workspace if it exists. + * This is either a CF_GLOBAL fullscreen container anywhere or a CF_OUTPUT + * fullscreen container in the workspace. + * + */ +Con *con_get_fullscreen_covering_ws(Con *ws) { + if (!ws) { + return NULL; + } + Con *fs = con_get_fullscreen_con(croot, CF_GLOBAL); + if (!fs) { + return con_get_fullscreen_con(ws, CF_OUTPUT); + } + return fs; +} + /** * Returns true if the container is internal, such as __i3_scratch * diff --git a/src/handlers.c b/src/handlers.c index 2c81939c..fe10d4b9 100644 --- a/src/handlers.c +++ b/src/handlers.c @@ -310,16 +310,8 @@ static void handle_configure_request(xcb_configure_request_event_t *event) { DLOG("Configure request!\n"); - Con *workspace = con_get_workspace(con), - *fullscreen = NULL; - - /* There might not be a corresponding workspace for dock cons, therefore we - * have to be careful here. */ - if (workspace) { - fullscreen = con_get_fullscreen_con(workspace, CF_OUTPUT); - if (!fullscreen) - fullscreen = con_get_fullscreen_con(workspace, CF_GLOBAL); - } + Con *workspace = con_get_workspace(con); + Con *fullscreen = con_get_fullscreen_covering_ws(workspace); if (fullscreen != con && con_is_floating(con) && con_is_leaf(con)) { /* find the height for the decorations */ diff --git a/src/manage.c b/src/manage.c index b4d0af95..f97ecc62 100644 --- a/src/manage.c +++ b/src/manage.c @@ -378,9 +378,7 @@ void manage_window(xcb_window_t window, xcb_get_window_attributes_cookie_t cooki /* handle fullscreen containers */ Con *ws = con_get_workspace(nc); - Con *fs = (ws ? con_get_fullscreen_con(ws, CF_OUTPUT) : NULL); - if (fs == NULL) - fs = con_get_fullscreen_con(croot, CF_GLOBAL); + Con *fs = con_get_fullscreen_covering_ws(ws); if (xcb_reply_contains_atom(state_reply, A__NET_WM_STATE_FULLSCREEN)) { /* If this window is already fullscreen (after restarting!), skip diff --git a/src/render.c b/src/render.c index f54094bb..d6306260 100644 --- a/src/render.c +++ b/src/render.c @@ -232,7 +232,7 @@ static void render_root(Con *con, Con *fullscreen) { continue; } Con *workspace = TAILQ_FIRST(&(content->focus_head)); - Con *fullscreen = con_get_fullscreen_con(workspace, CF_OUTPUT); + Con *fullscreen = con_get_fullscreen_covering_ws(workspace); Con *child; TAILQ_FOREACH(child, &(workspace->floating_head), floating_windows) { if (fullscreen != NULL) { -- 2.39.2