summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-08-11 10:19:51 +0200
committerLiang Qi <liang.qi@qt.io>2016-08-11 10:50:02 +0200
commit33ad940cddf0a9529f205fe645f1b1d76f6f04f1 (patch)
tree72751567959407b3c50dc92c56529e6159099ce7
parent061ed4599dd2b384e4ef74b297640bf4e92f7f43 (diff)
parent1bc3b0fdc8d934c1ab69a902054681896b56d672 (diff)
Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts: src/client/qwaylanddisplay.cpp src/client/qwaylanddisplay_p.h src/client/qwaylandxdgpopup_p.h Change-Id: If86ea09971773dc6c541f07819459a90e8ab73a0
-rw-r--r--src/client/client.pro6
-rw-r--r--src/client/qwaylanddatadevice.cpp7
-rw-r--r--src/client/qwaylanddisplay.cpp39
-rw-r--r--src/client/qwaylanddisplay_p.h7
-rw-r--r--src/client/qwaylandintegration.cpp43
-rw-r--r--src/client/qwaylandintegration_p.h1
-rw-r--r--src/client/qwaylandshellsurface_p.h1
-rw-r--r--src/client/qwaylandwlshellintegration.cpp62
-rw-r--r--src/client/qwaylandwlshellintegration_p.h72
-rw-r--r--src/client/qwaylandxdgpopup_p.cpp61
-rw-r--r--src/client/qwaylandxdgpopup_p.h79
-rw-r--r--src/client/qwaylandxdgshell.cpp19
-rw-r--r--src/client/qwaylandxdgshell_p.h6
-rw-r--r--src/client/qwaylandxdgshellintegration.cpp67
-rw-r--r--src/client/qwaylandxdgshellintegration_p.h73
-rw-r--r--src/client/qwaylandxdgsurface.cpp9
-rw-r--r--src/client/qwaylandxdgsurface_p.h6
-rw-r--r--tests/auto/client/mockcompositor.cpp89
-rw-r--r--tests/auto/client/mockcompositor.h25
-rw-r--r--tests/auto/client/mockinput.cpp216
-rw-r--r--tests/auto/client/mockinput.h33
-rw-r--r--tests/auto/client/tst_client.cpp102
22 files changed, 966 insertions, 57 deletions
diff --git a/src/client/client.pro b/src/client/client.pro
index 994cf5443..8be00c7ac 100644
--- a/src/client/client.pro
+++ b/src/client/client.pro
@@ -58,8 +58,11 @@ SOURCES += qwaylandintegration.cpp \
qwaylanddatasource.cpp \
qwaylandshellsurface.cpp \
qwaylandwlshellsurface.cpp \
+ qwaylandwlshellintegration.cpp \
qwaylandxdgshell.cpp \
qwaylandxdgsurface.cpp \
+ qwaylandxdgpopup_p.cpp \
+ qwaylandxdgshellintegration.cpp \
qwaylandextendedsurface.cpp \
qwaylandsubsurface.cpp \
qwaylandtouch.cpp \
@@ -93,8 +96,11 @@ HEADERS += qwaylandintegration_p.h \
qwaylanddatasource_p.h \
qwaylandshellsurface_p.h \
qwaylandwlshellsurface_p.h \
+ qwaylandwlshellintegration_p.h \
qwaylandxdgshell_p.h \
qwaylandxdgsurface_p.h \
+ qwaylandxdgpopup_p.h \
+ qwaylandxdgshellintegration_p.h \
qwaylandextendedsurface_p.h \
qwaylandsubsurface_p.h \
qwaylandtouch_p.h \
diff --git a/src/client/qwaylanddatadevice.cpp b/src/client/qwaylanddatadevice.cpp
index afc8849b3..0ff1f1979 100644
--- a/src/client/qwaylanddatadevice.cpp
+++ b/src/client/qwaylanddatadevice.cpp
@@ -56,8 +56,6 @@
#include <qpa/qplatformdrag.h>
#include <qpa/qwindowsysteminterface.h>
-#include <QDebug>
-
QT_BEGIN_NAMESPACE
namespace QtWaylandClient {
@@ -110,7 +108,10 @@ void QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon)
{
m_dragSource.reset(new QWaylandDataSource(m_display->dndSelectionHandler(), mimeData));
connect(m_dragSource.data(), &QWaylandDataSource::cancelled, this, &QWaylandDataDevice::dragSourceCancelled);
+
QWaylandWindow *origin = m_display->currentInputDevice()->pointerFocus();
+ if (!origin)
+ origin = m_display->currentInputDevice()->touchFocus();
start_drag(m_dragSource->object(), origin->object(), icon->object(), m_display->currentInputDevice()->serial());
}
@@ -129,8 +130,6 @@ void QWaylandDataDevice::data_device_drop()
{
QDrag *drag = static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->currentDrag();
- qDebug() << Q_FUNC_INFO << drag << m_dragOffer.data();
-
QMimeData *dragData = 0;
Qt::DropActions supportedActions;
if (drag) {
diff --git a/src/client/qwaylanddisplay.cpp b/src/client/qwaylanddisplay.cpp
index 7b3ff7bbb..5687a750a 100644
--- a/src/client/qwaylanddisplay.cpp
+++ b/src/client/qwaylanddisplay.cpp
@@ -84,16 +84,8 @@ struct wl_surface *QWaylandDisplay::createSurface(void *handle)
QWaylandShellSurface *QWaylandDisplay::createShellSurface(QWaylandWindow *window)
{
- if (mWaylandIntegration->shellIntegration())
- return mWaylandIntegration->shellIntegration()->createShellSurface(window);
-
- if (shellXdg()) {
- return new QWaylandXdgSurface(shellXdg()->get_xdg_surface(window->object()), window);
- } else if (shell()) {
- return new QWaylandWlShellSurface(shell()->get_shell_surface(window->object()), window);
- }
-
- return Q_NULLPTR;
+ Q_ASSERT(mWaylandIntegration->shellIntegration());
+ return mWaylandIntegration->shellIntegration()->createShellSurface(window);
}
struct ::wl_region *QWaylandDisplay::createRegion(const QRegion &qregion)
@@ -255,11 +247,6 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
mCompositor.init(registry, id, mCompositorVersion);
} else if (interface == QStringLiteral("wl_shm")) {
mShm.reset(new QWaylandShm(this, version, id));
- } else if (interface == QStringLiteral("xdg_shell")
- && qEnvironmentVariableIsSet("QT_WAYLAND_USE_XDG_SHELL")) {
- mShellXdg.reset(new QWaylandXdgShell(registry,id));
- } else if (interface == QStringLiteral("wl_shell")){
- mShell.reset(new QtWayland::wl_shell(registry, id, 1));
} else if (interface == QStringLiteral("wl_seat")) {
QWaylandInputDevice *inputDevice = mWaylandIntegration->createInputDevice(this, version, id);
mInputDevices.append(inputDevice);
@@ -311,6 +298,15 @@ void QWaylandDisplay::registry_global_remove(uint32_t id)
}
}
+bool QWaylandDisplay::hasRegistryGlobal(const QString &interfaceName)
+{
+ Q_FOREACH (const RegistryGlobal &global, mGlobals)
+ if (global.interface == interfaceName)
+ return true;
+
+ return false;
+}
+
void QWaylandDisplay::addRegistryListener(RegistryListener listener, void *data)
{
Listener l = { listener, data };
@@ -366,11 +362,6 @@ void QWaylandDisplay::forceRoundTrip()
wl_callback_destroy(callback);
}
-QtWayland::xdg_shell *QWaylandDisplay::shellXdg()
-{
- return mShellXdg.data();
-}
-
bool QWaylandDisplay::supportsWindowDecoration() const
{
static bool disabled = qgetenv("QT_WAYLAND_DISABLE_WINDOWDECORATION").toInt();
@@ -395,12 +386,6 @@ void QWaylandDisplay::setLastInputDevice(QWaylandInputDevice *device, uint32_t s
mLastInputWindow = win;
}
-bool QWaylandDisplay::shellManagesActiveState() const
-{
- //TODO: This should be part of a shell interface used by the shell protocol implementations
- return mShellXdg;
-}
-
void QWaylandDisplay::handleWindowActivated(QWaylandWindow *window)
{
if (mActiveWindows.contains(window))
@@ -424,7 +409,7 @@ void QWaylandDisplay::handleKeyboardFocusChanged(QWaylandInputDevice *inputDevic
{
QWaylandWindow *keyboardFocus = inputDevice->keyboardFocus();
- if (!shellManagesActiveState() && mLastKeyboardFocus != keyboardFocus) {
+ if (!keyboardFocus->shellSurface()->shellManagesActiveState() && mLastKeyboardFocus != keyboardFocus) {
if (keyboardFocus)
handleWindowActivated(keyboardFocus);
if (mLastKeyboardFocus)
diff --git a/src/client/qwaylanddisplay_p.h b/src/client/qwaylanddisplay_p.h
index b040d69a0..f4fb3fa56 100644
--- a/src/client/qwaylanddisplay_p.h
+++ b/src/client/qwaylanddisplay_p.h
@@ -134,9 +134,6 @@ public:
QtWayland::wl_compositor *compositor() { return &mCompositor; }
int compositorVersion() const { return mCompositorVersion; }
- QtWayland::wl_shell *shell() { return mShell.data(); }
- QtWayland::xdg_shell *shellXdg();
-
QList<QWaylandInputDevice *> inputDevices() const { return mInputDevices; }
QWaylandInputDevice *defaultInputDevice() const;
QWaylandInputDevice *currentInputDevice() const { return defaultInputDevice(); }
@@ -157,6 +154,7 @@ public:
: id(id_), interface(interface_), version(version_), registry(registry_) { }
};
QList<RegistryGlobal> globals() const { return mGlobals; }
+ bool hasRegistryGlobal(const QString &interfaceName);
/* wl_registry_add_listener does not add but rather sets a listener, so this function is used
* to enable many listeners at once. */
@@ -175,7 +173,6 @@ public:
QWaylandWindow *lastInputWindow() const;
void setLastInputDevice(QWaylandInputDevice *device, uint32_t serial, QWaylandWindow *window);
- bool shellManagesActiveState() const;
void handleWindowActivated(QWaylandWindow *window);
void handleWindowDeactivated(QWaylandWindow *window);
void handleKeyboardFocusChanged(QWaylandInputDevice *inputDevice);
@@ -200,8 +197,6 @@ private:
struct wl_display *mDisplay;
QtWayland::wl_compositor mCompositor;
QScopedPointer<QWaylandShm> mShm;
- QScopedPointer<QtWayland::wl_shell> mShell;
- QScopedPointer<QWaylandXdgShell> mShellXdg;
QList<QWaylandScreen *> mScreens;
QList<QWaylandInputDevice *> mInputDevices;
QList<Listener> mRegistryListeners;
diff --git a/src/client/qwaylandintegration.cpp b/src/client/qwaylandintegration.cpp
index 749b8d403..bd59e4270 100644
--- a/src/client/qwaylandintegration.cpp
+++ b/src/client/qwaylandintegration.cpp
@@ -75,6 +75,8 @@
#include "qwaylandshellintegration_p.h"
#include "qwaylandshellintegrationfactory_p.h"
+#include "qwaylandxdgshellintegration_p.h"
+#include "qwaylandwlshellintegration_p.h"
#include "qwaylandinputdeviceintegration_p.h"
#include "qwaylandinputdeviceintegrationfactory_p.h"
@@ -377,17 +379,29 @@ void QWaylandIntegration::initializeShellIntegration()
QByteArray integrationName = qgetenv("QT_WAYLAND_SHELL_INTEGRATION");
QString targetKey = QString::fromLocal8Bit(integrationName);
- if (targetKey.isEmpty()) {
- return;
+ if (!targetKey.isEmpty()) {
+ QStringList keys = QWaylandShellIntegrationFactory::keys();
+ if (keys.contains(targetKey)) {
+ qDebug("Using the '%s' shell integration", qPrintable(targetKey));
+ mShellIntegration = QWaylandShellIntegrationFactory::create(targetKey, QStringList());
+ }
+ } else {
+ QStringList preferredShells;
+ if (qEnvironmentVariableIsSet("QT_WAYLAND_USE_XDG_SHELL"))
+ preferredShells << QLatin1String("xdg_shell");
+ preferredShells << QLatin1String("wl_shell");
+
+ Q_FOREACH (QString preferredShell, preferredShells) {
+ if (mDisplay->hasRegistryGlobal(preferredShell)) {
+ mShellIntegration = createShellIntegration(preferredShell);
+ break;
+ }
+ }
}
- QStringList keys = QWaylandShellIntegrationFactory::keys();
- if (keys.contains(targetKey)) {
- mShellIntegration = QWaylandShellIntegrationFactory::create(targetKey, QStringList());
- }
- if (mShellIntegration && mShellIntegration->initialize(mDisplay)) {
- qDebug("Using the '%s' shell integration", qPrintable(targetKey));
- } else {
+ Q_ASSERT(mShellIntegration);
+
+ if (!mShellIntegration->initialize(mDisplay)) {
delete mShellIntegration;
mShellIntegration = Q_NULLPTR;
qWarning("Failed to load shell integration %s", qPrintable(targetKey));
@@ -420,6 +434,17 @@ void QWaylandIntegration::initializeInputDeviceIntegration()
}
}
+QWaylandShellIntegration *QWaylandIntegration::createShellIntegration(const QString &interfaceName)
+{
+ if (interfaceName == QLatin1Literal("wl_shell")) {
+ return new QWaylandWlShellIntegration(mDisplay);
+ } else if (interfaceName == QLatin1Literal("xdg_shell")) {
+ return new QWaylandXdgShellIntegration(mDisplay);
+ } else {
+ return Q_NULLPTR;
+ }
+}
+
}
QT_END_NAMESPACE
diff --git a/src/client/qwaylandintegration_p.h b/src/client/qwaylandintegration_p.h
index f5e68eaf4..e7e0fe6b0 100644
--- a/src/client/qwaylandintegration_p.h
+++ b/src/client/qwaylandintegration_p.h
@@ -121,6 +121,7 @@ private:
void initializeServerBufferIntegration();
void initializeShellIntegration();
void initializeInputDeviceIntegration();
+ QWaylandShellIntegration *createShellIntegration(const QString& interfaceName);
QPlatformFontDatabase *mFontDb;
QPlatformClipboard *mClipboard;
diff --git a/src/client/qwaylandshellsurface_p.h b/src/client/qwaylandshellsurface_p.h
index 63b77ab33..79f65b154 100644
--- a/src/client/qwaylandshellsurface_p.h
+++ b/src/client/qwaylandshellsurface_p.h
@@ -91,6 +91,7 @@ public:
virtual void setContentOrientationMask(Qt::ScreenOrientations orientation) { Q_UNUSED(orientation) }
virtual void sendProperty(const QString &name, const QVariant &value);
+ virtual bool shellManagesActiveState() const { return false; }
inline QWaylandWindow *window() { return m_window; }
diff --git a/src/client/qwaylandwlshellintegration.cpp b/src/client/qwaylandwlshellintegration.cpp
new file mode 100644
index 000000000..6a9220d26
--- /dev/null
+++ b/src/client/qwaylandwlshellintegration.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** 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 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandwlshellintegration_p.h"
+
+#include <QtWaylandClient/private/qwaylandwindow_p.h>
+#include <QtWaylandClient/private/qwaylanddisplay_p.h>
+#include <QtWaylandClient/private/qwaylandwlshellsurface_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace QtWaylandClient {
+
+QWaylandWlShellIntegration::QWaylandWlShellIntegration(QWaylandDisplay *display)
+ : m_wlShell(Q_NULLPTR)
+{
+ Q_FOREACH (QWaylandDisplay::RegistryGlobal global, display->globals()) {
+ if (global.interface == QLatin1String("wl_shell")) {
+ m_wlShell = new QtWayland::wl_shell(display->wl_registry(), global.id, 1);
+ break;
+ }
+ }
+}
+
+QWaylandShellSurface *QWaylandWlShellIntegration::createShellSurface(QWaylandWindow *window)
+{
+ return new QWaylandWlShellSurface(m_wlShell->get_shell_surface(window->object()), window);
+}
+
+}
+
+QT_END_NAMESPACE
diff --git a/src/client/qwaylandwlshellintegration_p.h b/src/client/qwaylandwlshellintegration_p.h
new file mode 100644
index 000000000..8531eb3aa
--- /dev/null
+++ b/src/client/qwaylandwlshellintegration_p.h
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** 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 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDWLSHELLINTEGRATION_P_H
+#define QWAYLANDWLSHELLINTEGRATION_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <wayland-client.h>
+#include <private/qwayland-wayland.h>
+
+#include <QtWaylandClient/private/qwaylandshellintegration_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace QtWaylandClient {
+
+class Q_WAYLAND_CLIENT_EXPORT QWaylandWlShellIntegration : public QWaylandShellIntegration
+{
+public:
+ QWaylandWlShellIntegration(QWaylandDisplay* display);
+ bool initialize(QWaylandDisplay *) Q_DECL_OVERRIDE { return m_wlShell != Q_NULLPTR; }
+ QWaylandShellSurface *createShellSurface(QWaylandWindow *window) Q_DECL_OVERRIDE;
+
+private:
+ QtWayland::wl_shell *m_wlShell;
+};
+
+}
+
+QT_END_NAMESPACE
+
+#endif // QWAYLANDWLSHELLINTEGRATION_P_H
diff --git a/src/client/qwaylandxdgpopup_p.cpp b/src/client/qwaylandxdgpopup_p.cpp
new file mode 100644
index 000000000..abc25278b
--- /dev/null
+++ b/src/client/qwaylandxdgpopup_p.cpp
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** 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 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandxdgpopup_p.h"
+
+#include "qwaylandwindow_p.h"
+#include "qwaylanddisplay_p.h"
+#include "qwaylandextendedsurface_p.h"
+
+QT_BEGIN_NAMESPACE
+
+namespace QtWaylandClient {
+
+QWaylandXdgPopup::QWaylandXdgPopup(struct ::xdg_popup *popup, QWaylandWindow *window)
+ : QWaylandShellSurface(window)
+ , QtWayland::xdg_popup(popup)
+ , m_extendedWindow(nullptr)
+{
+ if (window->display()->windowExtension())
+ m_extendedWindow = new QWaylandExtendedSurface(window);
+}
+
+QWaylandXdgPopup::~QWaylandXdgPopup()
+{
+ xdg_popup_destroy(object());
+ delete m_extendedWindow;
+}
+
+}
+
+QT_END_NAMESPACE
diff --git a/src/client/qwaylandxdgpopup_p.h b/src/client/qwaylandxdgpopup_p.h
new file mode 100644
index 000000000..1f211012d
--- /dev/null
+++ b/src/client/qwaylandxdgpopup_p.h
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the config.tests of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** 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 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDXDGPOPUP_P_H
+#define QWAYLANDXDGPOPUP_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <wayland-client.h>
+
+#include <QtWaylandClient/private/qwayland-xdg-shell.h>
+#include <QtWaylandClient/qwaylandclientexport.h>
+#include "qwaylandshellsurface_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QWindow;
+
+namespace QtWaylandClient {
+
+class QWaylandWindow;
+class QWaylandExtendedSurface;
+
+class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgPopup : public QWaylandShellSurface
+ , public QtWayland::xdg_popup
+{
+ Q_OBJECT
+public:
+ QWaylandXdgPopup(struct ::xdg_popup *popup, QWaylandWindow *window);
+ virtual ~QWaylandXdgPopup();
+
+private:
+ QWaylandExtendedSurface *m_extendedWindow;
+};
+
+QT_END_NAMESPACE
+
+}
+
+#endif // QWAYLANDXDGPOPUP_P_H
diff --git a/src/client/qwaylandxdgshell.cpp b/src/client/qwaylandxdgshell.cpp
index 383129863..6a378b8db 100644
--- a/src/client/qwaylandxdgshell.cpp
+++ b/src/client/qwaylandxdgshell.cpp
@@ -43,6 +43,8 @@
#include "qwaylandwindow_p.h"
#include "qwaylandinputdevice_p.h"
#include "qwaylandscreen_p.h"
+#include "qwaylandxdgpopup_p.h"
+#include "qwaylandxdgsurface_p.h"
#include <QtCore/QDebug>
@@ -66,6 +68,23 @@ QWaylandXdgShell::~QWaylandXdgShell()
xdg_shell_destroy(object());
}
+QWaylandXdgSurface *QWaylandXdgShell::createXdgSurface(QWaylandWindow *window)
+{
+ return new QWaylandXdgSurface(this, window);
+}
+
+QWaylandXdgPopup *QWaylandXdgShell::createXdgPopup(QWaylandWindow *window)
+{
+ QWaylandWindow *parentWindow = window->transientParent();
+ ::wl_surface *parentSurface = parentWindow->object();
+ QWaylandInputDevice *inputDevice = window->display()->lastInputDevice();
+ ::wl_seat *seat = inputDevice->wl_seat();
+ uint serial = inputDevice->serial();
+ QPoint position = window->geometry().topLeft();
+ int x = position.x() + parentWindow->frameMargins().left();
+ int y = position.y() + parentWindow->frameMargins().top();
+ return new QWaylandXdgPopup(get_xdg_popup(window->object(), parentSurface, seat, serial, x, y), window);
+}
void QWaylandXdgShell::xdg_shell_ping(uint32_t serial)
{
diff --git a/src/client/qwaylandxdgshell_p.h b/src/client/qwaylandxdgshell_p.h
index bce8345d0..77b05b462 100644
--- a/src/client/qwaylandxdgshell_p.h
+++ b/src/client/qwaylandxdgshell_p.h
@@ -67,15 +67,19 @@ namespace QtWaylandClient {
class QWaylandWindow;
class QWaylandInputDevice;
+class QWaylandXdgSurface;
+class QWaylandXdgPopup;
class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgShell : public QtWayland::xdg_shell
{
public:
QWaylandXdgShell(struct ::xdg_shell *shell);
QWaylandXdgShell(struct ::wl_registry *registry, uint32_t id);
-
virtual ~QWaylandXdgShell();
+ QWaylandXdgSurface *createXdgSurface(QWaylandWindow *window);
+ QWaylandXdgPopup *createXdgPopup(QWaylandWindow *window);
+
private:
void xdg_shell_ping(uint32_t serial) Q_DECL_OVERRIDE;
};
diff --git a/src/client/qwaylandxdgshellintegration.cpp b/src/client/qwaylandxdgshellintegration.cpp
new file mode 100644
index 000000000..b6b1d9d35
--- /dev/null
+++ b/src/client/qwaylandxdgshellintegration.cpp
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** 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 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandxdgshellintegration_p.h"
+
+#include <QtWaylandClient/private/qwaylandwindow_p.h>
+#include <QtWaylandClient/private/qwaylanddisplay_p.h>
+#include <QtWaylandClient/private/qwaylandxdgsurface_p.h>
+#include <QtWaylandClient/private/qwaylandxdgpopup_p.h>
+#include <QtWaylandClient/private/qwaylandxdgshell_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace QtWaylandClient {
+
+QWaylandXdgShellIntegration::QWaylandXdgShellIntegration(QWaylandDisplay *display)
+ : m_xdgShell(Q_NULLPTR)
+{
+ Q_FOREACH (QWaylandDisplay::RegistryGlobal global, display->globals()) {
+ if (global.interface == QLatin1String("xdg_shell")) {
+ m_xdgShell = new QWaylandXdgShell(display->wl_registry(), global.id);
+ break;
+ }
+ }
+}
+
+QWaylandShellSurface *QWaylandXdgShellIntegration::createShellSurface(QWaylandWindow *window)
+{
+ if (window->window()->type() == Qt::WindowType::Popup)
+ return m_xdgShell->createXdgPopup(window);
+ else
+ return m_xdgShell->createXdgSurface(window);
+}
+
+}
+
+QT_END_NAMESPACE
diff --git a/src/client/qwaylandxdgshellintegration_p.h b/src/client/qwaylandxdgshellintegration_p.h
new file mode 100644
index 000000000..29374ff1d
--- /dev/null
+++ b/src/client/qwaylandxdgshellintegration_p.h
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** 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 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDXDGSHELLINTEGRATION_P_H
+#define QWAYLANDXDGSHELLINTEGRATION_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <wayland-client.h>
+
+#include <QtWaylandClient/private/qwaylandshellintegration_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace QtWaylandClient {
+
+class QWaylandXdgShell;
+
+class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgShellIntegration : public QWaylandShellIntegration
+{
+public:
+ QWaylandXdgShellIntegration(QWaylandDisplay *display);
+ bool initialize(QWaylandDisplay *) Q_DECL_OVERRIDE { return m_xdgShell != Q_NULLPTR; }
+ QWaylandShellSurface *createShellSurface(QWaylandWindow *window) Q_DECL_OVERRIDE;
+
+private:
+ QWaylandXdgShell *m_xdgShell;
+};
+
+}
+
+QT_END_NAMESPACE
+
+#endif // QWAYLANDXDGSHELLINTEGRATION_P_H
diff --git a/src/client/qwaylandxdgsurface.cpp b/src/client/qwaylandxdgsurface.cpp
index 93263e0aa..4f9d8cfbf 100644
--- a/src/client/qwaylandxdgsurface.cpp
+++ b/src/client/qwaylandxdgsurface.cpp
@@ -45,16 +45,18 @@
#include "qwaylandabstractdecoration_p.h"
#include "qwaylandscreen_p.h"
#include "qwaylandextendedsurface_p.h"
+#include "qwaylandxdgshell_p.h"
QT_BEGIN_NAMESPACE
namespace QtWaylandClient {
-QWaylandXdgSurface::QWaylandXdgSurface(struct ::xdg_surface *xdg_surface, QWaylandWindow *window)
+QWaylandXdgSurface::QWaylandXdgSurface(QWaylandXdgShell *shell, QWaylandWindow *window)
: QWaylandShellSurface(window)
- , QtWayland::xdg_surface(xdg_surface)
+ , QtWayland::xdg_surface(shell->get_xdg_surface(window->object()))
, m_window(window)
+ , m_shell(shell)
, m_maximized(false)
, m_minimized(false)
, m_fullscreen(false)
@@ -136,8 +138,7 @@ void QWaylandXdgSurface::updateTransientParent(QWindow *parent)
QWaylandWindow *parent_wayland_window = static_cast<QWaylandWindow *>(parent->handle());
if (!parent_wayland_window)
return;
- QtWayland::xdg_shell *shell = parent_wayland_window->display()->shellXdg();
- set_parent(shell->get_xdg_surface(parent_wayland_window->object()));
+ set_parent(m_shell->get_xdg_surface(parent_wayland_window->object()));
}
void QWaylandXdgSurface::setTitle(const QString & title)
diff --git a/src/client/qwaylandxdgsurface_p.h b/src/client/qwaylandxdgsurface_p.h
index e98aa41e9..1ce029af8 100644
--- a/src/client/qwaylandxdgsurface_p.h
+++ b/src/client/qwaylandxdgsurface_p.h
@@ -69,13 +69,14 @@ namespace QtWaylandClient {
class QWaylandWindow;
class QWaylandInputDevice;
class QWaylandExtendedSurface;
+class QWaylandXdgShell;
class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgSurface : public QWaylandShellSurface
, public QtWayland::xdg_surface
{
Q_OBJECT
public:
- QWaylandXdgSurface(struct ::xdg_surface *shell_surface, QWaylandWindow *window);
+ QWaylandXdgSurface(QWaylandXdgShell *shell, QWaylandWindow *window);
virtual ~QWaylandXdgSurface();
using QtWayland::xdg_surface::resize;
@@ -95,6 +96,8 @@ public:
void setWindowFlags(Qt::WindowFlags flags) Q_DECL_OVERRIDE;
void sendProperty(const QString &name, const QVariant &value) Q_DECL_OVERRIDE;
+ bool shellManagesActiveState() const Q_DECL_OVERRIDE { return true; }
+
bool isFullscreen() const { return m_fullscreen; }
bool isMaximized() const { return m_maximized; }
@@ -109,6 +112,7 @@ private:
private:
QWaylandWindow *m_window;
+ QWaylandXdgShell* m_shell;
bool m_maximized;
bool m_minimized;
bool m_fullscreen;
diff --git a/tests/auto/client/mockcompositor.cpp b/tests/auto/client/mockcompositor.cpp
index 9fe02629d..c00d24bc3 100644
--- a/tests/auto/client/mockcompositor.cpp
+++ b/tests/auto/client/mockcompositor.cpp
@@ -117,6 +117,75 @@ void MockCompositor::sendKeyRelease(const QSharedPointer<MockSurface> &surface,
processCommand(command);
}
+void MockCompositor::sendTouchDown(const QSharedPointer<MockSurface> &surface, const QPoint &position, int id)
+{
+ Command command = makeCommand(Impl::Compositor::sendTouchDown, m_compositor);
+ command.parameters << QVariant::fromValue(surface) << position << id;
+ processCommand(command);
+}
+
+void MockCompositor::sendTouchMotion(const QSharedPointer<MockSurface> &surface, const QPoint &position, int id)
+{
+ Command command = makeCommand(Impl::Compositor::sendTouchMotion, m_compositor);
+ command.parameters << QVariant::fromValue(surface) << position << id;
+ processCommand(command);
+}
+
+void MockCompositor::sendTouchUp(const QSharedPointer<MockSurface> &surface, int id)
+{
+ Command command = makeCommand(Impl::Compositor::sendTouchUp, m_compositor);
+ command.parameters << QVariant::fromValue(surface) << id;
+ processCommand(command);
+}
+
+void MockCompositor::sendTouchFrame(const QSharedPointer<MockSurface> &surface)
+{
+ Command command = makeCommand(Impl::Compositor::sendTouchFrame, m_compositor);
+ command.parameters << QVariant::fromValue(surface);
+ processCommand(command);
+}
+
+void MockCompositor::sendDataDeviceDataOffer(const QSharedPointer<MockSurface> &surface)
+{
+ Command command = makeCommand(Impl::Compositor::sendDataDeviceDataOffer, m_compositor);
+ command.parameters << QVariant::fromValue(surface);
+ processCommand(command);
+}
+
+void MockCompositor::sendDataDeviceEnter(const QSharedPointer<MockSurface> &surface, const QPoint& position)
+{
+ Command command = makeCommand(Impl::Compositor::sendDataDeviceEnter, m_compositor);
+ command.parameters << QVariant::fromValue(surface) << QVariant::fromValue(position);
+ processCommand(command);
+}
+
+void MockCompositor::sendDataDeviceMotion(const QPoint &position)
+{
+ Command command = makeCommand(Impl::Compositor::sendDataDeviceMotion, m_compositor);
+ command.parameters << QVariant::fromValue(position);
+ processCommand(command);
+}
+
+void MockCompositor::sendDataDeviceDrop(const QSharedPointer<MockSurface> &surface)
+{
+ Command command = makeCommand(Impl::Compositor::sendDataDeviceDrop, m_compositor);
+ command.parameters << QVariant::fromValue(surface);
+ processCommand(command);
+}
+
+void MockCompositor::sendDataDeviceLeave(const QSharedPointer<MockSurface> &surface)
+{
+ Command command = makeCommand(Impl::Compositor::sendDataDeviceLeave, m_compositor);
+ command.parameters << QVariant::fromValue(surface);
+ processCommand(command);
+}
+
+void MockCompositor::waitForStartDrag()
+{
+ Command command = makeCommand(Impl::Compositor::waitForStartDrag, m_compositor);
+ processCommand(command);
+}
+
QSharedPointer<MockSurface> MockCompositor::surface()
{
QSharedPointer<MockSurface> result;
@@ -152,9 +221,16 @@ void MockCompositor::processCommand(const Command &command)
void MockCompositor::dispatchCommands()
{
- foreach (const Command &command, m_commandQueue)
+ lock();
+ int count = m_commandQueue.length();
+ unlock();
+
+ for (int i = 0; i < count; ++i) {
+ lock();
+ const Command command = m_commandQueue.takeFirst();
+ unlock();
command.callback(command.target, command.parameters);
- m_commandQueue.clear();
+ }
}
void *MockCompositor::run(void *data)
@@ -172,8 +248,11 @@ void *MockCompositor::run(void *data)
}
while (controller->m_alive) {
- QMutexLocker locker(&controller->m_mutex);
- controller->m_waitCondition.wait(&controller->m_mutex);
+ {
+ QMutexLocker locker(&controller->m_mutex);
+ if (controller->m_commandQueue.isEmpty())
+ controller->m_waitCondition.wait(&controller->m_mutex);
+ }
controller->dispatchCommands();
compositor.dispatchEvents(20);
}
@@ -185,6 +264,7 @@ namespace Impl {
Compositor::Compositor()
: m_display(wl_display_create())
+ , m_startDragSeen(false)
, m_time(0)
{
wl_list_init(&m_outputResources);
@@ -203,6 +283,7 @@ Compositor::Compositor()
m_seat.reset(new Seat(this, m_display));
m_pointer = m_seat->pointer();
m_keyboard = m_seat->keyboard();
+ m_touch = m_seat->touch();
wl_display_add_global(m_display, &wl_output_interface, this, bindOutput);
wl_display_add_global(m_display, &wl_shell_interface, this, bindShell);
diff --git a/tests/auto/client/mockcompositor.h b/tests/auto/client/mockcompositor.h
index 48b410698..dd6450fc9 100644
--- a/tests/auto/client/mockcompositor.h
+++ b/tests/auto/client/mockcompositor.h
@@ -47,6 +47,7 @@ typedef void (**Implementation)(void);
class Keyboard;
class Pointer;
+class Touch;
class Seat;
class DataDeviceManager;
class Surface;
@@ -75,6 +76,19 @@ public:
static void sendMouseRelease(void *data, const QList<QVariant> &parameters);
static void sendKeyPress(void *data, const QList<QVariant> &parameters);
static void sendKeyRelease(void *data, const QList<QVariant> &parameters);
+ static void sendTouchDown(void *data, const QList<QVariant> &parameters);
+ static void sendTouchUp(void *data, const QList<QVariant> &parameters);
+ static void sendTouchMotion(void *data, const QList<QVariant> &parameters);
+ static void sendTouchFrame(void *data, const QList<QVariant> &parameters);
+ static void sendDataDeviceDataOffer(void *data, const QList<QVariant> &parameters);
+ static void sendDataDeviceEnter(void *data, const QList<QVariant> &parameters);
+ static void sendDataDeviceMotion(void *data, const QList<QVariant> &parameters);
+ static void sendDataDeviceDrop(void *data, const QList<QVariant> &parameters);
+ static void sendDataDeviceLeave(void *data, const QList<QVariant> &parameters);
+ static void waitForStartDrag(void *data, const QList<QVariant> &parameters);
+
+public:
+ bool m_startDragSeen;
private:
static void bindCompositor(wl_client *client, void *data, uint32_t version, uint32_t id);
@@ -99,6 +113,7 @@ private:
QScopedPointer<Seat> m_seat;
Pointer *m_pointer;
Keyboard *m_keyboard;
+ Touch *m_touch;
QScopedPointer<DataDeviceManager> m_data_device_manager;
QVector<Surface *> m_surfaces;
};
@@ -141,6 +156,16 @@ public:
void sendMouseRelease(const QSharedPointer<MockSurface> &surface);
void sendKeyPress(const QSharedPointer<MockSurface> &surface, uint code);
void sendKeyRelease(const QSharedPointer<MockSurface> &surface, uint code);
+ void sendTouchDown(const QSharedPointer<MockSurface> &surface, const QPoint &position, int id);
+ void sendTouchMotion(const QSharedPointer<MockSurface> &surface, const QPoint &position, int id);
+ void sendTouchUp(const QSharedPointer<MockSurface> &surface, int id);
+ void sendTouchFrame(const QSharedPointer<MockSurface> &surface);
+ void sendDataDeviceDataOffer(const QSharedPointer<MockSurface> &surface);
+ void sendDataDeviceEnter(const QSharedPointer<MockSurface> &surface, const QPoint &position);
+ void sendDataDeviceMotion(const QPoint &position);
+ void sendDataDeviceDrop(const QSharedPointer<MockSurface> &surface);
+ void sendDataDeviceLeave(const QSharedPointer<MockSurface> &surface);
+ void waitForStartDrag();
QSharedPointer<MockSurface> surface();
diff --git a/tests/auto/client/mockinput.cpp b/tests/auto/client/mockinput.cpp
index a4d42c103..fe06bf79b 100644
--- a/tests/auto/client/mockinput.cpp
+++ b/tests/auto/client/mockinput.cpp
@@ -87,11 +87,128 @@ void Compositor::sendKeyRelease(void *data, const QList<QVariant> &parameters)
compositor->m_keyboard->sendKey(parameters.last().toUInt() - 8, 0);
}
+void Compositor::sendTouchDown(void *data, const QList<QVariant> &parameters)
+{
+ Compositor *compositor = static_cast<Compositor *>(data);
+ Surface *surface = resolveSurface(parameters.first());
+
+ Q_ASSERT(compositor);
+ Q_ASSERT(surface);
+
+ QPoint position = parameters.at(1).toPoint();
+ int id = parameters.at(2).toInt();
+
+ compositor->m_touch->sendDown(surface, position, id);
+}
+
+void Compositor::sendTouchUp(void *data, const QList<QVariant> &parameters)
+{
+ Compositor *compositor = static_cast<Compositor *>(data);
+ Surface *surface = resolveSurface(parameters.first());
+
+ Q_ASSERT(compositor);
+ Q_ASSERT(surface);
+
+ int id = parameters.at(1).toInt();
+
+ compositor->m_touch->sendUp(surface, id);
+}
+
+void Compositor::sendTouchMotion(void *data, const QList<QVariant> &parameters)
+{
+ Compositor *compositor = static_cast<Compositor *>(data);
+ Surface *surface = resolveSurface(parameters.first());
+
+ Q_ASSERT(compositor);
+ Q_ASSERT(surface);
+
+ QPoint position = parameters.at(1).toPoint();
+ int id = parameters.at(2).toInt();
+
+ compositor->m_touch->sendMotion(surface, position, id);
+}
+
+void Compositor::sendTouchFrame(void *data, const QList<QVariant> &parameters)
+{
+ Compositor *compositor = static_cast<Compositor *>(data);
+ Surface *surface = resolveSurface(parameters.first());
+
+ Q_ASSERT(compositor);
+ Q_ASSERT(surface);
+
+ compositor->m_touch->sendFrame(surface);
+}
+
+void Compositor::sendDataDeviceDataOffer(void *data, const QList<QVariant> &parameters)
+{
+ Compositor *compositor = static_cast<Compositor *>(data);
+ Surface *surface = resolveSurface(parameters.first());
+
+ Q_ASSERT(compositor);
+ Q_ASSERT(surface);
+
+ compositor->m_data_device_manager->dataDevice()->sendDataOffer(surface->resource()->client());
+}
+
+void Compositor::sendDataDeviceEnter(void *data, const QList<QVariant> &parameters)
+{
+ Compositor *compositor = static_cast<Compositor *>(data);
+ Surface *surface = resolveSurface(parameters.first());
+ QPoint position = parameters.at(1).toPoint();
+
+ Q_ASSERT(compositor);
+ Q_ASSERT(surface);
+
+ compositor->m_data_device_manager->dataDevice()->sendEnter(surface, position);
+}
+
+void Compositor::sendDataDeviceMotion(void *data, const QList<QVariant> &parameters)
+{
+ Compositor *compositor = static_cast<Compositor *>(data);
+ Q_ASSERT(compositor);
+ QPoint position = parameters.first().toPoint();
+ compositor->m_data_device_manager->dataDevice()->sendMotion(position);
+}
+
+void Compositor::sendDataDeviceDrop(void *data, const QList<QVariant> &parameters)
+{
+ Compositor *compositor = static_cast<Compositor *>(data);
+ Surface *surface = resolveSurface(parameters.first());
+
+ Q_ASSERT(compositor);
+ Q_ASSERT(surface);
+
+ compositor->m_data_device_manager->dataDevice()->sendDrop(surface);
+}
+
+void Compositor::sendDataDeviceLeave(void *data, const QList<QVariant> &parameters)
+{
+ Compositor *compositor = static_cast<Compositor *>(data);
+ Surface *surface = resolveSurface(parameters.first());
+
+ Q_ASSERT(compositor);
+ Q_ASSERT(surface);
+
+ compositor->m_data_device_manager->dataDevice()->sendLeave(surface);
+}
+
+void Compositor::waitForStartDrag(void *data, const QList<QVariant> &parameters)
+{
+ Compositor *compositor = static_cast<Compositor *>(data);
+ Q_ASSERT(compositor);
+ while (!compositor->m_startDragSeen) {
+ wl_display_flush_clients(compositor->m_display);
+ wl_event_loop_dispatch(compositor->m_loop, 100);
+ }
+ compositor->m_startDragSeen = false;
+}
+
Seat::Seat(Compositor *compositor, struct ::wl_display *display)
: wl_seat(display, 2)
, m_compositor(compositor)
, m_keyboard(new Keyboard(compositor))
, m_pointer(new Pointer(compositor))
+ , m_touch(new Touch(compositor))
{
}
@@ -101,7 +218,7 @@ Seat::~Seat()
void Seat::seat_bind_resource(Resource *resource)
{
- send_capabilities(resource->handle, capability_keyboard | capability_pointer);
+ send_capabilities(resource->handle, capability_keyboard | capability_pointer | capability_touch);
}
void Seat::seat_get_keyboard(Resource *resource, uint32_t id)
@@ -114,6 +231,11 @@ void Seat::seat_get_pointer(Resource *resource, uint32_t id)
m_pointer->add(resource->client(), id, resource->version());
}
+void Seat::seat_get_touch(Resource *resource, uint32_t id)
+{
+ m_touch->add(resource->client(), id, resource->version());
+}
+
Keyboard::Keyboard(Compositor *compositor)
: wl_keyboard()
, m_compositor(compositor)
@@ -214,18 +336,100 @@ void Pointer::pointer_destroy_resource(wl_pointer::Resource *resource)
m_focusResource = 0;
}
+Touch::Touch(Compositor *compositor)
+ : wl_touch()
+ , m_compositor(compositor)
+{
+}
+
+void Touch::sendDown(Surface *surface, const QPoint &position, int id)
+{
+ uint32_t serial = m_compositor->nextSerial();
+ uint32_t time = m_compositor->time();
+ Q_ASSERT(surface);
+ Resource *resource = resourceMap().value(surface->resource()->client());
+ Q_ASSERT(resource);
+ wl_touch_send_down(resource->handle, serial, time, surface->resource()->handle, id, position.x(), position.y());
+}
+
+void Touch::sendUp(Surface *surface, int id)
+{
+ Resource *resource = resourceMap().value(surface->resource()->client());
+ wl_touch_send_up(resource->handle, m_compositor->nextSerial(), m_compositor->time(), id);
+}
+
+void Touch::sendMotion(Surface *surface, const QPoint &position, int id)
+{
+ Resource *resource = resourceMap().value(surface->resource()->client());
+ uint32_t time = m_compositor->time();
+ wl_touch_send_motion(resource->handle, time, id, position.x(), position.y());
+}
+
+void Touch::sendFrame(Surface *surface)
+{
+ Resource *resource = resourceMap().value(surface->resource()->client());
+ wl_touch_send_frame(resource->handle);
+}
+
+DataOffer::DataOffer()
+ : wl_data_offer()
+{
+
+}
+
DataDevice::DataDevice(Compositor *compositor)
: wl_data_device()
, m_compositor(compositor)
+ , m_dataOffer(nullptr)
+ , m_focus(nullptr)
{
}
+void DataDevice::sendDataOffer(wl_client *client)
+{
+ m_dataOffer = new QtWaylandServer::wl_data_offer(client, 0, 1);
+ Resource *resource = resourceMap().value(client);
+ send_data_offer(resource->handle, m_dataOffer->resource()->handle);
+}
+
+void DataDevice::sendEnter(Surface *surface, const QPoint& position)
+{
+ uint serial = m_compositor->nextSerial();
+ m_focus = surface;
+ Resource *resource = resourceMap().value(surface->resource()->client());
+ send_enter(resource->handle, serial, surface->resource()->handle, position.x(), position.y(), m_dataOffer->resource()->handle);
+}
+
+void DataDevice::sendMotion(const QPoint &position)
+{
+ uint32_t time = m_compositor->time();
+ Resource *resource = resourceMap().value(m_focus->resource()->client());
+ send_motion(resource->handle, time, position.x(), position.y());
+}
+
+void DataDevice::sendDrop(Surface *surface)
+{
+ Resource *resource = resourceMap().value(surface->resource()->client());
+ send_drop(resource->handle);
+}
+
+void DataDevice::sendLeave(Surface *surface)
+{
+ Resource *resource = resourceMap().value(surface->resource()->client());
+ send_leave(resource->handle);
+}
+
DataDevice::~DataDevice()
{
}
+void DataDevice::data_device_start_drag(QtWaylandServer::wl_data_device::Resource *resource, wl_resource *source, wl_resource *origin, wl_resource *icon, uint32_t serial)
+{
+ m_compositor->m_startDragSeen = true;
+}
+
DataDeviceManager::DataDeviceManager(Compositor *compositor, wl_display *display)
: wl_data_device_manager(display, 1)
, m_compositor(compositor)
@@ -238,6 +442,11 @@ DataDeviceManager::~DataDeviceManager()
}
+DataDevice *DataDeviceManager::dataDevice() const
+{
+ return m_data_device.data();
+}
+
void DataDeviceManager::data_device_manager_get_data_device(Resource *resource, uint32_t id, struct ::wl_resource *seat)
{
if (!m_data_device)
@@ -245,4 +454,9 @@ void DataDeviceManager::data_device_manager_get_data_device(Resource *resource,
m_data_device->add(resource->client(), id, 1);
}
+void DataDeviceManager::data_device_manager_create_data_source(QtWaylandServer::wl_data_device_manager::Resource *resource, uint32_t id)
+{
+ new QtWaylandServer::wl_data_source(resource->client(), id, 1);
+}
+
}
diff --git a/tests/auto/client/mockinput.h b/tests/auto/client/mockinput.h
index eb9beb564..031be2a4a 100644
--- a/tests/auto/client/mockinput.h
+++ b/tests/auto/client/mockinput.h
@@ -51,17 +51,20 @@ public:
Keyboard *keyboard() const { return m_keyboard.data(); }
Pointer *pointer() const { return m_pointer.data(); }
+ Touch *touch() const { return m_touch.data(); }
protected:
void seat_bind_resource(Resource *resource) Q_DECL_OVERRIDE;
void seat_get_keyboard(Resource *resource, uint32_t id) Q_DECL_OVERRIDE;
void seat_get_pointer(Resource *resource, uint32_t id) Q_DECL_OVERRIDE;
+ void seat_get_touch(Resource *resource, uint32_t id) Q_DECL_OVERRIDE;
private:
Compositor *m_compositor;
QScopedPointer<Keyboard> m_keyboard;
QScopedPointer<Pointer> m_pointer;
+ QScopedPointer<Touch> m_touch;
};
class Keyboard : public QtWaylandServer::wl_keyboard
@@ -107,14 +110,42 @@ private:
Surface *m_focus;
};
+class Touch : public QtWaylandServer::wl_touch
+{
+public:
+ Touch(Compositor *compositor);
+ void sendDown(Surface *surface, const QPoint &position, int id);
+ void sendUp(Surface *surface, int id);
+ void sendMotion(Surface *surface, const QPoint &position, int id);
+ void sendFrame(Surface *surface);
+private:
+ Compositor *m_compositor;
+};
+
+class DataOffer : public QtWaylandServer::wl_data_offer
+{
+public:
+ DataOffer();
+};
+
class DataDevice : public QtWaylandServer::wl_data_device
{
public:
DataDevice(Compositor *compositor);
+ void sendDataOffer(wl_client *client);
+ void sendEnter(Surface *surface, const QPoint &position);
+ void sendMotion(const QPoint &position);
+ void sendDrop(Surface *surface);
+ void sendLeave(Surface *surface);
~DataDevice();
+protected:
+ void data_device_start_drag(Resource *resource, struct ::wl_resource *source, struct ::wl_resource *origin, struct ::wl_resource *icon, uint32_t serial) override;
+
private:
Compositor *m_compositor;
+ QtWaylandServer::wl_data_offer *m_dataOffer;
+ Surface* m_focus;
};
class DataDeviceManager : public QtWaylandServer::wl_data_device_manager
@@ -122,9 +153,11 @@ class DataDeviceManager : public QtWaylandServer::wl_data_device_manager
public:
DataDeviceManager(Compositor *compositor, struct ::wl_display *display);
~DataDeviceManager();
+ DataDevice *dataDevice() const;
protected:
void data_device_manager_get_data_device(Resource *resource, uint32_t id, struct ::wl_resource *seat) Q_DECL_OVERRIDE;
+ void data_device_manager_create_data_source(Resource *resource, uint32_t id) override;
private:
Compositor *m_compositor;
diff --git a/tests/auto/client/tst_client.cpp b/tests/auto/client/tst_client.cpp
index 9635c215f..74363ef5f 100644
--- a/tests/auto/client/tst_client.cpp
+++ b/tests/auto/client/tst_client.cpp
@@ -31,6 +31,10 @@
#include <QBackingStore>
#include <QPainter>
#include <QScreen>
+#include <QWindow>
+#include <QMimeData>
+#include <QPixmap>
+#include <QDrag>
#include <QtTest/QtTest>
@@ -46,6 +50,7 @@ public:
, keyReleaseEventCount(0)
, mousePressEventCount(0)
, mouseReleaseEventCount(0)
+ , touchEventCount(0)
, keyCode(0)
{
setSurfaceType(QSurface::RasterSurface);
@@ -86,12 +91,18 @@ public:
++mouseReleaseEventCount;
}
+ void touchEvent(QTouchEvent *event) Q_DECL_OVERRIDE
+ {
+ ++touchEventCount;
+ }
+
int focusInEventCount;
int focusOutEventCount;
int keyPressEventCount;
int keyReleaseEventCount;
int mousePressEventCount;
int mouseReleaseEventCount;
+ int touchEventCount;
uint keyCode;
QPoint mousePressPos;
@@ -129,6 +140,8 @@ private slots:
void createDestroyWindow();
void events();
void backingStore();
+ void touchDrag();
+ void mouseDrag();
private:
MockCompositor *compositor;
@@ -192,6 +205,15 @@ void tst_WaylandClient::events()
QCOMPARE(window.mouseReleaseEventCount, 0);
compositor->sendMouseRelease(surface);
QTRY_COMPARE(window.mouseReleaseEventCount, 1);
+
+ const int touchId = 0;
+ compositor->sendTouchDown(surface, QPoint(10, 10), touchId);
+ compositor->sendTouchFrame(surface);
+ QTRY_COMPARE(window.touchEventCount, 1);
+
+ compositor->sendTouchUp(surface, touchId);
+ compositor->sendTouchFrame(surface);
+ QTRY_COMPARE(window.touchEventCount, 2);
}
void tst_WaylandClient::backingStore()
@@ -230,6 +252,86 @@ void tst_WaylandClient::backingStore()
QTRY_VERIFY(surface->image.isNull());
}
+class DndWindow : public QWindow
+{
+ Q_OBJECT
+
+public:
+ DndWindow(QWindow *parent = 0)
+ : QWindow(parent)
+ , dragStarted(false)
+ {
+ QImage cursorImage(64,64,QImage::Format_ARGB32);
+ cursorImage.fill(Qt::blue);
+ m_dragIcon = QPixmap::fromImage(cursorImage);
+ }
+ ~DndWindow(){}
+ bool dragStarted;
+
+protected:
+ void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE
+ {
+ if (dragStarted)
+ return;
+ dragStarted = true;
+
+ QByteArray dataBytes;
+ QMimeData *mimeData = new QMimeData;
+ mimeData->setData("application/x-dnditemdata", dataBytes);
+ QDrag *drag = new QDrag(this);
+ drag->setMimeData(mimeData);
+ drag->setPixmap(m_dragIcon);
+ drag->exec(Qt::CopyAction | Qt::MoveAction, Qt::CopyAction);
+ }
+private:
+ QPixmap m_dragIcon;
+};
+
+void tst_WaylandClient::touchDrag()
+{
+ DndWindow window;
+ window.show();
+
+ QSharedPointer<MockSurface> surface;
+ QTRY_VERIFY(surface = compositor->surface());
+
+ compositor->setKeyboardFocus(surface);
+ QTRY_COMPARE(QGuiApplication::focusWindow(), &window);
+
+ const int id = 0;
+ compositor->sendTouchDown(surface, QPoint(10, 10), id);
+ compositor->sendTouchMotion(surface, QPoint(20, 20), id);
+ compositor->sendTouchFrame(surface);
+ compositor->waitForStartDrag();
+ compositor->sendDataDeviceDataOffer(surface);
+ compositor->sendDataDeviceEnter(surface, QPoint(20, 20));
+ compositor->sendDataDeviceMotion( QPoint(21, 21));
+ compositor->sendDataDeviceDrop(surface);
+ compositor->sendDataDeviceLeave(surface);
+ QTRY_VERIFY(window.dragStarted);
+}
+
+void tst_WaylandClient::mouseDrag()
+{
+ DndWindow window;
+ window.show();
+
+ QSharedPointer<MockSurface> surface;
+ QTRY_VERIFY(surface = compositor->surface());
+
+ compositor->setKeyboardFocus(surface);
+ QTRY_COMPARE(QGuiApplication::focusWindow(), &window);
+
+ compositor->sendMousePress(surface, QPoint(10, 10));
+ compositor->sendDataDeviceDataOffer(surface);
+ compositor->sendDataDeviceEnter(surface, QPoint(20, 20));
+ compositor->sendDataDeviceMotion( QPoint(21, 21));
+ compositor->waitForStartDrag();
+ compositor->sendDataDeviceDrop(surface);
+ compositor->sendDataDeviceLeave(surface);
+ QTRY_VERIFY(window.dragStarted);
+}
+
int main(int argc, char **argv)
{
setenv("XDG_RUNTIME_DIR", ".", 1);