diff options
author | Johan Klokkhammer Helsing <johan.helsing@qt.io> | 2019-10-22 12:02:23 +0200 |
---|---|---|
committer | Johan Klokkhammer Helsing <johan.helsing@qt.io> | 2019-10-25 09:20:00 +0200 |
commit | a3ab80f3463ce4f2e8c973e3f1048cc133fdba35 (patch) | |
tree | 661dc4eaf698b7a6bd76a552f80a82813436157f | |
parent | 1c67c2e281f8a5e1af5ae2ef697e570bdd50514b (diff) | |
download | qtwayland-a3ab80f3463ce4f2e8c973e3f1048cc133fdba35.tar.gz |
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.cpp | 16 | ||||
-rw-r--r-- | tests/auto/client/primaryselectionv1/tst_primaryselectionv1.cpp | 1 |
2 files changed, 12 insertions, 5 deletions
diff --git a/src/client/qwaylandclipboard.cpp b/src/client/qwaylandclipboard.cpp index c3a526dd..81f48e05 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 b3fa2b13..ee9fa110 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; |