Skip to content

Commit

Permalink
Wayland: Fix copying inside the app
Browse files Browse the repository at this point in the history
Fixes deadlock when copy/pasting in CopyQ (for example: item to editor
or search bar).

This relies on clipboard implementation in Qt.
  • Loading branch information
hluk committed Nov 17, 2024
1 parent 005dc01 commit f8f0b06
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
18 changes: 4 additions & 14 deletions src/platform/x11/x11platformclipboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,24 +149,14 @@ void X11PlatformClipboard::setData(ClipboardMode mode, const QVariantMap &dataMa
// WORKAROUND: Avoid getting X11 warning "QXcbClipboard: SelectionRequest too old".
QCoreApplication::processEvents();
DummyClipboard::setData(mode, dataMap);
} else {
} else if (qobject_cast<QApplication*>(qApp) == nullptr) {
// WORKAROUND: QClipboard::setMimeData() with a simple windowless
// QGuiAplication on Wayland does not work.
const auto data = createMimeData(dataMap);
const auto qmode = modeToQClipboardMode(mode);
WaylandClipboard::instance()->setMimeData(data, qmode);

// This makes pasting the clipboard work in own widgets.
const auto data2 = createMimeData(dataMap);
QGuiApplication::clipboard()->setMimeData(data2, qmode);
}
}

void X11PlatformClipboard::setRawData(ClipboardMode mode, QMimeData *mimeData)
{
if ( X11Info::isPlatformX11() ) {
DummyClipboard::setRawData(mode, mimeData);
} else {
const auto qmode = modeToQClipboardMode(mode);
WaylandClipboard::instance()->setMimeData(mimeData, qmode);
DummyClipboard::setData(mode, dataMap);
}
}

Expand Down
1 change: 0 additions & 1 deletion src/platform/x11/x11platformclipboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class X11PlatformClipboard final : public DummyClipboard
QVariantMap data(ClipboardMode mode, const QStringList &formats) const override;

void setData(ClipboardMode mode, const QVariantMap &dataMap) override;
void setRawData(ClipboardMode mode, QMimeData *mimeData) override;

bool isSelectionSupported() const override { return m_selectionSupported; }

Expand Down

0 comments on commit f8f0b06

Please sign in to comment.