2022-02-01 11:35:31 +00:00
|
|
|
From 591d38d21cdd215677c6e9e8e6e0cfa9acd9c48c Mon Sep 17 00:00:00 2001
|
2022-02-01 11:32:54 +00:00
|
|
|
From: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
|
2022-02-01 11:35:31 +00:00
|
|
|
Date: Tue, 01 Feb 2022 13:05:36 +0200
|
|
|
|
Subject: [PATCH] Client: Remove mWaitingForUpdateDelivery
|
2022-02-01 11:32:54 +00:00
|
|
|
|
2022-02-01 11:35:31 +00:00
|
|
|
Currently, mWaitingForUpdateDelivery is shared between the main thread
|
|
|
|
(doHandleFrameCallback()) and the frame callback event thread
|
|
|
|
(handleFrameCallback()), however the access to it is not synchronized
|
|
|
|
between neither both threads. On the other hand, QWaylandWindow
|
|
|
|
already ensures not to create a frame callback if there's already one
|
|
|
|
pending.
|
|
|
|
|
|
|
|
This change removes mWaitingForUpdateDelivery flag because it should be
|
|
|
|
already covered by mWaitingForFrameCallback and to remove unsynchronized
|
|
|
|
shared state between threads.
|
|
|
|
|
|
|
|
Change-Id: I0e5a25d18d1e66c4d7683e7e972330c4d7cbbf38
|
2022-02-01 11:32:54 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp
|
2022-02-01 12:59:37 +00:00
|
|
|
index 0415ca9..8e321b6 100644
|
2022-02-01 11:32:54 +00:00
|
|
|
--- a/src/client/qwaylandwindow.cpp
|
|
|
|
+++ b/src/client/qwaylandwindow.cpp
|
2022-02-01 12:59:37 +00:00
|
|
|
@@ -637,24 +637,18 @@ void QWaylandWindow::handleFrameCallback()
|
|
|
|
mWaitingForFrameCallback = false;
|
2022-02-01 11:32:54 +00:00
|
|
|
mFrameCallbackElapsedTimer.invalidate();
|
|
|
|
|
2022-02-01 12:59:37 +00:00
|
|
|
- // The rest can wait until we can run it on the correct thread
|
2022-02-01 11:32:54 +00:00
|
|
|
- if (!mWaitingForUpdateDelivery) {
|
2022-02-01 12:59:37 +00:00
|
|
|
- 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;
|
|
|
|
- };
|
|
|
|
-
|
2022-02-01 11:35:31 +00:00
|
|
|
- // Queued connection, to make sure we don't call handleUpdate() from inside waitForFrameSync()
|
|
|
|
- // in the single-threaded case.
|
2022-02-01 11:32:54 +00:00
|
|
|
- mWaitingForUpdateDelivery = true;
|
2022-02-01 12:59:37 +00:00
|
|
|
- QMetaObject::invokeMethod(this, doHandleExpose, Qt::QueuedConnection);
|
2022-02-01 11:35:31 +00:00
|
|
|
- }
|
2022-02-01 12:59:37 +00:00
|
|
|
+ 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();
|
|
|
|
+ };
|
|
|
|
+
|
2022-02-01 11:35:31 +00:00
|
|
|
+ // Queued connection, to make sure we don't call handleUpdate() from inside waitForFrameSync()
|
|
|
|
+ // in the single-threaded case.
|
2022-02-01 12:59:37 +00:00
|
|
|
+ QMetaObject::invokeMethod(this, doHandleExpose, Qt::QueuedConnection);
|
2022-02-01 11:32:54 +00:00
|
|
|
|
|
|
|
mFrameSyncWait.notify_all();
|
2022-02-01 11:35:31 +00:00
|
|
|
}
|
2022-02-01 11:32:54 +00:00
|
|
|
diff --git a/src/client/qwaylandwindow_p.h b/src/client/qwaylandwindow_p.h
|
2022-02-01 12:59:37 +00:00
|
|
|
index 990e46b..2b17f89 100644
|
2022-02-01 11:32:54 +00:00
|
|
|
--- a/src/client/qwaylandwindow_p.h
|
|
|
|
+++ b/src/client/qwaylandwindow_p.h
|
2022-02-01 12:59:37 +00:00
|
|
|
@@ -240,7 +240,6 @@ protected:
|
2022-02-01 11:32:54 +00:00
|
|
|
WId mWindowId;
|
|
|
|
bool mWaitingForFrameCallback = false;
|
|
|
|
bool mFrameCallbackTimedOut = false; // Whether the frame callback has timed out
|
|
|
|
- bool mWaitingForUpdateDelivery = false;
|
|
|
|
int mFrameCallbackCheckIntervalTimerId = -1;
|
|
|
|
QElapsedTimer mFrameCallbackElapsedTimer;
|
|
|
|
struct ::wl_callback *mFrameCallback = nullptr;
|