Bug 1406533 - Configure compositor widget to shape X11 window on non-compositing WM, r?lsalzman draft
authorMartin Stransky <stransky@redhat.com>
Tue, 24 Jul 2018 16:11:37 +0200
changeset 822012 406a961164b0021b7361209a6c79f308322ae33c
parent 822011 19379418823411fb7a4b70b4c62d93c1b611dd34
child 822013 c0b33d51d8b13067f927094f9c3d922425960a99
push id117252
push userstransky@redhat.com
push dateTue, 24 Jul 2018 14:29:28 +0000
reviewerslsalzman
bugs1406533
milestone63.0a1
Bug 1406533 - Configure compositor widget to shape X11 window on non-compositing WM, r?lsalzman Also remove mozilla.widget.use-argb-visuals which is useless since we don't allow transparent toplevel windows. MozReview-Commit-ID: 2ep3daeLZTG
widget/gtk/nsWindow.cpp
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -3656,16 +3656,18 @@ nsWindow::Create(nsIWidget* aParent,
     // figure out our parent window
     GtkWidget      *parentMozContainer = nullptr;
     GtkContainer   *parentGtkContainer = nullptr;
     GdkWindow      *parentGdkWindow = nullptr;
     GtkWindow      *topLevelParent = nullptr;
     nsWindow       *parentnsWindow = nullptr;
     GtkWidget      *eventWidget = nullptr;
     bool            drawToContainer = false;
+    bool            useAlphaVisual = (mWindowType == eWindowType_popup &&
+                                     aInitData->mSupportTranslucency);
 
     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)
@@ -3706,24 +3708,16 @@ nsWindow::Create(nsIWidget* aParent,
         // popup window position.
         GtkWindowType type = GTK_WINDOW_TOPLEVEL;
         if (mWindowType == eWindowType_popup) {
             type = (mIsX11Display && 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;
-
 #ifdef MOZ_X11
         // Ensure gfxPlatform is initialized, since that is what initializes
         // gfxVars, used below.
         Unused << gfxPlatform::GetPlatform();
 
         bool useWebRender = gfx::gfxVars::UseWebRender() &&
             AllowWebRenderForThisWindow();
 
@@ -4131,18 +4125,20 @@ nsWindow::Create(nsIWidget* aParent,
 #ifdef MOZ_X11
     if (mIsX11Display && mGdkWindow) {
       mXDisplay = GDK_WINDOW_XDISPLAY(mGdkWindow);
       mXWindow = gdk_x11_window_get_xid(mGdkWindow);
 
       GdkVisual* gdkVisual = gdk_window_get_visual(mGdkWindow);
       mXVisual = gdk_x11_visual_get_xvisual(gdkVisual);
       mXDepth = gdk_visual_get_depth(gdkVisual);
-
-      mSurfaceProvider.Initialize(mXDisplay, mXWindow, mXVisual, mXDepth);
+      bool shaped = useAlphaVisual && !IsComposited();
+
+      mSurfaceProvider.Initialize(mXDisplay, mXWindow, mXVisual, mXDepth,
+                                  shaped);
     }
 #ifdef MOZ_WAYLAND
     else if (!mIsX11Display) {
       mSurfaceProvider.Initialize(this);
     }
 #endif
 #endif
     return NS_OK;
@@ -7195,16 +7191,17 @@ nsWindow::RoundsWidgetCoordinatesTo()
     return GdkScaleFactor();
 }
 
 void nsWindow::GetCompositorWidgetInitData(mozilla::widget::CompositorWidgetInitData* aInitData)
 {
   *aInitData = mozilla::widget::GtkCompositorWidgetInitData(
                                 (mXWindow != X11None) ? mXWindow : (uintptr_t)nullptr,
                                 mXDisplay ? nsCString(XDisplayString(mXDisplay)) : nsCString(),
+                                mIsTransparent && !IsComposited(),
                                 GetClientSize());
 }
 
 bool
 nsWindow::IsComposited() const
 {
   if (!mGdkWindow) {
     NS_WARNING("nsWindow::HasARGBVisual called before realization!");