From b52533db8338714e2639860963dd76514ff22d8d Mon Sep 17 00:00:00 2001 From: Giulio Camuffo Date: Sat, 7 Feb 2015 19:29:19 +0200 Subject: [PATCH] Fix copying text to non-qt clients Like we do for pasting, set the mime type of text to "text/plain;charset=utf-8" too besides "text/plain". This allows copying text to clients such as weston example clients or Xwayland. Change-Id: I8a24f32d93e438f16db662e7c09b09ddd7578768 Reviewed-by: Laszlo Agocs --- src/plugins/platforms/wayland/qwaylandclipboard.cpp | 4 ++++ src/plugins/platforms/wayland/qwaylandinputdevice.cpp | 1 + 2 files changed, 5 insertions(+) diff --git a/src/plugins/platforms/wayland/qwaylandclipboard.cpp b/src/plugins/platforms/wayland/qwaylandclipboard.cpp index c40f023b55a..355a7163a80 100644 --- a/src/plugins/platforms/wayland/qwaylandclipboard.cpp +++ b/src/plugins/platforms/wayland/qwaylandclipboard.cpp @@ -86,6 +86,10 @@ void QWaylandClipboard::setMimeData(QMimeData *data, QClipboard::Mode mode) if (!inputDevice || !inputDevice->dataDevice()) return; + static const QString plain = QStringLiteral("text/plain"); + static const QString utf8 = QStringLiteral("text/plain;charset=utf-8"); + if (data && data->hasFormat(plain) && !data->hasFormat(utf8)) + data->setData(utf8, data->data(plain)); inputDevice->dataDevice()->setSelectionSource(data ? new QWaylandDataSource(mDisplay->dndSelectionHandler(), data) : 0); emitChanged(mode); diff --git a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp index b2dfd757db2..ad369bb324f 100644 --- a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp +++ b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp @@ -761,6 +761,7 @@ void QWaylandInputDevice::Keyboard::keyboard_key(uint32_t serial, uint32_t time, QEvent::Type type = isDown ? QEvent::KeyPress : QEvent::KeyRelease; QString text; int qtkey = key + 8; // qt-compositor substracts 8 for some reason + mParent->mSerial = serial; if (!window) { // We destroyed the keyboard focus surface, but the server