From 7b138e5ef0f679c9bb0078019d7c9c63fef36273 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Mon, 24 Sep 2018 20:54:57 +1000 Subject: Add CSD to border modes This replaces view.using_csd with a new border mode: B_CSD. This also removes sway_xdg_shell{_v6}_view.deco_mode and view->has_client_side_decorations as we can now get these from the border. You can use `border toggle` to cycle through the modes including CSD, or use `border csd` to set it directly. The client must support the xdg-decoration protocol, and the only client I know of that does is the example in wlroots. If the client switches from SSD to CSD without us expecting it (via the server-decoration protocol), we stash the previous border type into view.saved_border so we can restore it if the client returns to SSD. I haven't found a way to test this though. --- sway/desktop/xwayland.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'sway/desktop/xwayland.c') diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index a12ac854..f1205518 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c @@ -243,12 +243,14 @@ static bool wants_floating(struct sway_view *view) { return false; } -static bool has_client_side_decorations(struct sway_view *view) { - if (xwayland_view_from_view(view) == NULL) { - return false; - } - struct wlr_xwayland_surface *surface = view->wlr_xwayland_surface; - return surface->decorations != WLR_XWAYLAND_SURFACE_DECORATIONS_ALL; +static void handle_set_decorations(struct wl_listener *listener, void *data) { + struct sway_xwayland_view *xwayland_view = + wl_container_of(listener, xwayland_view, set_decorations); + struct sway_view *view = &xwayland_view->view; + struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; + + bool csd = xsurface->decorations != WLR_XWAYLAND_SURFACE_DECORATIONS_ALL; + view_set_csd_from_client(view, csd); } static void _close(struct sway_view *view) { @@ -274,7 +276,6 @@ static const struct sway_view_impl view_impl = { .set_tiled = set_tiled, .set_fullscreen = set_fullscreen, .wants_floating = wants_floating, - .has_client_side_decorations = has_client_side_decorations, .close = _close, .destroy = destroy, }; @@ -343,6 +344,7 @@ static void handle_destroy(struct wl_listener *listener, void *data) { wl_list_remove(&xwayland_view->set_role.link); wl_list_remove(&xwayland_view->set_window_type.link); wl_list_remove(&xwayland_view->set_hints.link); + wl_list_remove(&xwayland_view->set_decorations.link); wl_list_remove(&xwayland_view->map.link); wl_list_remove(&xwayland_view->unmap.link); view_begin_destroy(&xwayland_view->view); @@ -613,6 +615,10 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) { wl_signal_add(&xsurface->events.set_hints, &xwayland_view->set_hints); xwayland_view->set_hints.notify = handle_set_hints; + wl_signal_add(&xsurface->events.set_decorations, + &xwayland_view->set_decorations); + xwayland_view->set_decorations.notify = handle_set_decorations; + wl_signal_add(&xsurface->events.unmap, &xwayland_view->unmap); xwayland_view->unmap.notify = handle_unmap; -- cgit v1.2.3-54-g00ecf