Bug 1409493 - Load actual CSD config from Gtk+, r?jhorak
MozReview-Commit-ID: GVHGXEk4IN
--- a/widget/gtk/nsLookAndFeel.cpp
+++ b/widget/gtk/nsLookAndFeel.cpp
@@ -1056,16 +1056,44 @@ nsLookAndFeel::EnsureInit()
"cursor-aspect-ratio", &sCaretRatio,
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.
+ sCSDAvailable = gtk_check_version(3, 20, 0) == nullptr;
+ if (sCSDAvailable) {
+ sCSDAvailable =
+ mozilla::Preferences::GetBool("widget.allow-client-side-decoration",
+ false);
+ }
+
+ if (sCSDAvailable) {
+ 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 (decorationLayout) {
+ sCSDCloseButton = (strstr(decorationLayout, "close") != nullptr);
+ sCSDMaximizeButton = (strstr(decorationLayout, "maximize") != nullptr);
+ sCSDMinimizeButton = (strstr(decorationLayout, "minimize") != nullptr);
+ }
+ }
}
// virtual
char16_t
nsLookAndFeel::GetPasswordCharacterImpl()
{
EnsureInit();
return sInvisibleCharacter;
--- a/widget/gtk/nsLookAndFeel.h
+++ b/widget/gtk/nsLookAndFeel.h
@@ -27,16 +27,18 @@ public:
virtual bool GetFontImpl(FontID aID, nsString& aFontName,
gfxFontStyle& aFontStyle,
float aDevPixPerCSSPixel);
virtual void RefreshImpl();
virtual char16_t GetPasswordCharacterImpl();
virtual bool GetEchoPasswordImpl();
+ bool IsCSDAvailable() const { return sCSDAvailable; }
+
protected:
// Cached fonts
bool mDefaultFontCached;
bool mButtonFontCached;
bool mFieldFontCached;
bool mMenuFontCached;
nsString mDefaultFontName;