b=798157 use ARGB visuals only for popups that will be translucent r=roc
authorKarl Tomlinson <karlt+@karlt.net>
Tue, 13 Nov 2012 18:04:42 -0800
changeset 113177 3f605e71a350565efd61785d74a4b5f0d4cc103b
parent 113176 3b2f5b980477052f5cf87b1ffb00cf18ed231629
child 113178 aa2f835b67a56ab7a3d529b810156670326cd03a
push id17987
push userktomlinson@mozilla.com
push dateWed, 14 Nov 2012 02:05:12 +0000
treeherdermozilla-inbound@3f605e71a350 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs798157
milestone19.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
b=798157 use ARGB visuals only for popups that will be translucent r=roc
layout/xul/base/src/nsMenuPopupFrame.cpp
widget/gtk2/nsWindow.cpp
widget/nsWidgetInitData.h
--- a/layout/xul/base/src/nsMenuPopupFrame.cpp
+++ b/layout/xul/base/src/nsMenuPopupFrame.cpp
@@ -266,16 +266,17 @@ nsMenuPopupFrame::CreateWidgetForView(ns
   nsTransparencyMode mode = nsLayoutUtils::GetFrameTransparency(this, this);
   bool viewHasTransparentContent = !mInContentShell &&
                                      (eTransparencyTransparent ==
                                       mode);
   nsIContent* parentContent = GetContent()->GetParent();
   nsIAtom *tag = nullptr;
   if (parentContent)
     tag = parentContent->Tag();
+  widgetData.mSupportTranslucency = mode == eTransparencyTransparent;
   widgetData.mDropShadow = !(viewHasTransparentContent || tag == nsGkAtoms::menulist);
   widgetData.mPopupLevel = PopupLevel(widgetData.mNoAutoHide);
 
   // panels which have a parent level need a parent widget. This allows them to
   // always appear in front of the parent window but behind other windows that
   // should be in front of it.
   nsCOMPtr<nsIWidget> parentWidget;
   if (widgetData.mPopupLevel != ePopupLevelTop) {
--- a/widget/gtk2/nsWindow.cpp
+++ b/widget/gtk2/nsWindow.cpp
@@ -3461,39 +3461,35 @@ nsWindow::Create(nsIWidget        *aPare
             // (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) {
-                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
+
+            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.
-                // 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
+                // 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 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 {
+            }
+            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;
                   gtk_window_set_decorated(GTK_WINDOW(mShell), decorate);
--- a/widget/nsWidgetInitData.h
+++ b/widget/nsWidgetInitData.h
@@ -1,9 +1,9 @@
-/* -*- Mode: C++; tab-width: 40; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* -*- Mode: C++; tab-width: 40; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsWidgetInitData_h__
 #define nsWidgetInitData_h__
 
 #include "prtypes.h"
@@ -97,28 +97,31 @@ struct nsWidgetInitData {
       clipChildren(false), 
       clipSiblings(false), 
       mDropShadow(false),
       mListenForResizes(false),
       mUnicode(true),
       mRTL(false),
       mNoAutoHide(false),
       mIsDragPopup(false),
-      mIsAnimationSuppressed(false)
+      mIsAnimationSuppressed(false),
+      mSupportTranslucency(false)
   {
   }
 
   nsWindowType  mWindowType;
   nsBorderStyle mBorderStyle;
   nsPopupType   mPopupHint;
   nsPopupLevel  mPopupLevel;
   // when painting exclude area occupied by child windows and sibling windows
   bool          clipChildren, clipSiblings, mDropShadow;
   bool          mListenForResizes;
   bool          mUnicode;
   bool          mRTL;
   bool          mNoAutoHide; // true for noautohide panels
   bool          mIsDragPopup;  // true for drag feedback panels
-  bool          mIsAnimationSuppressed;  // true if window creation animation is
-                                         // suppressed, e.g. for session restore
+  // true if window creation animation is suppressed, e.g. for session restore
+  bool          mIsAnimationSuppressed;
+  // true if the window should support an alpha channel, if available.
+  bool          mSupportTranslucency;
 };
 
 #endif // nsWidgetInitData_h__