[geary/wip/csd-generalisations: 2/2] WIP: Add a util method to determine if CSD is being used



commit ebb1ae4c6ef74c42d9716385fbb6be2cac9560a3
Author: Michael Gratton <mike vee net>
Date:   Fri Aug 2 13:13:27 2019 +1000

    WIP: Add a util method to determine if CSD is being used
    
    This isn't generally useful since most of the time it will need to be
    called when constructed, and hence it won't have a top-level window
    to check the WM class.
    
    Need to check something else, or else ensure the code that uses this
    method is updated when the widget is realised.

 src/client/util/util-gtk.vala | 10 ++++++++++
 1 file changed, 10 insertions(+)
---
diff --git a/src/client/util/util-gtk.vala b/src/client/util/util-gtk.vala
index 3b871c3e..9dcb1d76 100644
--- a/src/client/util/util-gtk.vala
+++ b/src/client/util/util-gtk.vala
@@ -18,6 +18,16 @@ namespace Util.Gtk {
         ctx.set_source_rgb(rgba.red, rgba.green, rgba.blue);
     }
 
+    /** Determines if a widget's window has client-side WM decorations. */
+    public inline bool has_client_side_decorations(global::Gtk.Widget widget) {
+        bool has_csd = true;
+        global::Gtk.Window? window = widget.get_toplevel() as global::Gtk.Window;
+        if (window != null) {
+            has_csd = window.get_style_context().has_class(Gtk.STYLE_CLASS_CSD);
+        }
+        return has_csd;
+    }
+
     /**
      * Returns whether the close button is at the end of the headerbar.
      */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]