Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[wayland] Clear the retained clipboard data when a client clipboard i…
…s cleared. Contributes to JB#33931

Clear should mean clear.  When a client drops its data source drop the
retained data and notify other clients in the same way as if the client
simply set different data.

Change-Id: Iaff5d0905d788fb990de6f78f06d1d0654285e19
  • Loading branch information
denexter committed Mar 15, 2016
1 parent 516a78b commit 66be489
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/compositor/wayland_wrapper/qwldatadevicemanager.cpp
Expand Up @@ -84,10 +84,15 @@ void DataDeviceManager::setCurrentSelectionSource(DataSource *source)
// 2. make it possible for the compositor to participate in copy-paste
// The downside is decreased performance, therefore this mode has to be enabled
// explicitly in the compositors.
if (source && m_compositor->retainedSelectionEnabled()) {
if (m_compositor->retainedSelectionEnabled()) {
m_retainedData.clear();
m_retainedReadIndex = 0;
retain();

if (source) {
retain();
} else {
m_compositor->feedRetainedSelectionData(&m_retainedData);
}
}
}

Expand Down Expand Up @@ -185,8 +190,6 @@ struct wl_display *DataDeviceManager::display() const
void DataDeviceManager::overrideSelection(const QMimeData &mimeData)
{
QStringList formats = mimeData.formats();
if (formats.isEmpty())
return;

m_retainedData.clear();
foreach (const QString &format, formats)
Expand All @@ -196,6 +199,8 @@ void DataDeviceManager::overrideSelection(const QMimeData &mimeData)

m_compositorOwnsSelection = true;

if (formats.isEmpty())
return;
InputDevice *dev = m_compositor->defaultInputDevice();
Surface *focusSurface = dev->keyboardFocus();
if (focusSurface)
Expand Down Expand Up @@ -226,7 +231,7 @@ bool DataDeviceManager::offerFromCompositorToClient(wl_resource *clientDataDevic

void DataDeviceManager::offerRetainedSelection(wl_resource *clientDataDeviceResource)
{
if (m_retainedData.formats().isEmpty())
if (!m_compositor->retainedSelectionEnabled())
return;

m_compositorOwnsSelection = true;
Expand Down

0 comments on commit 66be489

Please sign in to comment.