Merge remote-tracking branch 'origin/5.13' into 5.14

Conflicts:
	src/client/qwaylandwindow.cpp
	tests/auto/compositor/compositor/tst_compositor.cpp

Change-Id: Iacfcae577a4a99c847694ae3a2c6e3e9ae050817
This commit is contained in:
Johan Klokkhammer Helsing 2019-10-19 03:02:05 +02:00
commit bd3dd42bd5
5 changed files with 15 additions and 41 deletions

View File

@ -1081,25 +1081,6 @@ QVariant QWaylandWindow::property(const QString &name, const QVariant &defaultVa
void QWaylandWindow::timerEvent(QTimerEvent *event)
{
if (event->timerId() == mFallbackUpdateTimerId) {
killTimer(mFallbackUpdateTimerId);
mFallbackUpdateTimerId = -1;
qCDebug(lcWaylandBackingstore) << "mFallbackUpdateTimer timed out";
if (!isExposed()) {
qCDebug(lcWaylandBackingstore) << "Fallback update timer: Window not exposed,"
<< "not delivering update request.";
return;
}
if (mWaitingForUpdate && hasPendingUpdateRequest() && !mWaitingForFrameCallback) {
qCWarning(lcWaylandBackingstore) << "Delivering update request through fallback timer,"
<< "may not be in sync with display";
deliverUpdateRequest();
}
}
if (mFrameCallbackTimerId.testAndSetOrdered(event->timerId(), -1)) {
killTimer(event->timerId());
qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
@ -1111,6 +1092,7 @@ void QWaylandWindow::timerEvent(QTimerEvent *event)
void QWaylandWindow::requestUpdate()
{
qCDebug(lcWaylandBackingstore) << "requestUpdate";
Q_ASSERT(hasPendingUpdateRequest()); // should be set by QPA
// If we have a frame callback all is good and will be taken care of there
@ -1118,20 +1100,17 @@ void QWaylandWindow::requestUpdate()
return;
// If we've already called deliverUpdateRequest(), but haven't seen any attach+commit/swap yet
if (mWaitingForUpdate) {
// Ideally, we should just have returned here, but we're not guaranteed that the client
// will actually update, so start this timer to deliver another request update after a while
// *IF* the client doesn't update.
int fallbackTimeout = 100;
mFallbackUpdateTimerId = startTimer(fallbackTimeout);
return;
}
// This is a somewhat redundant behavior and might indicate a bug in the calling code, so log
// here so we can get this information when debugging update/frame callback issues.
// Continue as nothing happened, though.
if (mWaitingForUpdate)
qCDebug(lcWaylandBackingstore) << "requestUpdate called twice without committing anything";
// Some applications (such as Qt Quick) depend on updates being delivered asynchronously,
// so use invokeMethod to delay the delivery a bit.
QMetaObject::invokeMethod(this, [this] {
// Things might have changed in the meantime
if (hasPendingUpdateRequest() && !mWaitingForUpdate && !mWaitingForFrameCallback)
if (hasPendingUpdateRequest() && !mWaitingForFrameCallback)
deliverUpdateRequest();
}, Qt::QueuedConnection);
}
@ -1141,6 +1120,7 @@ void QWaylandWindow::requestUpdate()
// Can be called from the render thread (without locking anything) so make sure to not make races in this method.
void QWaylandWindow::handleUpdate()
{
qCDebug(lcWaylandBackingstore) << "handleUpdate" << QThread::currentThread();
// TODO: Should sync subsurfaces avoid requesting frame callbacks?
QReadLocker lock(&mSurfaceLock);
if (!mSurface)
@ -1151,15 +1131,6 @@ void QWaylandWindow::handleUpdate()
mFrameCallback = nullptr;
}
if (mFallbackUpdateTimerId != -1) {
// Ideally, we would stop the fallback timer here, but since we're on another thread,
// it's not allowed. Instead we set mFallbackUpdateTimer to -1 here, so we'll just
// ignore it if it times out before it's cleaned up by the invokeMethod call.
int id = mFallbackUpdateTimerId;
mFallbackUpdateTimerId = -1;
QMetaObject::invokeMethod(this, [this, id] { killTimer(id); }, Qt::QueuedConnection);
}
mFrameCallback = mSurface->frame();
wl_callback_add_listener(mFrameCallback, &QWaylandWindow::callbackListener, this);
mWaitingForFrameCallback = true;
@ -1179,6 +1150,7 @@ void QWaylandWindow::handleUpdate()
void QWaylandWindow::deliverUpdateRequest()
{
qCDebug(lcWaylandBackingstore) << "deliverUpdateRequest";
mWaitingForUpdate = true;
QPlatformWindow::deliverUpdateRequest();
}

View File

@ -229,7 +229,6 @@ protected:
// True when we have called deliverRequestUpdate, but the client has not yet attached a new buffer
bool mWaitingForUpdate = false;
int mFallbackUpdateTimerId = -1; // Started when waiting for app to commit
QMutex mResizeLock;
bool mWaitingToApplyConfigure = false;

View File

@ -515,7 +515,8 @@ void tst_WaylandClient::longWindowTitleWithUtf16Characters()
int main(int argc, char **argv)
{
setenv("XDG_RUNTIME_DIR", ".", 1);
QTemporaryDir tmpRuntimeDir;
setenv("XDG_RUNTIME_DIR", tmpRuntimeDir.path().toLocal8Bit(), 1);
setenv("QT_QPA_PLATFORM", "wayland", 1); // force QGuiApplication to use wayland plugin
MockCompositor compositor;

View File

@ -173,7 +173,8 @@ void tst_inputcontext::inputContextReconfigurationWhenTogglingTextInputExtension
int main(int argc, char *argv[])
{
qputenv("XDG_RUNTIME_DIR", ".");
QTemporaryDir tmpRuntimeDir;
qputenv("XDG_RUNTIME_DIR", tmpRuntimeDir.path().toLocal8Bit());
qputenv("QT_QPA_PLATFORM", "wayland");
tst_inputcontext tc;

View File

@ -84,7 +84,8 @@ public:
#define QCOMPOSITOR_TEST_MAIN(test) \
int main(int argc, char **argv) \
{ \
setenv("XDG_RUNTIME_DIR", ".", 1); \
QTemporaryDir tmpRuntimeDir; \
setenv("XDG_RUNTIME_DIR", tmpRuntimeDir.path().toLocal8Bit(), 1); \
setenv("XDG_CURRENT_DESKTOP", "qtwaylandtests", 1); \
setenv("QT_QPA_PLATFORM", "wayland", 1); \
test tc; \