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 <eskil.abrahamsen-blomfeldt@qt.io>
This commit is contained in:
Jungi Byun 2021-02-23 13:20:20 +09:00
parent 8e336efb2d
commit f0435ab1a4
2 changed files with 14 additions and 12 deletions

View File

@ -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);

View File

@ -214,6 +214,7 @@ signals:
void wlSurfaceDestroyed();
protected:
virtual void doHandleFrameCallback();
void sendExposeEvent(const QRect &rect);
QWaylandDisplay *mDisplay = nullptr;