From 832ebc896655cb5ca7689559d4e42b426d764e71 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sun, 7 Oct 2018 20:40:05 +1000 Subject: Implement popup_during_fullscreen This introduces a new view_impl function: is_transient_for. Similar to container_has_ancestor but works using the surface parents rather than the tree. This patch modifies view_is_visible, container_at and so on to allow transient views to function normally when they're in front of a fullscreen view. --- sway/tree/view.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'sway/tree/view.c') diff --git a/sway/tree/view.c b/sway/tree/view.c index 73ce55ac..edf771c1 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -1042,7 +1042,14 @@ bool view_is_visible(struct sway_view *view) { // Check view isn't hidden by another fullscreen view if (workspace->fullscreen && !container_is_fullscreen_or_child(view->container)) { - return false; + // However, if we're transient for the fullscreen view and we allow + // "popups" during fullscreen then it might be visible + bool is_transient = config->popup_during_fullscreen == POPUP_SMART && + workspace->fullscreen->view && + view_is_transient_for(view, workspace->fullscreen->view); + if (!is_transient) { + return false; + } } return true; } @@ -1095,3 +1102,9 @@ void view_save_buffer(struct sway_view *view) { view->saved_buffer_height = view->surface->current.height; } } + +bool view_is_transient_for(struct sway_view *child, + struct sway_view *ancestor) { + return child->impl->is_transient_for && + child->impl->is_transient_for(child, ancestor); +} -- cgit v1.2.3 From f23588de3c7085830614f6764a5c0cd262538afd Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Mon, 8 Oct 2018 23:00:36 +1000 Subject: Introduce container_is_transient_for --- include/sway/tree/container.h | 3 +++ sway/desktop/output.c | 15 ++++++--------- sway/desktop/render.c | 12 ++++-------- sway/input/cursor.c | 18 +++++++----------- sway/input/seat.c | 6 +----- sway/tree/container.c | 7 +++++++ sway/tree/view.c | 6 ++---- 7 files changed, 30 insertions(+), 37 deletions(-) (limited to 'sway/tree/view.c') diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h index da6592b4..920ef038 100644 --- a/include/sway/tree/container.h +++ b/include/sway/tree/container.h @@ -292,4 +292,7 @@ bool sway_dir_to_wlr(enum movement_direction dir, enum wlr_direction *out); struct sway_container *container_split(struct sway_container *child, enum sway_container_layout layout); +bool container_is_transient_for(struct sway_container *child, + struct sway_container *ancestor); + #endif diff --git a/sway/desktop/output.c b/sway/desktop/output.c index 0bcdcac1..adc1ee10 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c @@ -329,15 +329,12 @@ static void send_frame_done(struct sway_output *output, struct timespec *when) { workspace->current.fullscreen, &data); container_for_each_child(workspace->current.fullscreen, send_frame_done_container_iterator, &data); - if (config->popup_during_fullscreen == POPUP_SMART && - workspace->current.fullscreen->view) { - for (int i = 0; i < workspace->current.floating->length; ++i) { - struct sway_container *floater = - workspace->current.floating->items[i]; - if (floater->view && view_is_transient_for(floater->view, - workspace->current.fullscreen->view)) { - send_frame_done_container_iterator(floater, &data); - } + for (int i = 0; i < workspace->current.floating->length; ++i) { + struct sway_container *floater = + workspace->current.floating->items[i]; + if (container_is_transient_for(floater, + workspace->current.fullscreen)) { + send_frame_done_container_iterator(floater, &data); } } #ifdef HAVE_XWAYLAND diff --git a/sway/desktop/render.c b/sway/desktop/render.c index c2a0d29f..765317db 100644 --- a/sway/desktop/render.c +++ b/sway/desktop/render.c @@ -962,14 +962,10 @@ void output_render(struct sway_output *output, struct timespec *when, fullscreen_con->current.focused); } - if (config->popup_during_fullscreen == POPUP_SMART && - fullscreen_con->view) { - for (int i = 0; i < workspace->floating->length; ++i) { - struct sway_container *floater = workspace->floating->items[i]; - if (floater->view && view_is_transient_for( - floater->view, fullscreen_con->view)) { - render_floating_container(output, damage, floater); - } + for (int i = 0; i < workspace->floating->length; ++i) { + struct sway_container *floater = workspace->floating->items[i]; + if (container_is_transient_for(floater, fullscreen_con)) { + render_floating_container(output, damage, floater); } } #ifdef HAVE_XWAYLAND diff --git a/sway/input/cursor.c b/sway/input/cursor.c index 08eeb812..6d57c45f 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c @@ -99,17 +99,13 @@ static struct sway_node *node_at_coords( } if (ws->fullscreen) { // Try transient containers - if (config->popup_during_fullscreen == POPUP_SMART && - ws->fullscreen->view) { - for (int i = 0; i < ws->floating->length; ++i) { - struct sway_container *floater = ws->floating->items[i]; - if (floater->view && view_is_transient_for( - floater->view, ws->fullscreen->view)) { - struct sway_container *con = tiling_container_at( - &floater->node, lx, ly, surface, sx, sy); - if (con) { - return &con->node; - } + for (int i = 0; i < ws->floating->length; ++i) { + struct sway_container *floater = ws->floating->items[i]; + if (container_is_transient_for(floater, ws->fullscreen)) { + struct sway_container *con = tiling_container_at( + &floater->node, lx, ly, surface, sx, sy); + if (con) { + return &con->node; } } } diff --git a/sway/input/seat.c b/sway/input/seat.c index 690b59e6..f418785d 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c @@ -656,11 +656,7 @@ void seat_set_focus_warp(struct sway_seat *seat, struct sway_node *node, if (new_workspace && new_workspace->fullscreen && container && !container_is_fullscreen_or_child(container)) { // Unless it's a transient container - bool is_transient = new_workspace->fullscreen->view && - config->popup_during_fullscreen == POPUP_SMART && - container->view && view_is_transient_for( - container->view, new_workspace->fullscreen->view); - if (!is_transient) { + if (!container_is_transient_for(container, new_workspace->fullscreen)) { return; } } diff --git a/sway/tree/container.c b/sway/tree/container.c index 9db7aed1..1664514a 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c @@ -1212,3 +1212,10 @@ struct sway_container *container_split(struct sway_container *child, return cont; } + +bool container_is_transient_for(struct sway_container *child, + struct sway_container *ancestor) { + return config->popup_during_fullscreen == POPUP_SMART && + child->view && ancestor->view && + view_is_transient_for(child->view, ancestor->view); +} diff --git a/sway/tree/view.c b/sway/tree/view.c index edf771c1..b107d871 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -1044,10 +1044,8 @@ bool view_is_visible(struct sway_view *view) { !container_is_fullscreen_or_child(view->container)) { // However, if we're transient for the fullscreen view and we allow // "popups" during fullscreen then it might be visible - bool is_transient = config->popup_during_fullscreen == POPUP_SMART && - workspace->fullscreen->view && - view_is_transient_for(view, workspace->fullscreen->view); - if (!is_transient) { + if (!container_is_transient_for(view->container, + workspace->fullscreen)) { return false; } } -- cgit v1.2.3 From d21d2c8665f8fdaad719bb81cc636052f7c1d1a1 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Mon, 8 Oct 2018 23:50:43 +1000 Subject: Remove duplicate code --- sway/desktop/xdg_shell.c | 11 ----------- sway/desktop/xdg_shell_v6.c | 11 ----------- sway/desktop/xwayland.c | 11 ----------- sway/tree/view.c | 10 ++++++++++ 4 files changed, 10 insertions(+), 33 deletions(-) (limited to 'sway/tree/view.c') diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c index 5b53653d..4690a3c5 100644 --- a/sway/desktop/xdg_shell.c +++ b/sway/desktop/xdg_shell.c @@ -401,17 +401,6 @@ static void handle_map(struct wl_listener *listener, void *data) { view_update_csd_from_client(view, csd); } - if (config->popup_during_fullscreen == POPUP_LEAVE && - view->container->workspace && - view->container->workspace->fullscreen && - view->container->workspace->fullscreen->view && - xdg_surface->toplevel->parent) { - struct sway_container *fs = view->container->workspace->fullscreen; - if (is_transient_for(view, fs->view)) { - container_set_fullscreen(fs, false); - } - } - if (xdg_surface->toplevel->client_pending.fullscreen) { container_set_fullscreen(view->container, true); arrange_workspace(view->container->workspace); diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c index ac42cfed..ff950c70 100644 --- a/sway/desktop/xdg_shell_v6.c +++ b/sway/desktop/xdg_shell_v6.c @@ -396,17 +396,6 @@ static void handle_map(struct wl_listener *listener, void *data) { WLR_SERVER_DECORATION_MANAGER_MODE_CLIENT; view_update_csd_from_client(view, csd); - if (config->popup_during_fullscreen == POPUP_LEAVE && - view->container->workspace && - view->container->workspace->fullscreen && - view->container->workspace->fullscreen->view && - xdg_surface->toplevel->parent) { - struct sway_container *fs = view->container->workspace->fullscreen; - if (is_transient_for(view, fs->view)) { - container_set_fullscreen(fs, false); - } - } - if (xdg_surface->toplevel->client_pending.fullscreen) { container_set_fullscreen(view->container, true); arrange_workspace(view->container->workspace); diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index 2bdb7dc0..ebf2131e 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c @@ -407,17 +407,6 @@ static void handle_map(struct wl_listener *listener, void *data) { // Put it back into the tree view_map(view, xsurface->surface); - if (config->popup_during_fullscreen == POPUP_LEAVE && - view->container->workspace && - view->container->workspace->fullscreen && - view->container->workspace->fullscreen->view && - xsurface->parent) { - struct sway_container *fs = view->container->workspace->fullscreen; - if (is_transient_for(view, fs->view)) { - container_set_fullscreen(fs, false); - } - } - if (xsurface->fullscreen) { container_set_fullscreen(view->container, true); arrange_workspace(view->container->workspace); diff --git a/sway/tree/view.c b/sway/tree/view.c index b107d871..97525d6b 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -575,6 +575,16 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface) { view_set_tiled(view, true); } + if (config->popup_during_fullscreen == POPUP_LEAVE && + view->container->workspace && + view->container->workspace->fullscreen && + view->container->workspace->fullscreen->view) { + struct sway_container *fs = view->container->workspace->fullscreen; + if (view_is_transient_for(view, fs->view)) { + container_set_fullscreen(fs, false); + } + } + if (should_focus(view)) { input_manager_set_focus(input_manager, &view->container->node); } -- cgit v1.2.3