зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1704965 [Linux] Remove display connection from nsWindow, CompositorWidgetParent and WindowSurfaceProvider, r=jhorak
Differential Revision: https://phabricator.services.mozilla.com/D113643
This commit is contained in:
Родитель
886cc45e9a
Коммит
8ff3771ef2
|
@ -788,7 +788,7 @@ already_AddRefed<GLContext> GLContextProviderGLX::CreateForCompositorWidget(
|
|||
GtkCompositorWidget* compWidget = aCompositorWidget->AsX11();
|
||||
MOZ_ASSERT(compWidget);
|
||||
|
||||
return CreateForWidget(compWidget->XDisplay(), compWidget->XWindow(),
|
||||
return CreateForWidget(DefaultXDisplay(), compWidget->XWindow(),
|
||||
aHardwareWebRender, aForceAccelerated);
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "mozilla/widget/InProcessCompositorWidget.h"
|
||||
#include "mozilla/widget/PlatformWidgetTypes.h"
|
||||
#include "nsWindow.h"
|
||||
#include "mozilla/X11Util.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace widget {
|
||||
|
@ -29,18 +30,11 @@ GtkCompositorWidget::GtkCompositorWidget(
|
|||
#endif
|
||||
#if defined(MOZ_X11)
|
||||
if (aInitData.IsX11Display()) {
|
||||
// If we have a nsWindow, then grab the already existing display connection
|
||||
// If we don't, then use the init data to connect to the display
|
||||
if (aWindow) {
|
||||
mXDisplay = aWindow->XDisplay();
|
||||
} else {
|
||||
mXDisplay = XOpenDisplay(aInitData.XDisplayString().get());
|
||||
}
|
||||
mXWindow = (Window)aInitData.XWindow();
|
||||
|
||||
// Grab the window's visual and depth
|
||||
XWindowAttributes windowAttrs;
|
||||
if (!XGetWindowAttributes(mXDisplay, mXWindow, &windowAttrs)) {
|
||||
if (!XGetWindowAttributes(DefaultXDisplay(), mXWindow, &windowAttrs)) {
|
||||
NS_WARNING("GtkCompositorWidget(): XGetWindowAttributes() failed!");
|
||||
}
|
||||
|
||||
|
@ -48,25 +42,14 @@ GtkCompositorWidget::GtkCompositorWidget(
|
|||
mDepth = windowAttrs.depth;
|
||||
|
||||
// Initialize the window surface provider
|
||||
mProvider.Initialize(mXDisplay, mXWindow, visual, mDepth,
|
||||
aInitData.Shaped());
|
||||
mProvider.Initialize(mXWindow, visual, mDepth, aInitData.Shaped());
|
||||
}
|
||||
#endif
|
||||
auto size = mClientSize.Lock();
|
||||
*size = aInitData.InitialClientSize();
|
||||
}
|
||||
|
||||
GtkCompositorWidget::~GtkCompositorWidget() {
|
||||
mProvider.CleanupResources();
|
||||
|
||||
#if defined(MOZ_X11)
|
||||
// If we created our own display connection, we need to destroy it
|
||||
if (!mWidget && mXDisplay) {
|
||||
XCloseDisplay(mXDisplay);
|
||||
mXDisplay = nullptr;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
GtkCompositorWidget::~GtkCompositorWidget() { mProvider.CleanupResources(); }
|
||||
|
||||
already_AddRefed<gfx::DrawTarget> GtkCompositorWidget::StartRemoteDrawing() {
|
||||
return nullptr;
|
||||
|
|
|
@ -64,7 +64,6 @@ class GtkCompositorWidget : public CompositorWidget,
|
|||
LayoutDeviceIntRegion GetTransparentRegion() override;
|
||||
|
||||
#if defined(MOZ_X11)
|
||||
Display* XDisplay() const { return mXDisplay; }
|
||||
Window XWindow() const { return mXWindow; }
|
||||
#endif
|
||||
#if defined(MOZ_WAYLAND)
|
||||
|
@ -90,7 +89,6 @@ class GtkCompositorWidget : public CompositorWidget,
|
|||
WindowSurfaceProvider mProvider;
|
||||
|
||||
#if defined(MOZ_X11)
|
||||
Display* mXDisplay = {};
|
||||
Window mXWindow = {};
|
||||
#endif
|
||||
int32_t mDepth = {};
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "WindowSurfaceX11Image.h"
|
||||
#include "WindowSurfaceX11SHM.h"
|
||||
#include "WindowSurfaceXRender.h"
|
||||
#include "mozilla/X11Util.h"
|
||||
#ifdef MOZ_WAYLAND
|
||||
# include "WindowSurfaceWayland.h"
|
||||
#endif
|
||||
|
@ -24,7 +25,6 @@ using namespace mozilla::layers;
|
|||
|
||||
WindowSurfaceProvider::WindowSurfaceProvider()
|
||||
: mIsX11Display(false),
|
||||
mXDisplay(nullptr),
|
||||
mXWindow(0),
|
||||
mXVisual(nullptr),
|
||||
mXDepth(0),
|
||||
|
@ -37,16 +37,8 @@ WindowSurfaceProvider::WindowSurfaceProvider()
|
|||
mIsShaped(false) {
|
||||
}
|
||||
|
||||
void WindowSurfaceProvider::Initialize(Display* aDisplay, Window aWindow,
|
||||
Visual* aVisual, int aDepth,
|
||||
bool aIsShaped) {
|
||||
// We should not be initialized
|
||||
MOZ_ASSERT(!mXDisplay);
|
||||
|
||||
// This should also be a valid initialization
|
||||
MOZ_ASSERT(aDisplay && aWindow != X11None && aVisual);
|
||||
|
||||
mXDisplay = aDisplay;
|
||||
void WindowSurfaceProvider::Initialize(Window aWindow, Visual* aVisual,
|
||||
int aDepth, bool aIsShaped) {
|
||||
mXWindow = aWindow;
|
||||
mXVisual = aVisual;
|
||||
mXDepth = aDepth;
|
||||
|
@ -71,30 +63,27 @@ UniquePtr<WindowSurface> WindowSurfaceProvider::CreateWindowSurface() {
|
|||
}
|
||||
#endif
|
||||
|
||||
// We should be initialized
|
||||
MOZ_ASSERT(mXDisplay);
|
||||
|
||||
// Blit to the window with the following priority:
|
||||
// 1. XRender (iff XRender is enabled && we are in-process)
|
||||
// 2. MIT-SHM
|
||||
// 3. XPutImage
|
||||
if (!mIsShaped && gfx::gfxVars::UseXRender()) {
|
||||
LOG(("Drawing to Window 0x%lx will use XRender\n", mXWindow));
|
||||
return MakeUnique<WindowSurfaceXRender>(mXDisplay, mXWindow, mXVisual,
|
||||
mXDepth);
|
||||
return MakeUnique<WindowSurfaceXRender>(DefaultXDisplay(), mXWindow,
|
||||
mXVisual, mXDepth);
|
||||
}
|
||||
|
||||
#ifdef MOZ_HAVE_SHMIMAGE
|
||||
if (!mIsShaped && nsShmImage::UseShm()) {
|
||||
LOG(("Drawing to Window 0x%lx will use MIT-SHM\n", mXWindow));
|
||||
return MakeUnique<WindowSurfaceX11SHM>(mXDisplay, mXWindow, mXVisual,
|
||||
mXDepth);
|
||||
return MakeUnique<WindowSurfaceX11SHM>(DefaultXDisplay(), mXWindow,
|
||||
mXVisual, mXDepth);
|
||||
}
|
||||
#endif // MOZ_HAVE_SHMIMAGE
|
||||
|
||||
LOG(("Drawing to Window 0x%lx will use XPutImage\n", mXWindow));
|
||||
return MakeUnique<WindowSurfaceX11Image>(mXDisplay, mXWindow, mXVisual,
|
||||
mXDepth, mIsShaped);
|
||||
return MakeUnique<WindowSurfaceX11Image>(DefaultXDisplay(), mXWindow,
|
||||
mXVisual, mXDepth, mIsShaped);
|
||||
}
|
||||
|
||||
already_AddRefed<gfx::DrawTarget>
|
||||
|
@ -117,7 +106,7 @@ WindowSurfaceProvider::StartRemoteDrawingInRegion(
|
|||
gfxWarningOnce()
|
||||
<< "Failed to lock WindowSurface, falling back to XPutImage backend.";
|
||||
mWindowSurface = MakeUnique<WindowSurfaceX11Image>(
|
||||
mXDisplay, mXWindow, mXVisual, mXDepth, mIsShaped);
|
||||
DefaultXDisplay(), mXWindow, mXVisual, mXDepth, mIsShaped);
|
||||
dt = mWindowSurface->Lock(aInvalidRegion);
|
||||
}
|
||||
return dt.forget();
|
||||
|
|
|
@ -40,8 +40,7 @@ class WindowSurfaceProvider final {
|
|||
* own the Display, Window, etc, and they must continue to exist
|
||||
* while WindowSurfaceProvider is used.
|
||||
*/
|
||||
void Initialize(Display* aDisplay, Window aWindow, Visual* aVisual,
|
||||
int aDepth, bool aIsShaped);
|
||||
void Initialize(Window aWindow, Visual* aVisual, int aDepth, bool aIsShaped);
|
||||
|
||||
#ifdef MOZ_WAYLAND
|
||||
void Initialize(nsWindow* aWidget);
|
||||
|
@ -50,7 +49,7 @@ class WindowSurfaceProvider final {
|
|||
/**
|
||||
* Releases any surfaces created by this provider.
|
||||
* This is used by GtkCompositorWidget to get rid
|
||||
* of resources before we close the display connection.
|
||||
* of resources.
|
||||
*/
|
||||
void CleanupResources();
|
||||
|
||||
|
@ -65,7 +64,6 @@ class WindowSurfaceProvider final {
|
|||
|
||||
// Can we access X?
|
||||
bool mIsX11Display;
|
||||
Display* mXDisplay;
|
||||
Window mXWindow;
|
||||
Visual* mXVisual;
|
||||
int mXDepth;
|
||||
|
|
|
@ -89,6 +89,7 @@
|
|||
#include "ScreenHelperGTK.h"
|
||||
#include "SystemTimeConverter.h"
|
||||
#include "WidgetUtilsGtk.h"
|
||||
#include "mozilla/X11Util.h"
|
||||
|
||||
#ifdef ACCESSIBILITY
|
||||
# include "mozilla/a11y/LocalAccessible.h"
|
||||
|
@ -478,7 +479,6 @@ nsWindow::nsWindow()
|
|||
#endif
|
||||
#ifdef MOZ_X11
|
||||
,
|
||||
mXDisplay(nullptr),
|
||||
mXWindow(X11None),
|
||||
mXVisual(nullptr),
|
||||
mXDepth(0)
|
||||
|
@ -5125,7 +5125,6 @@ nsresult nsWindow::Create(nsIWidget* aParent, nsNativeWidget aNativeParent,
|
|||
|
||||
#ifdef MOZ_X11
|
||||
if (GdkIsX11Display() && mGdkWindow) {
|
||||
mXDisplay = GDK_WINDOW_XDISPLAY(mGdkWindow);
|
||||
mXWindow = gdk_x11_window_get_xid(mGdkWindow);
|
||||
|
||||
GdkVisual* gdkVisual = gdk_window_get_visual(mGdkWindow);
|
||||
|
@ -5133,7 +5132,7 @@ nsresult nsWindow::Create(nsIWidget* aParent, nsNativeWidget aNativeParent,
|
|||
mXDepth = gdk_visual_get_depth(gdkVisual);
|
||||
bool shaped = popupNeedsAlphaVisual && !mHasAlphaVisual;
|
||||
|
||||
mSurfaceProvider.Initialize(mXDisplay, mXWindow, mXVisual, mXDepth, shaped);
|
||||
mSurfaceProvider.Initialize(mXWindow, mXVisual, mXDepth, shaped);
|
||||
|
||||
if (mIsTopLevel) {
|
||||
// Set window manager hint to keep fullscreen windows composited.
|
||||
|
@ -5145,7 +5144,9 @@ nsresult nsWindow::Create(nsIWidget* aParent, nsNativeWidget aNativeParent,
|
|||
}
|
||||
// Dummy call to a function in mozgtk to prevent the linker from removing
|
||||
// the dependency with --as-needed.
|
||||
XShmQueryExtension(mXDisplay);
|
||||
if (GdkIsX11Display()) {
|
||||
XShmQueryExtension(DefaultXDisplay());
|
||||
}
|
||||
}
|
||||
# ifdef MOZ_WAYLAND
|
||||
else if (GdkIsWaylandDisplay()) {
|
||||
|
@ -8354,18 +8355,21 @@ int32_t nsWindow::RoundsWidgetCoordinatesTo() { return GdkCeiledScaleFactor(); }
|
|||
|
||||
void nsWindow::GetCompositorWidgetInitData(
|
||||
mozilla::widget::CompositorWidgetInitData* aInitData) {
|
||||
// Make sure the window XID is propagated to X server, we can fail otherwise
|
||||
// in GPU process (Bug 1401634).
|
||||
if (mXDisplay && mXWindow != X11None) {
|
||||
XFlush(mXDisplay);
|
||||
nsCString displayName;
|
||||
|
||||
if (GdkIsX11Display() && mXWindow != X11None) {
|
||||
// Make sure the window XID is propagated to X server, we can fail otherwise
|
||||
// in GPU process (Bug 1401634).
|
||||
Display* display = DefaultXDisplay();
|
||||
XFlush(display);
|
||||
displayName = nsCString(XDisplayString(display));
|
||||
}
|
||||
|
||||
bool isShaped =
|
||||
mIsTransparent && !mHasAlphaVisual && !mTransparencyBitmapForTitlebar;
|
||||
*aInitData = mozilla::widget::GtkCompositorWidgetInitData(
|
||||
(mXWindow != X11None) ? mXWindow : (uintptr_t) nullptr,
|
||||
mXDisplay ? nsCString(XDisplayString(mXDisplay)) : nsCString(), isShaped,
|
||||
GdkIsX11Display(), GetClientSize());
|
||||
(mXWindow != X11None) ? mXWindow : (uintptr_t) nullptr, displayName,
|
||||
isShaped, GdkIsX11Display(), GetClientSize());
|
||||
}
|
||||
|
||||
#ifdef MOZ_WAYLAND
|
||||
|
|
|
@ -376,9 +376,6 @@ class nsWindow final : public nsBaseWidget {
|
|||
bool aFlippedX, bool aFlippedY);
|
||||
static bool IsToplevelWindowTransparent();
|
||||
|
||||
#ifdef MOZ_X11
|
||||
Display* XDisplay() { return mXDisplay; }
|
||||
#endif
|
||||
#ifdef MOZ_WAYLAND
|
||||
bool GetCSDDecorationOffset(int* aDx, int* aDy);
|
||||
void SetEGLNativeWindowSize(const LayoutDeviceIntSize& aEGLWindowSize);
|
||||
|
@ -698,7 +695,6 @@ class nsWindow final : public nsBaseWidget {
|
|||
GTK_WIDGET_COMPOSIDED_ENABLED = 2} WindowComposeRequest;
|
||||
void SetCompositorHint(WindowComposeRequest aState);
|
||||
|
||||
Display* mXDisplay;
|
||||
Window mXWindow;
|
||||
Visual* mXVisual;
|
||||
int mXDepth;
|
||||
|
|
Загрузка…
Ссылка в новой задаче