b=408284 use ARGB visuals for popup windows when window manager is compositing r=karlt
authorChris Coulson <chris.coulson@canonical.com>
Wed, 03 Oct 2012 19:53:53 +1300
changeset 109215 4aac63aa19dcefb866af1300c1dd78c2de5de409
parent 109214 6c2cfb9e0b45200216758c67e46805adeccaa6f1
child 109216 b2fd5b6ca0d97429d50a83af2fdef6d96a9753e7
push id82
push usershu@rfrn.org
push dateFri, 05 Oct 2012 13:20:22 +0000
reviewerskarlt
bugs408284
milestone18.0a1
b=408284 use ARGB visuals for popup windows when window manager is compositing r=karlt
widget/gtk2/nsWindow.cpp
--- a/widget/gtk2/nsWindow.cpp
+++ b/widget/gtk2/nsWindow.cpp
@@ -3435,29 +3435,49 @@ nsWindow::Create(nsIWidget        *aPare
         else if (mWindowType == eWindowType_popup) {
             // 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).
             mNeedsMove = true;
 
             // Popups that are not noautohide are only temporary. The are used
             // for menus and the like and disappear when another window is used.
+            // For most popups, use the standard GtkWindowType GTK_WINDOW_POPUP,
+            // which will use a Window with the override-redirect attribute
+            // (for temporary windows).
+            // For long-lived windows, their stacking order is managed by the
+            // window manager, as indicated by GTK_WINDOW_TOPLEVEL ...
+            GtkWindowType type = aInitData->mNoAutoHide ?
+                                     GTK_WINDOW_TOPLEVEL : GTK_WINDOW_POPUP;
+            mShell = gtk_window_new(type);
+            gtk_window_set_wmclass(GTK_WINDOW(mShell), "Popup",
+                                   gdk_get_program_class());
+            
             if (!aInitData->mNoAutoHide) {
-                // For most popups, use the standard GtkWindowType
-                // GTK_WINDOW_POPUP, which will use a Window with the
-                // override-redirect attribute (for temporary windows).
-                mShell = gtk_window_new(GTK_WINDOW_POPUP);
-                gtk_window_set_wmclass(GTK_WINDOW(mShell), "Popup", 
-                                       gdk_get_program_class());
+                GdkScreen *screen = gtk_widget_get_screen(mShell);
+                // Use an RGBA visual for all short-lived popup windows if
+                // we are on a compositing window manager. We don't do this in
+                // SetTransparencyMode() because it has to be done before the
+                // widget is realized.
+                // Normally we would need to hook up to the screen's
+                // "composited-changed" signal, but we don't do that because
+                // we are only changing the visual on short-lived windows,
+                // so it doesn't matter too much if the screens compositor
+                // goes away
+                if (gdk_screen_is_composited(screen)) {
+#if defined(MOZ_WIDGET_GTK2)
+                    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
+                }
             } else {
-                // For long-lived windows, their stacking order is managed by
-                // the window manager, as indicated by GTK_WINDOW_TOPLEVEL ...
-                mShell = gtk_window_new(GTK_WINDOW_TOPLEVEL);
-                gtk_window_set_wmclass(GTK_WINDOW(mShell), "Popup", 
-                                       gdk_get_program_class());
                 // ... 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;
                   gtk_window_set_decorated(GTK_WINDOW(mShell), decorate);