Bug 1283299 - Part 3: Add pref for using ARGB visuals on GTK. r?karlt draft
authorAndrew Comminos <andrew@comminos.com>
Tue, 05 Jul 2016 14:00:50 -0400
changeset 384220 1978e42078dc52777450bd81cb6df4dbb0f74ede
parent 384219 b0acd8753c8127cac4e126dd0c530c4910ca3ff0
child 384221 308e1f3d729801b0a694ec9f59749cbedfd5047d
push id22212
push userbmo:andrew@comminos.com
push dateTue, 05 Jul 2016 20:52:16 +0000
reviewerskarlt
bugs1283299
milestone50.0a1
Bug 1283299 - Part 3: Add pref for using ARGB visuals on GTK. r?karlt MozReview-Commit-ID: 2dskvXMRhGV
widget/gtk/nsWindow.cpp
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -3646,16 +3646,27 @@ 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);
 
+        if (Preferences::GetBool("mozilla.widget.use-argb-visuals", false)) {
+            GdkScreen *screen = gtk_widget_get_screen(mShell);
+#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",