xwl: Do not refresh the x11 Clipboard while fetching
At the moment there was a race condition when putting something into the keyboard from XWayland apps. The clipboard manager would announce a new thing before we'd submitted it all resulting in a broken state. This change detects when it's fetching and will only refresh the source after everything has been sent. BUG: 424754 CCBUG: 412350
This commit is contained in:
parent
439dcc4b1f
commit
d335070b80
2 changed files with 11 additions and 0 deletions
|
@ -66,6 +66,10 @@ Clipboard::Clipboard(xcb_atom_t atom, QObject *parent)
|
|||
|
||||
void Clipboard::wlSelectionChanged(KWaylandServer::AbstractDataSource *dsi)
|
||||
{
|
||||
if (m_waitingForTargets) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ownsSelection(dsi)) {
|
||||
// Wayland native client provides new selection
|
||||
if (!m_checkConnection) {
|
||||
|
@ -85,6 +89,10 @@ bool Clipboard::ownsSelection(KWaylandServer::AbstractDataSource *dsi) const
|
|||
|
||||
void Clipboard::checkWlSource()
|
||||
{
|
||||
if (m_waitingForTargets) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto dsi = waylandServer()->seat()->selection();
|
||||
auto removeSource = [this] {
|
||||
if (wlSource()) {
|
||||
|
@ -142,6 +150,7 @@ void Clipboard::doHandleXfixesNotify(xcb_xfixes_selection_notify_event_t *event)
|
|||
|
||||
if (X11Source *source = x11Source()) {
|
||||
source->getTargets();
|
||||
m_waitingForTargets = true;
|
||||
} else {
|
||||
qCWarning(KWIN_XWL) << "Could not create a source from" << event << Qt::hex << (event ? event->owner : -1);
|
||||
}
|
||||
|
@ -149,6 +158,7 @@ void Clipboard::doHandleXfixesNotify(xcb_xfixes_selection_notify_event_t *event)
|
|||
|
||||
void Clipboard::x11OffersChanged(const QStringList &added, const QStringList &removed)
|
||||
{
|
||||
m_waitingForTargets = false;
|
||||
X11Source *source = x11Source();
|
||||
if (!source) {
|
||||
qCWarning(KWIN_XWL) << "offers changed when not having an X11Source!?";
|
||||
|
|
|
@ -53,6 +53,7 @@ private:
|
|||
QMetaObject::Connection m_checkConnection;
|
||||
|
||||
Q_DISABLE_COPY(Clipboard)
|
||||
bool m_waitingForTargets = false;
|
||||
};
|
||||
|
||||
} // namespace Xwl
|
||||
|
|
Loading…
Reference in a new issue