commit fd68091d96cf339a422e17fa7f96466a4b6fef81
parent dc6cd6c9ae29f60feba4f5c4805fe307e39925c0
Author: pstanciu <pstanciu@mozilla.com>
Date: Mon, 24 Nov 2025 09:15:04 +0200
Revert "Bug 1988717 [Wayland] Set WaylandSurface size from nsWindow::DispatchResized() r=emilio" for causing build bustages @ andSurface.h
This reverts commit 1308e4fda440db0493b42ce93e66e3d2fc4ac557.
Revert "Bug 1988717 [Wayland] Use DesktopIntSize for WaylandSurface unscaled coordinates and remove unused scaled coords frm WaylandSurface r=emilio"
This reverts commit a2c849b752fa5d3d9dca7e64388d6304a5b6b866.
Diffstat:
10 files changed, 152 insertions(+), 92 deletions(-)
diff --git a/gfx/layers/NativeLayerWayland.cpp b/gfx/layers/NativeLayerWayland.cpp
@@ -606,7 +606,7 @@ RefPtr<WaylandBuffer> NativeLayerRootWayland::BorrowExternalBuffer(
NativeLayerWayland::NativeLayerWayland(NativeLayerRootWayland* aRootLayer,
const IntSize& aSize, bool aIsOpaque)
: mRootLayer(aRootLayer), mIsOpaque(aIsOpaque), mSize(aSize) {
- mSurface = new WaylandSurface(mRootLayer->GetRootWaylandSurface());
+ mSurface = new WaylandSurface(mRootLayer->GetRootWaylandSurface(), mSize);
#ifdef MOZ_LOGGING
mSurface->SetLoggingWidget(this);
#endif
@@ -794,13 +794,10 @@ void NativeLayerWayland::UpdateLayerPlacementLocked(
mSurface->SetTransformFlippedLocked(aProofOfLock, transform2D._11 < 0.0,
transform2D._22 < 0.0);
-
- // TODO! Downscale introduces rounding errors here.
auto unscaledRect =
gfx::RoundedToInt(surfaceRectClipped / UnknownScaleFactor(mScale));
- auto rect = DesktopIntRect::FromUnknownRect(unscaledRect);
- mSurface->MoveLocked(aProofOfLock, rect.TopLeft());
- mSurface->SetViewPortDestLocked(aProofOfLock, rect.Size());
+ mSurface->MoveLocked(aProofOfLock, unscaledRect.TopLeft());
+ mSurface->SetViewPortDestLocked(aProofOfLock, unscaledRect.Size());
auto transform2DInversed = transform2D.Inverse();
Rect bufferClip = transform2DInversed.TransformBounds(surfaceRectClipped);
@@ -867,7 +864,7 @@ bool NativeLayerWayland::Map(WaylandSurfaceLock* aParentWaylandSurfaceLock) {
MOZ_DIAGNOSTIC_ASSERT(mNeedsMainThreadUpdate != MainThreadUpdate::Map);
if (!mSurface->MapLocked(surfaceLock, aParentWaylandSurfaceLock,
- DesktopIntPoint())) {
+ gfx::IntPoint(0, 0))) {
gfxCriticalError() << "NativeLayerWayland::Map() failed!";
return false;
}
diff --git a/gfx/layers/opengl/CompositorOGL.cpp b/gfx/layers/opengl/CompositorOGL.cpp
@@ -742,6 +742,15 @@ Maybe<IntRect> CompositorOGL::BeginFrame(const nsIntRegion& aInvalidRegion,
MakeCurrent(ForceMakeCurrent);
mWidgetSize = LayoutDeviceIntSize::FromUnknownSize(rect.Size());
+#ifdef MOZ_WAYLAND
+ if (mWidget && mWidget->AsGTK()) {
+ // Wayland only check we have correct window size to avoid
+ // rendering artifacts.
+ if (!mWidget->AsGTK()->SetEGLNativeWindowSize(mWidgetSize)) {
+ return Nothing();
+ }
+ }
+#endif
} else {
MakeCurrent();
}
diff --git a/gfx/webrender_bindings/RenderCompositorEGL.cpp b/gfx/webrender_bindings/RenderCompositorEGL.cpp
@@ -88,7 +88,15 @@ bool RenderCompositorEGL::BeginFrame() {
<< "We don't have EGLSurface to draw into. Called too early?";
return false;
}
-
+#ifdef MOZ_WAYLAND
+ if (mWidget->AsGTK()) {
+ if (!mWidget->AsGTK()->SetEGLNativeWindowSize(GetBufferSize())) {
+ // Wayland only check we have correct window size to avoid
+ // rendering artifacts.
+ return false;
+ }
+ }
+#endif
if (!MakeCurrent()) {
gfxCriticalNote << "Failed to make render context current, can't draw.";
return false;
diff --git a/widget/gtk/GtkCompositorWidget.cpp b/widget/gtk/GtkCompositorWidget.cpp
@@ -122,6 +122,17 @@ EGLNativeWindowType GtkCompositorWidget::GetEGLNativeWindow() {
return window;
}
+bool GtkCompositorWidget::SetEGLNativeWindowSize(
+ const LayoutDeviceIntSize& aEGLWindowSize) {
+#if defined(MOZ_WAYLAND)
+ // We explicitly need to set EGL window size on Wayland only.
+ if (GdkIsWaylandDisplay() && mWidget) {
+ return mWidget->SetEGLNativeWindowSize(aEGLWindowSize);
+ }
+#endif
+ return true;
+}
+
LayoutDeviceIntRegion GtkCompositorWidget::GetTransparentRegion() {
LayoutDeviceIntRegion fullRegion(
LayoutDeviceIntRect(LayoutDeviceIntPoint(), GetClientSize()));
diff --git a/widget/gtk/GtkCompositorWidget.h b/widget/gtk/GtkCompositorWidget.h
@@ -79,6 +79,10 @@ class GtkCompositorWidget : public CompositorWidget,
// Resume rendering with to given aXWindow (X11) or nsWindow (Wayland).
void SetRenderingSurface(const uintptr_t aXWindow) override;
+ // If we fail to set window size (due to different screen scale or so)
+ // we can't paint the frame by compositor.
+ bool SetEGLNativeWindowSize(const LayoutDeviceIntSize& aEGLWindowSize);
+
#if defined(MOZ_X11)
Window XWindow() const { return mProvider.GetXWindow(); }
#endif
diff --git a/widget/gtk/MozContainerWayland.cpp b/widget/gtk/MozContainerWayland.cpp
@@ -83,7 +83,7 @@ using namespace mozilla;
using namespace mozilla::widget;
static bool moz_container_wayland_ensure_surface(
- MozContainer* container, DesktopIntPoint* aPosition = nullptr);
+ MozContainer* container, gfx::IntPoint* aPosition = nullptr);
// Invalidate gtk wl_surface to commit changes to wl_subsurface.
// wl_subsurface changes are effective when parent surface is commited.
@@ -176,14 +176,14 @@ void moz_container_wayland_size_allocate(GtkWidget* widget,
// We need to position our subsurface according to GdkWindow
// when offset changes (GdkWindow is maximized for instance).
// see gtk-clutter-embed.c for reference.
- auto pos = DesktopIntPoint(allocation->x, allocation->y);
- moz_container_wayland_ensure_surface(MOZ_CONTAINER(widget), &pos);
+ gfx::IntPoint position(allocation->x, allocation->y);
+ moz_container_wayland_ensure_surface(MOZ_CONTAINER(widget), &position);
MOZ_WL_CONTAINER(widget)->before_first_size_alloc = false;
}
}
static bool moz_container_wayland_ensure_surface(MozContainer* container,
- DesktopIntPoint* aPosition) {
+ gfx::IntPoint* aPosition) {
WaylandSurface* surface = MOZ_WL_SURFACE(container);
WaylandSurfaceLock lock(surface);
@@ -213,8 +213,12 @@ static bool moz_container_wayland_ensure_surface(MozContainer* container,
nsWindow* window = moz_container_get_nsWindow(container);
MOZ_RELEASE_ASSERT(window);
- if (!surface->MapLocked(lock, parentSurface,
- aPosition ? *aPosition : DesktopIntPoint())) {
+ gfx::IntPoint subsurfacePosition;
+ if (aPosition) {
+ subsurfacePosition = *aPosition;
+ }
+
+ if (!surface->MapLocked(lock, parentSurface, subsurfacePosition)) {
return false;
}
diff --git a/widget/gtk/WaylandSurface.cpp b/widget/gtk/WaylandSurface.cpp
@@ -86,10 +86,12 @@ bool WaylandSurface::IsOpaqueRegionEnabled() {
return sIsOpaqueRegionEnabled;
}
-WaylandSurface::WaylandSurface(RefPtr<WaylandSurface> aParent)
- : mParent(aParent) {
- LOGWAYLAND("WaylandSurface::WaylandSurface(), parent [%p]",
- mParent ? mParent->GetLoggingWidget() : nullptr);
+WaylandSurface::WaylandSurface(RefPtr<WaylandSurface> aParent,
+ gfx::IntSize aSize)
+ : mSizeScaled(aSize), mParent(aParent) {
+ LOGWAYLAND("WaylandSurface::WaylandSurface(), parent [%p] size [%d x %d]",
+ mParent ? mParent->GetLoggingWidget() : nullptr, mSizeScaled.width,
+ mSizeScaled.height);
struct wl_compositor* compositor = WaylandDisplayGet()->GetCompositor();
mSurface = wl_compositor_create_surface(compositor);
MOZ_RELEASE_ASSERT(mSurface, "Can't create wl_surface!");
@@ -402,7 +404,7 @@ void WaylandSurface::VisibleCallbackHandler() {
bool WaylandSurface::MapLocked(const WaylandSurfaceLock& aProofOfLock,
wl_surface* aParentWLSurface,
WaylandSurfaceLock* aParentWaylandSurfaceLock,
- DesktopIntPoint aSubsurfacePosition,
+ gfx::IntPoint aSubsurfacePosition,
bool aSubsurfaceDesync) {
LOGWAYLAND("WaylandSurface::MapLocked()");
MOZ_DIAGNOSTIC_ASSERT(&aProofOfLock == mSurfaceLock);
@@ -471,14 +473,14 @@ bool WaylandSurface::MapLocked(const WaylandSurfaceLock& aProofOfLock,
bool WaylandSurface::MapLocked(const WaylandSurfaceLock& aProofOfLock,
wl_surface* aParentWLSurface,
- DesktopIntPoint aSubsurfacePosition) {
+ gfx::IntPoint aSubsurfacePosition) {
return MapLocked(aProofOfLock, aParentWLSurface, nullptr, aSubsurfacePosition,
/* aSubsurfaceDesync */ true);
}
bool WaylandSurface::MapLocked(const WaylandSurfaceLock& aProofOfLock,
WaylandSurfaceLock* aParentWaylandSurfaceLock,
- DesktopIntPoint aSubsurfacePosition) {
+ gfx::IntPoint aSubsurfacePosition) {
return MapLocked(aProofOfLock, nullptr, aParentWaylandSurfaceLock,
aSubsurfacePosition,
/* aSubsurfaceDesync */ false);
@@ -542,7 +544,7 @@ void WaylandSurface::UnmapLocked(WaylandSurfaceLock& aSurfaceLock) {
ClearScaleLocked(aSurfaceLock);
MozClearPointer(mViewport, wp_viewport_destroy);
- mViewportDestinationSize = DesktopIntSize(-1, -1);
+ mViewportDestinationSize = gfx::IntSize(-1, -1);
mViewportSourceRect = gfx::Rect(-1, -1, -1, -1);
MozClearPointer(mFractionalScaleListener, wp_fractional_scale_v1_destroy);
@@ -606,7 +608,7 @@ void WaylandSurface::CommitLocked(const WaylandSurfaceLock& aProofOfLock,
}
void WaylandSurface::MoveLocked(const WaylandSurfaceLock& aProofOfLock,
- DesktopIntPoint aPosition) {
+ gfx::IntPoint aPosition) {
MOZ_DIAGNOSTIC_ASSERT(&aProofOfLock == mSurfaceLock);
MOZ_DIAGNOSTIC_ASSERT(mIsMapped);
@@ -615,7 +617,7 @@ void WaylandSurface::MoveLocked(const WaylandSurfaceLock& aProofOfLock,
}
MOZ_DIAGNOSTIC_ASSERT(mSubsurface);
- LOGWAYLAND("WaylandSurface::MoveLocked() unscaled [%d,%d]", (int)aPosition.x,
+ LOGWAYLAND("WaylandSurface::MoveLocked() [%d,%d]", (int)aPosition.x,
(int)aPosition.y);
mSubsurfacePosition = aPosition;
wl_subsurface_set_position(mSubsurface, aPosition.x, aPosition.y);
@@ -782,22 +784,22 @@ void WaylandSurface::SetCeiledScaleLocked(
}
}
-void WaylandSurface::SetRenderingSizeLocked(
- const WaylandSurfaceLock& aProofOfLock, DesktopIntSize aSize) {
+void WaylandSurface::SetSizeLocked(const WaylandSurfaceLock& aProofOfLock,
+ gfx::IntSize aSizeScaled,
+ gfx::IntSize aSizeUnscaled) {
MOZ_DIAGNOSTIC_ASSERT(&aProofOfLock == mSurfaceLock);
- LOGVERBOSE("WaylandSurface::SetRenderingSizeLocked(): size [%d x %d]",
- aSize.width, aSize.height);
- mSize = aSize;
-
- // non-EGL rendering changes are applied at WaylandSurface::AttachLocked().
- // We want to sync size changes with matching buffer.
- if (mViewportFollowsSizeChanges && mEGLWindow) {
- SetViewPortDestLocked(aProofOfLock, aSize);
+ LOGVERBOSE(
+ "WaylandSurface::SetSizeLocked(): Size [%d x %d] unscaled size [%d x %d]",
+ aSizeScaled.width, aSizeScaled.height, aSizeUnscaled.width,
+ aSizeUnscaled.height);
+ mSizeScaled = aSizeScaled;
+ if (mViewportFollowsSizeChanges) {
+ SetViewPortDestLocked(aProofOfLock, aSizeUnscaled);
}
}
void WaylandSurface::SetViewPortDestLocked(
- const WaylandSurfaceLock& aProofOfLock, DesktopIntSize aDestSize) {
+ const WaylandSurfaceLock& aProofOfLock, gfx::IntSize aDestSize) {
MOZ_DIAGNOSTIC_ASSERT(&aProofOfLock == mSurfaceLock);
if (!mViewport) {
return;
@@ -964,26 +966,36 @@ wl_egl_window* WaylandSurface::GetEGLWindow(DesktopIntSize aSize) {
wl_egl_window_resize(mEGLWindow, scaledSize.width, scaledSize.height, 0, 0);
}
- SetRenderingSizeLocked(lock, aSize);
+ if (mEGLWindow) {
+ SetSizeLocked(lock, scaledSize.ToUnknownSize(), aSize.ToUnknownSize());
+ }
+
return mEGLWindow;
}
-void WaylandSurface::SetSize(DesktopIntSize aSize) {
+// Return false if scale factor doesn't match buffer size.
+// We need to skip painting in such case do avoid Wayland compositor freaking.
+bool WaylandSurface::SetEGLWindowSize(LayoutDeviceIntSize aSize) {
WaylandSurfaceLock lock(this);
- auto scaledSize = LayoutDeviceIntSize::Round(
- aSize * DesktopToLayoutDeviceScale(GetScale()));
+ // We may be called after unmap so we're missing egl window completelly.
+ // In such case don't return false which would block compositor.
+ // We return true here and don't block flush WebRender queue.
+ // We'll be repainted if our window become visible again anyway.
+ MOZ_DIAGNOSTIC_ASSERT(mEGLWindow, "Missing ELG window?");
+
+ auto unscaledSize =
+ DesktopIntSize::Round(aSize / DesktopToLayoutDeviceScale(GetScale()));
LOGVERBOSE(
- "WaylandSurface::SetSize() size [%d x %d] "
- "scale %f scaled [%d x %d]",
- aSize.width, aSize.height, GetScale(), scaledSize.width,
- scaledSize.height);
+ "WaylandSurface::SetEGLWindowSize() scaled [%d x %d] unscaled [%d x %d] "
+ "scale %f",
+ aSize.width, aSize.height, unscaledSize.width, unscaledSize.height,
+ GetScale());
- if (mEGLWindow) {
- wl_egl_window_resize(mEGLWindow, scaledSize.width, scaledSize.height, 0, 0);
- }
- SetRenderingSizeLocked(lock, aSize);
+ wl_egl_window_resize(mEGLWindow, aSize.width, aSize.height, 0, 0);
+ SetSizeLocked(lock, aSize.ToUnknownSize(), unscaledSize.ToUnknownSize());
+ return true;
}
void WaylandSurface::InvalidateRegionLocked(
@@ -1071,28 +1083,16 @@ bool WaylandSurface::AttachLocked(const WaylandSurfaceLock& aSurfaceLock,
auto scale = GetScale();
LayoutDeviceIntSize bufferSize = aBuffer->GetSize();
- DesktopIntSize surfaceSize((int)round(mSize.width * scale),
- (int)round(mSize.height * scale));
- bool sizeMatches = bufferSize.width == surfaceSize.width &&
- bufferSize.height == surfaceSize.height;
+ // TODO: rounding?
+ SetSizeLocked(aSurfaceLock, gfx::IntSize(bufferSize.width, bufferSize.height),
+ gfx::IntSize((int)round(bufferSize.width / scale),
+ (int)round(bufferSize.height / scale)));
+
LOGWAYLAND(
"WaylandSurface::AttachLocked() transactions [%d] WaylandBuffer [%p] "
- "attached [%d] buffer size [%d x %d] surface (scaled) size [%d x %d] "
- "fractional scale %f matches %d",
+ "attached [%d] size [%d x %d] fractional scale %f",
(int)mBufferTransactions.Length(), aBuffer.get(), aBuffer->IsAttached(),
- bufferSize.width, bufferSize.height, surfaceSize.width,
- surfaceSize.height, scale, sizeMatches);
-
- if (mViewportFollowsSizeChanges) {
- DesktopIntSize viewportSize;
- if (!sizeMatches) {
- viewportSize =
- DesktopIntSize::Round(bufferSize / DesktopToLayoutDeviceScale(scale));
- } else {
- viewportSize = mSize;
- }
- SetViewPortDestLocked(aSurfaceLock, viewportSize);
- }
+ bufferSize.width, bufferSize.height, scale);
auto* transaction = GetNextTransactionLocked(aSurfaceLock, aBuffer);
if (!transaction) {
@@ -1113,7 +1113,7 @@ void WaylandSurface::RemoveAttachedBufferLocked(
LOGWAYLAND("WaylandSurface::RemoveAttachedBufferLocked()");
- SetRenderingSizeLocked(aSurfaceLock, DesktopIntSize());
+ SetSizeLocked(aSurfaceLock, gfx::IntSize(0, 0), gfx::IntSize(0, 0));
wl_surface_attach(mSurface, nullptr, 0, 0);
mLatestAttachedBuffer = 0;
mSurfaceNeedsCommit = true;
diff --git a/widget/gtk/WaylandSurface.h b/widget/gtk/WaylandSurface.h
@@ -35,7 +35,7 @@ class WaylandSurface final {
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(WaylandSurface);
- WaylandSurface(RefPtr<WaylandSurface> aParent);
+ WaylandSurface(RefPtr<WaylandSurface> aParent, gfx::IntSize aSize);
#ifdef MOZ_LOGGING
nsAutoCString GetDebugTag() const;
@@ -68,12 +68,12 @@ class WaylandSurface final {
const WaylandSurfaceLock& aProofOfLock,
const std::function<void(bool)>& aFrameCallbackStateHandler);
+ // Create and resize EGL window (Gdk coordinates).
wl_egl_window* GetEGLWindow(DesktopIntSize aSize);
+ // Resize EGL window (pixel coordinates).
+ bool SetEGLWindowSize(LayoutDeviceIntSize aSize);
bool HasEGLWindow() const { return !!mEGLWindow; }
- // Set WaylandSurface target size (viewport & ELG surface if it's present).
- void SetSize(DesktopIntSize aSize);
-
// Mapped means we have all internals created.
bool IsMapped() const { return mIsMapped; }
@@ -96,11 +96,11 @@ class WaylandSurface final {
// Mapped as direct surface of MozContainer
bool MapLocked(const WaylandSurfaceLock& aProofOfLock,
wl_surface* aParentWLSurface,
- DesktopIntPoint aSubsurfacePosition);
+ gfx::IntPoint aSubsurfacePosition);
// Mapped as child of WaylandSurface (used by layers)
bool MapLocked(const WaylandSurfaceLock& aProofOfLock,
WaylandSurfaceLock* aParentWaylandSurfaceLock,
- DesktopIntPoint aSubsurfacePosition);
+ gfx::IntPoint aSubsurfacePosition);
// Unmap surface which hides it
void UnmapLocked(WaylandSurfaceLock& aSurfaceLock);
@@ -159,11 +159,11 @@ class WaylandSurface final {
void PlaceAboveLocked(const WaylandSurfaceLock& aProofOfLock,
WaylandSurfaceLock& aLowerSurfaceLock);
void MoveLocked(const WaylandSurfaceLock& aProofOfLock,
- DesktopIntPoint aPosition);
+ gfx::IntPoint aPosition);
void SetViewPortSourceRectLocked(const WaylandSurfaceLock& aProofOfLock,
gfx::Rect aRect);
void SetViewPortDestLocked(const WaylandSurfaceLock& aProofOfLock,
- DesktopIntSize aDestSize);
+ gfx::IntSize aDestSize);
void SetTransformFlippedLocked(const WaylandSurfaceLock& aProofOfLock,
bool aFlippedX, bool aFlippedY);
@@ -277,10 +277,10 @@ class WaylandSurface final {
bool MapLocked(const WaylandSurfaceLock& aProofOfLock,
wl_surface* aParentWLSurface,
WaylandSurfaceLock* aParentWaylandSurfaceLock,
- DesktopIntPoint aSubsurfacePosition, bool aSubsurfaceDesync);
+ gfx::IntPoint aSubsurfacePosition, bool aSubsurfaceDesync);
- void SetRenderingSizeLocked(const WaylandSurfaceLock& aProofOfLock,
- DesktopIntSize aSize);
+ void SetSizeLocked(const WaylandSurfaceLock& aProofOfLock,
+ gfx::IntSize aSizeScaled, gfx::IntSize aUnscaledSize);
wl_surface* Lock(WaylandSurfaceLock* aWaylandSurfaceLock);
void Unlock(struct wl_surface** aSurface,
@@ -318,7 +318,9 @@ class WaylandSurface final {
std::function<void(void)> mGdkCommitCallback;
std::function<void(void)> mUnmapCallback;
- DesktopIntSize mSize;
+ // Scaled surface size, ceiled or fractional.
+ // This reflects real surface size which we paint.
+ gfx::IntSize mSizeScaled;
// Parent GdkWindow where we paint to, directly or via subsurface.
RefPtr<GdkWindow> mGdkWindow;
@@ -347,7 +349,7 @@ class WaylandSurface final {
bool mSubsurfaceDesync = true;
wl_subsurface* mSubsurface = nullptr;
- DesktopIntPoint mSubsurfacePosition{-1, -1};
+ gfx::IntPoint mSubsurfacePosition{-1, -1};
// Wayland buffers recently attached to this surface or held by
// Wayland compositor.
@@ -369,7 +371,7 @@ class WaylandSurface final {
bool mViewportFollowsSizeChanges = true;
wp_viewport* mViewport = nullptr;
gfx::Rect mViewportSourceRect{-1, -1, -1, -1};
- DesktopIntSize mViewportDestinationSize{-1, -1};
+ gfx::IntSize mViewportDestinationSize{-1, -1};
// Surface flip state on X/Y asix
bool mBufferTransformFlippedX = false;
diff --git a/widget/gtk/nsWindow.cpp b/widget/gtk/nsWindow.cpp
@@ -590,8 +590,8 @@ void nsWindow::DispatchResized() {
auto clientSize = GetClientSize();
- LOG("nsWindow::DispatchResized() client scaled size [%d, %d]",
- (int)clientSize.width, (int)clientSize.height);
+ LOG("nsWindow::DispatchResized() client size [%d, %d]", (int)clientSize.width,
+ (int)clientSize.height);
// Check out painting texture size
if (mCompositorSession &&
@@ -600,14 +600,6 @@ void nsWindow::DispatchResized() {
<< clientSize << " size state " << mSizeMode;
}
-#ifdef MOZ_WAYLAND
- if (mSurface) {
- LOG(" WaylanSurface unscaled size [%d, %d]", mClientArea.Size().width,
- mClientArea.Size().height);
- mSurface->SetSize(mClientArea.Size());
- }
-#endif
-
// Notify the GtkCompositorWidget of a ClientSizeChange
if (mCompositorWidgetDelegate) {
mCompositorWidgetDelegate->NotifyClientSizeChanged(clientSize);
@@ -6406,7 +6398,8 @@ nsresult nsWindow::Create(nsIWidget* aParent, const LayoutDeviceIntRect& aRect,
if (GdkIsWaylandDisplay()) {
mSurface = new WaylandSurface(
parentnsWindow ? MOZ_WL_SURFACE(parentnsWindow->GetMozContainer())
- : nullptr);
+ : nullptr,
+ gfx::IntSize(ToLayoutDevicePixels(mLastSizeRequest).ToUnknownSize()));
}
container = moz_container_new(this, mSurface);
#else
@@ -9891,6 +9884,37 @@ void nsWindow::LockAspectRatio(bool aShouldLock) {
nsWindow* nsWindow::GetFocusedWindow() { return gFocusWindow; }
+#ifdef MOZ_WAYLAND
+bool nsWindow::SetEGLNativeWindowSize(
+ const LayoutDeviceIntSize& aEGLWindowSize) {
+ // SetEGLNativeWindowSize() is Wayland only call.
+ MOZ_ASSERT(GdkIsWaylandDisplay());
+
+ if (mIsDestroyed) {
+ return true;
+ }
+
+# ifdef MOZ_LOGGING
+ if (LOG_ENABLED_VERBOSE()) {
+ float scale = FractionalScaleFactor();
+ static uintptr_t lastSizeLog = 0;
+ uintptr_t sizeLog =
+ uintptr_t(this) + aEGLWindowSize.width + aEGLWindowSize.height + scale +
+ aEGLWindowSize.width / scale + aEGLWindowSize.height / scale;
+ if (lastSizeLog != sizeLog) {
+ lastSizeLog = sizeLog;
+ LOGVERBOSE(
+ "nsWindow::SetEGLNativeWindowSize() %d x %d scale %.2f (unscaled "
+ "%.2f x %.2f)",
+ aEGLWindowSize.width, aEGLWindowSize.height, scale,
+ aEGLWindowSize.width / scale, aEGLWindowSize.height / scale);
+ }
+ }
+# endif
+ return mSurface->SetEGLWindowSize(aEGLWindowSize);
+}
+#endif
+
nsWindow* nsWindow::GetWindow(GdkWindow* window) {
return get_window_for_gdk_window(window);
}
diff --git a/widget/gtk/nsWindow.h b/widget/gtk/nsWindow.h
@@ -483,6 +483,7 @@ class nsWindow final : public nsIWidget {
static void TransferFocusToWaylandWindow(nsWindow* aWindow);
void FocusWaylandWindow(const char* aTokenID);
+ bool SetEGLNativeWindowSize(const LayoutDeviceIntSize& aEGLWindowSize);
void WaylandDragWorkaround(GdkEventButton* aEvent);
void CreateCompositorVsyncDispatcher() override;