From 3665223cf13d4b33d0bb6cd5d36c7a6ca96f9296 Mon Sep 17 00:00:00 2001 From: Martin Stransky Date: Thu, 28 Jul 2016 09:42:28 +0200 Subject: Enable dark themes by pref in about:config (Bug 1272332) --- mozilla-1272332.patch | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 mozilla-1272332.patch (limited to 'mozilla-1272332.patch') diff --git a/mozilla-1272332.patch b/mozilla-1272332.patch new file mode 100644 index 0000000..3d7b10e --- /dev/null +++ b/mozilla-1272332.patch @@ -0,0 +1,71 @@ +# HG changeset patch +# User Nicolas Silva +# Parent 14c5bf11d37b9e92d27f7089d9392de2ac339bb3 +Bug 1272332 - Allow gtk the global dark theme behind a pref. r=karlt + +diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js +--- a/modules/libpref/init/all.js ++++ b/modules/libpref/init/all.js +@@ -4560,16 +4560,17 @@ pref("gfx.content.use-native-pushlayer", + #ifdef ANDROID + pref("gfx.apitrace.enabled",false); + #endif + + #ifdef MOZ_X11 + pref("gfx.content.use-native-pushlayer", true); + #ifdef MOZ_WIDGET_GTK + pref("gfx.xrender.enabled",false); ++pref("widget.allow-gtk-dark-theme", false); + #endif + #endif + + #ifdef XP_WIN + pref("gfx.content.use-native-pushlayer", true); + + // Whether to disable the automatic detection and use of direct2d. + pref("gfx.direct2d.disabled", false); +diff --git a/widget/gtk/nsLookAndFeel.cpp b/widget/gtk/nsLookAndFeel.cpp +--- a/widget/gtk/nsLookAndFeel.cpp ++++ b/widget/gtk/nsLookAndFeel.cpp +@@ -1093,26 +1093,32 @@ nsLookAndFeel::Init() + GdkRGBA color; + GtkStyleContext *style; + + // Gtk manages a screen's CSS in the settings object so we + // ask Gtk to create it explicitly. Otherwise we may end up + // with wrong color theme, see Bug 972382 + GtkSettings *settings = gtk_settings_get_for_screen(gdk_screen_get_default()); + +- // Disable dark theme because it interacts poorly with widget styling in +- // web content (see bug 1216658). +- // To avoid triggering reload of theme settings unnecessarily, only set the +- // setting when necessary. +- const gchar* dark_setting = "gtk-application-prefer-dark-theme"; +- gboolean dark; +- g_object_get(settings, dark_setting, &dark, nullptr); + +- if (dark) { +- g_object_set(settings, dark_setting, FALSE, nullptr); ++ bool isContentProcess = XRE_IsContentProcess(); ++ bool allowDarkTheme = mozilla::Preferences::GetBool("widget.allow-gtk-dark-theme", false); ++ ++ if (isContentProcess || !allowDarkTheme) { ++ // Disable dark theme because it interacts poorly with widget styling in ++ // web content (see bug 1216658). ++ // To avoid triggering reload of theme settings unnecessarily, only set the ++ // setting when necessary. ++ const gchar* dark_setting = "gtk-application-prefer-dark-theme"; ++ gboolean dark; ++ g_object_get(settings, dark_setting, &dark, nullptr); ++ ++ if (dark) { ++ g_object_set(settings, dark_setting, FALSE, nullptr); ++ } + } + + GtkWidgetPath *path = gtk_widget_path_new(); + gtk_widget_path_append_type(path, GTK_TYPE_WINDOW); + + mBackgroundStyle = create_context(path); + gtk_style_context_add_class(mBackgroundStyle, GTK_STYLE_CLASS_BACKGROUND); + -- cgit