summaryrefslogtreecommitdiffstats
path: root/src/client/qwaylanddisplay.cpp
diff options
context:
space:
mode:
authorJohan Klokkhammer Helsing <johan.helsing@qt.io>2019-01-28 09:48:26 +0100
committerJohan Helsing <johan.helsing@qt.io>2019-04-24 12:09:30 +0000
commit85bb158ddf08aca4d76c13c6a9fcd2637d84d3ea (patch)
tree1136cf05b7e0ab62e7dc11e794affeb6ab5e073f /src/client/qwaylanddisplay.cpp
parent821cd2eae36ddbd9642208ad75a669c8c15f1b5f (diff)
Client: Full implementation for frame callbacks (second try)
The Wayland plugin now takes full control over delivering update request and implement frame callbacks for both egl and shm. [ChangeLog][QPA plugin] The non-blocking version of eglSwapBuffers is now used, if supported. This fixed a bug where minimized windows would block the event loop. [ChangeLog][QPA plugin] Windows that don't get frame callbacks from the compositor within 100 ms are now set as not exposed. This should stop most clients from rendering unnecessary frames to minimized or hidden windows. Also, when we relied on the QPA version of requestUpdate, we would sometimes deliver one update request while we were waiting for a frame callback. When we implement the fallback timer ourselves we can make sure we only deliver the fallback if there are no pending frame callbacks. QtQuick and other applications often depend on blocking swapBuffers to throttle animations. If the context's surface format has a non-zero swapInterval, try to emulate a blocking swap. Fixes: QTBUG-69077 Change-Id: I3c6964f31a16e9aff70b8ec3c5340e640a30fef2 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Diffstat (limited to 'src/client/qwaylanddisplay.cpp')
-rw-r--r--src/client/qwaylanddisplay.cpp38
1 files changed, 37 insertions, 1 deletions
diff --git a/src/client/qwaylanddisplay.cpp b/src/client/qwaylanddisplay.cpp
index f2bd3160a..82003a308 100644
--- a/src/client/qwaylanddisplay.cpp
+++ b/src/client/qwaylanddisplay.cpp
@@ -68,6 +68,8 @@
#include <QtWaylandClient/private/qwayland-text-input-unstable-v2.h>
+#include <QtCore/private/qcore_unix_p.h>
+
#include <QtCore/QAbstractEventDispatcher>
#include <QtGui/private/qguiapplication_p.h>
@@ -190,7 +192,6 @@ void QWaylandDisplay::flushRequests()
wl_display_flush(mDisplay);
}
-
void QWaylandDisplay::blockingReadEvents()
{
if (wl_display_dispatch(mDisplay) < 0) {
@@ -204,6 +205,41 @@ void QWaylandDisplay::exitWithError()
::exit(1);
}
+wl_event_queue *QWaylandDisplay::createEventQueue()
+{
+ return wl_display_create_queue(mDisplay);
+}
+
+void QWaylandDisplay::dispatchQueueWhile(wl_event_queue *queue, std::function<bool ()> condition, int timeout)
+{
+ if (!condition())
+ return;
+
+ QElapsedTimer timer;
+ timer.start();
+ struct pollfd pFd = qt_make_pollfd(wl_display_get_fd(mDisplay), POLLIN);
+ while (timeout == -1 || timer.elapsed() < timeout) {
+ while (wl_display_prepare_read_queue(mDisplay, queue) != 0)
+ wl_display_dispatch_queue_pending(mDisplay, queue);
+
+ wl_display_flush(mDisplay);
+
+ const int remaining = qMax(timeout - timer.elapsed(), 0ll);
+ const int pollTimeout = timeout == -1 ? -1 : remaining;
+ if (qt_poll_msecs(&pFd, 1, pollTimeout) > 0)
+ wl_display_read_events(mDisplay);
+ else
+ wl_display_cancel_read(mDisplay);
+
+ if (wl_display_dispatch_queue_pending(mDisplay, queue) < 0) {
+ checkError();
+ exitWithError();
+ }
+ if (!condition())
+ break;
+ }
+}
+
QWaylandScreen *QWaylandDisplay::screenForOutput(struct wl_output *output) const
{
for (int i = 0; i < mScreens.size(); ++i) {