Bug 1408360 - Make toplevel window transparent under mozilla.widget.titlebar-theme-round-corners pref, r=jhorak
authorMartin Stransky <stransky@redhat.com>
Thu, 06 Sep 2018 11:52:46 +0000
changeset 493526 7b006f2910ccabc207dd3a6c6e861406b5d18fb7
parent 493525 76b493351fd75d0d5541f051814326ed7e1b3d04
child 493527 e7ce94bb130b9d28aeb615a333af76aafcb57a22
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjhorak
bugs1408360
milestone64.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1408360 - Make toplevel window transparent under mozilla.widget.titlebar-theme-round-corners pref, r=jhorak Some Gtk+ themes use non-rectangular toplevel windows. To fully support such themes we need to make toplevel window transparent with ARGB visual. It may cause performance issue so let's put it under a preference and allow distros to enable it per default theme. Depends on D4664 Differential Revision: https://phabricator.services.mozilla.com/D4665
modules/libpref/init/all.js
widget/gtk/nsWindow.cpp
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -5936,14 +5936,19 @@ pref("browser.fastblock.timeout", 5000);
 
 // Enable clipboard readText() and writeText() by default
 pref("dom.events.asyncClipboard", true);
 // Disable clipboard read() and write() by default
 pref("dom.events.asyncClipboard.dataTransfer", false);
 // Should only be enabled in tests
 pref("dom.events.testing.asyncClipboard", false);
 
+// Enable to correctly draw CSD window headerbar
+#if defined(MOZ_WIDGET_GTK)
+pref("mozilla.widget.use-argb-visuals", false);
+#endif
+
 #ifdef NIGHTLY_BUILD
 // Disable moz* APIs in DataTransfer
 pref("dom.datatransfer.mozAtAPIs", false);
 #else
 pref("dom.datatransfer.mozAtAPIs", true);
 #endif
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -3663,16 +3663,25 @@ nsWindow::Create(nsIWidget* aParent,
     GdkWindow      *parentGdkWindow = nullptr;
     GtkWindow      *topLevelParent = nullptr;
     nsWindow       *parentnsWindow = nullptr;
     GtkWidget      *eventWidget = nullptr;
     bool            drawToContainer = false;
     bool            needsAlphaVisual = (mWindowType == eWindowType_popup &&
                                        aInitData->mSupportTranslucency);
 
+    // Some Gtk+ themes use non-rectangular toplevel windows. To fully support
+    // such themes we need to make toplevel window transparent with ARGB visual.
+    // It may cause performanance issue so let's put it under a preference
+    // and allow distros to enable it per default theme.
+    if (mWindowType == eWindowType_toplevel &&
+        Preferences::GetBool("mozilla.widget.use-argb-visuals", false)) {
+        needsAlphaVisual = true;
+    }
+
     if (aParent) {
         parentnsWindow = static_cast<nsWindow*>(aParent);
         parentGdkWindow = parentnsWindow->mGdkWindow;
     } else if (aNativeParent && GDK_IS_WINDOW(aNativeParent)) {
         parentGdkWindow = GDK_WINDOW(aNativeParent);
         parentnsWindow = get_window_for_gdk_window(parentGdkWindow);
         if (!parentnsWindow)
             return NS_ERROR_FAILURE;
@@ -3756,16 +3765,23 @@ nsWindow::Create(nsIWidget* aParent,
                     if (visual) {
                         gtk_widget_set_visual(mShell, visual);
                         mHasAlphaVisual = true;
                     }
                 }
             }
         }
 
+        // We have a toplevel window with transparency. Mark it as transparent
+        // now as nsWindow::SetTransparencyMode() can't be called after
+        // nsWindow is created (Bug 1344839).
+        if (mWindowType == eWindowType_toplevel && mHasAlphaVisual) {
+            mIsTransparent = true;
+        }
+
         // We only move a general managed toplevel window if someone has
         // actually placed the window somewhere.  If no placement has taken
         // place, we just let the window manager Do The Right Thing.
         NativeResize();
 
         if (mWindowType == eWindowType_dialog) {
             SetDefaultIcon();
             gtk_window_set_wmclass(GTK_WINDOW(mShell), "Dialog",