From 2452e84d8c38cc62fba52cf5bdf41b7a12ba35a1 Mon Sep 17 00:00:00 2001 From: Fushan Wen Date: Thu, 8 Feb 2024 17:14:20 +0800 Subject: [PATCH] Fix build with Qt6.8 handleExpose was removed in https://github.com/qt/qtwayland/commit/20fb0e7dd53a00dd7f4721a0b712e5554cb268fd --- src/qwaylandlayersurface.cpp | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/qwaylandlayersurface.cpp b/src/qwaylandlayersurface.cpp index 89f47ef..1367d65 100644 --- a/src/qwaylandlayersurface.cpp +++ b/src/qwaylandlayersurface.cpp @@ -16,6 +16,34 @@ #include +namespace +{ +template +concept QWaylandWindowOldV6Type = requires(T t) { t.handleExpose(QRect()); }; + +template +concept QWaylandWindowNewV6Type = requires(T t) { + t.sendRecursiveExposeEvent(); + !t.handleExpose(QRect()); +}; + +class ExposeHelper +{ +public: + template + ExposeHelper(V6T *window, const QSize &pendingSize) + { + window->handleExpose(QRect(QPoint(), pendingSize)); + } + + template + ExposeHelper(V6T *window, [[maybe_unused]] const QSize &pendingSize) + { + window->sendRecursiveExposeEvent(); + } +}; +} + namespace LayerShellQt { QWaylandLayerSurface::QWaylandLayerSurface(QWaylandLayerShellIntegration *shell, QtWaylandClient::QWaylandWindow *window) @@ -92,7 +120,7 @@ void QWaylandLayerSurface::zwlr_layer_surface_v1_configure(uint32_t serial, uint if (!m_configured) { m_configured = true; window()->resizeFromApplyConfigure(m_pendingSize); - window()->handleExpose(QRect(QPoint(), m_pendingSize)); + ExposeHelper helper(window(), m_pendingSize); } else { // Later configures are resizes, so we have to queue them up for a time when we // are not painting to the window.