Bug 1364355 - Enable argb visual for GTK window behind hidden preference mozilla.widget.use-argb-visuals, r=karlt
☠☠ backed out by fa6f4aec2a5c ☠ ☠
authorAndrew Comminos <andrew@comminos.com>
Thu, 25 May 2017 15:45:22 +0200
changeset 409043 c4c2645ca8b78d54f111e4c4ce81880a896821f4
parent 409042 d289ee2c794d960426f0190cc0ae418548f0a5a9
child 409044 2ee6598089a33536ce3969ea1ab37fa4f0fd8688
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskarlt
bugs1364355
milestone55.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 1364355 - Enable argb visual for GTK window behind hidden preference mozilla.widget.use-argb-visuals, r=karlt This preference is default to false and allows to experiment with transparent widgets on Gtk. Original patch autor is Andrew Comminos <andrew@comminos.com>. MozReview-Commit-ID: JZkCjBWny3m
widget/gtk/nsWindow.cpp
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -3599,16 +3599,41 @@ nsWindow::Create(nsIWidget* aParent,
         // (for temporary windows).
         // For long-lived windows, their stacking order is managed by the
         // window manager, as indicated by GTK_WINDOW_TOPLEVEL ...
         GtkWindowType type =
             mWindowType != eWindowType_popup || aInitData->mNoAutoHide ?
               GTK_WINDOW_TOPLEVEL : GTK_WINDOW_POPUP;
         mShell = gtk_window_new(type);
 
+        bool useAlphaVisual = (mWindowType == eWindowType_popup &&
+                               aInitData->mSupportTranslucency);
+
+        // mozilla.widget.use-argb-visuals is a hidden pref defaulting to false
+        // to allow experimentation
+        if (Preferences::GetBool("mozilla.widget.use-argb-visuals", false))
+            useAlphaVisual = true;
+
+        // We need to select an ARGB visual here instead of in
+        // SetTransparencyMode() because it has to be done before the
+        // widget is realized.  An ARGB visual is only useful if we
+        // are on a compositing window manager.
+        if (useAlphaVisual) {
+            GdkScreen *screen = gtk_widget_get_screen(mShell);
+            if (gdk_screen_is_composited(screen)) {
+#if (MOZ_WIDGET_GTK == 2)
+                GdkColormap *colormap = gdk_screen_get_rgba_colormap(screen);
+                gtk_widget_set_colormap(mShell, colormap);
+#else
+                GdkVisual *visual = gdk_screen_get_rgba_visual(screen);
+                gtk_widget_set_visual(mShell, visual);
+#endif
+            }
+        }
+
         // 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",
@@ -3622,33 +3647,16 @@ nsWindow::Create(nsIWidget* aParent,
             // With popup windows, we want to control their position, so don't
             // wait for the window manager to place them (which wouldn't
             // happen with override-redirect windows anyway).
             NativeMove();
 
             gtk_window_set_wmclass(GTK_WINDOW(mShell), "Popup",
                                    gdk_get_program_class());
 
-            if (aInitData->mSupportTranslucency) {
-                // We need to select an ARGB visual here instead of in
-                // SetTransparencyMode() because it has to be done before the
-                // widget is realized.  An ARGB visual is only useful if we
-                // are on a compositing window manager.
-                GdkScreen *screen = gtk_widget_get_screen(mShell);
-                if (gdk_screen_is_composited(screen)) {
-#if (MOZ_WIDGET_GTK == 2)
-                    GdkColormap *colormap =
-                        gdk_screen_get_rgba_colormap(screen);
-                    gtk_widget_set_colormap(mShell, colormap);
-#else
-                    GdkVisual *visual = gdk_screen_get_rgba_visual(screen);
-                    gtk_widget_set_visual(mShell, visual);
-#endif
-                }
-            }
             if (aInitData->mNoAutoHide) {
                 // ... but the window manager does not decorate this window,
                 // nor provide a separate taskbar icon.
                 if (mBorderStyle == eBorderStyle_default) {
                   gtk_window_set_decorated(GTK_WINDOW(mShell), FALSE);
                 }
                 else {
                   bool decorate = mBorderStyle & eBorderStyle_title;