summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Klokkhammer Helsing <johan.helsing@qt.io>2019-10-22 12:02:23 +0200
committerJohan Klokkhammer Helsing <johan.helsing@qt.io>2019-10-25 09:20:00 +0200
commita3ab80f3463ce4f2e8c973e3f1048cc133fdba35 (patch)
tree661dc4eaf698b7a6bd76a552f80a82813436157f
parent1c67c2e281f8a5e1af5ae2ef697e570bdd50514b (diff)
Fix QClipboard::ownSelection always returning false
It would return false regardless of whether we owned the selection. Change-Id: I6df394d8dbceeccb6eb6d0670b4351af1a158491 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
-rw-r--r--src/client/qwaylandclipboard.cpp16
-rw-r--r--tests/auto/client/primaryselectionv1/tst_primaryselectionv1.cpp1
2 files changed, 12 insertions, 5 deletions
diff --git a/src/client/qwaylandclipboard.cpp b/src/client/qwaylandclipboard.cpp
index c3a526ddc..81f48e05e 100644
--- a/src/client/qwaylandclipboard.cpp
+++ b/src/client/qwaylandclipboard.cpp
@@ -137,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/tests/auto/client/primaryselectionv1/tst_primaryselectionv1.cpp b/tests/auto/client/primaryselectionv1/tst_primaryselectionv1.cpp
index b3fa2b13c..ee9fa110e 100644
--- a/tests/auto/client/primaryselectionv1/tst_primaryselectionv1.cpp
+++ b/tests/auto/client/primaryselectionv1/tst_primaryselectionv1.cpp
@@ -472,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;