From f0435ab1a49473fccf8f7e2e86fb5f41ade9f101 Mon Sep 17 00:00:00 2001 From: Jungi Byun Date: Tue, 23 Feb 2021 13:20:20 +0900 Subject: [PATCH] Support handleFrameCallback to derived classes The lambda expression doHandleExpose() is used in handleFrameCallback() to deal with exposure. In order to support platform specific implementation for frame callback, make the method doHandleExpose() into a virtual protected member doHandleFrameCallback() in QWaylandWindow. Change-Id: I8b22d4a552c72db1620d606929005917588c680d Reviewed-by: Eskil Abrahamsen Blomfeldt --- .../platforms/wayland/qwaylandwindow.cpp | 25 ++++++++++--------- .../platforms/wayland/qwaylandwindow_p.h | 1 + 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp index 0f1752d6db6..330c84a4a6b 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow.cpp +++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp @@ -643,24 +643,25 @@ void QWaylandWindow::handleFrameCallback() // The rest can wait until we can run it on the correct thread if (!mWaitingForUpdateDelivery) { - auto doHandleExpose = [this]() { - bool wasExposed = isExposed(); - mFrameCallbackTimedOut = false; - if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed? - sendExposeEvent(QRect(QPoint(), geometry().size())); - if (wasExposed && hasPendingUpdateRequest()) - deliverUpdateRequest(); - - mWaitingForUpdateDelivery = false; - }; - // Queued connection, to make sure we don't call handleUpdate() from inside waitForFrameSync() // in the single-threaded case. mWaitingForUpdateDelivery = true; - QMetaObject::invokeMethod(this, doHandleExpose, Qt::QueuedConnection); + QMetaObject::invokeMethod(this, &QWaylandWindow::doHandleFrameCallback, Qt::QueuedConnection); } } +void QWaylandWindow::doHandleFrameCallback() +{ + bool wasExposed = isExposed(); + mFrameCallbackTimedOut = false; + if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed? + sendExposeEvent(QRect(QPoint(), geometry().size())); + if (wasExposed && hasPendingUpdateRequest()) + deliverUpdateRequest(); + + mWaitingForUpdateDelivery = false; +} + bool QWaylandWindow::waitForFrameSync(int timeout) { QMutexLocker locker(mFrameQueue.mutex); diff --git a/src/plugins/platforms/wayland/qwaylandwindow_p.h b/src/plugins/platforms/wayland/qwaylandwindow_p.h index 35850b8858a..c323618bdf2 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow_p.h +++ b/src/plugins/platforms/wayland/qwaylandwindow_p.h @@ -214,6 +214,7 @@ signals: void wlSurfaceDestroyed(); protected: + virtual void doHandleFrameCallback(); void sendExposeEvent(const QRect &rect); QWaylandDisplay *mDisplay = nullptr;