[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
This commit is contained in:
Roman Gilg 2019-02-06 09:23:56 +01:00
parent ba786ee2ec
commit 8b99a103b1
2 changed files with 17 additions and 0 deletions

View file

@ -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);
}
}

View file

@ -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