wayland: Allow setting the clipboard with the current serial

Some clients (for example Chromium and LibreOffice) display a certain
behavior in that they will set the clipboard twice in short succession
deleting the data source in between and using the same serial twice.
This allows setting the clipboard with the same serial as
the current clipboard which only the current owner (or previous
owner when the source was deleted) should know.
This commit is contained in:
David Redondo 2024-08-30 12:12:50 +02:00
parent 8141cc1871
commit 5a3d2593f1

View file

@ -321,7 +321,7 @@ void SeatInterfacePrivate::endDrag()
void SeatInterfacePrivate::updateSelection(DataSourceInterface *dataSource, quint32 serial) void SeatInterfacePrivate::updateSelection(DataSourceInterface *dataSource, quint32 serial)
{ {
if (currentSelectionSerial - serial < UINT32_MAX / 2) { if (currentSelectionSerial - serial < UINT32_MAX / 2 && currentSelectionSerial != serial) {
if (dataSource) { if (dataSource) {
dataSource->cancel(); dataSource->cancel();
} }
@ -332,7 +332,7 @@ void SeatInterfacePrivate::updateSelection(DataSourceInterface *dataSource, quin
void SeatInterfacePrivate::updatePrimarySelection(PrimarySelectionSourceV1Interface *dataSource, quint32 serial) void SeatInterfacePrivate::updatePrimarySelection(PrimarySelectionSourceV1Interface *dataSource, quint32 serial)
{ {
if (currentPrimarySelectionSerial - serial < UINT32_MAX / 2) { if (currentPrimarySelectionSerial - serial < UINT32_MAX / 2 && currentPrimarySelectionSerial != serial) {
if (dataSource) { if (dataSource) {
dataSource->cancel(); dataSource->cancel();
} }