]> git.mdlowis.com Git - proto/labwc.git/commitdiff
Decorations: respect earlier client side decoration negotion result
authorConsolatis <35009135+Consolatis@users.noreply.github.com>
Wed, 22 Mar 2023 18:53:17 +0000 (19:53 +0100)
committerJohan Malm <johanmalm@users.noreply.github.com>
Sat, 25 Mar 2023 07:24:40 +0000 (07:24 +0000)
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
src/decorations/xdg-deco.c
src/xdg.c

index c0732a8a1402274991a889f47b2db9feb53e9914..f7a0996eb5c1b533e689f0927bc457d41cf79bc7 100644 (file)
@@ -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;
index c8e818c0c7b88e899a6bcba7492ab89aedc100d6..3e0a5abfb764172d5fa0c562401a9effc544db1d 100644 (file)
@@ -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);
index a01962e6617776de35397a8201dde430510f923d..89775e608bf67aad0c143e80033c0f1758ec55ba 100644 (file)
--- 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) {