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/desktop/xwayland.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'sway/desktop/xwayland.c') diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index 4c710f7e..80489f93 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c @@ -15,6 +15,7 @@ #include "sway/tree/arrange.h" #include "sway/tree/container.h" #include "sway/tree/view.h" +#include "sway/tree/workspace.h" static const char *atom_map[ATOM_LAST] = { "_NET_WM_WINDOW_TYPE_NORMAL", @@ -253,6 +254,21 @@ static void handle_set_decorations(struct wl_listener *listener, void *data) { view_update_csd_from_client(view, csd); } +static bool is_transient_for(struct sway_view *child, + struct sway_view *ancestor) { + if (xwayland_view_from_view(child) == NULL) { + return false; + } + struct wlr_xwayland_surface *surface = child->wlr_xwayland_surface; + while (surface) { + if (surface->parent == ancestor->wlr_xwayland_surface) { + return true; + } + surface = surface->parent; + } + return false; +} + static void _close(struct sway_view *view) { if (xwayland_view_from_view(view) == NULL) { return; @@ -276,6 +292,7 @@ static const struct sway_view_impl view_impl = { .set_tiled = set_tiled, .set_fullscreen = set_fullscreen, .wants_floating = wants_floating, + .is_transient_for = is_transient_for, .close = _close, .destroy = destroy, }; @@ -390,6 +407,18 @@ 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 && + xsurface->parent) { + struct wlr_xwayland_surface *psurface = xsurface->parent; + struct sway_xwayland_view *parent = psurface->data; + struct sway_view *sway_view = &parent->view; + if (sway_view->container && sway_view->container->is_fullscreen) { + container_set_fullscreen(sway_view->container, false); + } + } + if (xsurface->fullscreen) { container_set_fullscreen(view->container, true); arrange_workspace(view->container->workspace); -- cgit v1.2.3 From b8002fc0c4c7e517665cb78ab206338f7f7560a7 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Mon, 8 Oct 2018 23:39:35 +1000 Subject: Look for any ancestor when checking for fullscreen exit --- sway/desktop/xwayland.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'sway/desktop/xwayland.c') diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index 80489f93..2bdb7dc0 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c @@ -410,12 +410,11 @@ static void handle_map(struct wl_listener *listener, void *data) { if (config->popup_during_fullscreen == POPUP_LEAVE && view->container->workspace && view->container->workspace->fullscreen && + view->container->workspace->fullscreen->view && xsurface->parent) { - struct wlr_xwayland_surface *psurface = xsurface->parent; - struct sway_xwayland_view *parent = psurface->data; - struct sway_view *sway_view = &parent->view; - if (sway_view->container && sway_view->container->is_fullscreen) { - container_set_fullscreen(sway_view->container, false); + struct sway_container *fs = view->container->workspace->fullscreen; + if (is_transient_for(view, fs->view)) { + container_set_fullscreen(fs, 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/xwayland.c | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'sway/desktop/xwayland.c') 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); -- cgit v1.2.3