]> git.mdlowis.com Git - proto/labwc.git/commitdiff
decorations: make has_ssd public
authorTobias Bengfort <tobias.bengfort@posteo.de>
Fri, 19 Apr 2024 11:35:16 +0000 (13:35 +0200)
committerJohan Malm <johanmalm@users.noreply.github.com>
Sun, 19 May 2024 18:03:42 +0000 (19:03 +0100)
include/view.h
src/view.c
src/xdg.c

index 6755037d1862b4803968d284626e9ca1dcd1141a..a89e75d25c7d578c91cc788107a8bceccbb7bac4 100644 (file)
@@ -471,6 +471,7 @@ void view_maximize(struct view *view, enum view_axis axis,
        bool store_natural_geometry);
 void view_set_fullscreen(struct view *view, bool fullscreen);
 void view_toggle_maximize(struct view *view, enum view_axis axis);
+bool view_wants_decorations(struct view *view);
 void view_toggle_decorations(struct view *view);
 
 bool view_is_always_on_top(struct view *view);
index 09cc697d8ca8afe6f3e852f7799e639ac835b702..d7e62646b9e08a9ad492375b27c8b2bb1a2951c8 100644 (file)
@@ -1218,6 +1218,37 @@ view_toggle_maximize(struct view *view, enum view_axis axis)
        }
 }
 
+bool
+view_wants_decorations(struct view *view)
+{
+       /* Window-rules take priority if they exist for this view */
+       switch (window_rules_get_property(view, "serverDecoration")) {
+       case LAB_PROP_TRUE:
+               return true;
+       case LAB_PROP_FALSE:
+               return false;
+       default:
+               break;
+       }
+
+       /*
+        * view->ssd_preference may be set by the decoration implementation
+        * e.g. src/decorations/xdg-deco.c or src/decorations/kde-deco.c.
+        */
+       switch (view->ssd_preference) {
+       case LAB_SSD_PREF_SERVER:
+               return true;
+       case LAB_SSD_PREF_CLIENT:
+               return false;
+       default:
+               /*
+                * We don't know anything about the client preference
+                * so fall back to core.decoration settings in rc.xml
+                */
+               return rc.xdg_shell_server_side_deco;
+       }
+}
+
 void
 view_toggle_decorations(struct view *view)
 {
index e9b5984faf67ab03c811bfb8125f0e9302e66475..2b8bf96ec93e21ea79057aa9262a629f83bd289b 100644 (file)
--- a/src/xdg.c
+++ b/src/xdg.c
@@ -75,37 +75,6 @@ handle_new_popup(struct wl_listener *listener, void *data)
        xdg_popup_create(view, wlr_popup);
 }
 
-static bool
-has_ssd(struct view *view)
-{
-       /* Window-rules take priority if they exist for this view */
-       switch (window_rules_get_property(view, "serverDecoration")) {
-       case LAB_PROP_TRUE:
-               return true;
-       case LAB_PROP_FALSE:
-               return false;
-       default:
-               break;
-       }
-
-       /*
-        * view->ssd_preference may be set by the decoration implementation
-        * e.g. src/decorations/xdg-deco.c or src/decorations/kde-deco.c.
-        */
-       switch (view->ssd_preference) {
-       case LAB_SSD_PREF_SERVER:
-               return true;
-       case LAB_SSD_PREF_CLIENT:
-               return false;
-       default:
-               /*
-                * We don't know anything about the client preference
-                * so fall back to core.decoration settings in rc.xml
-                */
-               return rc.xdg_shell_server_side_deco;
-       }
-}
-
 static void
 handle_commit(struct wl_listener *listener, void *data)
 {
@@ -599,7 +568,7 @@ xdg_toplevel_view_map(struct view *view)
 
                init_foreign_toplevel(view);
 
-               if (has_ssd(view)) {
+               if (view_wants_decorations(view)) {
                        view_set_ssd_mode(view, LAB_SSD_MODE_FULL);
                } else {
                        view_set_ssd_mode(view, LAB_SSD_MODE_NONE);