From 3665223cf13d4b33d0bb6cd5d36c7a6ca96f9296 Mon Sep 17 00:00:00 2001 From: Martin Stransky Date: Thu, 28 Jul 2016 09:42:28 +0200 Subject: [PATCH] Enable dark themes by pref in about:config (Bug 1272332) --- firefox.spec | 7 ++++- mozilla-1272332.patch | 71 +++++++++++++++++++++++++++++++++++++++++++ sources | 2 -- 3 files changed, 77 insertions(+), 3 deletions(-) create mode 100644 mozilla-1272332.patch diff --git a/firefox.spec b/firefox.spec index 7edf242..431625d 100644 --- a/firefox.spec +++ b/firefox.spec @@ -82,7 +82,7 @@ Summary: Mozilla Firefox Web browser Name: firefox Version: 48.0 -Release: 3%{?pre_tag}%{?dist} +Release: 4%{?pre_tag}%{?dist} URL: https://www.mozilla.org/firefox/ License: MPLv1.1 or GPLv2+ or LGPLv2+ Group: Applications/Internet @@ -129,6 +129,7 @@ Patch404: mozilla-1270046.patch Patch405: mozilla-1245783.patch Patch406: mozilla-256180.patch Patch407: mozilla-890908-async-nego.patch +Patch408: mozilla-1272332.patch # Debian patches Patch500: mozilla-440908.patch @@ -273,6 +274,7 @@ cd %{tarballdir} %patch405 -p1 -b .1245783 %patch406 -p1 -b .256180 %patch407 -p1 -b .890908-async-nego +%patch408 -p1 -b .1272332 # Debian extension patch %patch500 -p1 -b .440908 @@ -772,6 +774,9 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || : #--------------------------------------------------------------------- %changelog +* Thu Jul 28 2016 Martin Stransky - 48.0-4 +- Enable dark themes by pref in about:config (Bug 1272332) + * Wed Jul 27 2016 Martin Stransky - 48.0-3 - Updated to 48.0 (B2) 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); + diff --git a/sources b/sources index dc76efc..a4fcc2f 100644 --- a/sources +++ b/sources @@ -1,4 +1,2 @@ -c8efa23c33b6402b17d6477bc9f297d4 firefox-langpacks-48.0-20160726.tar.xz -c7f46b9cd8f5750ec16f9d557deb65fb firefox-48.0.source.tar.xz df52f6cfdf98e10b3f036479f38406c4 firefox-48.0.source.tar.xz be99fdaebb501a70c03cee3a49f716b1 firefox-langpacks-48.0-20160727.tar.xz