#include <QtCore/QtDebug>
#include <QtGui/private/qdnd_p.h>
-static QWaylandClipboard *clipboard;
+static QWaylandClipboard *clipboard = 0;
class QWaylandMimeData : public QInternalMimeData
{
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()
class QWaylandClipboard : public QPlatformClipboard
{
public:
- QWaylandClipboard(QWaylandDisplay *display);
+ static QWaylandClipboard *instance(QWaylandDisplay *display);
+
~QWaylandClipboard();
QMimeData *mimeData(QClipboard::Mode mode = QClipboard::Clipboard);
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);
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);
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)
void blockingReadEvents();
void flushRequests();
-private slots:
- void handleSelectionOffer(uint32_t id);
-
private:
void waitForScreens();
void displayHandleGlobal(uint32_t id,
bool mScreensInitialized;
uint32_t mSocketMask;
- uint32_t mSelectionOfferId;
struct wl_visual *argb_visual, *premultiplied_argb_visual, *rgb_visual;
, mDisplay(new QWaylandDisplay())
, mUseOpenGL(useOpenGL)
, mNativeInterface(new QWaylandNativeInterface)
- , mClipboard(0)
{
}
QPlatformClipboard *QWaylandIntegration::clipboard() const
{
- if (!mClipboard)
- mClipboard = new QWaylandClipboard(mDisplay);
- return mClipboard;
+ return QWaylandClipboard::instance(mDisplay);
}
QWaylandDisplay *mDisplay;
bool mUseOpenGL;
QPlatformNativeInterface *mNativeInterface;
- mutable QPlatformClipboard *mClipboard;
};
QT_END_NAMESPACE