summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/wayland
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/platforms/wayland')
-rw-r--r--src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp9
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp4
-rw-r--r--src/plugins/platforms/wayland/qwaylandclipboard.cpp115
-rw-r--r--src/plugins/platforms/wayland/qwaylandclipboard.h17
-rw-r--r--src/plugins/platforms/wayland/qwaylanddisplay.cpp50
-rw-r--r--src/plugins/platforms/wayland/qwaylanddisplay.h17
-rw-r--r--src/plugins/platforms/wayland/qwaylandwindow.cpp11
-rw-r--r--src/plugins/platforms/wayland/wayland.pro2
-rw-r--r--src/plugins/platforms/wayland/wayland_sha1.txt3
-rw-r--r--src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.cpp92
-rw-r--r--src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.h70
-rw-r--r--src/plugins/platforms/wayland/windowmanager_integration/windowmanager_integration.pri16
12 files changed, 365 insertions, 41 deletions
diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp
index 72ad5a8..0f27501 100644
--- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp
@@ -115,8 +115,15 @@ void *QWaylandGLContext::getProcAddress(const QString &string)
void QWaylandGLContext::setEglSurface(EGLSurface surface)
{
- doneCurrent();
+ bool wasCurrent = false;
+ if (QPlatformGLContext::currentContext() == this) {
+ wasCurrent = true;
+ doneCurrent();
+ }
mSurface = surface;
+ if (wasCurrent) {
+ makeCurrent();
+ }
}
EGLConfig QWaylandGLContext::eglConfig() const
diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp
index e53381e..dff6ffa 100644
--- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp
@@ -132,10 +132,12 @@ void QWaylandXCompositeGLXContext::geometryChanged()
Colormap cmap = XCreateColormap(mGlxIntegration->xDisplay(),mGlxIntegration->rootWindow(),visualInfo->visual,AllocNone);
XSetWindowAttributes a;
+ a.background_pixel = WhitePixel(mGlxIntegration->xDisplay(), mGlxIntegration->screen());
+ a.border_pixel = BlackPixel(mGlxIntegration->xDisplay(), mGlxIntegration->screen());
a.colormap = cmap;
mXWindow = XCreateWindow(mGlxIntegration->xDisplay(), mGlxIntegration->rootWindow(),0, 0, size.width(), size.height(),
0, visualInfo->depth, InputOutput, visualInfo->visual,
- CWColormap, &a);
+ CWBackPixel|CWBorderPixel|CWColormap, &a);
XCompositeRedirectWindow(mGlxIntegration->xDisplay(), mXWindow, CompositeRedirectManual);
XMapWindow(mGlxIntegration->xDisplay(), mXWindow);
diff --git a/src/plugins/platforms/wayland/qwaylandclipboard.cpp b/src/plugins/platforms/wayland/qwaylandclipboard.cpp
index f2e6ccf..b7f6ae5 100644
--- a/src/plugins/platforms/wayland/qwaylandclipboard.cpp
+++ b/src/plugins/platforms/wayland/qwaylandclipboard.cpp
@@ -48,16 +48,54 @@
#include <QtCore/QStringList>
#include <QtCore/QFile>
#include <QtCore/QtDebug>
+#include <QtGui/private/qdnd_p.h>
static QWaylandClipboard *clipboard;
+class QWaylandMimeData : public QInternalMimeData
+{
+public:
+ void clearAll();
+ void setFormats(const QStringList &formatList);
+ bool hasFormat_sys(const QString &mimeType) const;
+ QStringList formats_sys() const;
+ QVariant retrieveData_sys(const QString &mimeType, QVariant::Type type) const;
+private:
+ QStringList mFormatList;
+};
+
+void QWaylandMimeData::clearAll()
+{
+ clear();
+ mFormatList.clear();
+}
+
+void QWaylandMimeData::setFormats(const QStringList &formatList)
+{
+ mFormatList = formatList;
+}
+
+bool QWaylandMimeData::hasFormat_sys(const QString &mimeType) const
+{
+ return formats().contains(mimeType);
+}
+
+QStringList QWaylandMimeData::formats_sys() const
+{
+ return mFormatList;
+}
+
+QVariant QWaylandMimeData::retrieveData_sys(const QString &mimeType, QVariant::Type type) const
+{
+ return clipboard->retrieveData(mimeType, type);
+}
+
class QWaylandSelection
{
public:
QWaylandSelection(QWaylandDisplay *display, QMimeData *data);
~QWaylandSelection();
-private:
static uint32_t getTime();
static void send(void *data, struct wl_selection *selection, const char *mime_type, int fd);
static void cancelled(void *data, struct wl_selection *selection);
@@ -125,7 +163,7 @@ void QWaylandSelection::cancelled(void *data, struct wl_selection *selection)
}
QWaylandClipboard::QWaylandClipboard(QWaylandDisplay *display)
- : mDisplay(display), mSelection(0), mMimeDataIn(0), mOffer(0)
+ : mDisplay(display), mMimeDataIn(0), mOffer(0)
{
clipboard = this;
}
@@ -157,32 +195,39 @@ void QWaylandClipboard::forceRoundtrip(struct wl_display *display)
wl_display_iterate(display, WL_DISPLAY_READABLE);
}
-const QMimeData *QWaylandClipboard::mimeData(QClipboard::Mode mode) const
+QVariant QWaylandClipboard::retrieveData(const QString &mimeType, QVariant::Type type) const
+{
+ Q_UNUSED(type);
+ if (mOfferedMimeTypes.isEmpty() || !mOffer)
+ return QVariant();
+ int pipefd[2];
+ if (pipe(pipefd) == -1) {
+ qWarning("QWaylandClipboard: pipe() failed");
+ return QVariant();
+ }
+ QByteArray mimeTypeBa = mimeType.toLatin1();
+ wl_selection_offer_receive(mOffer, mimeTypeBa.constData(), pipefd[1]);
+ QByteArray content;
+ forceRoundtrip(mDisplay->wl_display());
+ char buf[256];
+ int n;
+ close(pipefd[1]);
+ while ((n = read(pipefd[0], &buf, sizeof buf)) > 0)
+ content.append(buf, n);
+ close(pipefd[0]);
+ return content;
+}
+
+QMimeData *QWaylandClipboard::mimeData(QClipboard::Mode mode)
{
Q_ASSERT(mode == QClipboard::Clipboard);
+ if (!mSelections.isEmpty())
+ return mSelections.last()->mMimeData;
if (!mMimeDataIn)
- mMimeDataIn = new QMimeData;
- mMimeDataIn->clear();
- if (!mOfferedMimeTypes.isEmpty() && mOffer) {
- foreach (const QString &mimeType, mOfferedMimeTypes) {
- int pipefd[2];
- if (pipe(pipefd) == -1) {
- qWarning("QWaylandClipboard::mimedata: pipe() failed");
- break;
- }
- QByteArray mimeTypeBa = mimeType.toLatin1();
- wl_selection_offer_receive(mOffer, mimeTypeBa.constData(), pipefd[1]);
- QByteArray content;
- forceRoundtrip(mDisplay->wl_display());
- char buf[256];
- int n;
- close(pipefd[1]);
- while ((n = read(pipefd[0], &buf, sizeof buf)) > 0)
- content.append(buf, n);
- close(pipefd[0]);
- mMimeDataIn->setData(mimeType, content);
- }
- }
+ mMimeDataIn = new QWaylandMimeData;
+ mMimeDataIn->clearAll();
+ if (!mOfferedMimeTypes.isEmpty() && mOffer)
+ mMimeDataIn->setFormats(mOfferedMimeTypes);
return mMimeDataIn;
}
@@ -192,7 +237,7 @@ void QWaylandClipboard::setMimeData(QMimeData *data, QClipboard::Mode mode)
if (!mDisplay->inputDevices().isEmpty()) {
if (!data)
data = new QMimeData;
- mSelection = new QWaylandSelection(mDisplay, data);
+ mSelections.append(new QWaylandSelection(mDisplay, data));
} else {
qWarning("QWaylandClipboard::setMimeData: No input devices");
}
@@ -222,21 +267,27 @@ void QWaylandClipboard::offer(void *data,
struct wl_selection_offer *selection_offer,
const char *type)
{
+ Q_UNUSED(data);
Q_UNUSED(selection_offer);
- QWaylandClipboard *self = static_cast<QWaylandClipboard *>(data);
- self->mOfferedMimeTypes.append(QString::fromLatin1(type));
+ clipboard->mOfferedMimeTypes.append(QString::fromLatin1(type));
}
void QWaylandClipboard::keyboardFocus(void *data,
struct wl_selection_offer *selection_offer,
wl_input_device *input_device)
{
- QWaylandClipboard *self = static_cast<QWaylandClipboard *>(data);
+ Q_UNUSED(data);
if (!input_device) {
wl_selection_offer_destroy(selection_offer);
- self->mOffer = 0;
+ clipboard->mOffer = 0;
return;
}
- self->mOffer = selection_offer;
- self->emitChanged(QClipboard::Clipboard);
+ clipboard->mOffer = selection_offer;
+ if (clipboard->mSelections.isEmpty())
+ QMetaObject::invokeMethod(&clipboard->mEmitter, "emitChanged", Qt::QueuedConnection);
+}
+
+void QWaylandClipboardSignalEmitter::emitChanged()
+{
+ clipboard->emitChanged(QClipboard::Clipboard);
}
diff --git a/src/plugins/platforms/wayland/qwaylandclipboard.h b/src/plugins/platforms/wayland/qwaylandclipboard.h
index dc51854..f45fb8d 100644
--- a/src/plugins/platforms/wayland/qwaylandclipboard.h
+++ b/src/plugins/platforms/wayland/qwaylandclipboard.h
@@ -44,18 +44,27 @@
#include <QtGui/QPlatformClipboard>
#include <QtCore/QStringList>
+#include <QtCore/QVariant>
class QWaylandDisplay;
class QWaylandSelection;
+class QWaylandMimeData;
struct wl_selection_offer;
+class QWaylandClipboardSignalEmitter : public QObject
+{
+ Q_OBJECT
+public slots:
+ void emitChanged();
+};
+
class QWaylandClipboard : public QPlatformClipboard
{
public:
QWaylandClipboard(QWaylandDisplay *display);
~QWaylandClipboard();
- const QMimeData *mimeData(QClipboard::Mode mode = QClipboard::Clipboard) const;
+ QMimeData *mimeData(QClipboard::Mode mode = QClipboard::Clipboard);
void setMimeData(QMimeData *data, QClipboard::Mode mode = QClipboard::Clipboard);
bool supportsMode(QClipboard::Mode mode) const;
@@ -63,6 +72,8 @@ public:
void createSelectionOffer(uint32_t id);
+ QVariant retrieveData(const QString &mimeType, QVariant::Type type) const;
+
private:
static void offer(void *data,
struct wl_selection_offer *selection_offer,
@@ -76,11 +87,11 @@ private:
static void forceRoundtrip(struct wl_display *display);
QWaylandDisplay *mDisplay;
- QWaylandSelection *mSelection;
- mutable QMimeData *mMimeDataIn;
+ QWaylandMimeData *mMimeDataIn;
QList<QWaylandSelection *> mSelections;
QStringList mOfferedMimeTypes;
struct wl_selection_offer *mOffer;
+ QWaylandClipboardSignalEmitter mEmitter;
};
#endif // QWAYLANDCLIPBOARD_H
diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.cpp b/src/plugins/platforms/wayland/qwaylanddisplay.cpp
index 14a8dcf..83516e9 100644
--- a/src/plugins/platforms/wayland/qwaylanddisplay.cpp
+++ b/src/plugins/platforms/wayland/qwaylanddisplay.cpp
@@ -51,6 +51,10 @@
#include "gl_integration/qwaylandglintegration.h"
#endif
+#ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT
+#include "windowmanager_integration/qwaylandwindowmanagerintegration.h"
+#endif
+
#include <QtCore/QAbstractEventDispatcher>
#include <QtGui/QApplication>
#include <QtGui/private/qapplication_p.h>
@@ -77,17 +81,17 @@ struct wl_buffer *QWaylandDisplay::createShmBuffer(int fd,
struct wl_visual *QWaylandDisplay::rgbVisual()
{
- return wl_display_get_rgb_visual(mDisplay);
+ return rgb_visual;
}
struct wl_visual *QWaylandDisplay::argbVisual()
{
- return wl_display_get_argb_visual(mDisplay);
+ return argb_visual;
}
struct wl_visual *QWaylandDisplay::argbPremultipliedVisual()
{
- return wl_display_get_premultiplied_argb_visual(mDisplay);
+ return premultiplied_argb_visual;
}
#ifdef QT_WAYLAND_GL_SUPPORT
@@ -97,6 +101,13 @@ QWaylandGLIntegration * QWaylandDisplay::eglIntegration()
}
#endif
+#ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT
+QWaylandWindowManagerIntegration *QWaylandDisplay::windowManagerIntegration()
+{
+ return mWindowManagerIntegration;
+}
+#endif
+
void QWaylandDisplay::shellHandleConfigure(void *data, struct wl_shell *shell,
uint32_t time, uint32_t edges,
struct wl_surface *surface,
@@ -116,6 +127,7 @@ const struct wl_shell_listener QWaylandDisplay::shellListener = {
};
QWaylandDisplay::QWaylandDisplay(void)
+ : argb_visual(0), premultiplied_argb_visual(0), rgb_visual(0)
{
mDisplay = wl_display_connect(NULL);
if (mDisplay == NULL) {
@@ -128,6 +140,11 @@ QWaylandDisplay::QWaylandDisplay(void)
#ifdef QT_WAYLAND_GL_SUPPORT
mEglIntegration = QWaylandGLIntegration::createGLIntegration(this);
#endif
+
+#ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT
+ mWindowManagerIntegration = QWaylandWindowManagerIntegration::createIntegration(this);
+#endif
+
blockingReadEvents();
qRegisterMetaType<uint32_t>("uint32_t");
@@ -228,6 +245,11 @@ const struct wl_output_listener QWaylandDisplay::outputListener = {
QWaylandDisplay::outputHandleGeometry
};
+const struct wl_compositor_listener QWaylandDisplay::compositorListener = {
+ QWaylandDisplay::handleVisual,
+};
+
+
void QWaylandDisplay::waitForScreens()
{
flushRequests();
@@ -256,6 +278,8 @@ void QWaylandDisplay::displayHandleGlobal(uint32_t id,
wl_output_add_listener(output, &outputListener, this);
} else if (interface == "wl_compositor") {
mCompositor = wl_compositor_create(mDisplay, id, 1);
+ wl_compositor_add_listener(mCompositor,
+ &compositorListener, this);
} else if (interface == "wl_shm") {
mShm = wl_shm_create(mDisplay, id, 1);
} else if (interface == "wl_shell"){
@@ -271,3 +295,23 @@ void QWaylandDisplay::displayHandleGlobal(uint32_t id,
clipboard->createSelectionOffer(id);
}
}
+
+void QWaylandDisplay::handleVisual(void *data,
+ struct wl_compositor *compositor,
+ uint32_t id, uint32_t token)
+{
+ QWaylandDisplay *self = static_cast<QWaylandDisplay *>(data);
+
+ switch (token) {
+ case WL_COMPOSITOR_VISUAL_ARGB32:
+ self->argb_visual = wl_visual_create(self->mDisplay, id, 1);
+ break;
+ case WL_COMPOSITOR_VISUAL_PREMULTIPLIED_ARGB32:
+ self->premultiplied_argb_visual =
+ wl_visual_create(self->mDisplay, id, 1);
+ break;
+ case WL_COMPOSITOR_VISUAL_XRGB32:
+ self->rgb_visual = wl_visual_create(self->mDisplay, id, 1);
+ break;
+ }
+}
diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.h b/src/plugins/platforms/wayland/qwaylanddisplay.h
index 7cb2df1..765be62 100644
--- a/src/plugins/platforms/wayland/qwaylanddisplay.h
+++ b/src/plugins/platforms/wayland/qwaylanddisplay.h
@@ -55,6 +55,8 @@ class QWaylandBuffer;
class QPlatformScreen;
class QWaylandScreen;
class QWaylandGLIntegration;
+class QWaylandWindowManagerIntegration;
+
class QWaylandDisplay : public QObject {
Q_OBJECT
@@ -74,6 +76,11 @@ public:
#ifdef QT_WAYLAND_GL_SUPPORT
QWaylandGLIntegration *eglIntegration();
#endif
+
+#ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT
+ QWaylandWindowManagerIntegration *windowManagerIntegration();
+#endif
+
void setCursor(QWaylandBuffer *buffer, int32_t x, int32_t y);
void syncCallback(wl_display_sync_func_t func, void *data);
@@ -109,7 +116,10 @@ private:
uint32_t mSocketMask;
+ struct wl_visual *argb_visual, *premultiplied_argb_visual, *rgb_visual;
+
static const struct wl_output_listener outputListener;
+ static const struct wl_compositor_listener compositorListener;
static int sourceUpdate(uint32_t mask, void *data);
static void displayHandleGlobal(struct wl_display *display,
uint32_t id,
@@ -120,10 +130,17 @@ private:
int32_t x, int32_t y,
int32_t width, int32_t height);
+ static void handleVisual(void *data,
+ struct wl_compositor *compositor,
+ uint32_t id, uint32_t token);
#ifdef QT_WAYLAND_GL_SUPPORT
QWaylandGLIntegration *mEglIntegration;
#endif
+#ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT
+ QWaylandWindowManagerIntegration *mWindowManagerIntegration;
+#endif
+
static void shellHandleConfigure(void *data, struct wl_shell *shell,
uint32_t time, uint32_t edges,
struct wl_surface *surface,
diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp
index 734591f..333a953 100644
--- a/src/plugins/platforms/wayland/qwaylandwindow.cpp
+++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp
@@ -46,6 +46,11 @@
#include "qwaylandinputdevice.h"
#include "qwaylandscreen.h"
+#ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT
+#include "windowmanager_integration/qwaylandwindowmanagerintegration.h"
+#endif
+
+#include <QCoreApplication>
#include <QtGui/QWidget>
#include <QtGui/QWindowSystemInterface>
@@ -60,6 +65,11 @@ QWaylandWindow::QWaylandWindow(QWidget *window)
static WId id = 1;
mWindowId = id++;
+#ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT
+ mDisplay->windowManagerIntegration()->mapClientToProcess(qApp->applicationPid());
+ mDisplay->windowManagerIntegration()->authenticateWithToken();
+#endif
+
mSurface = mDisplay->createSurface(this);
}
@@ -120,7 +130,6 @@ void QWaylandWindow::attach(QWaylandBuffer *buffer)
}
}
-
void QWaylandWindow::damage(const QRegion &region)
{
//We have to do sync stuff before calling damage, or we might
diff --git a/src/plugins/platforms/wayland/wayland.pro b/src/plugins/platforms/wayland/wayland.pro
index 76f8be5..dca72fd 100644
--- a/src/plugins/platforms/wayland/wayland.pro
+++ b/src/plugins/platforms/wayland/wayland.pro
@@ -40,8 +40,10 @@ QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_WAYLAND
INCLUDEPATH += $$PWD
include ($$PWD/gl_integration/gl_integration.pri)
+include ($$PWD/windowmanager_integration/windowmanager_integration.pri)
include (../fontdatabases/genericunix/genericunix.pri)
target.path += $$[QT_INSTALL_PLUGINS]/platforms
INSTALLS += target
+
diff --git a/src/plugins/platforms/wayland/wayland_sha1.txt b/src/plugins/platforms/wayland/wayland_sha1.txt
new file mode 100644
index 0000000..d262437
--- /dev/null
+++ b/src/plugins/platforms/wayland/wayland_sha1.txt
@@ -0,0 +1,3 @@
+This version of the Qt Wayland plugin is checked against the following sha1
+from the Wayland repository:
+eff7fc0d99be2e51eaa351785030c8d374ac71de
diff --git a/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.cpp b/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.cpp
new file mode 100644
index 0000000..e4a6218
--- /dev/null
+++ b/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.cpp
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandwindowmanagerintegration.h"
+#include "qwaylandwindowmanager-client-protocol.h"
+
+#include <stdint.h>
+
+QWaylandWindowManagerIntegration *QWaylandWindowManagerIntegration::createIntegration(QWaylandDisplay *waylandDisplay)
+{
+ return new QWaylandWindowManagerIntegration(waylandDisplay);
+}
+
+QWaylandWindowManagerIntegration::QWaylandWindowManagerIntegration(QWaylandDisplay *waylandDisplay)
+ : mWaylandDisplay(waylandDisplay)
+ , mWaylandWindowManager(0)
+{
+ wl_display_add_global_listener(mWaylandDisplay->wl_display(),
+ QWaylandWindowManagerIntegration::wlHandleListenerGlobal,
+ this);
+}
+
+QWaylandWindowManagerIntegration::~QWaylandWindowManagerIntegration()
+{
+
+}
+
+struct wl_windowmanager *QWaylandWindowManagerIntegration::windowManager() const
+{
+ return mWaylandWindowManager;
+}
+
+void QWaylandWindowManagerIntegration::wlHandleListenerGlobal(wl_display *display, uint32_t id, const char *interface, uint32_t version, void *data)
+{
+ if (strcmp(interface, "wl_windowmanager") == 0) {
+ QWaylandWindowManagerIntegration *integration = static_cast<QWaylandWindowManagerIntegration *>(data);
+ integration->mWaylandWindowManager = wl_windowmanager_create(display, id);
+ }
+}
+
+void QWaylandWindowManagerIntegration::mapClientToProcess(long long processId)
+{
+ if (mWaylandWindowManager)
+ wl_windowmanager_map_client_to_process(mWaylandWindowManager, (uint32_t) processId);
+}
+
+void QWaylandWindowManagerIntegration::authenticateWithToken(const QByteArray &token)
+{
+ QByteArray authToken = token;
+ if (authToken.isEmpty())
+ authToken = qgetenv("WL_AUTHENTICATION_TOKEN");
+ if (mWaylandWindowManager)
+ wl_windowmanager_authenticate_with_token(mWaylandWindowManager, authToken.constData());
+}
diff --git a/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.h b/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.h
new file mode 100644
index 0000000..a79f205
--- /dev/null
+++ b/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDWINDOWMANAGERINTEGRATION_H
+#define QWAYLANDWINDOWMANAGERINTEGRATION_H
+
+#include <QObject>
+#include "wayland-client.h"
+#include "qwaylanddisplay.h"
+
+class QWaylandWindowManagerIntegration
+{
+public:
+ explicit QWaylandWindowManagerIntegration(QWaylandDisplay *waylandDisplay);
+ virtual ~QWaylandWindowManagerIntegration();
+ static QWaylandWindowManagerIntegration *createIntegration(QWaylandDisplay *waylandDisplay);
+ struct wl_windowmanager *windowManager() const;
+
+ void mapSurfaceToProcess(struct wl_surface *surface, long long processId);
+ void mapClientToProcess(long long processId);
+ void authenticateWithToken(const QByteArray &token = QByteArray());
+
+private:
+ static void wlHandleListenerGlobal(wl_display *display, uint32_t id,
+ const char *interface, uint32_t version, void *data);
+
+private:
+ QWaylandDisplay *mWaylandDisplay;
+ struct wl_windowmanager *mWaylandWindowManager;
+};
+
+#endif // QWAYLANDWINDOWMANAGERINTEGRATION_H
diff --git a/src/plugins/platforms/wayland/windowmanager_integration/windowmanager_integration.pri b/src/plugins/platforms/wayland/windowmanager_integration/windowmanager_integration.pri
new file mode 100644
index 0000000..664389a
--- /dev/null
+++ b/src/plugins/platforms/wayland/windowmanager_integration/windowmanager_integration.pri
@@ -0,0 +1,16 @@
+DEFINES += QT_WAYLAND_WINDOWMANAGER_SUPPORT
+
+contains(DEFINES, QT_WAYLAND_WINDOWMANAGER_SUPPORT) {
+
+ HEADERS += \
+ $$PWD/qwaylandwindowmanagerintegration.h
+
+ SOURCES += \
+ $$PWD/qwaylandwindowmanagerintegration.cpp
+
+ INCLUDEPATH += $$QT_SOURCE_TREE/src/3rdparty/wayland
+ HEADERS += \
+ $$QT_SOURCE_TREE/src/3rdparty/wayland/qwaylandwindowmanager-client-protocol.h
+ SOURCES += \
+ $$QT_SOURCE_TREE/src/3rdparty/wayland/wayland-windowmanager-protocol.c
+}