Have the selection offer global handled always without delay.
In a previous attempt to solve the problem of selection offer globals arriving too early, the handling was delayed. This solved the issue of crashing but introduced a timing issue, because the offers (the mime types) will arrive immediately after the global and therefore will simply be ignored in case the delayed processing of the selection offer had not yet been done. The visibility of the problem depended on the implementation of the compositor, with recent changes to qt-compositor the issue is very visible. The patch solves the issue properly: The wayland clipboard instance is created right away, as early when needed, and the integration will simply pick up the already created instance. Change-Id: I75aaba4b0590c05cc0091bed7bb3593186c1188f Reviewed-on: http://codereview.qt.nokia.com/687 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Paul Olav Tvete <paul.tvete@nokia.com>
This commit is contained in:
parent
ea933359b7
commit
73746a5a89
@ -50,7 +50,7 @@
|
||||
#include <QtCore/QtDebug>
|
||||
#include <QtGui/private/qdnd_p.h>
|
||||
|
||||
static QWaylandClipboard *clipboard;
|
||||
static QWaylandClipboard *clipboard = 0;
|
||||
|
||||
class QWaylandMimeData : public QInternalMimeData
|
||||
{
|
||||
@ -162,10 +162,16 @@ void QWaylandSelection::cancelled(void *data, struct wl_selection *selection)
|
||||
delete static_cast<QWaylandSelection *>(data);
|
||||
}
|
||||
|
||||
QWaylandClipboard *QWaylandClipboard::instance(QWaylandDisplay *display)
|
||||
{
|
||||
if (!clipboard)
|
||||
clipboard = new QWaylandClipboard(display);
|
||||
return clipboard;
|
||||
}
|
||||
|
||||
QWaylandClipboard::QWaylandClipboard(QWaylandDisplay *display)
|
||||
: mDisplay(display), mMimeDataIn(0), mOffer(0)
|
||||
{
|
||||
clipboard = this;
|
||||
}
|
||||
|
||||
QWaylandClipboard::~QWaylandClipboard()
|
||||
|
@ -61,7 +61,8 @@ public slots:
|
||||
class QWaylandClipboard : public QPlatformClipboard
|
||||
{
|
||||
public:
|
||||
QWaylandClipboard(QWaylandDisplay *display);
|
||||
static QWaylandClipboard *instance(QWaylandDisplay *display);
|
||||
|
||||
~QWaylandClipboard();
|
||||
|
||||
QMimeData *mimeData(QClipboard::Mode mode = QClipboard::Clipboard);
|
||||
@ -75,6 +76,8 @@ public:
|
||||
QVariant retrieveData(const QString &mimeType, QVariant::Type type) const;
|
||||
|
||||
private:
|
||||
QWaylandClipboard(QWaylandDisplay *display);
|
||||
|
||||
static void offer(void *data,
|
||||
struct wl_selection_offer *selection_offer,
|
||||
const char *type);
|
||||
|
@ -126,9 +126,12 @@ const struct wl_shell_listener QWaylandDisplay::shellListener = {
|
||||
QWaylandDisplay::shellHandleConfigure,
|
||||
};
|
||||
|
||||
static QWaylandDisplay *display = 0;
|
||||
|
||||
QWaylandDisplay::QWaylandDisplay(void)
|
||||
: argb_visual(0), premultiplied_argb_visual(0), rgb_visual(0)
|
||||
{
|
||||
display = this;
|
||||
qRegisterMetaType<uint32_t>("uint32_t");
|
||||
|
||||
mDisplay = wl_display_connect(NULL);
|
||||
@ -309,25 +312,10 @@ void QWaylandDisplay::displayHandleGlobal(uint32_t id,
|
||||
new QWaylandInputDevice(mDisplay, id);
|
||||
mInputDevices.append(inputDevice);
|
||||
} else if (interface == "wl_selection_offer") {
|
||||
QPlatformIntegration *plat = QApplicationPrivate::platformIntegration();
|
||||
mSelectionOfferId = id;
|
||||
if (plat)
|
||||
handleSelectionOffer(id);
|
||||
else
|
||||
QMetaObject::invokeMethod(this, "handleSelectionOffer",
|
||||
Qt::QueuedConnection, Q_ARG(uint32_t, id));
|
||||
QWaylandClipboard::instance(display)->createSelectionOffer(id);
|
||||
}
|
||||
}
|
||||
|
||||
void QWaylandDisplay::handleSelectionOffer(uint32_t id)
|
||||
{
|
||||
if (mSelectionOfferId != id)
|
||||
return;
|
||||
QPlatformIntegration *plat = QApplicationPrivate::platformIntegration();
|
||||
QWaylandClipboard *clipboard = static_cast<QWaylandClipboard *>(plat->clipboard());
|
||||
clipboard->createSelectionOffer(id);
|
||||
}
|
||||
|
||||
void QWaylandDisplay::handleVisual(void *data,
|
||||
struct wl_compositor *compositor,
|
||||
uint32_t id, uint32_t token)
|
||||
|
@ -97,9 +97,6 @@ public slots:
|
||||
void blockingReadEvents();
|
||||
void flushRequests();
|
||||
|
||||
private slots:
|
||||
void handleSelectionOffer(uint32_t id);
|
||||
|
||||
private:
|
||||
void waitForScreens();
|
||||
void displayHandleGlobal(uint32_t id,
|
||||
@ -118,7 +115,6 @@ private:
|
||||
bool mScreensInitialized;
|
||||
|
||||
uint32_t mSocketMask;
|
||||
uint32_t mSelectionOfferId;
|
||||
|
||||
struct wl_visual *argb_visual, *premultiplied_argb_visual, *rgb_visual;
|
||||
|
||||
|
@ -65,7 +65,6 @@ QWaylandIntegration::QWaylandIntegration(bool useOpenGL)
|
||||
, mDisplay(new QWaylandDisplay())
|
||||
, mUseOpenGL(useOpenGL)
|
||||
, mNativeInterface(new QWaylandNativeInterface)
|
||||
, mClipboard(0)
|
||||
{
|
||||
}
|
||||
|
||||
@ -137,7 +136,5 @@ bool QWaylandIntegration::hasOpenGL() const
|
||||
|
||||
QPlatformClipboard *QWaylandIntegration::clipboard() const
|
||||
{
|
||||
if (!mClipboard)
|
||||
mClipboard = new QWaylandClipboard(mDisplay);
|
||||
return mClipboard;
|
||||
return QWaylandClipboard::instance(mDisplay);
|
||||
}
|
||||
|
@ -74,7 +74,6 @@ private:
|
||||
QWaylandDisplay *mDisplay;
|
||||
bool mUseOpenGL;
|
||||
QPlatformNativeInterface *mNativeInterface;
|
||||
mutable QPlatformClipboard *mClipboard;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
Loading…
Reference in New Issue
Block a user