[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:
parent
ba786ee2ec
commit
8b99a103b1
2 changed files with 17 additions and 0 deletions
|
@ -273,6 +273,7 @@ void SeatInterface::Private::registerDataDevice(DataDeviceInterface *dataDevice)
|
||||||
if (currentSelection == dataDevice) {
|
if (currentSelection == dataDevice) {
|
||||||
// current selection is cleared
|
// current selection is cleared
|
||||||
currentSelection = nullptr;
|
currentSelection = nullptr;
|
||||||
|
emit q->selectionChanged(nullptr);
|
||||||
if (keys.focus.selection) {
|
if (keys.focus.selection) {
|
||||||
keys.focus.selection->sendClearSelection();
|
keys.focus.selection->sendClearSelection();
|
||||||
}
|
}
|
||||||
|
@ -405,6 +406,7 @@ void SeatInterface::Private::cancelPreviousSelection(DataDeviceInterface *dataDe
|
||||||
|
|
||||||
void SeatInterface::Private::updateSelection(DataDeviceInterface *dataDevice, bool set)
|
void SeatInterface::Private::updateSelection(DataDeviceInterface *dataDevice, bool set)
|
||||||
{
|
{
|
||||||
|
bool selChanged = currentSelection != dataDevice;
|
||||||
if (keys.focus.surface && (keys.focus.surface->client() == dataDevice->client())) {
|
if (keys.focus.surface && (keys.focus.surface->client() == dataDevice->client())) {
|
||||||
// cancel the previous selection
|
// cancel the previous selection
|
||||||
cancelPreviousSelection(dataDevice);
|
cancelPreviousSelection(dataDevice);
|
||||||
|
@ -419,9 +421,13 @@ void SeatInterface::Private::updateSelection(DataDeviceInterface *dataDevice, bo
|
||||||
} else {
|
} else {
|
||||||
keys.focus.selection->sendClearSelection();
|
keys.focus.selection->sendClearSelection();
|
||||||
currentSelection = nullptr;
|
currentSelection = nullptr;
|
||||||
|
selChanged = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (selChanged) {
|
||||||
|
emit q->selectionChanged(currentSelection);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SeatInterface::setHasKeyboard(bool has)
|
void SeatInterface::setHasKeyboard(bool has)
|
||||||
|
@ -1580,6 +1586,7 @@ void SeatInterface::setSelection(DataDeviceInterface *dataDevice)
|
||||||
d->keys.focus.selection->sendClearSelection();
|
d->keys.focus.selection->sendClearSelection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
emit selectionChanged(dataDevice);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -644,6 +644,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* @returns The DataDeviceInterface holding the current clipboard selection.
|
* @returns The DataDeviceInterface holding the current clipboard selection.
|
||||||
* @since 5.24
|
* @since 5.24
|
||||||
|
* @see selectionChanged
|
||||||
* @see setSelection
|
* @see setSelection
|
||||||
**/
|
**/
|
||||||
DataDeviceInterface *selection() const;
|
DataDeviceInterface *selection() const;
|
||||||
|
@ -657,6 +658,7 @@ public:
|
||||||
*
|
*
|
||||||
* @param dataDevice Sets the current clipboard selection.
|
* @param dataDevice Sets the current clipboard selection.
|
||||||
* @see selection
|
* @see selection
|
||||||
|
* @see selectionChanged
|
||||||
* @since 5.24
|
* @since 5.24
|
||||||
**/
|
**/
|
||||||
void setSelection(DataDeviceInterface *dataDevice);
|
void setSelection(DataDeviceInterface *dataDevice);
|
||||||
|
@ -682,6 +684,14 @@ Q_SIGNALS:
|
||||||
**/
|
**/
|
||||||
void focusedPointerChanged(KWayland::Server::PointerInterface*);
|
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
|
* Emitted when a drag'n'drop operation is started
|
||||||
* @since 5.6
|
* @since 5.6
|
||||||
|
|
Loading…
Reference in a new issue