Bug 1414212 - Enable titlebar rendering on Gtk+ >= 3.10, r?jhorak draft
authorMartin Stransky <stransky@redhat.com>
Thu, 16 Nov 2017 15:18:17 +0100
changeset 699066 b270f033767e2ea1679e8b24f8ccab84120ed6a6
parent 698679 f41930a869a84af81df1a88d8e82323ff3a6509a
child 740521 15c48685defeb7f8b88e2a20b0d5a6c2e6084c6d
push id89449
push userstransky@redhat.com
push dateThu, 16 Nov 2017 14:20:23 +0000
reviewersjhorak
bugs1414212
milestone59.0a1
Bug 1414212 - Enable titlebar rendering on Gtk+ >= 3.10, r?jhorak MozReview-Commit-ID: JFmpa8JyHEl
widget/gtk/nsLookAndFeel.cpp
--- a/widget/gtk/nsLookAndFeel.cpp
+++ b/widget/gtk/nsLookAndFeel.cpp
@@ -1071,47 +1071,53 @@ nsLookAndFeel::EnsureInit()
                          nullptr);
 
     GetSystemFontInfo(gtk_widget_get_style_context(entry),
                       &mFieldFontName, &mFieldFontStyle);
 
     gtk_widget_destroy(window);
     g_object_unref(labelWidget);
 
-    // Require GTK 3.20 for client-side decoration support.
-    mCSDAvailable = gtk_check_version(3, 20, 0) == nullptr;
+    // Require GTK 3.10 for GtkHeaderBar support.
+    mCSDAvailable = gtk_check_version(3, 10, 0) == nullptr;
     if (mCSDAvailable) {
         mCSDAvailable =
             mozilla::Preferences::GetBool("widget.allow-client-side-decoration",
                                           false);
     }
 
     // We need to initialize whole CSD config explicitly because it's queried
     // as -moz-gtk* media features.
-    mCSDCloseButton = false;
+    mCSDCloseButton = true;
     mCSDMaximizeButton = false;
     mCSDMinimizeButton = false;
 
     if (mCSDAvailable) {
         static auto sGtkHeaderBarGetDecorationLayoutPtr =
           (const gchar* (*)(GtkWidget*))
           dlsym(RTLD_DEFAULT, "gtk_header_bar_get_decoration_layout");
 
-        GtkWidget* headerBar = GetWidget(MOZ_GTK_HEADER_BAR);
-        const gchar* decorationLayout =
-            sGtkHeaderBarGetDecorationLayoutPtr(headerBar);
-        if (!decorationLayout) {
-            g_object_get(settings, "gtk-decoration-layout", &decorationLayout,
-                         nullptr);
-        }
+        if (sGtkHeaderBarGetDecorationLayoutPtr) {
+            GtkWidget* headerBar = GetWidget(MOZ_GTK_HEADER_BAR);
+            const gchar* decorationLayout =
+                sGtkHeaderBarGetDecorationLayoutPtr(headerBar);
+            if (!decorationLayout) {
+                g_object_get(settings, "gtk-decoration-layout",
+                             &decorationLayout,
+                             nullptr);
+            }
 
-        if (decorationLayout) {
-            mCSDCloseButton = (strstr(decorationLayout, "close") != nullptr);
-            mCSDMaximizeButton = (strstr(decorationLayout, "maximize") != nullptr);
-            mCSDMinimizeButton = (strstr(decorationLayout, "minimize") != nullptr);
+            if (decorationLayout) {
+                mCSDCloseButton =
+                    (strstr(decorationLayout, "close") != nullptr);
+                mCSDMaximizeButton =
+                    (strstr(decorationLayout, "maximize") != nullptr);
+                mCSDMinimizeButton =
+                    (strstr(decorationLayout, "minimize") != nullptr);
+            }
         }
     }
 }
 
 // virtual
 char16_t
 nsLookAndFeel::GetPasswordCharacterImpl()
 {