Gentoo Archives: gentoo-commits

From: Andreas Sturmlechner <asturm@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-qt/qtwayland/files/, dev-qt/qtwayland/
Date: Tue, 08 Feb 2022 19:59:02
Message-Id: 1644350309.dd788798d12a04fb9c052c5df2d111a052e07ab0.asturm@gentoo
1 commit: dd788798d12a04fb9c052c5df2d111a052e07ab0
2 Author: Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
3 AuthorDate: Tue Feb 8 19:55:08 2022 +0000
4 Commit: Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
5 CommitDate: Tue Feb 8 19:58:29 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=dd788798
7
8 dev-qt/qtwayland: Add upstream-pending fixes in advance
9
10 - client: Gracefully handle shutdown and window hiding
11 - Use proper dependencies in compile tests
12 - Client: Remove mWaitingForUpdateDelivery
13 - Wayland mutex fixes
14
15 See also:
16 https://invent.kde.org/qt/qt/qtwayland/-/merge_requests/23
17 https://invent.kde.org/qt/qt/qtwayland/-/merge_requests/33
18 https://invent.kde.org/qt/qt/qtwayland/-/merge_requests/35
19 https://invent.kde.org/qt/qt/qtwayland/-/merge_requests/34
20
21 KDE-bug: https://bugs.kde.org/show_bug.cgi?id=449163
22 QTBUG: https://bugreports.qt.io/browse/QTBUG-91264
23 QTBUG: https://bugreports.qt.io/browse/QTBUG-90037
24 QTBUG: https://bugreports.qt.io/browse/QTBUG-100475
25 Package-Manager: Portage-3.0.30, Repoman-3.0.3
26 Signed-off-by: Andreas Sturmlechner <asturm <AT> gentoo.org>
27
28 dev-qt/qtwayland/Manifest | 1 +
29 .../qtwayland-5.15.2-QTBUG-90037-QTBUG-91264.patch | 131 +++++++++++++++++++++
30 .../files/qtwayland-5.15.2-fix-qmake-deps.patch | 126 ++++++++++++++++++++
31 .../files/qtwayland-5.15.2-fixup-mutexes.patch | 87 ++++++++++++++
32 .../qtwayland-5.15.2-guard-mResizeDirty.patch | 37 ++++++
33 ...d-5.15.2-remove-mWaitingForUpdateDelivery.patch | 79 +++++++++++++
34 dev-qt/qtwayland/qtwayland-5.15.2-r19.ebuild | 52 ++++++++
35 7 files changed, 513 insertions(+)
36
37 diff --git a/dev-qt/qtwayland/Manifest b/dev-qt/qtwayland/Manifest
38 index b5b66bd5c2dd..2ff54b09a0bf 100644
39 --- a/dev-qt/qtwayland/Manifest
40 +++ b/dev-qt/qtwayland/Manifest
41 @@ -1,2 +1,3 @@
42 DIST qtwayland-5.15.2-4644d51f.tar.gz 831697 BLAKE2B c3d60416ef71030018918ec5157122e2585d270d5aa1a74d66874a33f14f0c4ac85da5a1dd7bfb422a1090f79e5d2c08763c68fe724416b34bad16f945d1740c SHA512 e350396e9bdfa6f0fda938af74c722792d50473eb3d786442ba11919e7801f0cd8d045916c8e49d8a63ffd966376cb74e7cc1c3d4d1732e71061fb8343a497d3
43 DIST qtwayland-5.15.2-867540b9.tar.gz 830061 BLAKE2B b831288d6a3e671631b4df00eb1edb72e35128f3ed5a73983b3e15193f554fddcd0337deb832d44b795d2e37f0601fe35b8b0fcb5986bcc44154d172f3a54193 SHA512 b834802811d9f65559ef5e7468189b53c666e390aa09edeb490e5fee2dece13082b11da0f8b5924b89f7dc8e1eba375a485940f4dfbf0445f3d1e96033e33f24
44 +DIST qtwayland-5.15.2-ce2caf49.tar.gz 831808 BLAKE2B af7006f3ce5bb262710c5405f20107239140afe5c7f2b8b10ac834b7e41076a274adbf34152cba3fed19538f653f70faffb1255e622b8607d34f5a4695603461 SHA512 8eaf58da68311b072f5d0192444dafc5819971807682bb85f2316c10e4e64a735a95b05a0a5c1e4a66542702281deb364a6470f6bd0ea042818edb5a9b0396fb
45
46 diff --git a/dev-qt/qtwayland/files/qtwayland-5.15.2-QTBUG-90037-QTBUG-91264.patch b/dev-qt/qtwayland/files/qtwayland-5.15.2-QTBUG-90037-QTBUG-91264.patch
47 new file mode 100644
48 index 000000000000..8bffa3e08b3e
49 --- /dev/null
50 +++ b/dev-qt/qtwayland/files/qtwayland-5.15.2-QTBUG-90037-QTBUG-91264.patch
51 @@ -0,0 +1,131 @@
52 +From d7b34dbf072236cdfb3b64e5ad26d1ff29dfec5f Mon Sep 17 00:00:00 2001
53 +From: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@××.io>
54 +Date: Thu, 22 Apr 2021 08:42:33 +0200
55 +Subject: client: Gracefully handle shutdown and window hiding
56 +
57 +When a window is hidden or destroyed, the render thread may already
58 +be rendering. We need to properly read-lock the surface pointer
59 +when it is in use and exit when it becomes null.
60 +
61 +Note that there is also a potential crash in the Mesa GL driver
62 +where it keeps a proxy to the wl_surface, so if we delete this
63 +while we are still rendering, it can crash inside the driver.
64 +This is not addressed by this patch, and has not been reproduced
65 +on any other drivers so far.
66 +
67 +[ChangeLog][Client] Fixed a crash that could happen when hiding
68 +or closing windows while Qt Quick was actively rendering on
69 +a different thread.
70 +
71 +Pick-to: 6.0 6.1 5.15
72 +Fixes: QTBUG-91264
73 +Fixes: QTBUG-90037
74 +Task-number: QTBUG-92249
75 +Change-Id: I029b123b83c58740321e8b90a463ced748d8bcf4
76 +Reviewed-by: Laszlo Agocs <laszlo.agocs@××.io>
77 +Reviewed-by: David Edmundson <davidedmundson@×××.org>
78 +(cherry picked from commit b19b0fbaf775e8b8eda1e03c265a5393d618c6c0)
79 +---
80 + src/client/qwaylandwindow.cpp | 17 ++++++++++++++++-
81 + src/client/qwaylandwindow_p.h | 2 +-
82 + .../client/wayland-egl/qwaylandglcontext.cpp | 1 -
83 + 3 files changed, 17 insertions(+), 3 deletions(-)
84 +
85 +diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp
86 +index 494911b3..0d849b57 100644
87 +--- a/src/client/qwaylandwindow.cpp
88 ++++ b/src/client/qwaylandwindow.cpp
89 +@@ -414,6 +414,7 @@ void QWaylandWindow::closePopups(QWaylandWindow *parent)
90 +
91 + QPlatformScreen *QWaylandWindow::calculateScreenFromSurfaceEvents() const
92 + {
93 ++ QReadLocker lock(&mSurfaceLock);
94 + if (mSurface) {
95 + if (auto *screen = mSurface->oldestEnteredScreen())
96 + return screen;
97 +@@ -552,6 +553,10 @@ void QWaylandWindow::sendRecursiveExposeEvent()
98 +
99 + void QWaylandWindow::attach(QWaylandBuffer *buffer, int x, int y)
100 + {
101 ++ QReadLocker locker(&mSurfaceLock);
102 ++ if (mSurface == nullptr)
103 ++ return;
104 ++
105 + if (buffer) {
106 + Q_ASSERT(!buffer->committed());
107 + handleUpdate();
108 +@@ -571,6 +576,10 @@ void QWaylandWindow::attachOffset(QWaylandBuffer *buffer)
109 +
110 + void QWaylandWindow::damage(const QRect &rect)
111 + {
112 ++ QReadLocker locker(&mSurfaceLock);
113 ++ if (mSurface == nullptr)
114 ++ return;
115 ++
116 + const int s = scale();
117 + if (mDisplay->compositorVersion() >= 4)
118 + mSurface->damage_buffer(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height());
119 +@@ -605,6 +614,8 @@ void QWaylandWindow::commit(QWaylandBuffer *buffer, const QRegion &damage)
120 + qCDebug(lcWaylandBackingstore) << "Buffer already committed, ignoring.";
121 + return;
122 + }
123 ++
124 ++ QReadLocker locker(&mSurfaceLock);
125 + if (!mSurface)
126 + return;
127 +
128 +@@ -624,7 +635,9 @@ void QWaylandWindow::commit(QWaylandBuffer *buffer, const QRegion &damage)
129 +
130 + void QWaylandWindow::commit()
131 + {
132 +- mSurface->commit();
133 ++ QReadLocker locker(&mSurfaceLock);
134 ++ if (mSurface != nullptr)
135 ++ mSurface->commit();
136 + }
137 +
138 + const wl_callback_listener QWaylandWindow::callbackListener = {
139 +@@ -725,6 +738,7 @@ QPointF QWaylandWindow::mapFromWlSurface(const QPointF &surfacePosition) const
140 +
141 + wl_surface *QWaylandWindow::wlSurface()
142 + {
143 ++ QReadLocker locker(&mSurfaceLock);
144 + return mSurface ? mSurface->object() : nullptr;
145 + }
146 +
147 +@@ -749,6 +763,7 @@ QWaylandScreen *QWaylandWindow::waylandScreen() const
148 +
149 + void QWaylandWindow::handleContentOrientationChange(Qt::ScreenOrientation orientation)
150 + {
151 ++ QReadLocker locker(&mSurfaceLock);
152 + if (mDisplay->compositorVersion() < 2)
153 + return;
154 +
155 +diff --git a/src/client/qwaylandwindow_p.h b/src/client/qwaylandwindow_p.h
156 +index d45980a8..54ac67a9 100644
157 +--- a/src/client/qwaylandwindow_p.h
158 ++++ b/src/client/qwaylandwindow_p.h
159 +@@ -288,7 +288,7 @@ private:
160 +
161 + static QWaylandWindow *mMouseGrab;
162 +
163 +- QReadWriteLock mSurfaceLock;
164 ++ mutable QReadWriteLock mSurfaceLock;
165 +
166 + friend class QWaylandSubSurface;
167 + };
168 +diff --git a/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp b/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp
169 +index 683fe123..8f12736d 100644
170 +--- a/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp
171 ++++ b/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp
172 +@@ -192,7 +192,6 @@ public:
173 + }
174 + void blit(QWaylandEglWindow *window)
175 + {
176 +- Q_ASSERT(window->wlSurface());
177 + QOpenGLTextureCache *cache = QOpenGLTextureCache::cacheForContext(m_context->context());
178 +
179 + QSize surfaceSize = window->surfaceSize();
180 +--
181 +2.35.0
182 +
183
184 diff --git a/dev-qt/qtwayland/files/qtwayland-5.15.2-fix-qmake-deps.patch b/dev-qt/qtwayland/files/qtwayland-5.15.2-fix-qmake-deps.patch
185 new file mode 100644
186 index 000000000000..e0c18228ed0f
187 --- /dev/null
188 +++ b/dev-qt/qtwayland/files/qtwayland-5.15.2-fix-qmake-deps.patch
189 @@ -0,0 +1,126 @@
190 +From 3b72261b8b06397a532a40e41103c6b7a44e3ab5 Mon Sep 17 00:00:00 2001
191 +From: Fabian Vogt <fabian@×××××××××××.de>
192 +Date: Fri, 4 Feb 2022 11:07:36 +0100
193 +Subject: [PATCH] Use proper dependencies in compile tests
194 +
195 +Use the dependencies as found by the "libraries" section instead of relying
196 +on them being available in the default location (e.g. "-ldrm").
197 +
198 +Additionally, VK_USE_PLATFORM_WAYLAND_KHR requires <wayland-client.h>, so
199 +add the wayland-client dependency.
200 +
201 +This fixes those tests if e.g. wayland-client headers need to be found through
202 +pkgconfig.
203 +
204 +This part of the code changed completely in Qt 6, so this is a totally
205 +different patch and not a cherry-pick of 5fc2e1915c3a
206 +("CMake: Fix qtwayland feature detection").
207 +
208 +Fixes: QTBUG-100475
209 +---
210 + src/client/configure.json | 8 ++++----
211 + src/compositor/configure.json | 34 +++++++++++++++++++++++++++++-----
212 + 2 files changed, 33 insertions(+), 9 deletions(-)
213 +
214 +diff --git a/src/client/configure.json b/src/client/configure.json
215 +index 2f424580..29222357 100644
216 +--- a/src/client/configure.json
217 ++++ b/src/client/configure.json
218 +@@ -149,8 +149,7 @@
219 + "#endif"
220 + ]
221 + },
222 +- "libs": "-ldrm",
223 +- "use": "egl"
224 ++ "use": "drm egl"
225 + },
226 + "vulkan-server-buffer": {
227 + "label": "Vulkan Buffer Sharing",
228 +@@ -168,7 +167,8 @@
229 + "exportAllocInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;",
230 + "return 0;"
231 + ]
232 +- }
233 ++ },
234 ++ "use": "wayland-client"
235 + },
236 + "egl_1_5-wayland": {
237 + "label": "EGL 1.5 with Wayland Platform",
238 +@@ -183,7 +183,7 @@
239 + "eglGetPlatformDisplay(EGL_PLATFORM_WAYLAND_EXT, (struct wl_display *)(nullptr), nullptr);"
240 + ]
241 + },
242 +- "use": "egl"
243 ++ "use": "egl wayland-client"
244 + }
245 + },
246 +
247 +diff --git a/src/compositor/configure.json b/src/compositor/configure.json
248 +index bcfd5215..da95d07b 100644
249 +--- a/src/compositor/configure.json
250 ++++ b/src/compositor/configure.json
251 +@@ -7,6 +7,31 @@
252 + "testDir": "../../config.tests",
253 +
254 + "libraries": {
255 ++ "wayland-client": {
256 ++ "label": "Wayland client library",
257 ++ "headers": "wayland-version.h",
258 ++ "test": {
259 ++ "main": [
260 ++ "#if WAYLAND_VERSION_MAJOR < 1",
261 ++ "# error Wayland 1.8.0 or higher required",
262 ++ "#endif",
263 ++ "#if WAYLAND_VERSION_MAJOR == 1",
264 ++ "# if WAYLAND_VERSION_MINOR < 8",
265 ++ "# error Wayland 1.8.0 or higher required",
266 ++ "# endif",
267 ++ "# if WAYLAND_VERSION_MINOR == 8",
268 ++ "# if WAYLAND_VERSION_MICRO < 0",
269 ++ "# error Wayland 1.8.0 or higher required",
270 ++ "# endif",
271 ++ "# endif",
272 ++ "#endif"
273 ++ ]
274 ++ },
275 ++ "sources": [
276 ++ { "type": "pkgConfig", "args": "wayland-client" },
277 ++ "-lwayland-client"
278 ++ ]
279 ++ },
280 + "wayland-server": {
281 + "label": "wayland-server",
282 + "headers": "wayland-version.h",
283 +@@ -151,8 +176,7 @@
284 + "#endif"
285 + ]
286 + },
287 +- "libs": "-ldrm",
288 +- "use": "egl"
289 ++ "use": "drm egl"
290 + },
291 + "dmabuf-client-buffer": {
292 + "label": "Linux Client dma-buf Buffer Sharing",
293 +@@ -176,8 +200,7 @@
294 + "return 0;"
295 + ]
296 + },
297 +- "libs": "-ldrm",
298 +- "use": "egl"
299 ++ "use": "drm egl"
300 + },
301 + "vulkan-server-buffer": {
302 + "label": "Vulkan Buffer Sharing",
303 +@@ -195,7 +218,8 @@
304 + "exportAllocInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;",
305 + "return 0;"
306 + ]
307 +- }
308 ++ },
309 ++ "use": "wayland-client"
310 + }
311 + },
312 +
313 +--
314 +GitLab
315 +
316
317 diff --git a/dev-qt/qtwayland/files/qtwayland-5.15.2-fixup-mutexes.patch b/dev-qt/qtwayland/files/qtwayland-5.15.2-fixup-mutexes.patch
318 new file mode 100644
319 index 000000000000..b861cebe60ac
320 --- /dev/null
321 +++ b/dev-qt/qtwayland/files/qtwayland-5.15.2-fixup-mutexes.patch
322 @@ -0,0 +1,87 @@
323 +From bf4335b1ea9b179076cbd7a1c2e8cfa9538b1dc1 Mon Sep 17 00:00:00 2001
324 +From: David Edmundson <davidedmundson@×××.org>
325 +Date: Thu, 3 Feb 2022 14:27:08 +0000
326 +Subject: [PATCH] Fix up mutexes for frame callbacks
327 +
328 +Everything related to frame callback timings is used by potentially 3
329 +threads. Access needs guarding.
330 +
331 +Change-Id: I9f22390c175d9f2f63d31b1ebf0cdc0b830be937
332 +---
333 + src/client/qwaylandwindow.cpp | 14 +++++++++-----
334 + src/client/qwaylandwindow_p.h | 10 +++++++---
335 + 2 files changed, 16 insertions(+), 8 deletions(-)
336 +
337 +diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp
338 +index 7aee362a..72e0e601 100644
339 +--- a/src/client/qwaylandwindow.cpp
340 ++++ b/src/client/qwaylandwindow.cpp
341 +@@ -256,8 +256,12 @@ void QWaylandWindow::reset()
342 + mFrameCallback = nullptr;
343 + }
344 +
345 +- mFrameCallbackElapsedTimer.invalidate();
346 +- mWaitingForFrameCallback = false;
347 ++ {
348 ++ QMutexLocker locker(&mFrameSyncMutex);
349 ++ mFrameCallbackElapsedTimer.invalidate();
350 ++ mWaitingForFrameCallback = false;
351 ++ }
352 ++
353 + mFrameCallbackTimedOut = false;
354 +
355 + mMask = QRegion();
356 +@@ -1142,6 +1146,7 @@ QVariant QWaylandWindow::property(const QString &name, const QVariant &defaultVa
357 +
358 + void QWaylandWindow::timerEvent(QTimerEvent *event)
359 + {
360 ++ QMutexLocker locker(&mFrameSyncMutex);
361 + if (event->timerId() != mFrameCallbackCheckIntervalTimerId)
362 + return;
363 +
364 +@@ -1200,15 +1205,14 @@ void QWaylandWindow::handleUpdate()
365 + {
366 + qCDebug(lcWaylandBackingstore) << "handleUpdate" << QThread::currentThread();
367 +
368 +- if (mWaitingForFrameCallback)
369 +- return;
370 +-
371 + // TODO: Should sync subsurfaces avoid requesting frame callbacks?
372 + QReadLocker lock(&mSurfaceLock);
373 + if (!mSurface)
374 + return;
375 +
376 + QMutexLocker locker(&mFrameSyncMutex);
377 ++ if (mWaitingForFrameCallback)
378 ++ return;
379 +
380 + struct ::wl_surface *wrappedSurface = reinterpret_cast<struct ::wl_surface *>(wl_proxy_create_wrapper(mSurface->object()));
381 + wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(wrappedSurface), mDisplay->frameEventQueue());
382 +diff --git a/src/client/qwaylandwindow_p.h b/src/client/qwaylandwindow_p.h
383 +index 3ff68ccb..025d7917 100644
384 +--- a/src/client/qwaylandwindow_p.h
385 ++++ b/src/client/qwaylandwindow_p.h
386 +@@ -226,13 +226,17 @@ protected:
387 + Qt::MouseButtons mMousePressedInContentArea = Qt::NoButton;
388 +
389 + WId mWindowId;
390 ++
391 ++ // The following are used by the main thread the render thread and the event frame thread
392 ++ // Access should be guarded by mFrameSyncMutex
393 ++ QMutex mFrameSyncMutex;
394 ++ QWaitCondition mFrameSyncWait;
395 + bool mWaitingForFrameCallback = false;
396 +- bool mFrameCallbackTimedOut = false; // Whether the frame callback has timed out
397 + int mFrameCallbackCheckIntervalTimerId = -1;
398 + QElapsedTimer mFrameCallbackElapsedTimer;
399 ++
400 ++ bool mFrameCallbackTimedOut = false; // Whether the frame callback has timed out
401 + struct ::wl_callback *mFrameCallback = nullptr;
402 +- QMutex mFrameSyncMutex;
403 +- QWaitCondition mFrameSyncWait;
404 +
405 + // True when we have called deliverRequestUpdate, but the client has not yet attached a new buffer
406 + bool mWaitingForUpdate = false;
407 +--
408 +GitLab
409 +
410
411 diff --git a/dev-qt/qtwayland/files/qtwayland-5.15.2-guard-mResizeDirty.patch b/dev-qt/qtwayland/files/qtwayland-5.15.2-guard-mResizeDirty.patch
412 new file mode 100644
413 index 000000000000..c2e377cff054
414 --- /dev/null
415 +++ b/dev-qt/qtwayland/files/qtwayland-5.15.2-guard-mResizeDirty.patch
416 @@ -0,0 +1,37 @@
417 +From 2e2042aa18efd1389a140a5d0028d8359bd455a7 Mon Sep 17 00:00:00 2001
418 +From: David Edmundson <davidedmundson@×××.org>
419 +Date: Thu, 3 Feb 2022 19:42:33 +0000
420 +Subject: [PATCH] Guard mResizeDirty by the correctMutex
421 +
422 +mResizeDirty is used in the GUI thread in setCanResize which can be
423 +called from the GUI thread. It is queried and set whilst the resizeLock
424 +is held. We need to guard our usage.
425 +
426 +Change-Id: I5f8dcf8aa2cb2c4bb6274103df1da9e3e268605a
427 +---
428 + src/client/qwaylandwindow.cpp | 7 ++++---
429 + 1 file changed, 4 insertions(+), 3 deletions(-)
430 +
431 +diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp
432 +index 949374b1..7aee362a 100644
433 +--- a/src/client/qwaylandwindow.cpp
434 ++++ b/src/client/qwaylandwindow.cpp
435 +@@ -357,11 +357,12 @@ void QWaylandWindow::setGeometry(const QRect &rect)
436 + if (mWindowDecoration)
437 + mWindowDecoration->update();
438 +
439 +- if (mResizeAfterSwap && windowType() == Egl && mSentInitialResize)
440 ++ if (mResizeAfterSwap && windowType() == Egl && mSentInitialResize) {
441 ++ QMutexLocker lock(&mResizeLock);
442 + mResizeDirty = true;
443 +- else
444 ++ } else {
445 + QWindowSystemInterface::handleGeometryChange(window(), geometry());
446 +-
447 ++ }
448 + mSentInitialResize = true;
449 + }
450 + QRect exposeGeometry(QPoint(), geometry().size());
451 +--
452 +GitLab
453 +
454
455 diff --git a/dev-qt/qtwayland/files/qtwayland-5.15.2-remove-mWaitingForUpdateDelivery.patch b/dev-qt/qtwayland/files/qtwayland-5.15.2-remove-mWaitingForUpdateDelivery.patch
456 new file mode 100644
457 index 000000000000..a76b15d39cac
458 --- /dev/null
459 +++ b/dev-qt/qtwayland/files/qtwayland-5.15.2-remove-mWaitingForUpdateDelivery.patch
460 @@ -0,0 +1,79 @@
461 +From 214f7ab9d3384a4123f14d9f6cd0205cf0aaa794 Mon Sep 17 00:00:00 2001
462 +From: Vlad Zahorodnii <vlad.zahorodnii@×××.org>
463 +Date: Tue, 1 Feb 2022 13:05:36 +0200
464 +Subject: [PATCH] Client: Remove mWaitingForUpdateDelivery
465 +
466 +Currently, mWaitingForUpdateDelivery is shared between the main thread
467 +(doHandleFrameCallback()) and the frame callback event thread
468 +(handleFrameCallback()), however the access to it is not synchronized
469 +between both threads. On the other hand, QWaylandWindow
470 +already ensures not to create a frame callback if there's already one
471 +pending.
472 +
473 +This change removes mWaitingForUpdateDelivery flag because it should be
474 +already covered by mWaitingForFrameCallback and to remove unsynchronized
475 +shared state between threads.
476 +
477 +Change-Id: I0e5a25d18d1e66c4d7683e7e972330c4d7cbbf38
478 +Reviewed-by: David Edmundson <davidedmundson@×××.org>
479 +(cherry picked from commit feb1a5c207c13d0bf87c0d8ad039279dbf8cee9e)
480 +---
481 + src/client/qwaylandwindow.cpp | 29 ++++++++++++-----------------
482 + src/client/qwaylandwindow_p.h | 1 -
483 + 2 files changed, 12 insertions(+), 18 deletions(-)
484 +
485 +diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp
486 +index 4c5711a0..949374b1 100644
487 +--- a/src/client/qwaylandwindow.cpp
488 ++++ b/src/client/qwaylandwindow.cpp
489 +@@ -648,23 +648,18 @@ void QWaylandWindow::handleFrameCallback()
490 + mFrameCallbackElapsedTimer.invalidate();
491 +
492 + // The rest can wait until we can run it on the correct thread
493 +- if (!mWaitingForUpdateDelivery) {
494 +- auto doHandleExpose = [this]() {
495 +- bool wasExposed = isExposed();
496 +- mFrameCallbackTimedOut = false;
497 +- if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
498 +- sendExposeEvent(QRect(QPoint(), geometry().size()));
499 +- if (wasExposed && hasPendingUpdateRequest())
500 +- deliverUpdateRequest();
501 +-
502 +- mWaitingForUpdateDelivery = false;
503 +- };
504 +-
505 +- // Queued connection, to make sure we don't call handleUpdate() from inside waitForFrameSync()
506 +- // in the single-threaded case.
507 +- mWaitingForUpdateDelivery = true;
508 +- QMetaObject::invokeMethod(this, doHandleExpose, Qt::QueuedConnection);
509 +- }
510 ++ auto doHandleExpose = [this]() {
511 ++ bool wasExposed = isExposed();
512 ++ mFrameCallbackTimedOut = false;
513 ++ if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
514 ++ sendExposeEvent(QRect(QPoint(), geometry().size()));
515 ++ if (wasExposed && hasPendingUpdateRequest())
516 ++ deliverUpdateRequest();
517 ++ };
518 ++
519 ++ // Queued connection, to make sure we don't call handleUpdate() from inside waitForFrameSync()
520 ++ // in the single-threaded case.
521 ++ QMetaObject::invokeMethod(this, doHandleExpose, Qt::QueuedConnection);
522 +
523 + mFrameSyncWait.notify_all();
524 + }
525 +diff --git a/src/client/qwaylandwindow_p.h b/src/client/qwaylandwindow_p.h
526 +index d45980a8..3ff68ccb 100644
527 +--- a/src/client/qwaylandwindow_p.h
528 ++++ b/src/client/qwaylandwindow_p.h
529 +@@ -228,7 +228,6 @@ protected:
530 + WId mWindowId;
531 + bool mWaitingForFrameCallback = false;
532 + bool mFrameCallbackTimedOut = false; // Whether the frame callback has timed out
533 +- bool mWaitingForUpdateDelivery = false;
534 + int mFrameCallbackCheckIntervalTimerId = -1;
535 + QElapsedTimer mFrameCallbackElapsedTimer;
536 + struct ::wl_callback *mFrameCallback = nullptr;
537 +--
538 +GitLab
539 +
540
541 diff --git a/dev-qt/qtwayland/qtwayland-5.15.2-r19.ebuild b/dev-qt/qtwayland/qtwayland-5.15.2-r19.ebuild
542 new file mode 100644
543 index 000000000000..2761a297bc7b
544 --- /dev/null
545 +++ b/dev-qt/qtwayland/qtwayland-5.15.2-r19.ebuild
546 @@ -0,0 +1,52 @@
547 +# Copyright 1999-2022 Gentoo Authors
548 +# Distributed under the terms of the GNU General Public License v2
549 +
550 +EAPI=8
551 +
552 +KDE_ORG_COMMIT=ce2caf493a1343fbd9f8e4c85baf6a61c057f242
553 +inherit qt5-build
554 +
555 +DESCRIPTION="Wayland platform plugin for Qt"
556 +
557 +if [[ ${QT5_BUILD_TYPE} == release ]]; then
558 + KEYWORDS="~amd64 ~arm ~arm64 ~hppa ~ppc ~ppc64 ~riscv ~sparc ~x86"
559 +fi
560 +
561 +SLOT=5/${QT5_PV} # bug 815646
562 +IUSE="vulkan X"
563 +
564 +DEPEND="
565 + dev-libs/wayland
566 + =dev-qt/qtcore-${QT5_PV}*:5=
567 + =dev-qt/qtdeclarative-${QT5_PV}*:5=
568 + =dev-qt/qtgui-${QT5_PV}*:5=[egl,libinput,vulkan=,X?]
569 + media-libs/libglvnd
570 + vulkan? ( dev-util/vulkan-headers )
571 + X? (
572 + =dev-qt/qtgui-${QT5_PV}*[-gles2-only]
573 + x11-libs/libX11
574 + x11-libs/libXcomposite
575 + )
576 +"
577 +RDEPEND="${DEPEND}"
578 +BDEPEND="
579 + dev-util/wayland-scanner
580 +"
581 +
582 +PATCHES=(
583 + "${FILESDIR}/${P}-QTBUG-90037-QTBUG-91264.patch"
584 + "${FILESDIR}/${P}-fix-qmake-deps.patch"
585 + "${FILESDIR}/${P}-remove-mWaitingForUpdateDelivery.patch"
586 + "${FILESDIR}/${P}-guard-mResizeDirty.patch"
587 + "${FILESDIR}/${P}-fixup-mutexes.patch"
588 +)
589 +
590 +src_configure() {
591 + local myqmakeargs=(
592 + --
593 + $(qt_use vulkan feature-wayland-vulkan-server-buffer)
594 + $(qt_use X feature-xcomposite-egl)
595 + $(qt_use X feature-xcomposite-glx)
596 + )
597 + qt5-build_src_configure
598 +}