From 35e71ada826bd5d6888676dd317b91ec838f028a Mon Sep 17 00:00:00 2001 From: Consolatis <35009135+Consolatis@users.noreply.github.com> Date: Wed, 22 Mar 2023 19:53:17 +0100 Subject: [PATCH] Decorations: respect earlier client side decoration negotion result Before this patch, it was impossible to differentiate between negotiations resulting in client side decorations and no negotiations at all. By adding an enum we are now able to differentiate between the two states. --- include/view.h | 7 +++++++ src/decorations/xdg-deco.c | 14 +++++++++++++- src/xdg.c | 8 ++++++-- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/include/view.h b/include/view.h index c0732a8a..f7a0996e 100644 --- a/include/view.h +++ b/include/view.h @@ -20,6 +20,12 @@ enum view_type { #endif }; +enum ssd_preference { + LAB_SSD_PREF_UNSPEC = 0, + LAB_SSD_PREF_CLIENT, + LAB_SSD_PREF_SERVER, +}; + struct view; struct view_impl { void (*configure)(struct view *view, struct wlr_box geo); @@ -63,6 +69,7 @@ struct view { bool mapped; bool been_mapped; bool ssd_enabled; + enum ssd_preference ssd_preference; bool minimized; bool maximized; bool fullscreen; diff --git a/src/decorations/xdg-deco.c b/src/decorations/xdg-deco.c index c8e818c0..3e0a5abf 100644 --- a/src/decorations/xdg-deco.c +++ b/src/decorations/xdg-deco.c @@ -28,10 +28,22 @@ xdg_deco_request_mode(struct wl_listener *listener, void *data) enum wlr_xdg_toplevel_decoration_v1_mode client_mode = xdg_deco->wlr_decoration->requested_mode; - if (client_mode == WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_NONE) { + switch (client_mode) { + case WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE: + xdg_deco->view->ssd_preference = LAB_SSD_PREF_SERVER; + break; + case WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE: + xdg_deco->view->ssd_preference = LAB_SSD_PREF_CLIENT; + break; + case WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_NONE: + xdg_deco->view->ssd_preference = LAB_SSD_PREF_UNSPEC; client_mode = rc.xdg_shell_server_side_deco ? WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE : WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE; + break; + default: + wlr_log(WLR_ERROR, "Unspecified decoration variant requested: %u", + client_mode); } wlr_xdg_toplevel_decoration_v1_set_mode(xdg_deco->wlr_decoration, client_mode); diff --git a/src/xdg.c b/src/xdg.c index a01962e6..89775e60 100644 --- a/src/xdg.c +++ b/src/xdg.c @@ -48,9 +48,13 @@ handle_new_xdg_popup(struct wl_listener *listener, void *data) static bool has_ssd(struct view *view) { - if (view->ssd_enabled) { - /* View prefers server side decorations */ + switch (view->ssd_preference) { + case LAB_SSD_PREF_SERVER: return true; + case LAB_SSD_PREF_CLIENT: + return false; + default: + break; } if (!rc.xdg_shell_server_side_deco) {