diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2019-10-31 14:34:01 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2019-10-31 14:42:48 +0100 |
commit | 1a52c4db428e65f4a0b92bea5811014aaa387263 (patch) | |
tree | 5a8c0d02c08cd32db10b3923496fa0010336a123 | |
parent | 5832b6628d848b271efae99585206fa02fc214c9 (diff) | |
parent | 8d1fedd6781babaf130486e5c7192b0ebc9fb039 (diff) | |
download | qtwayland-1a52c4db428e65f4a0b92bea5811014aaa387263.tar.gz |
Merge remote-tracking branch 'origin/5.15' into dev
Conflicts:
src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp
Change-Id: I42733f5ad9429a5d2ff6c804eb1f3f2d50f50811
49 files changed, 441 insertions, 187 deletions
diff --git a/dist/changes-5.13.2 b/dist/changes-5.13.2 new file mode 100644 index 00000000..6248863e --- /dev/null +++ b/dist/changes-5.13.2 @@ -0,0 +1,67 @@ +Qt 5.13.2 is a bug-fix release. It maintains both forward and backward +compatibility (source and binary) with Qt 5.13.0 through 5.13.1. + +For more details, refer to the online documentation included in this +distribution. The documentation is also available online: + +https://doc.qt.io/qt-5/index.html + +The Qt version 5.13 series is binary compatible with the 5.12.x series. +Applications compiled for 5.12 will continue to run with 5.13. + +Some of the changes listed in this file include issue tracking numbers +corresponding to tasks in the Qt Bug Tracker: + +https://bugreports.qt.io/ + +Each of these identifiers can be entered in the bug tracker to obtain more +information about a particular change. + +**************************************************************************** +* Compositor * +**************************************************************************** + + - Fixed various rounding errors related to touch and mouse input. + - Fixed touch and click events on right and left surface borders not being + forwarded to clients. + - Fixed a crash when closing windows via XdgToplevel.sendClose(). + - [QTBUG-78969] Fixed a crash when trying to maximize an XdgToplevel with + no WaylandOutput assigned. + + - Important Behavior Changes: + * Between version 5.11 and 5.12 binary compatibility for the wayland + compositor module was broken by adding an additional member to various + classes. This was not apparent from user code as the member was behind + an #ifdef which would only be set while compiling Qt. As several + versions of Qt incompatible to 5.11 have already been released now, + rolling back the incompatible change would introduce further + incompatibility. Therefore, the change is made consistent by + unconditionally adding the member to the headers. + +**************************************************************************** +* QPA plugin * +**************************************************************************** + + - Fixed a bug where key repeat would not be disabled when configured by the + compositor. + - Fixed a freeze that happened when starting a drag-and-drop operation + without a valid source surface. + - Fixed a bug where some windows would never become visible. + - Fixed a bug where clipboard contents would be truncated for large pastes. + - [QTBUG-76504] Fixed a crash that could happen if createPlatformWindow and + createPlatformOpenGLContext were called on the GUI and render thread + simultaneously. + - Fixed a crash that could happen when destroying a window. + - Qt now handles libwayland errors by calling qFatal() instead of exit(1). + This allows applications to clean up. + - Fixed a bug where touch focus would be cleared on any touch point + release, also during multi-touch sequences. + - [QTBUG-77987] Fixed a bug where the cursor rectangle for virtual keyboard + was incorrectly positioned. + - Fixed a freeze that could happen if doing recursive waiting for + compositor frame callbacks. + - Fixed touch rounding errors. Clients now receive fractional instead of + integer positions. + - [QTBUG-78478] Fixed a crash that could happen if setting absurdly long + window titles with UTF-16 code units that convert to multiple bytes in + UTF-8. diff --git a/src/client/qwaylandclipboard.cpp b/src/client/qwaylandclipboard.cpp index 369c6ec0..81f48e05 100644 --- a/src/client/qwaylandclipboard.cpp +++ b/src/client/qwaylandclipboard.cpp @@ -93,8 +93,10 @@ QMimeData *QWaylandClipboard::mimeData(QClipboard::Mode mode) void QWaylandClipboard::setMimeData(QMimeData *data, QClipboard::Mode mode) { auto *seat = mDisplay->currentInputDevice(); - if (!seat) + if (!seat) { + qCWarning(lcQpaWayland) << "Can't set clipboard contents with no wl_seats available"; return; + } static const QString plain = QStringLiteral("text/plain"); static const QString utf8 = QStringLiteral("text/plain;charset=utf-8"); @@ -135,14 +137,20 @@ bool QWaylandClipboard::supportsMode(QClipboard::Mode mode) const bool QWaylandClipboard::ownsMode(QClipboard::Mode mode) const { - if (mode != QClipboard::Clipboard) + QWaylandInputDevice *seat = mDisplay->currentInputDevice(); + if (!seat) return false; - QWaylandInputDevice *inputDevice = mDisplay->currentInputDevice(); - if (!inputDevice || !inputDevice->dataDevice()) + switch (mode) { + case QClipboard::Clipboard: + return seat->dataDevice() && seat->dataDevice()->selectionSource() != nullptr; +#if QT_CONFIG(wayland_client_primary_selection) + case QClipboard::Selection: + return seat->primarySelectionDevice() && seat->primarySelectionDevice()->selectionSource() != nullptr; +#endif + default: return false; - - return inputDevice->dataDevice()->selectionSource() != nullptr; + } } } diff --git a/src/client/qwaylanddatadevice.cpp b/src/client/qwaylanddatadevice.cpp index fc3c7077..f7d135e4 100644 --- a/src/client/qwaylanddatadevice.cpp +++ b/src/client/qwaylanddatadevice.cpp @@ -81,7 +81,14 @@ QWaylandDataOffer *QWaylandDataDevice::selectionOffer() const void QWaylandDataDevice::invalidateSelectionOffer() { + if (m_selectionOffer.isNull()) + return; + m_selectionOffer.reset(); + +#if QT_CONFIG(clipboard) + QGuiApplicationPrivate::platformIntegration()->clipboard()->emitChanged(QClipboard::Clipboard); +#endif } QWaylandDataSource *QWaylandDataDevice::selectionSource() const diff --git a/src/client/qwaylandprimaryselectionv1.cpp b/src/client/qwaylandprimaryselectionv1.cpp index 3ddf6dac..832f9678 100644 --- a/src/client/qwaylandprimaryselectionv1.cpp +++ b/src/client/qwaylandprimaryselectionv1.cpp @@ -96,6 +96,15 @@ QWaylandPrimarySelectionDeviceV1::~QWaylandPrimarySelectionDeviceV1() destroy(); } +void QWaylandPrimarySelectionDeviceV1::invalidateSelectionOffer() +{ + if (!m_selectionOffer) + return; + + m_selectionOffer.reset(); + QGuiApplicationPrivate::platformIntegration()->clipboard()->emitChanged(QClipboard::Selection); +} + void QWaylandPrimarySelectionDeviceV1::setSelectionSource(QWaylandPrimarySelectionSourceV1 *source) { if (source) { diff --git a/src/client/qwaylandprimaryselectionv1_p.h b/src/client/qwaylandprimaryselectionv1_p.h index b165c51b..3f0a42a6 100644 --- a/src/client/qwaylandprimaryselectionv1_p.h +++ b/src/client/qwaylandprimaryselectionv1_p.h @@ -125,7 +125,7 @@ class QWaylandPrimarySelectionDeviceV1 : public QObject, public QtWayland::zwp_p public: ~QWaylandPrimarySelectionDeviceV1() override; QWaylandPrimarySelectionOfferV1 *selectionOffer() const { return m_selectionOffer.data(); } - void invalidateSelectionOffer() { m_selectionOffer.reset(); } + void invalidateSelectionOffer(); QWaylandPrimarySelectionSourceV1 *selectionSource() const { return m_selectionSource.data(); } void setSelectionSource(QWaylandPrimarySelectionSourceV1 *source); diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp index 2704705e..bffb5701 100644 --- a/src/client/qwaylandwindow.cpp +++ b/src/client/qwaylandwindow.cpp @@ -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(); } diff --git a/src/client/qwaylandwindow_p.h b/src/client/qwaylandwindow_p.h index 8d582eb7..c488c2e3 100644 --- a/src/client/qwaylandwindow_p.h +++ b/src/client/qwaylandwindow_p.h @@ -230,7 +230,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; diff --git a/src/client/qwaylandwindowmanagerintegration.cpp b/src/client/qwaylandwindowmanagerintegration.cpp index 17ae8a5a..dd1acaf7 100644 --- a/src/client/qwaylandwindowmanagerintegration.cpp +++ b/src/client/qwaylandwindowmanagerintegration.cpp @@ -110,13 +110,17 @@ void QWaylandWindowManagerIntegration::windowmanager_quit() void QWaylandWindowManagerIntegration::openUrl_helper(const QUrl &url) { Q_ASSERT(isInitialized()); - QByteArray data = url.toString().toUtf8(); + QString data = url.toString(); static const int chunkSize = 128; while (!data.isEmpty()) { - QByteArray chunk = data.left(chunkSize); + QString chunk = data.left(chunkSize); data = data.mid(chunkSize); - open_url(!data.isEmpty(), QString::fromUtf8(chunk)); + if (chunk.at(chunk.size() - 1).isHighSurrogate() && !data.isEmpty()) { + chunk.append(data.at(0)); + data = data.mid(1); + } + open_url(!data.isEmpty(), chunk); } } diff --git a/src/compositor/compositor_api/qwaylandcompositor.cpp b/src/compositor/compositor_api/qwaylandcompositor.cpp index 471018eb..b75ead7b 100644 --- a/src/compositor/compositor_api/qwaylandcompositor.cpp +++ b/src/compositor/compositor_api/qwaylandcompositor.cpp @@ -365,11 +365,6 @@ void QWaylandCompositorPrivate::initializeHardwareIntegration() loadClientBufferIntegration(); loadServerBufferIntegration(); - - if (client_buffer_integration) - client_buffer_integration->initializeHardware(display); - if (server_buffer_integration) - server_buffer_integration->initializeHardware(q); #endif } @@ -399,18 +394,39 @@ void QWaylandCompositorPrivate::loadClientBufferIntegration() if (!targetKey.isEmpty()) { client_buffer_integration.reset(QtWayland::ClientBufferIntegrationFactory::create(targetKey, QStringList())); if (client_buffer_integration) { + qCDebug(qLcWaylandCompositorHardwareIntegration) << "Loaded client buffer integration:" << targetKey; client_buffer_integration->setCompositor(q); - if (hw_integration) - hw_integration->setClientBufferIntegration(targetKey); + if (!client_buffer_integration->initializeHardware(display)) { + qCWarning(qLcWaylandCompositorHardwareIntegration) + << "Failed to initialize hardware for client buffer integration:" << targetKey; + client_buffer_integration.reset(); + } + } else { + qCWarning(qLcWaylandCompositorHardwareIntegration) + << "Failed to load client buffer integration:" << targetKey; } } - //BUG: if there is no client buffer integration, bad things will happen when opengl is used + + if (!client_buffer_integration) { + qCWarning(qLcWaylandCompositorHardwareIntegration) + << "No client buffer integration was loaded, this means that clients will fall back" + << "to use CPU buffers (wl_shm) for transmitting buffers instead of using zero-copy" + << "GPU buffer handles. Expect serious performance impact with OpenGL clients due" + << "to potentially multiple copies between CPU and GPU memory per buffer.\n" + << "See the QtWayland readme for more info about how to build and configure Qt for" + << "your device."; + return; + } + + if (client_buffer_integration && hw_integration) + hw_integration->setClientBufferIntegration(targetKey); #endif } void QWaylandCompositorPrivate::loadServerBufferIntegration() { #if QT_CONFIG(opengl) + Q_Q(QWaylandCompositor); QStringList keys = QtWayland::ServerBufferIntegrationFactory::keys(); QString targetKey; QByteArray serverBufferIntegration = qgetenv("QT_WAYLAND_SERVER_BUFFER_INTEGRATION"); @@ -419,9 +435,22 @@ void QWaylandCompositorPrivate::loadServerBufferIntegration() } if (!targetKey.isEmpty()) { server_buffer_integration.reset(QtWayland::ServerBufferIntegrationFactory::create(targetKey, QStringList())); - if (hw_integration) - hw_integration->setServerBufferIntegration(targetKey); + if (server_buffer_integration) { + qCDebug(qLcWaylandCompositorHardwareIntegration) + << "Loaded server buffer integration:" << targetKey; + if (!server_buffer_integration->initializeHardware(q)) { + qCWarning(qLcWaylandCompositorHardwareIntegration) + << "Failed to initialize hardware for server buffer integration:" << targetKey; + server_buffer_integration.reset(); + } + } else { + qCWarning(qLcWaylandCompositorHardwareIntegration) + << "Failed to load server buffer integration:" << targetKey; + } } + + if (server_buffer_integration && hw_integration) + hw_integration->setServerBufferIntegration(targetKey); #endif } diff --git a/src/compositor/compositor_api/qwaylandsurface.cpp b/src/compositor/compositor_api/qwaylandsurface.cpp index 7b73688c..2ebb04a3 100644 --- a/src/compositor/compositor_api/qwaylandsurface.cpp +++ b/src/compositor/compositor_api/qwaylandsurface.cpp @@ -378,7 +378,8 @@ QWaylandSurface::QWaylandSurface(QWaylandSurfacePrivate &dptr) QWaylandSurface::~QWaylandSurface() { Q_D(QWaylandSurface); - QWaylandCompositorPrivate::get(d->compositor)->unregisterSurface(this); + if (d->compositor) + QWaylandCompositorPrivate::get(d->compositor)->unregisterSurface(this); d->notifyViewsAboutDestruction(); } diff --git a/src/compositor/extensions/qwaylandwlshell.cpp b/src/compositor/extensions/qwaylandwlshell.cpp index aa8a93af..6eb1c06e 100644 --- a/src/compositor/extensions/qwaylandwlshell.cpp +++ b/src/compositor/extensions/qwaylandwlshell.cpp @@ -457,7 +457,8 @@ QWaylandWlShellSurface::QWaylandWlShellSurface(QWaylandWlShell *shell, QWaylandS QWaylandWlShellSurface::~QWaylandWlShellSurface() { Q_D(QWaylandWlShellSurface); - QWaylandWlShellPrivate::get(d->m_shell)->unregisterShellSurface(this); + if (d->m_shell) + QWaylandWlShellPrivate::get(d->m_shell)->unregisterShellSurface(this); } /*! diff --git a/src/compositor/hardware_integration/qwlclientbufferintegration_p.h b/src/compositor/hardware_integration/qwlclientbufferintegration_p.h index 0195f3d4..2e962273 100644 --- a/src/compositor/hardware_integration/qwlclientbufferintegration_p.h +++ b/src/compositor/hardware_integration/qwlclientbufferintegration_p.h @@ -64,7 +64,7 @@ public: void setCompositor(QWaylandCompositor *compositor) { m_compositor = compositor; } QWaylandCompositor *compositor() const { return m_compositor; } - virtual void initializeHardware(struct ::wl_display *display) = 0; + virtual bool initializeHardware(struct ::wl_display *display) = 0; virtual ClientBuffer *createBufferFor(struct ::wl_resource *buffer) = 0; diff --git a/src/compositor/hardware_integration/qwlserverbufferintegration.cpp b/src/compositor/hardware_integration/qwlserverbufferintegration.cpp index 42337666..e8c1a21f 100644 --- a/src/compositor/hardware_integration/qwlserverbufferintegration.cpp +++ b/src/compositor/hardware_integration/qwlserverbufferintegration.cpp @@ -58,9 +58,10 @@ ServerBufferIntegration::ServerBufferIntegration() ServerBufferIntegration::~ServerBufferIntegration() { } -void ServerBufferIntegration::initializeHardware(QWaylandCompositor *compositor) +bool ServerBufferIntegration::initializeHardware(QWaylandCompositor *compositor) { Q_UNUSED(compositor); + return true; } } diff --git a/src/compositor/hardware_integration/qwlserverbufferintegration_p.h b/src/compositor/hardware_integration/qwlserverbufferintegration_p.h index bd4911e4..96efd9e4 100644 --- a/src/compositor/hardware_integration/qwlserverbufferintegration_p.h +++ b/src/compositor/hardware_integration/qwlserverbufferintegration_p.h @@ -93,7 +93,7 @@ public: ServerBufferIntegration(); virtual ~ServerBufferIntegration(); - virtual void initializeHardware(QWaylandCompositor *); + virtual bool initializeHardware(QWaylandCompositor *); virtual bool supportsFormat(ServerBuffer::Format format) const = 0; virtual ServerBuffer *createServerBufferFromImage(const QImage &qimage, ServerBuffer::Format format) = 0; diff --git a/src/hardwareintegration/compositor/brcm-egl/brcmeglintegration.cpp b/src/hardwareintegration/compositor/brcm-egl/brcmeglintegration.cpp index de39ff1d..8ddb4f95 100644 --- a/src/hardwareintegration/compositor/brcm-egl/brcmeglintegration.cpp +++ b/src/hardwareintegration/compositor/brcm-egl/brcmeglintegration.cpp @@ -67,46 +67,48 @@ BrcmEglIntegration::BrcmEglIntegration() { } -void BrcmEglIntegration::initializeHardware(struct ::wl_display *display) +bool BrcmEglIntegration::initializeHardware(struct ::wl_display *display) { Q_D(BrcmEglIntegration); QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface(); - if (nativeInterface) { - d->egl_display = nativeInterface->nativeResourceForIntegration("EglDisplay"); - if (!d->egl_display) - qWarning("Failed to acquire EGL display from platform integration"); + if (!nativeInterface) + return false; - d->eglQueryGlobalImageBRCM = (PFNEGLQUERYGLOBALIMAGEBRCMPROC) eglGetProcAddress("eglQueryGlobalImageBRCM"); + d->egl_display = nativeInterface->nativeResourceForIntegration("EglDisplay"); + if (!d->egl_display) + qWarning("Failed to acquire EGL display from platform integration"); - if (!d->eglQueryGlobalImageBRCM) { - qWarning("Failed to resolve eglQueryGlobalImageBRCM"); - return; - } + d->eglQueryGlobalImageBRCM = (PFNEGLQUERYGLOBALIMAGEBRCMPROC) eglGetProcAddress("eglQueryGlobalImageBRCM"); - d->glEGLImageTargetTexture2DOES = (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC)eglGetProcAddress("glEGLImageTargetTexture2DOES"); + if (!d->eglQueryGlobalImageBRCM) { + qWarning("Failed to resolve eglQueryGlobalImageBRCM"); + return false; + } + + d->glEGLImageTargetTexture2DOES = (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC)eglGetProcAddress("glEGLImageTargetTexture2DOES"); - if (!d->glEGLImageTargetTexture2DOES) { - qWarning("Failed to resolve glEGLImageTargetTexture2DOES"); - return; - } + if (!d->glEGLImageTargetTexture2DOES) { + qWarning("Failed to resolve glEGLImageTargetTexture2DOES"); + return false; + } - d->eglCreateImageKHR = (PFNEGLCREATEIMAGEKHRPROC)eglGetProcAddress("eglCreateImageKHR"); + d->eglCreateImageKHR = (PFNEGLCREATEIMAGEKHRPROC)eglGetProcAddress("eglCreateImageKHR"); - if (!d->eglCreateImageKHR) { - qWarning("Failed to resolve eglCreateImageKHR"); - return; - } + if (!d->eglCreateImageKHR) { + qWarning("Failed to resolve eglCreateImageKHR"); + return false; + } - d->eglDestroyImageKHR = (PFNEGLDESTROYIMAGEKHRPROC)eglGetProcAddress("eglDestroyImageKHR"); + d->eglDestroyImageKHR = (PFNEGLDESTROYIMAGEKHRPROC)eglGetProcAddress("eglDestroyImageKHR"); - if (!d->eglDestroyImageKHR) { - qWarning("Failed to resolve eglDestroyImageKHR"); - return; - } - d->valid = true; - init(display, 1); + if (!d->eglDestroyImageKHR) { + qWarning("Failed to resolve eglDestroyImageKHR"); + return false; } + d->valid = true; + init(display, 1); + return true; } QtWayland::ClientBuffer *BrcmEglIntegration::createBufferFor(wl_resource *buffer) diff --git a/src/hardwareintegration/compositor/brcm-egl/brcmeglintegration.h b/src/hardwareintegration/compositor/brcm-egl/brcmeglintegration.h index 3728da7b..4bc98e8c 100644 --- a/src/hardwareintegration/compositor/brcm-egl/brcmeglintegration.h +++ b/src/hardwareintegration/compositor/brcm-egl/brcmeglintegration.h @@ -47,7 +47,7 @@ class BrcmEglIntegration : public QtWayland::ClientBufferIntegration, public QtW public: BrcmEglIntegration(); - void initializeHardware(struct ::wl_display *display) override; + bool initializeHardware(struct ::wl_display *display) override; QtWayland::ClientBuffer *createBufferFor(wl_resource *buffer) override; protected: diff --git a/src/hardwareintegration/compositor/dmabuf-server/dmabufserverbufferintegration.cpp b/src/hardwareintegration/compositor/dmabuf-server/dmabufserverbufferintegration.cpp index dc3adfed..133e1eca 100644 --- a/src/hardwareintegration/compositor/dmabuf-server/dmabufserverbufferintegration.cpp +++ b/src/hardwareintegration/compositor/dmabuf-server/dmabufserverbufferintegration.cpp @@ -137,48 +137,49 @@ DmaBufServerBufferIntegration::~DmaBufServerBufferIntegration() { } -void DmaBufServerBufferIntegration::initializeHardware(QWaylandCompositor *compositor) +bool DmaBufServerBufferIntegration::initializeHardware(QWaylandCompositor *compositor) { Q_ASSERT(QGuiApplication::platformNativeInterface()); m_egl_display = static_cast<EGLDisplay>(QGuiApplication::platformNativeInterface()->nativeResourceForIntegration("egldisplay")); if (!m_egl_display) { qCWarning(qLcWaylandCompositorHardwareIntegration) << "Cannot initialize dmabuf server buffer integration. Missing egl display from platform plugin"; - return; + return false; } const char *extensionString = eglQueryString(m_egl_display, EGL_EXTENSIONS); if (!extensionString || !strstr(extensionString, "EGL_KHR_image")) { qCWarning(qLcWaylandCompositorHardwareIntegration) << "Failed to initialize dmabuf server buffer integration. There is no EGL_KHR_image extension."; - return; + return false; } m_egl_create_image = reinterpret_cast<PFNEGLCREATEIMAGEKHRPROC>(eglGetProcAddress("eglCreateImageKHR")); m_egl_destroy_image = reinterpret_cast<PFNEGLDESTROYIMAGEKHRPROC>(eglGetProcAddress("eglDestroyImageKHR")); if (!m_egl_create_image || !m_egl_destroy_image) { qCWarning(qLcWaylandCompositorHardwareIntegration) << "Failed to initialize dmabuf server buffer integration. Could not resolve eglCreateImageKHR or eglDestroyImageKHR"; - return; + return false; } m_gl_egl_image_target_texture_2d = reinterpret_cast<PFNGLEGLIMAGETARGETTEXTURE2DOESPROC>(eglGetProcAddress("glEGLImageTargetTexture2DOES")); if (!m_gl_egl_image_target_texture_2d) { qCWarning(qLcWaylandCompositorHardwareIntegration) << "Failed to initialize dmabuf server buffer integration. Could not find glEGLImageTargetTexture2DOES."; - return; + return false; } m_egl_export_dmabuf_image_query = reinterpret_cast<PFNEGLEXPORTDMABUFIMAGEQUERYMESAPROC>(eglGetProcAddress("eglExportDMABUFImageQueryMESA")); if (!m_egl_export_dmabuf_image_query) { qCWarning(qLcWaylandCompositorHardwareIntegration) << "Failed to initialize dmabuf server buffer integration. Could not find eglExportDMABUFImageQueryMESA."; - return; + return false; } m_egl_export_dmabuf_image = reinterpret_cast<PFNEGLEXPORTDMABUFIMAGEMESAPROC>(eglGetProcAddress("eglExportDMABUFImageMESA")); if (!m_egl_export_dmabuf_image) { qCWarning(qLcWaylandCompositorHardwareIntegration) << "Failed to initialize dmabuf server buffer integration. Could not find eglExportDMABUFImageMESA."; - return; + return false; } QtWaylandServer::qt_dmabuf_server_buffer::init(compositor->display(), 1); + return true; } bool DmaBufServerBufferIntegration::supportsFormat(QtWayland::ServerBuffer::Format format) const diff --git a/src/hardwareintegration/compositor/dmabuf-server/dmabufserverbufferintegration.h b/src/hardwareintegration/compositor/dmabuf-server/dmabufserverbufferintegration.h index 23f50142..4e9f8c74 100644 --- a/src/hardwareintegration/compositor/dmabuf-server/dmabufserverbufferintegration.h +++ b/src/hardwareintegration/compositor/dmabuf-server/dmabufserverbufferintegration.h @@ -98,7 +98,7 @@ public: DmaBufServerBufferIntegration(); ~DmaBufServerBufferIntegration() override; - void initializeHardware(QWaylandCompositor *) override; + bool initializeHardware(QWaylandCompositor *) override; bool supportsFormat(QtWayland::ServerBuffer::Format format) const override; QtWayland::ServerBuffer *createServerBufferFromImage(const QImage &qimage, QtWayland::ServerBuffer::Format format) override; diff --git a/src/hardwareintegration/compositor/drm-egl-server/drmeglserverbufferintegration.cpp b/src/hardwareintegration/compositor/drm-egl-server/drmeglserverbufferintegration.cpp index 4f483f24..03b389ef 100644 --- a/src/hardwareintegration/compositor/drm-egl-server/drmeglserverbufferintegration.cpp +++ b/src/hardwareintegration/compositor/drm-egl-server/drmeglserverbufferintegration.cpp @@ -124,47 +124,48 @@ DrmEglServerBufferIntegration::~DrmEglServerBufferIntegration() { } -void DrmEglServerBufferIntegration::initializeHardware(QWaylandCompositor *compositor) +bool DrmEglServerBufferIntegration::initializeHardware(QWaylandCompositor *compositor) { Q_ASSERT(QGuiApplication::platformNativeInterface()); m_egl_display = static_cast<EGLDisplay>(QGuiApplication::platformNativeInterface()->nativeResourceForIntegration("egldisplay")); if (!m_egl_display) { qWarning("Can't initialize drm egl server buffer integration. Missing egl display from platform plugin"); - return; + return false; } const char *extensionString = eglQueryString(m_egl_display, EGL_EXTENSIONS); if (!extensionString || !strstr(extensionString, "EGL_KHR_image")) { qWarning("Failed to initialize drm egl server buffer integration. There is no EGL_KHR_image extension.\n"); - return; + return false; } m_egl_create_image = reinterpret_cast<PFNEGLCREATEIMAGEKHRPROC>(eglGetProcAddress("eglCreateImageKHR")); m_egl_destroy_image = reinterpret_cast<PFNEGLDESTROYIMAGEKHRPROC>(eglGetProcAddress("eglDestroyImageKHR")); if (!m_egl_create_image || !m_egl_destroy_image) { qWarning("Failed to initialize drm egl server buffer integration. Could not resolve eglCreateImageKHR or eglDestroyImageKHR"); - return; + return false; } if (!extensionString || !strstr(extensionString, "EGL_MESA_drm_image")) { qWarning("Failed to initialize drm egl server buffer integration. There is no EGL_MESA_drm_image extension.\n"); - return; + return false; } m_egl_create_drm_image = reinterpret_cast<PFNEGLCREATEDRMIMAGEMESAPROC>(eglGetProcAddress("eglCreateDRMImageMESA")); m_egl_export_drm_image = reinterpret_cast<PFNEGLEXPORTDRMIMAGEMESAPROC>(eglGetProcAddress("eglExportDRMImageMESA")); if (!m_egl_create_drm_image || !m_egl_export_drm_image) { qWarning("Failed to initialize drm egl server buffer integration. Could not find eglCreateDRMImageMESA or eglExportDRMImageMESA.\n"); - return; + return false; } m_gl_egl_image_target_texture_2d = reinterpret_cast<PFNGLEGLIMAGETARGETTEXTURE2DOESPROC>(eglGetProcAddress("glEGLImageTargetTexture2DOES")); if (!m_gl_egl_image_target_texture_2d) { qWarning("Failed to initialize drm egl server buffer integration. Could not find glEGLImageTargetTexture2DOES.\n"); - return; + return false; } QtWaylandServer::qt_drm_egl_server_buffer::init(compositor->display(), 1); + return true; } bool DrmEglServerBufferIntegration::supportsFormat(QtWayland::ServerBuffer::Format format) const diff --git a/src/hardwareintegration/compositor/drm-egl-server/drmeglserverbufferintegration.h b/src/hardwareintegration/compositor/drm-egl-server/drmeglserverbufferintegration.h index f932ff0d..eab5f0c5 100644 --- a/src/hardwareintegration/compositor/drm-egl-server/drmeglserverbufferintegration.h +++ b/src/hardwareintegration/compositor/drm-egl-server/drmeglserverbufferintegration.h @@ -92,7 +92,7 @@ public: DrmEglServerBufferIntegration(); ~DrmEglServerBufferIntegration() override; - void initializeHardware(QWaylandCompositor *) override; + bool initializeHardware(QWaylandCompositor *) override; bool supportsFormat(QtWayland::ServerBuffer::Format format) const override; QtWayland::ServerBuffer *createServerBufferFromImage(const QImage &qimage, QtWayland::ServerBuffer::Format format) override; diff --git a/src/hardwareintegration/compositor/libhybris-egl-server/libhybriseglserverbufferintegration.cpp b/src/hardwareintegration/compositor/libhybris-egl-server/libhybriseglserverbufferintegration.cpp index a47adaf3..f9ef5635 100644 --- a/src/hardwareintegration/compositor/libhybris-egl-server/libhybriseglserverbufferintegration.cpp +++ b/src/hardwareintegration/compositor/libhybris-egl-server/libhybriseglserverbufferintegration.cpp @@ -124,51 +124,52 @@ LibHybrisEglServerBufferIntegration::~LibHybrisEglServerBufferIntegration() { } -void LibHybrisEglServerBufferIntegration::initializeHardware(QWaylandCompositor *compositor) +bool LibHybrisEglServerBufferIntegration::initializeHardware(QWaylandCompositor *compositor) { Q_ASSERT(QGuiApplication::platformNativeInterface()); m_egl_display = static_cast<EGLDisplay>(QGuiApplication::platformNativeInterface()->nativeResourceForIntegration("egldisplay")); if (!m_egl_display) { qWarning("Can't initialize libhybris egl server buffer integration. Missing egl display from platform plugin"); - return; + return false; } m_egl_create_buffer = reinterpret_cast<PFNEGLHYBRISCREATENATIVEBUFFERPROC>(eglGetProcAddress("eglHybrisCreateNativeBuffer")); if (!m_egl_create_buffer) { qWarning("Failed to initialize libhybris egl server buffer integration. Could not find eglHybrisCreateNativeBuffer.\n"); - return; + return false; } m_egl_get_buffer_info = reinterpret_cast<PFNEGLHYBRISGETNATIVEBUFFERINFOPROC>(eglGetProcAddress("eglHybrisGetNativeBufferInfo")); if (!m_egl_get_buffer_info) { qWarning("Failed to initialize libhybris egl server buffer integration. Could not find eglHybrisGetNativeBufferInfo.\n"); - return; + return false; } m_egl_serialize_buffer = reinterpret_cast<PFNEGLHYBRISSERIALIZENATIVEBUFFERPROC>(eglGetProcAddress("eglHybrisSerializeNativeBuffer")); if (!m_egl_serialize_buffer) { qWarning("Failed to initialize libhybris egl server buffer integration. Could not find eglHybrisSerializeNativeBuffer.\n"); - return; + return false; } const char *extensionString = eglQueryString(m_egl_display, EGL_EXTENSIONS); if (!extensionString || !strstr(extensionString, "EGL_KHR_image")) { qWarning("Failed to initialize libhybris egl server buffer integration. There is no EGL_KHR_image extension.\n"); - return; + return false; } m_egl_create_image = reinterpret_cast<PFNEGLCREATEIMAGEKHRPROC>(eglGetProcAddress("eglCreateImageKHR")); m_egl_destroy_image = reinterpret_cast<PFNEGLDESTROYIMAGEKHRPROC>(eglGetProcAddress("eglDestroyImageKHR")); if (!m_egl_create_image || !m_egl_destroy_image) { qWarning("Failed to initialize libhybris egl server buffer integration. Could not resolve eglCreateImageKHR or eglDestroyImageKHR"); - return; + return false; } m_gl_egl_image_target_texture_2d = reinterpret_cast<PFNGLEGLIMAGETARGETTEXTURE2DOESPROC>(eglGetProcAddress("glEGLImageTargetTexture2DOES")); if (!m_gl_egl_image_target_texture_2d) { qWarning("Failed to initialize libhybris egl server buffer integration. Could not find glEGLImageTargetTexture2DOES.\n"); - return; + return false; } QtWaylandServer::qt_libhybris_egl_server_buffer::init(compositor->display(), 1); + return true; } bool LibHybrisEglServerBufferIntegration::supportsFormat(QtWayland::ServerBuffer::Format format) const diff --git a/src/hardwareintegration/compositor/libhybris-egl-server/libhybriseglserverbufferintegration.h b/src/hardwareintegration/compositor/libhybris-egl-server/libhybriseglserverbufferintegration.h index d26cb0ec..addbb71f 100644 --- a/src/hardwareintegration/compositor/libhybris-egl-server/libhybriseglserverbufferintegration.h +++ b/src/hardwareintegration/compositor/libhybris-egl-server/libhybriseglserverbufferintegration.h @@ -95,7 +95,7 @@ public: LibHybrisEglServerBufferIntegration(); ~LibHybrisEglServerBufferIntegration(); - void initializeHardware(QWaylandCompositor *); + bool initializeHardware(QWaylandCompositor *); bool supportsFormat(QtWayland::ServerBuffer::Format format) const override; QtWayland::ServerBuffer *createServerBufferFromImage(const QImage &qimage, QtWayland::ServerBuffer::Format format) override; diff --git a/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabufclientbufferintegration.cpp b/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabufclientbufferintegration.cpp index 74417586..fc711e5a 100644 --- a/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabufclientbufferintegration.cpp +++ b/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabufclientbufferintegration.cpp @@ -275,7 +275,7 @@ LinuxDmabufClientBufferIntegration::~LinuxDmabufClientBufferIntegration() m_importedBuffers.clear(); } -void LinuxDmabufClientBufferIntegration::initializeHardware(struct ::wl_display *display) +bool LinuxDmabufClientBufferIntegration::initializeHardware(struct ::wl_display *display) { m_linuxDmabuf.reset(new LinuxDmabuf(display, this)); @@ -286,40 +286,40 @@ void LinuxDmabufClientBufferIntegration::initializeHardware(struct ::wl_display egl_query_dmabuf_formats_ext = reinterpret_cast<PFNEGLQUERYDMABUFFORMATSEXTPROC>(eglGetProcAddress("eglQueryDmaBufFormatsEXT")); if (!egl_query_dmabuf_modifiers_ext || !egl_query_dmabuf_formats_ext) { qCWarning(qLcWaylandCompositorHardwareIntegration) << "Failed to initialize EGL display. Could not find eglQueryDmaBufModifiersEXT and eglQueryDmaBufFormatsEXT."; - return; + return false; } egl_bind_wayland_display = reinterpret_cast<PFNEGLBINDWAYLANDDISPLAYWL>(eglGetProcAddress("eglBindWaylandDisplayWL")); egl_unbind_wayland_display = reinterpret_cast<PFNEGLUNBINDWAYLANDDISPLAYWL>(eglGetProcAddress("eglUnbindWaylandDisplayWL")); if ((!egl_bind_wayland_display || !egl_unbind_wayland_display) && !ignoreBindDisplay) { qCWarning(qLcWaylandCompositorHardwareIntegration) << "Failed to initialize EGL display. Could not find eglBindWaylandDisplayWL and eglUnbindWaylandDisplayWL."; - return; + return false; } egl_create_image = reinterpret_cast<PFNEGLCREATEIMAGEKHRPROC>(eglGetProcAddress("eglCreateImageKHR")); egl_destroy_image = reinterpret_cast<PFNEGLDESTROYIMAGEKHRPROC>(eglGetProcAddress("eglDestroyImageKHR")); if (!egl_create_image || !egl_destroy_image) { qCWarning(qLcWaylandCompositorHardwareIntegration) << "Failed to initialize EGL display. Could not find eglCreateImageKHR and eglDestroyImageKHR."; - return; + return false; } // initialize EGL display QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface(); if (!nativeInterface) { qCWarning(qLcWaylandCompositorHardwareIntegration) << "Failed to initialize EGL display. No native platform interface available."; - return; + return false; } m_eglDisplay = nativeInterface->nativeResourceForIntegration("EglDisplay"); if (!m_eglDisplay) { qCWarning(qLcWaylandCompositorHardwareIntegration) << "Failed to initialize EGL display. Could not get EglDisplay for window."; - return; + return false; } const char *extensionString = eglQueryString(m_eglDisplay, EGL_EXTENSIONS); if (!extensionString || !strstr(extensionString, "EGL_EXT_image_dma_buf_import")) { qCWarning(qLcWaylandCompositorHardwareIntegration) << "Failed to initialize EGL display. There is no EGL_EXT_image_dma_buf_import extension."; - return; + return false; } if (strstr(extensionString, "EGL_EXT_image_dma_buf_import_modifiers")) m_supportsDmabufModifiers = true; @@ -331,7 +331,7 @@ void LinuxDmabufClientBufferIntegration::initializeHardware(struct ::wl_display qCWarning(qLcWaylandCompositorHardwareIntegration) << "Could not bind Wayland display. Ignoring."; } else { qCWarning(qLcWaylandCompositorHardwareIntegration) << "Failed to initialize EGL display. Could not bind Wayland display."; - return; + return false; } } } @@ -342,6 +342,7 @@ void LinuxDmabufClientBufferIntegration::initializeHardware(struct ::wl_display modifiers[format] = supportedDrmModifiers(format); } m_linuxDmabuf->setSupportedModifiers(modifiers); + return true; } QVector<uint32_t> LinuxDmabufClientBufferIntegration::supportedDrmFormats() diff --git a/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabufclientbufferintegration.h b/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabufclientbufferintegration.h index cbbd4d9b..8909fa89 100644 --- a/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabufclientbufferintegration.h +++ b/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabufclientbufferintegration.h @@ -67,7 +67,7 @@ public: LinuxDmabufClientBufferIntegration(); ~LinuxDmabufClientBufferIntegration() override; - void initializeHardware(struct ::wl_display *display) override; + bool initializeHardware(struct ::wl_display *display) override; QtWayland::ClientBuffer *createBufferFor(wl_resource *resource) override; bool importBuffer(wl_resource *resource, LinuxDmabufWlBuffer *linuxDmabufBuffer); void removeBuffer(wl_resource *resource); diff --git a/src/hardwareintegration/compositor/shm-emulation-server/shmserverbufferintegration.cpp b/src/hardwareintegration/compositor/shm-emulation-server/shmserverbufferintegration.cpp index 359f39b6..7d7efee3 100644 --- a/src/hardwareintegration/compositor/shm-emulation-server/shmserverbufferintegration.cpp +++ b/src/hardwareintegration/compositor/shm-emulation-server/shmserverbufferintegration.cpp @@ -113,11 +113,12 @@ ShmServerBufferIntegration::~ShmServerBufferIntegration() { } -void ShmServerBufferIntegration::initializeHardware(QWaylandCompositor *compositor) +bool ShmServerBufferIntegration::initializeHardware(QWaylandCompositor *compositor) { Q_ASSERT(QGuiApplication::platformNativeInterface()); QtWaylandServer::qt_shm_emulation_server_buffer::init(compositor->display(), 1); + return true; } bool ShmServerBufferIntegration::supportsFormat(QtWayland::ServerBuffer::Format format) const diff --git a/src/hardwareintegration/compositor/shm-emulation-server/shmserverbufferintegration.h b/src/hardwareintegration/compositor/shm-emulation-server/shmserverbufferintegration.h index a39ba81c..95439f08 100644 --- a/src/hardwareintegration/compositor/shm-emulation-server/shmserverbufferintegration.h +++ b/src/hardwareintegration/compositor/shm-emulation-server/shmserverbufferintegration.h @@ -76,7 +76,7 @@ public: ShmServerBufferIntegration(); ~ShmServerBufferIntegration() override; - void initializeHardware(QWaylandCompositor *) override; + bool initializeHardware(QWaylandCompositor *) override; bool supportsFormat(QtWayland::ServerBuffer::Format format) const override; QtWayland::ServerBuffer *createServerBufferFromImage(const QImage &qimage, QtWayland::ServerBuffer::Format format) override; diff --git a/src/hardwareintegration/compositor/vulkan-server/vulkanserverbufferintegration.cpp b/src/hardwareintegration/compositor/vulkan-server/vulkanserverbufferintegration.cpp index 4f9b2f3f..69af5f9f 100644 --- a/src/hardwareintegration/compositor/vulkan-server/vulkanserverbufferintegration.cpp +++ b/src/hardwareintegration/compositor/vulkan-server/vulkanserverbufferintegration.cpp @@ -265,11 +265,12 @@ VulkanServerBufferIntegration::~VulkanServerBufferIntegration() { } -void VulkanServerBufferIntegration::initializeHardware(QWaylandCompositor *compositor) +bool VulkanServerBufferIntegration::initializeHardware(QWaylandCompositor *compositor) { Q_ASSERT(QGuiApplication::platformNativeInterface()); QtWaylandServer::zqt_vulkan_server_buffer_v1::init(compositor->display(), 1); + return true; } bool VulkanServerBufferIntegration::supportsFormat(QtWayland::ServerBuffer::Format format) const diff --git a/src/hardwareintegration/compositor/vulkan-server/vulkanserverbufferintegration.h b/src/hardwareintegration/compositor/vulkan-server/vulkanserverbufferintegration.h index df020f8a..6e2c51dd 100644 --- a/src/hardwareintegration/compositor/vulkan-server/vulkanserverbufferintegration.h +++ b/src/hardwareintegration/compositor/vulkan-server/vulkanserverbufferintegration.h @@ -86,7 +86,7 @@ public: VulkanWrapper *vulkanWrapper() const { return m_vulkanWrapper; } - void initializeHardware(QWaylandCompositor *) override; + bool initializeHardware(QWaylandCompositor *) override; bool supportsFormat(QtWayland::ServerBuffer::Format format) const override; QtWayland::ServerBuffer *createServerBufferFromImage(const QImage &qimage, QtWayland::ServerBuffer::Format format) override; diff --git a/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp b/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp index bfd4a1f6..cb3369c4 100644 --- a/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp +++ b/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp @@ -174,7 +174,6 @@ public: void deleteOrphanedTextures(); EGLDisplay egl_display = EGL_NO_DISPLAY; - bool valid = false; bool display_bound = false; ::wl_display *wlDisplay = nullptr; QOffscreenSurface *offscreenSurface = nullptr; @@ -221,7 +220,8 @@ void WaylandEglClientBufferIntegrationPrivate::initEglTexture(WaylandEglClientBu gl_egl_image_target_texture_2d = reinterpret_cast<PFNGLEGLIMAGETARGETTEXTURE2DOESPROC>(eglGetProcAddress("glEGLImageTargetTexture2DOES")); if (!gl_egl_image_target_texture_2d) { - qWarning("QtCompositor: bindTextureToBuffer() failed. Could not find glEGLImageTargetTexture2DOES."); + qCWarning(qLcWaylandCompositorHardwareIntegration) + << "BindTextureToBuffer() failed. Could not find glEGLImageTargetTexture2DOES."; return; } @@ -266,8 +266,10 @@ void WaylandEglClientBufferIntegrationPrivate::initEglTexture(WaylandEglClientBu buffer->waylandBufferHandle(), attribs); - if (image == EGL_NO_IMAGE_KHR) - qWarning("failed to create EGL image for plane %d", i); + if (image == EGL_NO_IMAGE_KHR) { + qCWarning(qLcWaylandCompositorHardwareIntegration) + << "Failed to create EGL image for plane" << i; + } state.egl_images << image; state.textures[i] = nullptr; @@ -316,13 +318,14 @@ bool WaylandEglClientBufferIntegrationPrivate::initEglStream(WaylandEglClientBuf } if (state.egl_stream == EGL_NO_STREAM_KHR) { - qWarning("%s:%d: eglCreateStreamFromFileDescriptorKHR failed: 0x%x", Q_FUNC_INFO, __LINE__, eglGetError()); + qCWarning(qLcWaylandCompositorHardwareIntegration, "%s:%d: eglCreateStreamFromFileDescriptorKHR failed: 0x%x", Q_FUNC_INFO, __LINE__, eglGetError()); return false; } state.eglMode = BufferState::ModeEGLStream; if (!QOpenGLContext::currentContext()) { - qWarning("EglClientBufferIntegration: creating texture with no current context"); + qCWarning(qLcWaylandCompositorHardwareIntegration) + << "EglClientBufferIntegration: creating texture with no current context"; return false; } @@ -335,7 +338,7 @@ bool WaylandEglClientBufferIntegrationPrivate::initEglStream(WaylandEglClientBuf auto newStream = funcs->stream_consumer_gltexture(egl_display, state.egl_stream); if (!newStream) { EGLint code = eglGetError(); - qWarning() << "Could not initialize EGLStream:" << egl_error_string(code) << Qt::hex << (long)code; + qCWarning(qLcWaylandCompositorHardwareIntegration) << "Could not initialize EGLStream:" << egl_error_string(code) << Qt::hex << (long)code; funcs->destroy_stream(egl_display, state.egl_stream); state.egl_stream = EGL_NO_STREAM_KHR; return false; @@ -363,7 +366,9 @@ void WaylandEglClientBufferIntegrationPrivate::handleEglstreamTexture(WaylandEgl if (stream_state == EGL_STREAM_STATE_NEW_FRAME_AVAILABLE_KHR) { if (funcs->stream_consumer_acquire(egl_display, state.egl_stream) != EGL_TRUE) - qWarning("%s:%d: eglStreamConsumerAcquireKHR failed: 0x%x", Q_FUNC_INFO, __LINE__, eglGetError()); + qCWarning(qLcWaylandCompositorHardwareIntegration, + "%s:%d: eglStreamConsumerAcquireKHR failed: 0x%x", Q_FUNC_INFO, __LINE__, + eglGetError()); } if (usingLocalContext) @@ -389,11 +394,11 @@ WaylandEglClientBufferIntegration::~WaylandEglClientBufferIntegration() if (d->egl_unbind_wayland_display && d->display_bound) { Q_ASSERT(d->wlDisplay); if (!d->egl_unbind_wayland_display(d->egl_display, d->wlDisplay)) - qWarning() << "Qt Wayland Compositor: eglUnbindWaylandDisplayWL failed"; + qCWarning(qLcWaylandCompositorHardwareIntegration) << "eglUnbindWaylandDisplayWL failed"; } } -void WaylandEglClientBufferIntegration::initializeHardware(struct wl_display *display) +bool WaylandEglClientBufferIntegration::initializeHardware(struct wl_display *display) { Q_D(WaylandEglClientBufferIntegration); @@ -401,50 +406,57 @@ void WaylandEglClientBufferIntegration::initializeHardware(struct wl_display *di QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface(); if (!nativeInterface) { - qWarning("QtCompositor: Failed to initialize EGL display. No native platform interface available."); - return; + qCWarning(qLcWaylandCompositorHardwareIntegration) + << "Failed to initialize EGL display. No native platform interface available."; + return false; } d->egl_display = nativeInterface->nativeResourceForIntegration("EglDisplay"); if (!d->egl_display) { - qWarning("QtCompositor: Failed to initialize EGL display. Could not get EglDisplay for window."); - return; + qCWarning(qLcWaylandCompositorHardwareIntegration) + << "Failed to initialize EGL display. Could not get EglDisplay for window."; + return false; } const char *extensionString = eglQueryString(d->egl_display, EGL_EXTENSIONS); if ((!extensionString || !strstr(extensionString, "EGL_WL_bind_wayland_display")) && !ignoreBindDisplay) { - qWarning("QtCompositor: Failed to initialize EGL display. There is no EGL_WL_bind_wayland_display extension."); - return; + qCWarning(qLcWaylandCompositorHardwareIntegration) + << "Failed to initialize EGL display. There is no EGL_WL_bind_wayland_display extension."; + return false; } d->egl_bind_wayland_display = reinterpret_cast<PFNEGLBINDWAYLANDDISPLAYWL>(eglGetProcAddress("eglBindWaylandDisplayWL")); d->egl_unbind_wayland_display = reinterpret_cast<PFNEGLUNBINDWAYLANDDISPLAYWL>(eglGetProcAddress("eglUnbindWaylandDisplayWL")); if ((!d->egl_bind_wayland_display || !d->egl_unbind_wayland_display) && !ignoreBindDisplay) { - qWarning("QtCompositor: Failed to initialize EGL display. Could not find eglBindWaylandDisplayWL and eglUnbindWaylandDisplayWL."); - return; + qCWarning(qLcWaylandCompositorHardwareIntegration) + << "Failed to initialize EGL display. Could not find eglBindWaylandDisplayWL and eglUnbindWaylandDisplayWL."; + return false; } d->egl_query_wayland_buffer = reinterpret_cast<PFNEGLQUERYWAYLANDBUFFERWL_compat>(eglGetProcAddress("eglQueryWaylandBufferWL")); if (!d->egl_query_wayland_buffer) { - qWarning("QtCompositor: Failed to initialize EGL display. Could not find eglQueryWaylandBufferWL."); - return; + qCWarning(qLcWaylandCompositorHardwareIntegration) + << "Failed to initialize EGL display. Could not find eglQueryWaylandBufferWL."; + return false; } d->egl_create_image = reinterpret_cast<PFNEGLCREATEIMAGEKHRPROC>(eglGetProcAddress("eglCreateImageKHR")); d->egl_destroy_image = reinterpret_cast<PFNEGLDESTROYIMAGEKHRPROC>(eglGetProcAddress("eglDestroyImageKHR")); if (!d->egl_create_image || !d->egl_destroy_image) { - qWarning("QtCompositor: Failed to initialize EGL display. Could not find eglCreateImageKHR and eglDestroyImageKHR."); - return; + qCWarning(qLcWaylandCompositorHardwareIntegration) + << "Failed to initialize EGL display. Could not find eglCreateImageKHR and eglDestroyImageKHR."; + return false; } if (d->egl_bind_wayland_display && d->egl_unbind_wayland_display) { d->display_bound = d->egl_bind_wayland_display(d->egl_display, display); if (!d->display_bound) { if (!ignoreBindDisplay) { - qWarning("QtCompositor: Failed to initialize EGL display. Could not bind Wayland display."); - return; + qCWarning(qLcWaylandCompositorHardwareIntegration) + << "Failed to initialize EGL display. Could not bind Wayland display."; + return false; } else { - qWarning("QtCompositor: Could not bind Wayland display. Ignoring."); + qCWarning(qLcWaylandCompositorHardwareIntegration) << "Could not bind Wayland display. Ignoring."; } } d->wlDisplay = display; @@ -453,7 +465,7 @@ void WaylandEglClientBufferIntegration::initializeHardware(struct wl_display *di d->funcs = new QEGLStreamConvenience; d->funcs->initialize(d->egl_display); - d->valid = true; + return true; } QtWayland::ClientBuffer *WaylandEglClientBufferIntegration::createBufferFor(wl_resource *buffer) diff --git a/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.h b/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.h index bbc0eafe..3b9959e2 100644 --- a/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.h +++ b/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.h @@ -45,7 +45,7 @@ public: WaylandEglClientBufferIntegration(); ~WaylandEglClientBufferIntegration() override; - void initializeHardware(struct ::wl_display *display) override; + bool initializeHardware(struct ::wl_display *display) override; QtWayland::ClientBuffer *createBufferFor(wl_resource *buffer) override; diff --git a/src/hardwareintegration/compositor/wayland-eglstream-controller/waylandeglstreamintegration.cpp b/src/hardwareintegration/compositor/wayland-eglstream-controller/waylandeglstreamintegration.cpp index 07a01ae0..86bd07df 100644 --- a/src/hardwareintegration/compositor/wayland-eglstream-controller/waylandeglstreamintegration.cpp +++ b/src/hardwareintegration/compositor/wayland-eglstream-controller/waylandeglstreamintegration.cpp @@ -298,7 +298,7 @@ void WaylandEglStreamClientBufferIntegration::attachEglStreamConsumer(struct ::w d->initEglStream(clientBuffer, wl_buffer); } -void WaylandEglStreamClientBufferIntegration::initializeHardware(struct wl_display *display) +bool WaylandEglStreamClientBufferIntegration::initializeHardware(struct wl_display *display) { Q_D(WaylandEglStreamClientBufferIntegration); @@ -307,32 +307,32 @@ void WaylandEglStreamClientBufferIntegration::initializeHardware(struct wl_displ QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface(); if (!nativeInterface) { qWarning("QtCompositor: Failed to initialize EGL display. No native platform interface available."); - return; + return false; } d->egl_display = nativeInterface->nativeResourceForIntegration("EglDisplay"); if (!d->egl_display) { qWarning("QtCompositor: Failed to initialize EGL display. Could not get EglDisplay for window."); - return; + return false; } const char *extensionString = eglQueryString(d->egl_display, EGL_EXTENSIONS); if ((!extensionString || !strstr(extensionString, "EGL_WL_bind_wayland_display")) && !ignoreBindDisplay) { qWarning("QtCompositor: Failed to initialize EGL display. There is no EGL_WL_bind_wayland_display extension."); - return; + return false; } d->egl_bind_wayland_display = reinterpret_cast<PFNEGLBINDWAYLANDDISPLAYWL>(eglGetProcAddress("eglBindWaylandDisplayWL")); d->egl_unbind_wayland_display = reinterpret_cast<PFNEGLUNBINDWAYLANDDISPLAYWL>(eglGetProcAddress("eglUnbindWaylandDisplayWL")); if ((!d->egl_bind_wayland_display || !d->egl_unbind_wayland_display) && !ignoreBindDisplay) { qWarning("QtCompositor: Failed to initialize EGL display. Could not find eglBindWaylandDisplayWL and eglUnbindWaylandDisplayWL."); - return; + return false; } d->egl_query_wayland_buffer = reinterpret_cast<PFNEGLQUERYWAYLANDBUFFERWL_compat>(eglGetProcAddress("eglQueryWaylandBufferWL")); if (!d->egl_query_wayland_buffer) { qWarning("QtCompositor: Failed to initialize EGL display. Could not find eglQueryWaylandBufferWL."); - return; + return false; } if (d->egl_bind_wayland_display && d->egl_unbind_wayland_display) { @@ -340,7 +340,7 @@ void WaylandEglStreamClientBufferIntegration::initializeHardware(struct wl_displ if (!d->display_bound) { if (!ignoreBindDisplay) { qWarning("QtCompositor: Failed to initialize EGL display. Could not bind Wayland display."); - return; + return false; } else { qWarning("QtCompositor: Could not bind Wayland display. Ignoring."); } @@ -351,6 +351,12 @@ void WaylandEglStreamClientBufferIntegration::initializeHardware(struct wl_displ d->funcs = new QEGLStreamConvenience; d->funcs->initialize(d->egl_display); + if (!d->funcs->initialized) { + qWarning(qLcWaylandCompositorHardwareIntegration) << "Failed to initialize eglstreams API"; + return false; + } + + return true; } QtWayland::ClientBuffer *WaylandEglStreamClientBufferIntegration::createBufferFor(wl_resource *buffer) diff --git a/src/hardwareintegration/compositor/wayland-eglstream-controller/waylandeglstreamintegration.h b/src/hardwareintegration/compositor/wayland-eglstream-controller/waylandeglstreamintegration.h index 4c4cce25..35d2c80d 100644 --- a/src/hardwareintegration/compositor/wayland-eglstream-controller/waylandeglstreamintegration.h +++ b/src/hardwareintegration/compositor/wayland-eglstream-controller/waylandeglstreamintegration.h @@ -44,7 +44,7 @@ public: WaylandEglStreamClientBufferIntegration(); ~WaylandEglStreamClientBufferIntegration() override; - void initializeHardware(struct ::wl_display *display) override; + bool initializeHardware(struct ::wl_display *display) override; QtWayland::ClientBuffer *createBufferFor(wl_resource *buffer) override; diff --git a/src/hardwareintegration/compositor/xcomposite-egl/xcompositeeglintegration.cpp b/src/hardwareintegration/compositor/xcomposite-egl/xcompositeeglintegration.cpp index 3cf51a8d..3c302c7f 100644 --- a/src/hardwareintegration/compositor/xcomposite-egl/xcompositeeglintegration.cpp +++ b/src/hardwareintegration/compositor/xcomposite-egl/xcompositeeglintegration.cpp @@ -62,20 +62,26 @@ XCompositeEglClientBufferIntegration::XCompositeEglClientBufferIntegration() } -void XCompositeEglClientBufferIntegration::initializeHardware(struct ::wl_display *) +bool XCompositeEglClientBufferIntegration::initializeHardware(struct ::wl_display *) { QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface(); if (nativeInterface) { mDisplay = static_cast<Display *>(nativeInterface->nativeResourceForIntegration("Display")); - if (!mDisplay) - qFatal("could not retrieve Display from platform integration"); + if (!mDisplay) { + qCWarning(qLcWaylandCompositorHardwareIntegration) << "could not retrieve Display from platform integration"; + return false; + } mEglDisplay = static_cast<EGLDisplay>(nativeInterface->nativeResourceForIntegration("EGLDisplay")); - if (!mEglDisplay) - qFatal("could not retrieve EGLDisplay from platform integration"); + if (!mEglDisplay) { + qCWarning(qLcWaylandCompositorHardwareIntegration) << "could not retrieve EGLDisplay from platform integration"; + return false; + } } else { - qFatal("Platform integration doesn't have native interface"); + qCWarning(qLcWaylandCompositorHardwareIntegration) << "Platform integration doesn't have native interface"; + return false; } new XCompositeHandler(m_compositor, mDisplay); + return true; } QtWayland::ClientBuffer *XCompositeEglClientBufferIntegration::createBufferFor(wl_resource *buffer) diff --git a/src/hardwareintegration/compositor/xcomposite-egl/xcompositeeglintegration.h b/src/hardwareintegration/compositor/xcomposite-egl/xcompositeeglintegration.h index 80ce88b5..2c3116df 100644 --- a/src/hardwareintegration/compositor/xcomposite-egl/xcompositeeglintegration.h +++ b/src/hardwareintegration/compositor/xcomposite-egl/xcompositeeglintegration.h @@ -45,7 +45,7 @@ class XCompositeEglClientBufferIntegration : public QtWayland::ClientBufferInteg public: XCompositeEglClientBufferIntegration(); - void initializeHardware(struct ::wl_display *display) override; + bool initializeHardware(struct ::wl_display *display) override; QtWayland::ClientBuffer *createBufferFor(wl_resource *buffer) override; inline Display *xDisplay() const { return mDisplay; } inline EGLDisplay eglDisplay() const { return mEglDisplay; } diff --git a/src/hardwareintegration/compositor/xcomposite-glx/xcompositeglxintegration.cpp b/src/hardwareintegration/compositor/xcomposite-glx/xcompositeglxintegration.cpp index 3c8fc9d0..db439025 100644 --- a/src/hardwareintegration/compositor/xcomposite-glx/xcompositeglxintegration.cpp +++ b/src/hardwareintegration/compositor/xcomposite-glx/xcompositeglxintegration.cpp @@ -70,16 +70,19 @@ XCompositeGLXClientBufferIntegration::~XCompositeGLXClientBufferIntegration() delete mHandler; } -void XCompositeGLXClientBufferIntegration::initializeHardware(struct ::wl_display *) +bool XCompositeGLXClientBufferIntegration::initializeHardware(struct ::wl_display *) { qDebug() << "Initializing GLX integration"; QPlatformNativeInterface *nativeInterface = QGuiApplicationPrivate::platformIntegration()->nativeInterface(); if (nativeInterface) { mDisplay = static_cast<Display *>(nativeInterface->nativeResourceForIntegration("Display")); - if (!mDisplay) - qFatal("could not retrieve Display from platform integration"); + if (!mDisplay) { + qCWarning(qLcWaylandCompositorHardwareIntegration) << "could not retrieve Display from platform integration"; + return false; + } } else { - qFatal("Platform integration doesn't have native interface"); + qCWarning(qLcWaylandCompositorHardwareIntegration) << "Platform integration doesn't have native interface"; + return false; } mScreen = XDefaultScreen(mDisplay); @@ -90,7 +93,8 @@ void XCompositeGLXClientBufferIntegration::initializeHardware(struct ::wl_displa m_glxBindTexImageEXT = reinterpret_cast<PFNGLXBINDTEXIMAGEEXTPROC>(glContext->getProcAddress("glXBindTexImageEXT")); if (!m_glxBindTexImageEXT) { - qDebug() << "Did not find glxBindTexImageExt, everything will FAIL!"; + qCWarning(qLcWaylandCompositorHardwareIntegration) << "Did not find glxBindTexImageExt, everything will FAIL!"; + return false; } m_glxReleaseTexImageEXT = reinterpret_cast<PFNGLXRELEASETEXIMAGEEXTPROC>(glContext->getProcAddress("glXReleaseTexImageEXT")); if (!m_glxReleaseTexImageEXT) { @@ -98,6 +102,7 @@ void XCompositeGLXClientBufferIntegration::initializeHardware(struct ::wl_displa } delete glContext; + return true; } QtWayland::ClientBuffer *XCompositeGLXClientBufferIntegration::createBufferFor(wl_resource *buffer) diff --git a/src/hardwareintegration/compositor/xcomposite-glx/xcompositeglxintegration.h b/src/hardwareintegration/compositor/xcomposite-glx/xcompositeglxintegration.h index e783d41b..6763d591 100644 --- a/src/hardwareintegration/compositor/xcomposite-glx/xcompositeglxintegration.h +++ b/src/hardwareintegration/compositor/xcomposite-glx/xcompositeglxintegration.h @@ -48,7 +48,7 @@ public: XCompositeGLXClientBufferIntegration(); ~XCompositeGLXClientBufferIntegration() override; - void initializeHardware(struct ::wl_display *display) override; + bool initializeHardware(struct ::wl_display *display) override; QtWayland::ClientBuffer *createBufferFor(wl_resource *buffer) override; inline Display *xDisplay() const { return mDisplay; } diff --git a/src/imports/compositor/WaylandCursorItem.qml b/src/imports/compositor/WaylandCursorItem.qml index 8feb3e4f..bb0a840a 100644 --- a/src/imports/compositor/WaylandCursorItem.qml +++ b/src/imports/compositor/WaylandCursorItem.qml @@ -63,7 +63,7 @@ WaylandQuickItem { x: cursorItem.hotspotX + offset.x y: cursorItem.hotspotY + offset.y z: -1 - surface: cursorItem.seat.drag.icon + surface: cursorItem.seat ? cursorItem.seat.drag.icon : null Connections { target: dragIcon.surface diff --git a/src/imports/compositor/plugins.qmltypes b/src/imports/compositor/plugins.qmltypes index 07a306e5..d05cf3c1 100644 --- a/src/imports/compositor/plugins.qmltypes +++ b/src/imports/compositor/plugins.qmltypes @@ -4,7 +4,7 @@ import QtQuick.tooling 1.2 // It is used for QML tooling purposes only. // // This file was auto-generated by: -// 'qmlplugindump -nonrelocatable -defaultplatform QtWayland.Compositor 1.13' +// 'qmlplugindump -nonrelocatable QtWayland.Compositor 1.14' Module { dependencies: ["QtQuick 2.0", "QtQuick.Window 2.11"] @@ -120,6 +120,15 @@ Module { Method { name: "drop" } Method { name: "cancelDrag" } } + Component { name: "QWaylandIdleInhibitManagerV1"; prototype: "QWaylandCompositorExtension" } + Component { + name: "QWaylandIdleInhibitManagerV1QuickExtension" + defaultProperty: "data" + prototype: "QWaylandIdleInhibitManagerV1" + exports: ["QtWayland.Compositor/IdleInhibitManagerV1 1.14"] + exportMetaObjectRevisions: [0] + Property { name: "data"; type: "QObject"; isList: true; isReadonly: true } + } Component { name: "QWaylandIviApplication" prototype: "QWaylandCompositorExtension" @@ -376,6 +385,13 @@ Module { Property { name: "clientRenderingEnabled"; type: "bool" } } Component { + name: "QWaylandQuickXdgOutputV1" + defaultProperty: "data" + prototype: "QWaylandXdgOutputV1" + exports: ["QtWayland.Compositor/XdgOutputV1 1.14"] + exportMetaObjectRevisions: [0] + } + Component { name: "QWaylandResource" exports: ["QtWayland.Compositor/WaylandResource 1.0"] isCreatable: false @@ -495,6 +511,7 @@ Module { Property { name: "origin"; type: "QWaylandSurface::Origin"; isReadonly: true } Property { name: "hasContent"; type: "bool"; isReadonly: true } Property { name: "cursorSurface"; type: "bool" } + Property { name: "inhibitsIdle"; revision: 14; type: "bool"; isReadonly: true } Signal { name: "damaged" Parameter { name: "rect"; type: "QRegion" } @@ -532,6 +549,7 @@ Module { name: "dragStarted" Parameter { name: "drag"; type: "QWaylandDrag"; isPointer: true } } + Signal { name: "inhibitsIdleChanged"; revision: 14 } Signal { name: "configure" Parameter { name: "hasBuffer"; type: "bool" } @@ -691,6 +709,33 @@ Module { exportMetaObjectRevisions: [0] Property { name: "data"; type: "QObject"; isList: true; isReadonly: true } } + Component { name: "QWaylandXdgOutputManagerV1"; prototype: "QWaylandCompositorExtension" } + Component { + name: "QWaylandXdgOutputManagerV1QuickExtension" + defaultProperty: "data" + prototype: "QWaylandXdgOutputManagerV1" + exports: ["QtWayland.Compositor/XdgOutputManagerV1 1.14"] + exportMetaObjectRevisions: [0] + Property { name: "data"; type: "QObject"; isList: true; isReadonly: true } + } + Component { + name: "QWaylandXdgOutputV1" + defaultProperty: "data" + prototype: "QObject" + Property { name: "data"; type: "QObject"; isList: true; isReadonly: true } + Property { + name: "manager" + type: "QWaylandXdgOutputManagerV1" + isReadonly: true + isPointer: true + } + Property { name: "output"; type: "QWaylandOutput"; isReadonly: true; isPointer: true } + Property { name: "name"; type: "string" } + Property { name: "description"; type: "string" } + Property { name: "logicalPosition"; type: "QPoint" } + Property { name: "logicalSize"; type: "QSize" } + Property { name: "logicalGeometry"; type: "QRect"; isReadonly: true } + } Component { name: "QWaylandXdgPopup" prototype: "QObject" @@ -719,6 +764,7 @@ Module { type: "uint" Parameter { name: "geometry"; type: "QRect" } } + Method { name: "sendPopupDone"; revision: 14 } } Component { name: "QWaylandXdgPopupV5" @@ -769,6 +815,7 @@ Module { type: "uint" Parameter { name: "geometry"; type: "QRect" } } + Method { name: "sendPopupDone"; revision: 14 } } Component { name: "QWaylandXdgShell" diff --git a/tests/auto/client/client/tst_client.cpp b/tests/auto/client/client/tst_client.cpp index e19acff7..499a93a1 100644 --- a/tests/auto/client/client/tst_client.cpp +++ b/tests/auto/client/client/tst_client.cpp @@ -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; diff --git a/tests/auto/client/datadevicev1/tst_datadevicev1.cpp b/tests/auto/client/datadevicev1/tst_datadevicev1.cpp index e3babceb..1568b3b9 100644 --- a/tests/auto/client/datadevicev1/tst_datadevicev1.cpp +++ b/tests/auto/client/datadevicev1/tst_datadevicev1.cpp @@ -59,6 +59,7 @@ private slots: void pasteUtf8(); void destroysPreviousSelection(); void destroysSelectionWithSurface(); + void destroysSelectionOnLeave(); void dragWithoutFocus(); }; @@ -215,6 +216,35 @@ void tst_datadevicev1::destroysSelectionWithSurface() QCOMPOSITOR_TRY_COMPARE(dataDevice()->m_sentSelectionOffers.size(), 0); } +void tst_datadevicev1::destroysSelectionOnLeave() +{ + QRasterWindow window; + window.resize(64, 64); + window.show(); + QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial); + + exec([&] { + auto *offer = dataDevice()->sendDataOffer(client(), {"text/plain"}); + dataDevice()->sendSelection(offer); + + auto *surface = xdgSurface()->m_surface; + keyboard()->sendEnter(surface); // Need to set keyboard focus according to protocol + }); + + QTRY_VERIFY(QGuiApplication::clipboard()->mimeData(QClipboard::Clipboard)); + QTRY_VERIFY(QGuiApplication::clipboard()->mimeData(QClipboard::Clipboard)->hasText()); + + QSignalSpy dataChangedSpy(QGuiApplication::clipboard(), &QClipboard::dataChanged); + + exec([&] { + auto *surface = xdgSurface()->m_surface; + keyboard()->sendLeave(surface); + }); + + QTRY_COMPARE(dataChangedSpy.count(), 1); + QVERIFY(!QGuiApplication::clipboard()->mimeData(QClipboard::Clipboard)->hasText()); +} + // The application should not crash if it attempts to start a drag operation // when it doesn't have input focus (QTBUG-76368) void tst_datadevicev1::dragWithoutFocus() diff --git a/tests/auto/client/fullscreenshellv1/tst_fullscreenshellv1.cpp b/tests/auto/client/fullscreenshellv1/tst_fullscreenshellv1.cpp index f93d9fbc..55158474 100644 --- a/tests/auto/client/fullscreenshellv1/tst_fullscreenshellv1.cpp +++ b/tests/auto/client/fullscreenshellv1/tst_fullscreenshellv1.cpp @@ -93,7 +93,8 @@ void tst_WaylandClientFullScreenShellV1::createDestroyWindow() 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 setenv("QT_WAYLAND_SHELL_INTEGRATION", "fullscreen-shell-v1", 1); setenv("QT_WAYLAND_DISABLE_WINDOWDECORATION", "1", 1); // window decorations don't make much sense here diff --git a/tests/auto/client/inputcontext/tst_inputcontext.cpp b/tests/auto/client/inputcontext/tst_inputcontext.cpp index 7c0132e3..1f07eb52 100644 --- a/tests/auto/client/inputcontext/tst_inputcontext.cpp +++ b/tests/auto/client/inputcontext/tst_inputcontext.cpp @@ -171,7 +171,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; diff --git a/tests/auto/client/iviapplication/tst_iviapplication.cpp b/tests/auto/client/iviapplication/tst_iviapplication.cpp index 59ff6f55..8d6ea648 100644 --- a/tests/auto/client/iviapplication/tst_iviapplication.cpp +++ b/tests/auto/client/iviapplication/tst_iviapplication.cpp @@ -124,7 +124,8 @@ void tst_WaylandClientIviApplication::uniqueIviIds() 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 setenv("QT_WAYLAND_SHELL_INTEGRATION", "ivi-shell", 1); setenv("QT_WAYLAND_DISABLE_WINDOWDECORATION", "1", 1); // window decorations don't make much sense on ivi-application diff --git a/tests/auto/client/primaryselectionv1/tst_primaryselectionv1.cpp b/tests/auto/client/primaryselectionv1/tst_primaryselectionv1.cpp index 216db85c..ee9fa110 100644 --- a/tests/auto/client/primaryselectionv1/tst_primaryselectionv1.cpp +++ b/tests/auto/client/primaryselectionv1/tst_primaryselectionv1.cpp @@ -261,6 +261,7 @@ private slots: void pasteAscii(); void pasteUtf8(); void destroysPreviousSelection(); + void destroysSelectionOnLeave(); void copy(); }; @@ -411,6 +412,35 @@ void tst_primaryselectionv1::destroysPreviousSelection() QCOMPOSITOR_TRY_COMPARE(primarySelectionDevice()->m_sentSelectionOffers.size(), 1); } +void tst_primaryselectionv1::destroysSelectionOnLeave() +{ + QRasterWindow window; + window.resize(64, 64); + window.show(); + QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial); + + exec([&] { + auto *surface = xdgSurface()->m_surface; + keyboard()->sendEnter(surface); // Need to set keyboard focus according to protocol + + auto *offer = primarySelectionDevice()->sendDataOffer({"text/plain"}); + primarySelectionDevice()->sendSelection(offer); + }); + + QTRY_VERIFY(QGuiApplication::clipboard()->mimeData(QClipboard::Selection)); + QTRY_VERIFY(QGuiApplication::clipboard()->mimeData(QClipboard::Selection)->hasText()); + + QSignalSpy selectionChangedSpy(QGuiApplication::clipboard(), &QClipboard::selectionChanged); + + exec([&] { + auto *surface = xdgSurface()->m_surface; + keyboard()->sendLeave(surface); + }); + + QTRY_COMPARE(selectionChangedSpy.count(), 1); + QVERIFY(!QGuiApplication::clipboard()->mimeData(QClipboard::Selection)->hasText()); +} + void tst_primaryselectionv1::copy() { class Window : public QRasterWindow { @@ -442,6 +472,7 @@ void tst_primaryselectionv1::copy() }); QCOMPOSITOR_TRY_VERIFY(primarySelectionDevice()->m_selectionSource); QCOMPOSITOR_TRY_VERIFY(mouseSerials.contains(primarySelectionDevice()->m_serial)); + QVERIFY(QGuiApplication::clipboard()->ownsSelection()); QByteArray pastedBuf; exec([&](){ auto *source = primarySelectionDevice()->m_selectionSource; diff --git a/tests/auto/client/shared/corecompositor.cpp b/tests/auto/client/shared/corecompositor.cpp index 7edb1c2d..5c6c83ba 100644 --- a/tests/auto/client/shared/corecompositor.cpp +++ b/tests/auto/client/shared/corecompositor.cpp @@ -43,6 +43,7 @@ CoreCompositor::CoreCompositor() } }) { + qputenv("WAYLAND_DISPLAY", m_socketName); m_timer.start(); Q_ASSERT(isClean()); } diff --git a/tests/auto/client/shared/datadevice.h b/tests/auto/client/shared/datadevice.h index a96da86f..98e780b2 100644 --- a/tests/auto/client/shared/datadevice.h +++ b/tests/auto/client/shared/datadevice.h @@ -65,7 +65,6 @@ public: ~DataDevice() override; void send_data_offer(::wl_resource *resource) = delete; DataOffer *sendDataOffer(::wl_client *client, const QStringList &mimeTypes = {}); - DataOffer *sendDataOffer(const QStringList &mimeTypes = {}); void send_selection(::wl_resource *resource) = delete; void sendSelection(DataOffer *offer); diff --git a/tests/auto/client/shared/mockcompositor.h b/tests/auto/client/shared/mockcompositor.h index fc4d7cc4..c7d85b95 100644 --- a/tests/auto/client/shared/mockcompositor.h +++ b/tests/auto/client/shared/mockcompositor.h @@ -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; \ diff --git a/tests/auto/client/xdgshellv6/tst_xdgshellv6.cpp b/tests/auto/client/xdgshellv6/tst_xdgshellv6.cpp index 027e1dfa..e44475de 100644 --- a/tests/auto/client/xdgshellv6/tst_xdgshellv6.cpp +++ b/tests/auto/client/xdgshellv6/tst_xdgshellv6.cpp @@ -422,7 +422,8 @@ void tst_WaylandClientXdgShellV6::dontSpamExposeEvents() 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 setenv("QT_WAYLAND_SHELL_INTEGRATION", "xdg-shell-v6", 1); diff --git a/tests/auto/compositor/compositor/tst_compositor.cpp b/tests/auto/compositor/compositor/tst_compositor.cpp index 64fb29b8..1397414a 100644 --- a/tests/auto/compositor/compositor/tst_compositor.cpp +++ b/tests/auto/compositor/compositor/tst_compositor.cpp @@ -121,10 +121,15 @@ private slots: void idleInhibit(); void xdgOutput(); + +private: + QTemporaryDir m_tmpRuntimeDir; }; void tst_WaylandCompositor::init() { - qputenv("XDG_RUNTIME_DIR", "."); + // We need to set a test specific runtime dir so we don't conflict with other tests' + // compositors by accident. + qputenv("XDG_RUNTIME_DIR", m_tmpRuntimeDir.path().toLocal8Bit()); } void tst_WaylandCompositor::singleClient() |