From 27283b02ca5f30f2f57b24c306a986c572e87cd6 Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Tue, 29 Apr 2025 11:52:35 +0200 Subject: [PATCH] wayland: Make initial commit for surface state opt-in After setting up the shell surface we setup the initial state and have to commit the surface to apply the surface role in order to get a configure event from the compositor. This is not a requirement for subsurfaces, and can be skipped. It is also problematic for some 3rd party shells, such as ext-session-lock-v1, which has a different setup behaviour. Task-number: QTBUG-136337 Change-Id: I9e7874ec2f4150e24eb4790384eacc4123f9552b Reviewed-by: Vlad Zahorodnii --- src/plugins/platforms/wayland/qwaylandshellsurface.cpp | 10 ++++++++++ src/plugins/platforms/wayland/qwaylandshellsurface_p.h | 2 ++ src/plugins/platforms/wayland/qwaylandwindow.cpp | 3 ++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/wayland/qwaylandshellsurface.cpp b/src/plugins/platforms/wayland/qwaylandshellsurface.cpp index 2dc218c2f75..4079f7e0848 100644 --- a/src/plugins/platforms/wayland/qwaylandshellsurface.cpp +++ b/src/plugins/platforms/wayland/qwaylandshellsurface.cpp @@ -85,6 +85,16 @@ void QWaylandShellSurface::requestXdgActivationToken(quint32 serial) Q_UNUSED(serial); Q_EMIT m_window->xdgActivationTokenCreated({}); } + +/*! + Determines whether the client should commit the surface with no buffer + after creating the role and performing initial setup +*/ +bool QWaylandShellSurface::commitSurfaceRole() const +{ + return true; +} + } QT_END_NAMESPACE diff --git a/src/plugins/platforms/wayland/qwaylandshellsurface_p.h b/src/plugins/platforms/wayland/qwaylandshellsurface_p.h index 71599259977..88adb338ca3 100644 --- a/src/plugins/platforms/wayland/qwaylandshellsurface_p.h +++ b/src/plugins/platforms/wayland/qwaylandshellsurface_p.h @@ -92,6 +92,8 @@ public: virtual void setIcon(const QIcon &icon) { Q_UNUSED(icon); } + virtual bool commitSurfaceRole() const; + protected: void resizeFromApplyConfigure(const QSize &sizeWithMargins, const QPoint &offset = {0, 0}); void repositionFromApplyConfigure(const QPoint &position); diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp index f14ddb78d56..7475fe6608c 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow.cpp +++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp @@ -203,7 +203,8 @@ void QWaylandWindow::initWindow() handleContentOrientationChange(window()->contentOrientation()); mFlags = window()->flags(); - mSurface->commit(); + if (mShellSurface && mShellSurface->commitSurfaceRole()) + mSurface->commit(); } void QWaylandWindow::setPendingImageDescription()