Fix missing emission of QClipboard::selectionChanged
And add a test to verify we've fixed it. Change-Id: Ic6d5e64b3000444465935f7caf7e32ec9c4f1012 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
This commit is contained in:
parent
37e0cd278a
commit
94ea0eaf83
@ -96,6 +96,15 @@ QWaylandPrimarySelectionDeviceV1::~QWaylandPrimarySelectionDeviceV1()
|
|||||||
destroy();
|
destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QWaylandPrimarySelectionDeviceV1::invalidateSelectionOffer()
|
||||||
|
{
|
||||||
|
if (!m_selectionOffer)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_selectionOffer.reset();
|
||||||
|
QGuiApplicationPrivate::platformIntegration()->clipboard()->emitChanged(QClipboard::Selection);
|
||||||
|
}
|
||||||
|
|
||||||
void QWaylandPrimarySelectionDeviceV1::setSelectionSource(QWaylandPrimarySelectionSourceV1 *source)
|
void QWaylandPrimarySelectionDeviceV1::setSelectionSource(QWaylandPrimarySelectionSourceV1 *source)
|
||||||
{
|
{
|
||||||
if (source) {
|
if (source) {
|
||||||
|
@ -125,7 +125,7 @@ class QWaylandPrimarySelectionDeviceV1 : public QObject, public QtWayland::zwp_p
|
|||||||
public:
|
public:
|
||||||
~QWaylandPrimarySelectionDeviceV1() override;
|
~QWaylandPrimarySelectionDeviceV1() override;
|
||||||
QWaylandPrimarySelectionOfferV1 *selectionOffer() const { return m_selectionOffer.data(); }
|
QWaylandPrimarySelectionOfferV1 *selectionOffer() const { return m_selectionOffer.data(); }
|
||||||
void invalidateSelectionOffer() { m_selectionOffer.reset(); }
|
void invalidateSelectionOffer();
|
||||||
QWaylandPrimarySelectionSourceV1 *selectionSource() const { return m_selectionSource.data(); }
|
QWaylandPrimarySelectionSourceV1 *selectionSource() const { return m_selectionSource.data(); }
|
||||||
void setSelectionSource(QWaylandPrimarySelectionSourceV1 *source);
|
void setSelectionSource(QWaylandPrimarySelectionSourceV1 *source);
|
||||||
|
|
||||||
|
@ -261,6 +261,7 @@ private slots:
|
|||||||
void pasteAscii();
|
void pasteAscii();
|
||||||
void pasteUtf8();
|
void pasteUtf8();
|
||||||
void destroysPreviousSelection();
|
void destroysPreviousSelection();
|
||||||
|
void destroysSelectionOnLeave();
|
||||||
void copy();
|
void copy();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -411,6 +412,35 @@ void tst_primaryselectionv1::destroysPreviousSelection()
|
|||||||
QCOMPOSITOR_TRY_COMPARE(primarySelectionDevice()->m_sentSelectionOffers.size(), 1);
|
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()
|
void tst_primaryselectionv1::copy()
|
||||||
{
|
{
|
||||||
class Window : public QRasterWindow {
|
class Window : public QRasterWindow {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user