Merge remote-tracking branch 'qt/5.7' into 5.8
Conflicts: src/compositor/compositor_api/qwaylandseat.cpp src/compositor/compositor_api/qwaylandview.cpp tests/auto/compositor/compositor.pro tests/auto/compositor/compositor/testinputdevice.cpp tests/auto/compositor/compositor/testinputdevice.h tests/auto/compositor/testinputdevice.cpp tests/auto/compositor/testinputdevice.h tests/auto/compositor/testseat.cpp tests/auto/compositor/testseat.h Change-Id: I98e045908dd964e5d4120bd35e71b8839c0d923a
This commit is contained in:
commit
673cdbe1e0
@ -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 \
|
||||
|
@ -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) {
|
||||
|
@ -84,16 +84,8 @@ struct wl_surface *QWaylandDisplay::createSurface(void *handle)
|
||||
|
||||
QWaylandShellSurface *QWaylandDisplay::createShellSurface(QWaylandWindow *window)
|
||||
{
|
||||
if (mWaylandIntegration->shellIntegration())
|
||||
Q_ASSERT(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;
|
||||
}
|
||||
|
||||
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,13 +409,16 @@ void QWaylandDisplay::handleKeyboardFocusChanged(QWaylandInputDevice *inputDevic
|
||||
{
|
||||
QWaylandWindow *keyboardFocus = inputDevice->keyboardFocus();
|
||||
|
||||
if (!shellManagesActiveState() && mLastKeyboardFocus != keyboardFocus) {
|
||||
if (keyboardFocus)
|
||||
if (mLastKeyboardFocus == keyboardFocus)
|
||||
return;
|
||||
|
||||
if (keyboardFocus && !keyboardFocus->shellManagesActiveState())
|
||||
handleWindowActivated(keyboardFocus);
|
||||
if (mLastKeyboardFocus)
|
||||
|
||||
if (mLastKeyboardFocus && !mLastKeyboardFocus->shellManagesActiveState())
|
||||
handleWindowDeactivated(mLastKeyboardFocus);
|
||||
}
|
||||
mLastKeyboardFocus = inputDevice->keyboardFocus();
|
||||
|
||||
mLastKeyboardFocus = keyboardFocus;
|
||||
}
|
||||
|
||||
void QWaylandDisplay::handleWaylandSync()
|
||||
|
@ -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;
|
||||
|
@ -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());
|
||||
}
|
||||
if (mShellIntegration && mShellIntegration->initialize(mDisplay)) {
|
||||
qDebug("Using the '%s' shell integration", qPrintable(targetKey));
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
|
@ -121,6 +121,7 @@ private:
|
||||
void initializeServerBufferIntegration();
|
||||
void initializeShellIntegration();
|
||||
void initializeInputDeviceIntegration();
|
||||
QWaylandShellIntegration *createShellIntegration(const QString& interfaceName);
|
||||
|
||||
QPlatformFontDatabase *mFontDb;
|
||||
QPlatformClipboard *mClipboard;
|
||||
|
@ -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; }
|
||||
|
||||
|
@ -527,6 +527,11 @@ QWaylandSubSurface *QWaylandWindow::subSurfaceWindow() const
|
||||
return mSubSurfaceWindow;
|
||||
}
|
||||
|
||||
bool QWaylandWindow::shellManagesActiveState() const
|
||||
{
|
||||
return mShellSurface && mShellSurface->shellManagesActiveState();
|
||||
}
|
||||
|
||||
void QWaylandWindow::handleContentOrientationChange(Qt::ScreenOrientation orientation)
|
||||
{
|
||||
if (mDisplay->compositorVersion() < 2)
|
||||
|
@ -142,6 +142,8 @@ public:
|
||||
QWaylandSubSurface *subSurfaceWindow() const;
|
||||
QWaylandScreen *screen() const { return mScreen; }
|
||||
|
||||
bool shellManagesActiveState() const;
|
||||
|
||||
void handleContentOrientationChange(Qt::ScreenOrientation orientation) Q_DECL_OVERRIDE;
|
||||
void setOrientationMask(Qt::ScreenOrientations mask);
|
||||
|
||||
|
62
src/plugins/platforms/wayland/qwaylandwlshellintegration.cpp
Normal file
62
src/plugins/platforms/wayland/qwaylandwlshellintegration.cpp
Normal file
@ -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
|
72
src/plugins/platforms/wayland/qwaylandwlshellintegration_p.h
Normal file
72
src/plugins/platforms/wayland/qwaylandwlshellintegration_p.h
Normal file
@ -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
|
@ -157,6 +157,13 @@ void QWaylandWlShellSurface::setTopLevel()
|
||||
set_toplevel();
|
||||
}
|
||||
|
||||
static inline bool testShowWithoutActivating(const QWindow *window)
|
||||
{
|
||||
// QWidget-attribute Qt::WA_ShowWithoutActivating.
|
||||
const QVariant showWithoutActivating = window->property("_q_showWithoutActivating");
|
||||
return showWithoutActivating.isValid() && showWithoutActivating.toBool();
|
||||
}
|
||||
|
||||
void QWaylandWlShellSurface::updateTransientParent(QWindow *parent)
|
||||
{
|
||||
QWaylandWindow *parent_wayland_window = static_cast<QWaylandWindow *>(parent->handle());
|
||||
@ -174,7 +181,8 @@ void QWaylandWlShellSurface::updateTransientParent(QWindow *parent)
|
||||
uint32_t flags = 0;
|
||||
Qt::WindowFlags wf = m_window->window()->flags();
|
||||
if (wf.testFlag(Qt::ToolTip)
|
||||
|| wf.testFlag(Qt::WindowTransparentForInput))
|
||||
|| wf.testFlag(Qt::WindowTransparentForInput)
|
||||
|| testShowWithoutActivating(m_window->window()))
|
||||
flags |= WL_SHELL_SURFACE_TRANSIENT_INACTIVE;
|
||||
|
||||
set_transient(parent_wayland_window->object(),
|
||||
|
61
src/plugins/platforms/wayland/qwaylandxdgpopup_p.cpp
Normal file
61
src/plugins/platforms/wayland/qwaylandxdgpopup_p.cpp
Normal file
@ -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
|
79
src/plugins/platforms/wayland/qwaylandxdgpopup_p.h
Normal file
79
src/plugins/platforms/wayland/qwaylandxdgpopup_p.h
Normal file
@ -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
|
@ -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)
|
||||
{
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -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
|
@ -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
|
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -1,25 +1,3 @@
|
||||
CONFIG += testcase link_pkgconfig
|
||||
TARGET = tst_client
|
||||
TEMPLATE=subdirs
|
||||
|
||||
QT += testlib
|
||||
QT += core-private gui-private
|
||||
|
||||
!contains(QT_CONFIG, no-pkg-config) {
|
||||
PKGCONFIG += wayland-client wayland-server
|
||||
} else {
|
||||
LIBS += -lwayland-client -lwayland-server
|
||||
}
|
||||
|
||||
CONFIG += wayland-scanner
|
||||
WAYLANDSERVERSOURCES += \
|
||||
../../../src/3rdparty/protocol/wayland.xml
|
||||
|
||||
SOURCES += tst_client.cpp \
|
||||
mockcompositor.cpp \
|
||||
mockinput.cpp \
|
||||
mockshell.cpp \
|
||||
mocksurface.cpp \
|
||||
mockoutput.cpp
|
||||
HEADERS += mockcompositor.h \
|
||||
mockinput.h \
|
||||
mocksurface.h \
|
||||
SUBDIRS += client
|
||||
|
28
tests/auto/wayland/client/client.pro
Normal file
28
tests/auto/wayland/client/client.pro
Normal file
@ -0,0 +1,28 @@
|
||||
CONFIG += testcase link_pkgconfig
|
||||
TARGET = tst_client
|
||||
|
||||
QT += testlib
|
||||
QT += core-private gui-private
|
||||
|
||||
!contains(QT_CONFIG, no-pkg-config) {
|
||||
PKGCONFIG += wayland-client wayland-server
|
||||
} else {
|
||||
LIBS += -lwayland-client -lwayland-server
|
||||
}
|
||||
|
||||
CONFIG += wayland-scanner
|
||||
WAYLANDSERVERSOURCES += \
|
||||
../../../../src/3rdparty/protocol/wayland.xml
|
||||
|
||||
SOURCES += \
|
||||
tst_client.cpp \
|
||||
mockcompositor.cpp \
|
||||
mockinput.cpp \
|
||||
mockshell.cpp \
|
||||
mocksurface.cpp \
|
||||
mockoutput.cpp
|
||||
|
||||
HEADERS += \
|
||||
mockcompositor.h \
|
||||
mockinput.h \
|
||||
mocksurface.h
|
@ -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);
|
||||
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_global_create(m_display, &wl_output_interface, 1, this, bindOutput);
|
||||
wl_global_create(m_display, &wl_shell_interface, 1, this, bindShell);
|
@ -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> ¶meters);
|
||||
static void sendKeyPress(void *data, const QList<QVariant> ¶meters);
|
||||
static void sendKeyRelease(void *data, const QList<QVariant> ¶meters);
|
||||
static void sendTouchDown(void *data, const QList<QVariant> ¶meters);
|
||||
static void sendTouchUp(void *data, const QList<QVariant> ¶meters);
|
||||
static void sendTouchMotion(void *data, const QList<QVariant> ¶meters);
|
||||
static void sendTouchFrame(void *data, const QList<QVariant> ¶meters);
|
||||
static void sendDataDeviceDataOffer(void *data, const QList<QVariant> ¶meters);
|
||||
static void sendDataDeviceEnter(void *data, const QList<QVariant> ¶meters);
|
||||
static void sendDataDeviceMotion(void *data, const QList<QVariant> ¶meters);
|
||||
static void sendDataDeviceDrop(void *data, const QList<QVariant> ¶meters);
|
||||
static void sendDataDeviceLeave(void *data, const QList<QVariant> ¶meters);
|
||||
static void waitForStartDrag(void *data, const QList<QVariant> ¶meters);
|
||||
|
||||
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();
|
||||
|
@ -87,11 +87,128 @@ void Compositor::sendKeyRelease(void *data, const QList<QVariant> ¶meters)
|
||||
compositor->m_keyboard->sendKey(parameters.last().toUInt() - 8, 0);
|
||||
}
|
||||
|
||||
void Compositor::sendTouchDown(void *data, const QList<QVariant> ¶meters)
|
||||
{
|
||||
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> ¶meters)
|
||||
{
|
||||
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> ¶meters)
|
||||
{
|
||||
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> ¶meters)
|
||||
{
|
||||
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> ¶meters)
|
||||
{
|
||||
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> ¶meters)
|
||||
{
|
||||
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> ¶meters)
|
||||
{
|
||||
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> ¶meters)
|
||||
{
|
||||
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> ¶meters)
|
||||
{
|
||||
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> ¶meters)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
@ -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;
|
@ -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);
|
Loading…
x
Reference in New Issue
Block a user