Merge remote-tracking branch 'origin/5.15' into dev
Conflicts: src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp Change-Id: I42733f5ad9429a5d2ff6c804eb1f3f2d50f50811
This commit is contained in:
commit
3909d1aaa9
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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()
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -43,6 +43,7 @@ CoreCompositor::CoreCompositor()
|
||||
}
|
||||
})
|
||||
{
|
||||
qputenv("WAYLAND_DISPLAY", m_socketName);
|
||||
m_timer.start();
|
||||
Q_ASSERT(isClean());
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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; \
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user