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/output.c | 11 +++++++++++ sway/desktop/render.c | 11 +++++++++++ sway/desktop/xdg_shell.c | 29 +++++++++++++++++++++++++++++ sway/desktop/xdg_shell_v6.c | 28 ++++++++++++++++++++++++++++ sway/desktop/xwayland.c | 29 +++++++++++++++++++++++++++++ 5 files changed, 108 insertions(+) (limited to 'sway/desktop') diff --git a/sway/desktop/output.c b/sway/desktop/output.c index cfb5a710..0bcdcac1 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c @@ -329,6 +329,17 @@ 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); + } + } + } #ifdef HAVE_XWAYLAND send_frame_done_unmanaged(output, &root->xwayland_unmanaged, when); #endif diff --git a/sway/desktop/render.c b/sway/desktop/render.c index c8b08a58..c2a0d29f 100644 --- a/sway/desktop/render.c +++ b/sway/desktop/render.c @@ -961,6 +961,17 @@ void output_render(struct sway_output *output, struct timespec *when, render_container(output, damage, fullscreen_con, 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); + } + } + } #ifdef HAVE_XWAYLAND render_unmanaged(output, damage, &root->xwayland_unmanaged); #endif diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c index a8b527a7..54831679 100644 --- a/sway/desktop/xdg_shell.c +++ b/sway/desktop/xdg_shell.c @@ -192,6 +192,21 @@ static void for_each_popup(struct sway_view *view, wlr_xdg_surface_for_each_popup(view->wlr_xdg_surface, iterator, user_data); } +static bool is_transient_for(struct sway_view *child, + struct sway_view *ancestor) { + if (xdg_shell_view_from_view(child) == NULL) { + return false; + } + struct wlr_xdg_surface *surface = child->wlr_xdg_surface; + while (surface) { + if (surface->toplevel->parent == ancestor->wlr_xdg_surface) { + return true; + } + surface = surface->toplevel->parent; + } + return false; +} + static void _close(struct sway_view *view) { if (xdg_shell_view_from_view(view) == NULL) { return; @@ -233,6 +248,7 @@ static const struct sway_view_impl view_impl = { .wants_floating = wants_floating, .for_each_surface = for_each_surface, .for_each_popup = for_each_popup, + .is_transient_for = is_transient_for, .close = _close, .close_popups = close_popups, .destroy = destroy, @@ -385,6 +401,18 @@ 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 && + xdg_surface->toplevel->parent) { + struct wlr_xdg_surface *psurface = xdg_surface->toplevel->parent; + struct sway_xdg_shell_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 (xdg_surface->toplevel->client_pending.fullscreen) { container_set_fullscreen(view->container, true); arrange_workspace(view->container->workspace); @@ -395,6 +423,7 @@ static void handle_map(struct wl_listener *listener, void *data) { arrange_workspace(view->container->workspace); } } + transaction_commit_dirty(); xdg_shell_view->commit.notify = handle_commit; diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c index a7838c0f..dacfca02 100644 --- a/sway/desktop/xdg_shell_v6.c +++ b/sway/desktop/xdg_shell_v6.c @@ -189,6 +189,21 @@ static void for_each_popup(struct sway_view *view, user_data); } +static bool is_transient_for(struct sway_view *child, + struct sway_view *ancestor) { + if (xdg_shell_v6_view_from_view(child) == NULL) { + return false; + } + struct wlr_xdg_surface_v6 *surface = child->wlr_xdg_surface_v6; + while (surface) { + if (surface->toplevel->parent == ancestor->wlr_xdg_surface_v6) { + return true; + } + surface = surface->toplevel->parent; + } + return false; +} + static void _close(struct sway_view *view) { if (xdg_shell_v6_view_from_view(view) == NULL) { return; @@ -230,6 +245,7 @@ static const struct sway_view_impl view_impl = { .wants_floating = wants_floating, .for_each_surface = for_each_surface, .for_each_popup = for_each_popup, + .is_transient_for = is_transient_for, .close = _close, .close_popups = close_popups, .destroy = destroy, @@ -380,6 +396,18 @@ 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 && + xdg_surface->toplevel->parent) { + struct wlr_xdg_surface_v6 *psurface = xdg_surface->toplevel->parent; + struct sway_xdg_shell_v6_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 (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 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-54-g00ecf