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 From 6d0442c0c2cfcb75f855348b8133abcb2f3c2427 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Thu, 27 Sep 2018 17:09:05 +1000 Subject: Rename view_set_csd_from_client to view_update_csd_from_client --- include/sway/tree/view.h | 2 +- sway/decoration.c | 2 +- sway/desktop/xdg_shell.c | 2 +- sway/desktop/xdg_shell_v6.c | 2 +- sway/desktop/xwayland.c | 2 +- sway/tree/view.c | 2 +- sway/xdg_decoration.c | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) (limited to 'sway/desktop/xwayland.c') diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index 49df7c88..e7aaffd7 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h @@ -275,7 +275,7 @@ void view_set_csd_from_server(struct sway_view *view, bool enabled); * Updates the view's border setting when the client unexpectedly changes their * decoration mode. */ -void view_set_csd_from_client(struct sway_view *view, bool enabled); +void view_update_csd_from_client(struct sway_view *view, bool enabled); void view_set_tiled(struct sway_view *view, bool tiled); diff --git a/sway/decoration.c b/sway/decoration.c index fea6ed4c..849fa89c 100644 --- a/sway/decoration.c +++ b/sway/decoration.c @@ -28,7 +28,7 @@ static void server_decoration_handle_mode(struct wl_listener *listener, bool csd = deco->wlr_server_decoration->mode == WLR_SERVER_DECORATION_MANAGER_MODE_CLIENT; - view_set_csd_from_client(view, csd); + view_update_csd_from_client(view, csd); arrange_container(view->container); transaction_commit_dirty(); diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c index d563edae..2680af64 100644 --- a/sway/desktop/xdg_shell.c +++ b/sway/desktop/xdg_shell.c @@ -381,7 +381,7 @@ static void handle_map(struct wl_listener *listener, void *data) { decoration_from_surface(xdg_surface->surface); bool csd = !deco || deco->wlr_server_decoration->mode == WLR_SERVER_DECORATION_MANAGER_MODE_CLIENT; - view_set_csd_from_client(view, csd); + view_update_csd_from_client(view, csd); if (xdg_surface->toplevel->client_pending.fullscreen) { container_set_fullscreen(view->container, true); diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c index 8c8085f7..a7838c0f 100644 --- a/sway/desktop/xdg_shell_v6.c +++ b/sway/desktop/xdg_shell_v6.c @@ -378,7 +378,7 @@ static void handle_map(struct wl_listener *listener, void *data) { decoration_from_surface(xdg_surface->surface); bool csd = !deco || deco->wlr_server_decoration->mode == WLR_SERVER_DECORATION_MANAGER_MODE_CLIENT; - view_set_csd_from_client(view, csd); + view_update_csd_from_client(view, csd); if (xdg_surface->toplevel->client_pending.fullscreen) { container_set_fullscreen(view->container, true); diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index f1205518..4c710f7e 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c @@ -250,7 +250,7 @@ static void handle_set_decorations(struct wl_listener *listener, void *data) { 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); + view_update_csd_from_client(view, csd); } static void _close(struct sway_view *view) { diff --git a/sway/tree/view.c b/sway/tree/view.c index c370de2d..1c94de4c 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -318,7 +318,7 @@ void view_set_csd_from_server(struct sway_view *view, bool enabled) { } } -void view_set_csd_from_client(struct sway_view *view, bool enabled) { +void view_update_csd_from_client(struct sway_view *view, bool enabled) { if (enabled && view->border != B_CSD) { view->saved_border = view->border; view->border = B_CSD; diff --git a/sway/xdg_decoration.c b/sway/xdg_decoration.c index 2e7e4bd0..80b2f57e 100644 --- a/sway/xdg_decoration.c +++ b/sway/xdg_decoration.c @@ -26,7 +26,7 @@ static void xdg_decoration_handle_surface_commit(struct wl_listener *listener, WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE; struct sway_view *view = decoration->view; - view_set_csd_from_client(view, csd); + view_update_csd_from_client(view, csd); arrange_container(view->container); transaction_commit_dirty(); -- cgit v1.2.3