diff options
Diffstat (limited to 'sway/tree/view.c')
-rw-r--r-- | sway/tree/view.c | 41 |
1 files changed, 28 insertions, 13 deletions
diff --git a/sway/tree/view.c b/sway/tree/view.c index ca5e6ab0..9c7c44e9 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -5,6 +5,8 @@ #include <wlr/render/wlr_renderer.h> #include <wlr/types/wlr_buffer.h> #include <wlr/types/wlr_output_layout.h> +#include <wlr/types/wlr_server_decoration.h> +#include <wlr/types/wlr_xdg_decoration_v1.h> #include "config.h" #ifdef HAVE_XWAYLAND #include <wlr/xwayland.h> @@ -23,6 +25,7 @@ #include "sway/tree/view.h" #include "sway/tree/workspace.h" #include "sway/config.h" +#include "sway/xdg_decoration.h" #include "pango.h" #include "stringop.h" @@ -248,12 +251,8 @@ void view_autoconfigure(struct sway_view *view) { view->border_top = false; } - enum sway_container_border border = view->border; - if (view->using_csd) { - border = B_NONE; - } - - switch (border) { + switch (view->border) { + case B_CSD: case B_NONE: x = con->x; y = con->y + y_offset; @@ -326,16 +325,32 @@ void view_request_activate(struct sway_view *view) { } } -void view_set_tiled(struct sway_view *view, bool tiled) { - if (!tiled) { - view->using_csd = true; - if (view->impl->has_client_side_decorations) { - view->using_csd = view->impl->has_client_side_decorations(view); +void view_set_csd_from_server(struct sway_view *view, bool enabled) { + wlr_log(WLR_DEBUG, "Telling view %p to set CSD to %i", view, enabled); + if (view->xdg_decoration) { + uint32_t mode = enabled ? + WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE : + WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE; + wlr_xdg_toplevel_decoration_v1_set_mode( + view->xdg_decoration->wlr_xdg_decoration, mode); + } + view->using_csd = enabled; +} + +void view_update_csd_from_client(struct sway_view *view, bool enabled) { + wlr_log(WLR_DEBUG, "View %p updated CSD to %i", view, enabled); + if (enabled && view->border != B_CSD) { + view->saved_border = view->border; + if (container_is_floating(view->container)) { + view->border = B_CSD; } - } else { - view->using_csd = false; + } else if (!enabled && view->border == B_CSD) { + view->border = view->saved_border; } + view->using_csd = enabled; +} +void view_set_tiled(struct sway_view *view, bool tiled) { if (view->impl->set_tiled) { view->impl->set_tiled(view, tiled); } |