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
--- 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!");