From 8b99a103b1f9a04368992c5426635907387aaee5 Mon Sep 17 00:00:00 2001 From: Roman Gilg Date: Wed, 6 Feb 2019 09:23:56 +0100 Subject: [PATCH] [server] Add selectionChanged signal Summary: This signal notifies a compositor about selection changes on a seat. Reviewers: #kwin, davidedmundson Reviewed By: #kwin, davidedmundson Subscribers: kde-frameworks-devel Tags: #frameworks Differential Revision: https://phabricator.kde.org/D15023 --- src/wayland/seat_interface.cpp | 7 +++++++ src/wayland/seat_interface.h | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/wayland/seat_interface.cpp b/src/wayland/seat_interface.cpp index 0c48e53a98..bfa57b2d98 100644 --- a/src/wayland/seat_interface.cpp +++ b/src/wayland/seat_interface.cpp @@ -273,6 +273,7 @@ void SeatInterface::Private::registerDataDevice(DataDeviceInterface *dataDevice) if (currentSelection == dataDevice) { // current selection is cleared currentSelection = nullptr; + emit q->selectionChanged(nullptr); if (keys.focus.selection) { keys.focus.selection->sendClearSelection(); } @@ -405,6 +406,7 @@ void SeatInterface::Private::cancelPreviousSelection(DataDeviceInterface *dataDe void SeatInterface::Private::updateSelection(DataDeviceInterface *dataDevice, bool set) { + bool selChanged = currentSelection != dataDevice; if (keys.focus.surface && (keys.focus.surface->client() == dataDevice->client())) { // cancel the previous selection cancelPreviousSelection(dataDevice); @@ -419,9 +421,13 @@ void SeatInterface::Private::updateSelection(DataDeviceInterface *dataDevice, bo } else { keys.focus.selection->sendClearSelection(); currentSelection = nullptr; + selChanged = true; } } } + if (selChanged) { + emit q->selectionChanged(currentSelection); + } } void SeatInterface::setHasKeyboard(bool has) @@ -1580,6 +1586,7 @@ void SeatInterface::setSelection(DataDeviceInterface *dataDevice) d->keys.focus.selection->sendClearSelection(); } } + emit selectionChanged(dataDevice); } } diff --git a/src/wayland/seat_interface.h b/src/wayland/seat_interface.h index 85a7afebad..5187c70990 100644 --- a/src/wayland/seat_interface.h +++ b/src/wayland/seat_interface.h @@ -644,6 +644,7 @@ public: /** * @returns The DataDeviceInterface holding the current clipboard selection. * @since 5.24 + * @see selectionChanged * @see setSelection **/ DataDeviceInterface *selection() const; @@ -657,6 +658,7 @@ public: * * @param dataDevice Sets the current clipboard selection. * @see selection + * @see selectionChanged * @since 5.24 **/ void setSelection(DataDeviceInterface *dataDevice); @@ -682,6 +684,14 @@ Q_SIGNALS: **/ void focusedPointerChanged(KWayland::Server::PointerInterface*); + /** + * Emitted whenever the selection changes + * @since 5.56 + * @see selection + * @see setSelection + **/ + void selectionChanged(DataDeviceInterface*); + /** * Emitted when a drag'n'drop operation is started * @since 5.6