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/xdg_shell.c | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) (limited to 'sway/desktop/xdg_shell.c') diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c index 6d1ccdd7..d563edae 100644 --- a/sway/desktop/xdg_shell.c +++ b/sway/desktop/xdg_shell.c @@ -175,15 +175,6 @@ static bool wants_floating(struct sway_view *view) { || toplevel->parent; } -static bool has_client_side_decorations(struct sway_view *view) { - struct sway_xdg_shell_view *xdg_shell_view = - xdg_shell_view_from_view(view); - if (xdg_shell_view == NULL) { - return true; - } - return xdg_shell_view->deco_mode != WLR_SERVER_DECORATION_MANAGER_MODE_SERVER; -} - static void for_each_surface(struct sway_view *view, wlr_surface_iterator_func_t iterator, void *user_data) { if (xdg_shell_view_from_view(view) == NULL) { @@ -240,7 +231,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, .for_each_surface = for_each_surface, .for_each_popup = for_each_popup, .close = _close, @@ -385,15 +375,13 @@ static void handle_map(struct wl_listener *listener, void *data) { view->natural_height = view->wlr_xdg_surface->surface->current.height; } + view_map(view, view->wlr_xdg_surface->surface); + struct sway_server_decoration *deco = decoration_from_surface(xdg_surface->surface); - if (deco != NULL) { - xdg_shell_view->deco_mode = deco->wlr_server_decoration->mode; - } else { - xdg_shell_view->deco_mode = WLR_SERVER_DECORATION_MANAGER_MODE_CLIENT; - } - - view_map(view, view->wlr_xdg_surface->surface); + bool csd = !deco || deco->wlr_server_decoration->mode == + WLR_SERVER_DECORATION_MANAGER_MODE_CLIENT; + view_set_csd_from_client(view, csd); if (xdg_surface->toplevel->client_pending.fullscreen) { container_set_fullscreen(view->container, true); -- 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/xdg_shell.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 From f16529e2588f5e71d6777f4c06dfb58b29308cd0 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Thu, 27 Sep 2018 23:00:10 +1000 Subject: Remove server-decoration assumption if view supports xdg-decoration --- sway/desktop/xdg_shell.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'sway/desktop/xdg_shell.c') diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c index 2680af64..a8b527a7 100644 --- a/sway/desktop/xdg_shell.c +++ b/sway/desktop/xdg_shell.c @@ -377,11 +377,13 @@ static void handle_map(struct wl_listener *listener, void *data) { view_map(view, view->wlr_xdg_surface->surface); - struct sway_server_decoration *deco = - decoration_from_surface(xdg_surface->surface); - bool csd = !deco || deco->wlr_server_decoration->mode == - WLR_SERVER_DECORATION_MANAGER_MODE_CLIENT; - view_update_csd_from_client(view, csd); + if (!view->xdg_decoration) { + struct sway_server_decoration *deco = + decoration_from_surface(xdg_surface->surface); + bool csd = !deco || deco->wlr_server_decoration->mode == + WLR_SERVER_DECORATION_MANAGER_MODE_CLIENT; + view_update_csd_from_client(view, csd); + } if (xdg_surface->toplevel->client_pending.fullscreen) { container_set_fullscreen(view->container, true); -- cgit v1.2.3