diff options
65 files changed, 1254 insertions, 289 deletions
diff --git a/examples/wayland/qwindow-compositor/compositor.cpp b/examples/wayland/qwindow-compositor/compositor.cpp index 13e5718d2..d9f850424 100644 --- a/examples/wayland/qwindow-compositor/compositor.cpp +++ b/examples/wayland/qwindow-compositor/compositor.cpp @@ -456,8 +456,10 @@ void Compositor::handleDrag(View *target, QMouseEvent *me) } QWaylandDrag *currentDrag = defaultSeat()->drag(); currentDrag->dragMove(surface, pos); - if (me->buttons() == Qt::NoButton) + if (me->buttons() == Qt::NoButton) { + m_views.removeOne(findView(currentDrag->icon())); currentDrag->drop(); + } } // We only have a flat list of views, plus pointers from child to parent, diff --git a/src/client/client.pro b/src/client/client.pro index 63012c127..fa2036745 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..a5e61e28a 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,13 +409,16 @@ void QWaylandDisplay::handleKeyboardFocusChanged(QWaylandInputDevice *inputDevic { QWaylandWindow *keyboardFocus = inputDevice->keyboardFocus(); - if (!shellManagesActiveState() && mLastKeyboardFocus != keyboardFocus) { - if (keyboardFocus) - handleWindowActivated(keyboardFocus); - if (mLastKeyboardFocus) - handleWindowDeactivated(mLastKeyboardFocus); - } - mLastKeyboardFocus = inputDevice->keyboardFocus(); + if (mLastKeyboardFocus == keyboardFocus) + return; + + if (keyboardFocus && !keyboardFocus->shellManagesActiveState()) + handleWindowActivated(keyboardFocus); + + if (mLastKeyboardFocus && !mLastKeyboardFocus->shellManagesActiveState()) + handleWindowDeactivated(mLastKeyboardFocus); + + mLastKeyboardFocus = keyboardFocus; } void QWaylandDisplay::handleWaylandSync() 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/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp index 51cf20a72..9cbc6e231 100644 --- a/src/client/qwaylandwindow.cpp +++ b/src/client/qwaylandwindow.cpp @@ -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) diff --git a/src/client/qwaylandwindow_p.h b/src/client/qwaylandwindow_p.h index c2aa1a501..82898152c 100644 --- a/src/client/qwaylandwindow_p.h +++ b/src/client/qwaylandwindow_p.h @@ -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); 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/qwaylandwlshellsurface.cpp b/src/client/qwaylandwlshellsurface.cpp index 5aae260ce..3527015c7 100644 --- a/src/client/qwaylandwlshellsurface.cpp +++ b/src/client/qwaylandwlshellsurface.cpp @@ -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(), 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/src/compositor/compositor_api/qwaylandbufferref.cpp b/src/compositor/compositor_api/qwaylandbufferref.cpp index a00bbcdd9..7cc17fcbe 100644 --- a/src/compositor/compositor_api/qwaylandbufferref.cpp +++ b/src/compositor/compositor_api/qwaylandbufferref.cpp @@ -56,7 +56,7 @@ public: * \class QWaylandBufferRef * \inmodule QtWaylandCompositor * \preliminary - * \brief A class which holds a reference to a surface buffer + * \brief The QWaylandBufferRef class holds the reference to a surface buffer * * This class can be used to reference a surface buffer. As long as a reference * to the buffer exists, it is owned by the compositor and the client cannot modify it. diff --git a/src/compositor/compositor_api/qwaylandclient.cpp b/src/compositor/compositor_api/qwaylandclient.cpp index 0b21bcd63..23c3745d7 100644 --- a/src/compositor/compositor_api/qwaylandclient.cpp +++ b/src/compositor/compositor_api/qwaylandclient.cpp @@ -88,7 +88,7 @@ public: * \qmltype WaylandClient * \inqmlmodule QtWayland.Compositor * \preliminary - * \brief A client connecting to the WaylandCompositor. + * \brief Represents a client connecting to the WaylandCompositor. * * This type represents a client connecting to the compositor using the Wayland protocol. * It corresponds to the Wayland interface wl_client. @@ -98,7 +98,7 @@ public: * \class QWaylandClient * \inmodule QtWaylandCompositor * \preliminary - * \brief A client connecting to the QWaylandCompositor. + * \brief The QWaylandClient class represents a client connecting to the QWaylandCompositor. * * This class corresponds to a client connecting to the compositor using the Wayland protocol. * It corresponds to the Wayland interface wl_client. @@ -199,6 +199,7 @@ wl_client *QWaylandClient::client() const /*! * \property QWaylandClient::userId + * \readonly * * This property holds the user id of this QWaylandClient. */ @@ -211,6 +212,7 @@ qint64 QWaylandClient::userId() const /*! * \qmlproperty int QtWaylandCompositor::WaylandClient::groupId + * \readonly * * This property holds the group id of this WaylandClient. */ @@ -229,6 +231,7 @@ qint64 QWaylandClient::groupId() const /*! * \qmlproperty int QtWaylandCompositor::WaylandClient::processId + * \readonly * * This property holds the process id of this WaylandClient. */ diff --git a/src/compositor/compositor_api/qwaylandcompositor.cpp b/src/compositor/compositor_api/qwaylandcompositor.cpp index 0feba9857..391b39416 100644 --- a/src/compositor/compositor_api/qwaylandcompositor.cpp +++ b/src/compositor/compositor_api/qwaylandcompositor.cpp @@ -408,7 +408,7 @@ void QWaylandCompositorPrivate::loadServerBufferIntegration() \qmltype WaylandCompositor \inqmlmodule QtWayland.Compositor \preliminary - \brief Type managing the Wayland display server. + \brief Manages the Wayland display server. The WaylandCompositor manages the connections to the clients, as well as the different \l{WaylandOutput}{outputs} and \l{QWaylandSeat}{seats}. @@ -427,7 +427,7 @@ void QWaylandCompositorPrivate::loadServerBufferIntegration() \class QWaylandCompositor \inmodule QtWaylandCompositor \preliminary - \brief Class managing the Wayland display server. + \brief The QWaylandCompositor class manages the Wayland display server. The QWaylandCompositor manages the connections to the clients, as well as the different \l{QWaylandOutput}{outputs} and \l{QWaylandSeat}{seats}. @@ -486,9 +486,8 @@ bool QWaylandCompositor::isCreated() const * clients. It must be set before the component is completed. * * If the socketName is empty (the default), the contents of the start argument - * --wayland-socket-name is used instead. If this is not set, then the compositor - * will try to find a socket name automatically, which in the default case will - * be "wayland-0". + * \c --wayland-socket-name are used instead. If the argument is not set, the + * compositor tries to find a socket name, which is \c{wayland-0} by default. */ /*! @@ -498,9 +497,8 @@ bool QWaylandCompositor::isCreated() const * clients. This must be set before the QWaylandCompositor is \l{create()}{created}. * * If the socketName is empty (the default), the contents of the start argument - * --wayland-socket-name is used instead. If this is not set, then the compositor - * will try to find a socket name automatically, which in the default case will - * be "wayland-0". + * \c --wayland-socket-name are used instead. If the argument is not set, the + * compositor tries to find a socket name, which is \c{wayland-0} by default. */ void QWaylandCompositor::setSocketName(const QByteArray &name) { @@ -844,11 +842,11 @@ void QWaylandCompositor::setUseHardwareIntegrationExtension(bool use) /*! * Grab the surface content from the given \a buffer. * The default implementation requires a OpenGL context to be bound to the current thread - * to work. If this is not possible reimplement this function in your compositor subclass + * to work. If this is not possible, reimplement this function in your compositor subclass * to implement custom logic. * The default implementation only grabs shared memory and OpenGL buffers, reimplement this in your * compositor subclass to handle more buffer types. - * You should not call this manually, but rather use QWaylandSurfaceGrabber (\a grabber). + * \note You should not call this manually, but rather use QWaylandSurfaceGrabber (\a grabber). */ void QWaylandCompositor::grabSurface(QWaylandSurfaceGrabber *grabber, const QWaylandBufferRef &buffer) { diff --git a/src/compositor/compositor_api/qwaylandkeyboard.cpp b/src/compositor/compositor_api/qwaylandkeyboard.cpp index d29b9d947..42349fb24 100644 --- a/src/compositor/compositor_api/qwaylandkeyboard.cpp +++ b/src/compositor/compositor_api/qwaylandkeyboard.cpp @@ -382,7 +382,7 @@ void QWaylandKeyboardPrivate::sendRepeatInfo() * \class QWaylandKeyboard * \inmodule QtWaylandCompositor * \preliminary - * \brief The QWaylandKeyboard class provides access to a keyboard device. + * \brief The QWaylandKeyboard class represents a keyboard device. * * This class provides access to the keyboard device in a QWaylandSeat. It corresponds to * the Wayland interface wl_keyboard. diff --git a/src/compositor/compositor_api/qwaylandoutput.cpp b/src/compositor/compositor_api/qwaylandoutput.cpp index 9e66b9a44..c34080b36 100644 --- a/src/compositor/compositor_api/qwaylandoutput.cpp +++ b/src/compositor/compositor_api/qwaylandoutput.cpp @@ -190,32 +190,32 @@ QWaylandOutput::QWaylandOutput() \qmltype WaylandOutput \inqmlmodule QtWayland.Compositor \preliminary - \brief Type providing access to a displayable area managed by the compositor. + \brief Provides access to a displayable area managed by the compositor. - The WaylandOutput manages a rectangular part of the compositor's geometry that - can be used for displaying client content. This could, for instance, be a screen - managed by the WaylandCompositor. + The WaylandOutput manages a rectangular area within bounds of the compositor's + geometry, to use it for displaying client content. This could, for instance, be + a screen managed by the WaylandCompositor. - The type corresponds to the wl_output interface in the Wayland protocol. + The type corresponds to the \c wl_output interface in the Wayland protocol. */ /*! \class QWaylandOutput \inmodule QtWaylandCompositor \preliminary - \brief The QWaylandOutput class provides access to a displayable area managed by the compositor. + \brief The QWaylandOutput class represents a displayable area managed by the compositor. - The QWaylandOutput manages a rectangular part of the compositor's geometry that - can be used for displaying client content. This could, for instance, be a screen - managed by the QWaylandCompositor. + The QWaylandOutput manages a rectangular area within bounds of the compositor's + geometry, to use it for displaying client content. This could, for instance, be + a screen managed by the WaylandCompositor. - The class corresponds to the wl_output interface in the Wayland protocol. + The class corresponds to the \c wl_output interface in the Wayland protocol. */ /*! * Constructs a QWaylandOutput in \a compositor and with the specified \a window. The - * \l{QWaylandCompositor::create()}{create()} function must have been called on the - * \a compositor before a QWaylandOutput is constructed for it. + * \l{QWaylandCompositor::create()}{create()} function must be called on the + * \a compositor before constructing a QWaylandOutput for it. * * The QWaylandOutput object is initialized later, in reaction to an event. * At this point it is added as an output for the \a compositor. If it is the @@ -307,8 +307,10 @@ void QWaylandOutput::update() /*! * \qmlproperty object QtWaylandCompositor::WaylandOutput::compositor * - * This property holds the compositor displaying content on this QWaylandOutput. - * This property can only be set once, before the WaylandOutput component is completed. + * This property holds the compositor displaying content on this WaylandOutput. + * + * \note This property can be set only once, before the WaylandOutput component + * is completed. */ /*! @@ -643,14 +645,14 @@ void QWaylandOutput::setSubpixel(const Subpixel &subpixel) * * This enum type is used to specify the orientation of a QWaylandOutput. * - * \value TransformNormal The QWaylandOutput orientation is normal. - * \value Transform90 The QWaylandOutput is rotated 90 degrees. - * \value Transform180 The QWaylandOutput is rotated 180 degrees. - * \value Transform270 The QWaylandOutput is rotated 270 degrees. - * \value TransformFlipped The QWaylandOutput is mirrored. - * \value TransformFlipped90 The QWaylandOutput is mirrored, and rotated 90 degrees. - * \value TransformFlipped180 The QWaylandOutput is mirrored, and rotated 180 degrees. - * \value TransformFlipped270 The QWaylandOutput is mirrored, and rotated 270 degrees. + * \value TransformNormal The orientation is normal. + * \value Transform90 The orientation is rotated 90 degrees. + * \value Transform180 The orientation is rotated 180 degrees. + * \value Transform270 The orientation is rotated 270 degrees. + * \value TransformFlipped The orientation is mirrored. + * \value TransformFlipped90 The orientation is mirrored, and rotated 90 degrees. + * \value TransformFlipped180 The orientation is mirrored, and rotated 180 degrees. + * \value TransformFlipped270 The orientation is mirrored, and rotated 270 degrees. * * \sa QWaylandOutput::transform */ @@ -662,14 +664,14 @@ void QWaylandOutput::setSubpixel(const Subpixel &subpixel) * to compensate for the orientation of the QWaylandOutput. * * \list - * \li WaylandOutput.TransformNormal The QWaylandOutput orientation is normal. - * \li WaylandOutput.Transform90 The QWaylandOutput is rotated 90 degrees. - * \li WaylandOutput.Transform180 The QWaylandOutput is rotated 180 degrees. - * \li WaylandOutput.Transform270 The QWaylandOutput is rotated 270 degrees. - * \li WaylandOutput.TransformFlipped The QWaylandOutput is mirrored. - * \li WaylandOutput.TransformFlipped90 The QWaylandOutput is mirrored, then rotated 90 degrees. - * \li WaylandOutput.TransformFlipped180 The QWaylandOutput is mirrored, then rotated 180 degrees. - * \li WaylandOutput.TransformFlipped270 The QWaylandOutput is mirrored, then rotated 270 degrees. + * \li WaylandOutput.TransformNormal The orientation is normal. + * \li WaylandOutput.Transform90 The orientation is rotated 90 degrees. + * \li WaylandOutput.Transform180 The orientation is rotated 180 degrees. + * \li WaylandOutput.Transform270 The orientation is rotated 270 degrees. + * \li WaylandOutput.TransformFlipped The orientation is mirrored. + * \li WaylandOutput.TransformFlipped90 The orientation is mirrored, then rotated 90 degrees. + * \li WaylandOutput.TransformFlipped180 The orientation is mirrored, then rotated 180 degrees. + * \li WaylandOutput.TransformFlipped270 The orientation is mirrored, then rotated 270 degrees. * \endlist * * The default is WaylandOutput.TransformNormal. @@ -705,7 +707,7 @@ void QWaylandOutput::setTransform(const Transform &transform) * \qmlproperty int QtWaylandCompositor::WaylandOutput::scaleFactor * * This property holds the factor by which the WaylandCompositor scales surface buffers - * before they are displayed. This is used on high density output devices where unscaled content + * before they are displayed. It is used on high density output devices where unscaled content * would be too small to be practical. The client can in turn set the scale factor of its * buffer to match the output if it prefers to provide high resolution content that is * suitable for the output device. @@ -753,7 +755,7 @@ void QWaylandOutput::setScaleFactor(int scale) * This property controls whether the size of the WaylandOutput matches the * size of its window. * - * The default is true if this WaylandOutput has a window. + * The default is \c true if this WaylandOutput has a window. */ /*! @@ -762,7 +764,7 @@ void QWaylandOutput::setScaleFactor(int scale) * This property controls whether the size of the QWaylandOutput matches the * size of its window. * - * The default is true if this QWaylandOutput has a window. + * The default is \c true if this QWaylandOutput has a window. */ bool QWaylandOutput::sizeFollowsWindow() const { @@ -794,8 +796,10 @@ void QWaylandOutput::setSizeFollowsWindow(bool follow) /*! * \qmlproperty object QtWaylandCompositor::WaylandOutput::window * - * This property holds the Window for this WaylandOutput. This property can only be set once, - * before the WaylandOutput component is completed. + * This property holds the Window for this WaylandOutput. + * + * \note This property can be set only once, before the WaylandOutput + * component is completed. */ /*! @@ -822,7 +826,7 @@ void QWaylandOutput::setWindow(QWindow *window) } /*! - * Tells the QWaylandOutput that a frame has started. + * Informs QWaylandOutput that a frame has started. */ void QWaylandOutput::frameStarted() { @@ -878,7 +882,7 @@ void QWaylandOutput::surfaceLeave(QWaylandSurface *surface) } /*! - * This functions sets the width of this QWaylandOutput to \a newWidth. + * Sets the width of this QWaylandOutput to \a newWidth. * * \sa setHeight, QWaylandOutput::geometry */ @@ -894,7 +898,7 @@ void QWaylandOutput::setWidth(int newWidth) } /*! - * This functions sets the height of this QWaylandOutput to \a newHeight. + * Sets the height of this QWaylandOutput to \a newHeight. * * \sa setWidth, QWaylandOutput::geometry */ diff --git a/src/compositor/compositor_api/qwaylandpointer.cpp b/src/compositor/compositor_api/qwaylandpointer.cpp index 2ca8c51a2..742987c8b 100644 --- a/src/compositor/compositor_api/qwaylandpointer.cpp +++ b/src/compositor/compositor_api/qwaylandpointer.cpp @@ -95,7 +95,7 @@ void QWaylandPointerPrivate::pointer_set_cursor(wl_pointer::Resource *resource, * \class QWaylandPointer * \inmodule QtWaylandCompositor * \preliminary - * \brief The QWaylandPointer class provides access to a pointer device. + * \brief The QWaylandPointer class represents a pointer device. * * This class provides access to the pointer device in a QWaylandSeat. It corresponds to * the Wayland interface wl_pointer. diff --git a/src/compositor/compositor_api/qwaylandquickcompositor.cpp b/src/compositor/compositor_api/qwaylandquickcompositor.cpp index ae34cddf9..07ea381b4 100644 --- a/src/compositor/compositor_api/qwaylandquickcompositor.cpp +++ b/src/compositor/compositor_api/qwaylandquickcompositor.cpp @@ -79,8 +79,8 @@ QWaylandQuickCompositor::QWaylandQuickCompositor(QObject *parent) * any Wayland extension the compositor should support, instantiate its component, * and add it to the list of extensions. * - * For instance, the following code would allow the clients to request wl shell surfaces - * in the compositor using the wl_shell interface. + * For instance, the following code would allow the clients to request \c wl_shell + * surfaces in the compositor using the \c wl_shell interface. * * \code * import QtWayland.Compositor 1.0 diff --git a/src/compositor/compositor_api/qwaylandquickitem.cpp b/src/compositor/compositor_api/qwaylandquickitem.cpp index 6ea44feac..08eefffa0 100644 --- a/src/compositor/compositor_api/qwaylandquickitem.cpp +++ b/src/compositor/compositor_api/qwaylandquickitem.cpp @@ -336,10 +336,10 @@ private: * \qmltype WaylandQuickItem * \inqmlmodule QtWayland.Compositor * \preliminary - * \brief A Qt Quick item representing a WaylandView. + * \brief Provides a Qt Quick item that represents a WaylandView. * - * When writing a WaylandCompositor in Qt Quick, this type can be used to display a - * client's contents on an output device and will pass user input to the + * Qt Quick-based Wayland compositors can use this type to display a client's + * contents on an output device. It passes user input to the * client. */ @@ -347,7 +347,7 @@ private: * \class QWaylandQuickItem * \inmodule QtWaylandCompositor * \preliminary - * \brief A Qt Quick item representing a QWaylandView. + * \brief The QWaylandQuickItem class provides a Qt Quick item representing a QWaylandView. * * When writing a QWaylandCompositor in Qt Quick, this class can be used to display a * client's contents on an output device and will pass user input to the @@ -402,7 +402,7 @@ QWaylandCompositor *QWaylandQuickItem::compositor() const } /*! - * \qmlproperty object QWaylandQuickItem::view + * \qmlproperty object QtWaylandCompositor::WaylandQuickItem::view * * This property holds the view rendered by this WaylandQuickItem. */ @@ -419,7 +419,7 @@ QWaylandView *QWaylandQuickItem::view() const } /*! - * \qmlproperty object QWaylandQuickItem::surface + * \qmlproperty object QtWaylandCompositor::WaylandQuickItem::surface * * This property holds the surface rendered by this WaylandQuickItem. */ @@ -944,7 +944,7 @@ void QWaylandQuickItem::updateSize() * This property specifies whether the WaylandQuickItem should take focus when * it is clicked. * - * The default is true. + * The default is \c true. */ /*! @@ -953,7 +953,7 @@ void QWaylandQuickItem::updateSize() * This property specifies whether the QWaylandQuickItem should take focus when * it is clicked. * - * The default is true. + * The default is \c true. */ bool QWaylandQuickItem::focusOnClick() const { @@ -972,7 +972,7 @@ void QWaylandQuickItem::setFocusOnClick(bool focus) } /*! - * Returns true if the input region of this item's surface contains the + * Returns \c true if the input region of this item's surface contains the * position given by \a localPosition. */ bool QWaylandQuickItem::inputRegionContains(const QPointF &localPosition) @@ -999,7 +999,7 @@ QPointF QWaylandQuickItem::mapToSurface(const QPointF &point) const * This property specifies whether the size of the item should always match * the size of its surface. * - * The default is true. + * The default is \c true. */ /*! @@ -1008,7 +1008,7 @@ QPointF QWaylandQuickItem::mapToSurface(const QPointF &point) const * This property specifies whether the size of the item should always match * the size of its surface. * - * The default is true. + * The default is \c true. */ bool QWaylandQuickItem::sizeFollowsSurface() const { @@ -1046,12 +1046,19 @@ QVariant QWaylandQuickItem::inputMethodQuery(Qt::InputMethodQuery query, QVarian #endif /*! - \qmlproperty bool QtWayland::QWaylandSurfaceItem::paintEnabled + \qmlproperty bool QtWaylandCompositor::WaylandQuickItem::paintEnabled + + If this property is \c true, the item is hidden, though the texture + is still updated. As opposed to hiding the item by + setting \l{Item::visible}{visible} to \c false, setting this property to \c true + will not prevent mouse or keyboard input from reaching item. +*/ - If this property is true, the \l item is hidden, though the texture - will still be updated. As opposed to hiding the \l item by - setting \l{Item::visible}{visible} to false, setting this property to true - will not prevent mouse or keyboard input from reaching \l item. +/*! + If this property is \c true, the item is hidden, though the texture + is still updated. As opposed to hiding the item by + setting \l{Item::visible}{visible} to \c false, setting this property to \c true + will not prevent mouse or keyboard input from reaching item. */ bool QWaylandQuickItem::paintEnabled() const { diff --git a/src/compositor/compositor_api/qwaylandquicksurface.cpp b/src/compositor/compositor_api/qwaylandquicksurface.cpp index 0fc07c6c5..30a94556f 100644 --- a/src/compositor/compositor_api/qwaylandquicksurface.cpp +++ b/src/compositor/compositor_api/qwaylandquicksurface.cpp @@ -87,7 +87,7 @@ QWaylandQuickSurface::~QWaylandQuickSurface() } /*! - * \qmlproperty QtWaylandCompositor::WaylandSurface::useTextureAlpha + * \qmlproperty bool QtWaylandCompositor::WaylandSurface::useTextureAlpha * * This property specifies whether the surface should use texture alpha. */ @@ -108,7 +108,7 @@ void QWaylandQuickSurface::setUseTextureAlpha(bool useTextureAlpha) } /*! - * \qmlproperty QtWaylandCompositor::WaylandSurface::clientRenderingEnabled + * \qmlproperty bool QtWaylandCompositor::WaylandSurface::clientRenderingEnabled * * This property specifies whether client rendering is enabled for the surface. */ diff --git a/src/compositor/compositor_api/qwaylandseat.cpp b/src/compositor/compositor_api/qwaylandseat.cpp index 1f5fd026e..f84325185 100644 --- a/src/compositor/compositor_api/qwaylandseat.cpp +++ b/src/compositor/compositor_api/qwaylandseat.cpp @@ -152,7 +152,7 @@ QWaylandKeymap::QWaylandKeymap(const QString &layout, const QString &variant, co * \class QWaylandSeat * \inmodule QtWaylandCompositor * \preliminary - * \brief The QWaylandSeat class provides access to keyboard, mouse and touch input. + * \brief The QWaylandSeat class provides access to keyboard, mouse, and touch input. * * The QWaylandSeat provides access to different types of user input and maintains * a keyboard focus and a mouse pointer. It corresponds to the wl_seat interface in the Wayland protocol. diff --git a/src/compositor/compositor_api/qwaylandsurface.cpp b/src/compositor/compositor_api/qwaylandsurface.cpp index 09eba77e0..ea94433bb 100644 --- a/src/compositor/compositor_api/qwaylandsurface.cpp +++ b/src/compositor/compositor_api/qwaylandsurface.cpp @@ -378,20 +378,20 @@ QtWayland::SurfaceBuffer *QWaylandSurfacePrivate::createSurfaceBuffer(struct ::w * \qmltype WaylandSurface * \inqmlmodule QtWayland.Compositor * \preliminary - * \brief A rectangular area which is displayed on an output device. + * \brief Represents a rectangular area on an output device. * * This type encapsulates a rectangular area of pixels that is displayed on an output device. It - * corresponds to the interface wl_surface in the Wayland protocol. + * corresponds to the interface \c wl_surface in the Wayland protocol. */ /*! * \class QWaylandSurface * \inmodule QtWaylandCompositor * \preliminary - * \brief A rectangular area which is displayed on an output device. + * \brief The QWaylandSurface class represents a rectangular area on an output device. * * This class encapsulates a rectangular area of pixels that is displayed on an output device. It - * corresponds to the interface wl_surface in the Wayland protocol. + * corresponds to the interface \c wl_surface in the Wayland protocol. */ /*! @@ -433,7 +433,7 @@ QWaylandSurface::~QWaylandSurface() /*! * \qmlmethod void QtWaylandCompositor::WaylandSurface::initialize(object compositor, object client, int id, int version) * - * Initializes the QWaylandSurface with the given \a compositor and \a client, and with the given \a id + * Initializes the WaylandSurface with the given \a compositor and \a client, and with the given \a id * and \a version. */ @@ -466,7 +466,7 @@ bool QWaylandSurface::isInitialized() const /*! * \qmlproperty object QtWaylandCompositor::WaylandSurface::client * - * This property holds the client using this QWaylandSurface. + * This property holds the client using this WaylandSurface. */ /*! @@ -543,7 +543,7 @@ int QWaylandSurface::bufferScale() const * * This property holds the orientation of the WaylandSurface's contents. * - * \sa QWaylandOutput::transform + * \sa {WaylandOutput::transform}{WaylandOutput.transform} */ /*! @@ -632,8 +632,8 @@ void QWaylandSurface::sendFrameCallbacks() } /*! - * Returns true if the QWaylandSurface's input region contains the point \a p. - * Otherwise returns false. + * Returns \c true if the QWaylandSurface's input region contains the point \a p. + * Otherwise returns \c false. */ bool QWaylandSurface::inputRegionContains(const QPoint &p) const { @@ -644,7 +644,7 @@ bool QWaylandSurface::inputRegionContains(const QPoint &p) const /*! * \qmlmethod void QtWaylandCompositor::WaylandSurface::destroy() * - * Destroys the QWaylandSurface. + * Destroys the WaylandSurface. */ /*! @@ -659,7 +659,7 @@ void QWaylandSurface::destroy() /*! * \qmlmethod bool QtWaylandCompositor::WaylandSurface::isDestroyed() * - * Returns true if the WaylandSurface has been destroyed. Otherwise returns false. + * Returns \c true if the WaylandSurface has been destroyed. Otherwise returns \c false. */ /*! @@ -701,9 +701,9 @@ QWaylandInputMethodControl *QWaylandSurface::inputMethodControl() const } /*! - * Updates the surface with the compositor's retained clipboard selection. While this - * is done automatically when the surface receives keyboard focus, this function is - * useful for updating clients which do not have keyboard focus. + * Updates the surface with the compositor's retained clipboard selection. Although + * this is done automatically when the surface receives keyboard focus, this + * function is useful for updating clients which do not have keyboard focus. */ void QWaylandSurface::updateSelection() { @@ -784,13 +784,11 @@ struct wl_resource *QWaylandSurface::resource() const } /*! - * Sets a role on the surface. A role defines how a surface will be mapped on screen, without a role - * a surface is supposed to be hidden. Only one role at all times can be set on a surface. Attempting - * to change the role of a surface will trigger a protocol error to the client, while setting the same - * role many times is allowed. + * Sets a \a role on the surface. A role defines how a surface will be mapped on screen, without a role + * a surface is supposed to be hidden. Only one role at all times can be set on a surface. Although + * setting the same role many times is allowed, attempting to change the role of a surface will trigger + * a protocol error to the \a errorResource and send an \a errorCode to the client. * - * \param errorResource The resource the error will be sent to if the role is being changed. - * \param errorCode The error code that will be sent to the client. */ bool QWaylandSurface::setRole(QWaylandSurfaceRole *role, wl_resource *errorResource, uint32_t errorCode) { diff --git a/src/compositor/compositor_api/qwaylandview.cpp b/src/compositor/compositor_api/qwaylandview.cpp index f605de55c..1f32bb61d 100644 --- a/src/compositor/compositor_api/qwaylandview.cpp +++ b/src/compositor/compositor_api/qwaylandview.cpp @@ -62,18 +62,20 @@ void QWaylandViewPrivate::markSurfaceAsDestroyed(QWaylandSurface *surface) * \preliminary * \brief Represents a view of a surface on an output. * - * The WaylandView corresponds to the presentation of a surface on a specific output, managing - * the buffers that contain the contents to be rendered. You can have several views into the same surface. + * The WaylandView corresponds to the presentation of a surface on a specific + * output, managing the buffers that contain the contents to be rendered. + * You can have several views into the same surface. */ /*! * \class QWaylandView * \inmodule QtWaylandCompositor * \preliminary - * \brief Represents a view of a surface on an output. + * \brief The QWaylandView class represents a view of a surface on an output. * - * The WaylandView corresponds to the presentation of a surface on a specific output, managing - * the buffers that contain the contents to be rendered. You can have several views into the same surface. + * The QWaylandView corresponds to the presentation of a surface on a specific + * output, managing the buffers that contain the contents to be rendered. + * You can have several views into the same surface. */ /*! @@ -104,20 +106,19 @@ QWaylandView::~QWaylandView() } /*! - \internal Didn't we decide to remove this property? +* \internal +* Didn't we decide to remove this property? */ QObject *QWaylandView::renderObject() const { Q_D(const QWaylandView); return d->renderObject; } - /*! - * \qmlproperty object QtWaylandCompositor::WaylandView::surface - * - * This property holds the surface viewed by this WaylandView. - */ - +* \qmlproperty object QtWaylandCompositor::WaylandView::surface +* +* This property holds the surface viewed by this WaylandView. +*/ /*! * \property QWaylandView::surface * @@ -163,7 +164,7 @@ void QWaylandView::setSurface(QWaylandSurface *newSurface) } /*! - * \qmlproperty object QtWaylandCompositor::WaylandView::surface + * \qmlproperty object QtWaylandCompositor::WaylandView::output * * This property holds the output on which this view displays its surface. */ @@ -197,8 +198,8 @@ void QWaylandView::setOutput(QWaylandOutput *newOutput) } /*! - * Attaches a new buffer \a ref and \a damage region to this QWaylandView. These - * will become current the next time advance() is called. + * Attaches a new buffer \a ref and a \a damage region to this QWaylandView. These + * will become current on a subsequent call to the advance() method. */ void QWaylandView::attach(const QWaylandBufferRef &ref, const QRegion &damage) { @@ -209,21 +210,20 @@ void QWaylandView::attach(const QWaylandBufferRef &ref, const QRegion &damage) } /*! - * Sets the next buffer and damage to current and returns true. If the buffer + * Sets the next buffer and damage region to current and returns \c true. If the buffer * is locked or if no new buffer has been attached since the last call to - * advance(), the function returns false and does nothing. + * advance(), the function returns \c false and does nothing. * - * If this view is set as its surface's throttling view, discardCurrentBuffer() - * will be called on all views of the same surface for which the + * If this view is set as the surface's throttling view, discardCurrentBuffer() + * is called on all views of the same surface for which the * \l{QWaylandView::allowDiscardFrontBuffer}{allowDiscardFrontBuffer} * property is set to true and the current buffer is the same as the * throttling view's current buffer. * - * This allows for a design where a primary - * view can make sure that views running on a lower frequency will release their - * front buffer references so that the buffer can be reused on the client side, - * avoiding the situation where the lower frequency views throttle the frame rate - * of the client application. + * To enable clients to reuse existing buffers, enable the primary view to ensure + * that views running on a lower frequency will release their front buffer + * references. This design approach should avoid the situation where the lower + * frequency views throttle the frame rate of the client application. */ bool QWaylandView::advance() { @@ -283,20 +283,20 @@ QRegion QWaylandView::currentDamage() * \qmlproperty bool QtWaylandCompositor::WaylandView::bufferLocked * * This property holds whether the view's buffer is currently locked. When - * the buffer is locked, advance() will not advance to the next buffer, - * but will instead return false. + * the buffer is locked, advance() will not advance to the next buffer and + * returns \c false. * - * The default is false. + * The default is \c false. */ /*! * \property QWaylandView::bufferLocked * * This property holds whether the view's buffer is currently locked. When - * the buffer is locked, advance() will not advance to the next buffer, - * but will instead return false. + * the buffer is locked, advance() will not advance to the next buffer + * and returns \c false. * - * The default is false. + * The default is \c false. */ bool QWaylandView::isBufferLocked() const { @@ -312,13 +312,19 @@ void QWaylandView::setBufferLocked(bool locked) d->bufferLocked = locked; emit bufferLockedChanged(); } - /*! - * \property bool QWaylandView::allowDiscardFrontBuffer + * \qmlproperty bool QtWaylandCompositor::WaylandView::allowDiscardFrontBuffer * * By default, the view locks the current buffer until advance() is called. Set this property * to true to allow Qt to release the buffer when the throttling view is no longer using it. */ + +/*! + * \property QWaylandView::allowDiscardFrontBuffer + * + * By default, the view locks the current buffer until advance() is called. Set this property + * to \c true to allow Qt to release the buffer when the throttling view is no longer using it. + */ bool QWaylandView::allowDiscardFrontBuffer() const { Q_D(const QWaylandView); diff --git a/src/compositor/doc/src/qtwaylandcompositor-overview.qdoc b/src/compositor/doc/src/qtwaylandcompositor-overview.qdoc index 9811d5205..d2f0f6f40 100644 --- a/src/compositor/doc/src/qtwaylandcompositor-overview.qdoc +++ b/src/compositor/doc/src/qtwaylandcompositor-overview.qdoc @@ -30,25 +30,31 @@ \title Qt Wayland Compositor \brief An API to develop display servers supporting the Wayland protocol - Qt Wayland Compositor is a module consisting of QML and C++ APIs for developing - custom display servers based on the \l{http://wayland.freedesktop.org}{Wayland protocol}. - The server displays content from client applications that support the Wayland protocol. + Qt Wayland Compositor is a module that provides QML and C++ APIs for + developing custom display servers based on the + \l{http://wayland.freedesktop.org}{Wayland protocol}. The server displays + content from client applications that support the Wayland protocol. \section1 Environment Variables and Command-line Arguments - The Qt Wayland Compositor API recognizes some environment variables and command-line arguments - that can be used to customize its behavior. + The Qt Wayland Compositor API recognizes some environment variables and + command-line arguments that can be used to customize its behavior. - The environment variables: \list - \li QT_WAYLAND_HARDWARE_INTEGRATION Selects which hardware integration plugin to use. - \li QT_WAYLAND_CLIENT_BUFFER_INTEGRATION Selects which client buffer integration plugin to use. - \li QT_WAYLAND_SERVER_BUFFER_INTEGRATION Selects which server integration plugin to use. - \endlist - - The command-line arguments: - \list - \li --wayland-socket-name Overrides the default socket name used for communicating with clients. + \li Environment variables: + \list + \li \b QT_WAYLAND_HARDWARE_INTEGRATION Selects the hardware integration + plugin to use. + \li \b QT_WAYLAND_CLIENT_BUFFER_INTEGRATION Selects the client buffer + integration plugin to use. + \li \b QT_WAYLAND_SERVER_BUFFER_INTEGRATION Selects the server + integration plugin to use. + \endlist + \li Command-line arguments: + \list + \li \c{--wayland-socket-name} Overrides the default socket name used for + communicating with clients. + \endlist \endlist \section1 Examples diff --git a/src/compositor/extensions/qwaylandquickshellsurfaceitem.cpp b/src/compositor/extensions/qwaylandquickshellsurfaceitem.cpp index 5fe43e547..9cb65fbef 100644 --- a/src/compositor/extensions/qwaylandquickshellsurfaceitem.cpp +++ b/src/compositor/extensions/qwaylandquickshellsurfaceitem.cpp @@ -46,19 +46,21 @@ QT_BEGIN_NAMESPACE * \qmltype ShellSurfaceItem * \inqmlmodule QtWayland.Compositor * \preliminary - * \brief An item representing a WlShellSurface. + * \brief A Qt Quick item type representing a WlShellSurface. * - * This type is used to render wl_shell or xdg_shell surfaces as part of a Qt Quick + * This type is used to render \c wl_shell or \c xdg_shell surfaces as part of a Qt Quick * scene. It handles moving and resizing triggered by clicking on the window decorations. + * + * \sa WaylandQuickItem */ /*! * \class QWaylandQuickShellSurfaceItem * \inmodule QtWaylandCompositor * \preliminary - * \brief A Qt Quick item for QWaylandShellSurface. + * \brief The QWaylandQuickShellSurfaceItem class provides a Qt Quick item that represents a QWaylandShellSurface. * - * This class is used to render wl_shell or xdg_shell surfaces as part of a Qt Quick + * This class is used to render \c wl_shell or \c xdg_shell surfaces as part of a Qt Quick * scene. It handles moving and resizing triggered by clicking on the window decorations. * * \sa QWaylandQuickItem diff --git a/src/compositor/extensions/qwaylandwlshell.cpp b/src/compositor/extensions/qwaylandwlshell.cpp index 6d11fd50e..a1313a6c2 100644 --- a/src/compositor/extensions/qwaylandwlshell.cpp +++ b/src/compositor/extensions/qwaylandwlshell.cpp @@ -268,13 +268,13 @@ void QWaylandWlShellSurfacePrivate::shell_surface_set_class(Resource *resource, * \qmltype WlShell * \inqmlmodule QtWayland.Compositor * \preliminary - * \brief Extension for desktop-style user interfaces. + * \brief Provides an extension for desktop-style user interfaces. * * The WlShell extension provides a way to assiociate a ShellSurface * with a regular Wayland surface. Using the shell surface interface, the client * can request that the surface is resized, moved, and so on. * - * WlShell corresponds to the Wayland interface wl_shell. + * WlShell corresponds to the Wayland interface \c wl_shell. * * To provide the functionality of the shell extension in a compositor, create * an instance of the WlShell component and add it to the list of extensions @@ -294,13 +294,13 @@ void QWaylandWlShellSurfacePrivate::shell_surface_set_class(Resource *resource, * \class QWaylandWlShell * \inmodule QtWaylandCompositor * \preliminary - * \brief Extension for desktop-style user interfaces. + * \brief The QWaylandWlShell class is an extension for desktop-style user interfaces. * * The QWaylandWlShell extension provides a way to assiociate a QWaylandWlShellSurface with * a regular Wayland surface. Using the shell surface interface, the client * can request that the surface is resized, moved, and so on. * - * WlShell corresponds to the Wayland interface wl_shell. + * WlShell corresponds to the Wayland interface \c wl_shell. */ /*! @@ -361,8 +361,8 @@ const struct wl_interface *QWaylandWlShell::interface() /*! * \qmlsignal void QtWaylandCompositor::WlShell::wlShellSurfaceRequested(object surface, object client, int id) * - * This signal is emitted when the \a client has requested a wl_shell_surface to be associated - * with \a surface and be assigned the given \a id. The handler for this signal is + * This signal is emitted when the \a client has requested a \c wl_shell_surface to be associated + * with \a surface, which is identified by \a id. The handler for this signal is * expected to create the shell surface and initialize it within the scope of the * signal emission. */ @@ -385,26 +385,26 @@ QByteArray QWaylandWlShell::interfaceName() * \qmltype WlShellSurface * \inqmlmodule QtWayland.Compositor * \preliminary - * \brief A wl_shell_surface providing desktop-style compositor-specific features to a surface. + * \brief Provides a \c wl_shell_surface that offers desktop-style compositor-specific features to a surface. * * This type is part of the \l{WlShell} extension and provides a way to extend * the functionality of an existing WaylandSurface with features specific to desktop-style * compositors, such as resizing and moving the surface. * - * It corresponds to the Wayland interface wl_shell_surface. + * It corresponds to the Wayland interface \c wl_shell_surface. */ /*! * \class QWaylandWlShellSurface * \inmodule QtWaylandCompositor * \preliminary - * \brief A shell surface providing desktop-style compositor-specific features to a surface. + * \brief The QWaylandWlShellSurface class provides desktop-style compositor-specific features to a surface. * * This class is part of the QWaylandWlShell extension and provides a way to extend * the functionality of an existing QWaylandSurface with features specific to desktop-style * compositors, such as resizing and moving the surface. * - * It corresponds to the Wayland interface wl_shell_surface. + * It corresponds to the Wayland interface \c wl_shell_surface. */ /*! @@ -433,11 +433,11 @@ QWaylandWlShellSurface::~QWaylandWlShellSurface() /*! * \qmlmethod void QtWaylandCompositor::WlShellSurface::initialize(object shell, object surface, object client, int id) * - * Initializes the WlShellSurface, associating it with the given \a shell, \a surface, \a client, and \a id. + * Initializes the WlShellSurface with \a id and associates it with the given \a shell, \a surface, and \a client. */ /*! - * Initializes the QWaylandWlShellSurface, associating it with the given \a shell, \a surface and \a resource. + * Initializes the QWaylandWlShellSurface and associates it with the given \a shell, \a surface, and \a resource. */ void QWaylandWlShellSurface::initialize(QWaylandWlShell *shell, QWaylandSurface *surface, const QWaylandResource &resource) { @@ -492,10 +492,10 @@ QSize QWaylandWlShellSurface::sizeForResize(const QSizeF &size, const QPointF &d /*! * \enum QWaylandWlShellSurface::ResizeEdge * - * This enum type provides a way to specify a specific edge or corner of + * This enum type provides a way to specify an edge or corner of * the surface. * - * \value None No edge. + * \value NoneEdge No edge. * \value TopEdge The top edge. * \value BottomEdge The bottom edge. * \value LeftEdge The left edge. @@ -552,7 +552,7 @@ QWaylandQuickShellIntegration *QWaylandWlShellSurface::createIntegration(QWaylan /*! * \qmlproperty object QtWaylandCompositor::WlShellSurface::surface * - * This property holds the wl_surface associated with this WlShellSurface. + * This property holds the \c wl_surface associated with this WlShellSurface. */ /*! diff --git a/src/compositor/extensions/qwaylandxdgshell.cpp b/src/compositor/extensions/qwaylandxdgshell.cpp index 273803d68..ab2c60ecc 100644 --- a/src/compositor/extensions/qwaylandxdgshell.cpp +++ b/src/compositor/extensions/qwaylandxdgshell.cpp @@ -614,7 +614,7 @@ void QWaylandXdgShell::handleFocusChanged(QWaylandSurface *newSurface, QWaylandS * \class QWaylandXdgSurface * \inmodule QtWaylandCompositor * \preliminary - * \brief An xdg surface providing desktop-style compositor-specific features to a surface. + * \brief The QWaylandXdgSurface class provides desktop-style compositor-specific features to an xdg surface. * * This class is part of the QWaylandXdgShell extension and provides a way to * extend the functionality of an existing QWaylandSurface with features @@ -1008,7 +1008,7 @@ QWaylandQuickShellIntegration *QWaylandXdgSurface::createIntegration(QWaylandQui * \class QWaylandXdgPopup * \inmodule QtWaylandCompositor * \preliminary - * \brief An xdg popup providing menus for an xdg surface + * \brief The QWaylandXdgPopup class provides menus for an xdg surface * * This class is part of the QWaylandXdgShell extension and provides a way to * extend the functionality of an existing QWaylandSurface with features diff --git a/src/hardwareintegration/client/wayland-egl/qwaylandeglinclude.h b/src/hardwareintegration/client/wayland-egl/qwaylandeglinclude.h index 078da0306..024809ff6 100644 --- a/src/hardwareintegration/client/wayland-egl/qwaylandeglinclude.h +++ b/src/hardwareintegration/client/wayland-egl/qwaylandeglinclude.h @@ -46,7 +46,6 @@ #include <wayland-egl.h> #define EGL_EGLEXT_PROTOTYPES -#include <EGL/egl.h> -#include <EGL/eglext.h> +#include <QtPlatformSupport/private/qt_egl_p.h> #endif // QWAYLANDEGLINCLUDE_H diff --git a/src/hardwareintegration/client/wayland-egl/wayland-egl.pri b/src/hardwareintegration/client/wayland-egl/wayland-egl.pri index c5e01f125..520c1eb0f 100644 --- a/src/hardwareintegration/client/wayland-egl/wayland-egl.pri +++ b/src/hardwareintegration/client/wayland-egl/wayland-egl.pri @@ -6,6 +6,7 @@ INCLUDEPATH += $$PWD LIBS += -lwayland-client -lwayland-egl } +DEFINES += QT_EGL_WAYLAND CONFIG += egl QT += platformsupport-private diff --git a/tests/auto/client/client.pro b/tests/auto/client/client.pro index eaf6c6e95..916b3abe4 100644 --- a/tests/auto/client/client.pro +++ b/tests/auto/client/client.pro @@ -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 diff --git a/tests/auto/client/client/client.pro b/tests/auto/client/client/client.pro new file mode 100644 index 000000000..006d130a0 --- /dev/null +++ b/tests/auto/client/client/client.pro @@ -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 diff --git a/tests/auto/client/mockcompositor.cpp b/tests/auto/client/client/mockcompositor.cpp index 4cea75ea2..45a35ea7d 100644 --- a/tests/auto/client/mockcompositor.cpp +++ b/tests/auto/client/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_global_create(m_display, &wl_output_interface, 1, this, bindOutput); wl_global_create(m_display, &wl_shell_interface, 1, this, bindShell); diff --git a/tests/auto/client/mockcompositor.h b/tests/auto/client/client/mockcompositor.h index 48b410698..dd6450fc9 100644 --- a/tests/auto/client/mockcompositor.h +++ b/tests/auto/client/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> ¶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(); diff --git a/tests/auto/client/mockinput.cpp b/tests/auto/client/client/mockinput.cpp index a4d42c103..fe06bf79b 100644 --- a/tests/auto/client/mockinput.cpp +++ b/tests/auto/client/client/mockinput.cpp @@ -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); +} + } diff --git a/tests/auto/client/mockinput.h b/tests/auto/client/client/mockinput.h index eb9beb564..031be2a4a 100644 --- a/tests/auto/client/mockinput.h +++ b/tests/auto/client/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/mockoutput.cpp b/tests/auto/client/client/mockoutput.cpp index 86561976f..86561976f 100644 --- a/tests/auto/client/mockoutput.cpp +++ b/tests/auto/client/client/mockoutput.cpp diff --git a/tests/auto/client/mockshell.cpp b/tests/auto/client/client/mockshell.cpp index d5eede22e..d5eede22e 100644 --- a/tests/auto/client/mockshell.cpp +++ b/tests/auto/client/client/mockshell.cpp diff --git a/tests/auto/client/mocksurface.cpp b/tests/auto/client/client/mocksurface.cpp index 55712af11..55712af11 100644 --- a/tests/auto/client/mocksurface.cpp +++ b/tests/auto/client/client/mocksurface.cpp diff --git a/tests/auto/client/mocksurface.h b/tests/auto/client/client/mocksurface.h index d04386ac8..d04386ac8 100644 --- a/tests/auto/client/mocksurface.h +++ b/tests/auto/client/client/mocksurface.h diff --git a/tests/auto/client/tst_client.cpp b/tests/auto/client/client/tst_client.cpp index 9635c215f..74363ef5f 100644 --- a/tests/auto/client/tst_client.cpp +++ b/tests/auto/client/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); diff --git a/tests/auto/compositor/compositor.pro b/tests/auto/compositor/compositor.pro index 50378c6d4..6bf2aef6c 100644 --- a/tests/auto/compositor/compositor.pro +++ b/tests/auto/compositor/compositor.pro @@ -1,38 +1,3 @@ -CONFIG += testcase link_pkgconfig -CONFIG += wayland-scanner -TARGET = tst_compositor +TEMPLATE=subdirs -QT += testlib -QT += core-private gui-private waylandcompositor waylandcompositor-private - -!contains(QT_CONFIG, no-pkg-config) { - PKGCONFIG += wayland-client wayland-server -} else { - LIBS += -lwayland-client -lwayland-server -} - -config_xkbcommon { - !contains(QT_CONFIG, no-pkg-config) { - PKGCONFIG_PRIVATE += xkbcommon - } else { - LIBS_PRIVATE += -lxkbcommon - } -} else { - DEFINES += QT_NO_WAYLAND_XKB -} - -WAYLANDCLIENTSOURCES += \ - ../../../src/3rdparty/protocol/xdg-shell.xml \ - -SOURCES += tst_compositor.cpp \ - testcompositor.cpp \ - testkeyboardgrabber.cpp \ - mockclient.cpp \ - mockseat.cpp \ - testseat.cpp - -HEADERS += testcompositor.h \ - testkeyboardgrabber.h \ - mockclient.h \ - mockseat.h \ - testseat.h +SUBDIRS += compositor diff --git a/tests/auto/compositor/BLACKLIST b/tests/auto/compositor/compositor/BLACKLIST index df4672be3..df4672be3 100644 --- a/tests/auto/compositor/BLACKLIST +++ b/tests/auto/compositor/compositor/BLACKLIST diff --git a/tests/auto/compositor/compositor/compositor.pro b/tests/auto/compositor/compositor/compositor.pro new file mode 100644 index 000000000..a3748697d --- /dev/null +++ b/tests/auto/compositor/compositor/compositor.pro @@ -0,0 +1,40 @@ +CONFIG += testcase link_pkgconfig +CONFIG += wayland-scanner +TARGET = tst_compositor + +QT += testlib +QT += core-private gui-private waylandcompositor waylandcompositor-private + +!contains(QT_CONFIG, no-pkg-config) { + PKGCONFIG += wayland-client wayland-server +} else { + LIBS += -lwayland-client -lwayland-server +} + +config_xkbcommon { + !contains(QT_CONFIG, no-pkg-config) { + PKGCONFIG_PRIVATE += xkbcommon + } else { + LIBS_PRIVATE += -lxkbcommon + } +} else { + DEFINES += QT_NO_WAYLAND_XKB +} + +WAYLANDCLIENTSOURCES += \ + ../../../../src/3rdparty/protocol/xdg-shell.xml \ + +SOURCES += \ + tst_compositor.cpp \ + testcompositor.cpp \ + testkeyboardgrabber.cpp \ + mockclient.cpp \ + mockseat.cpp \ + testseat.cpp + +HEADERS += \ + testcompositor.h \ + testkeyboardgrabber.h \ + mockclient.h \ + mockseat.h \ + testseat.h diff --git a/tests/auto/compositor/mockclient.cpp b/tests/auto/compositor/compositor/mockclient.cpp index 9b6d327a9..9b6d327a9 100644 --- a/tests/auto/compositor/mockclient.cpp +++ b/tests/auto/compositor/compositor/mockclient.cpp diff --git a/tests/auto/compositor/mockclient.h b/tests/auto/compositor/compositor/mockclient.h index 33ada638a..33ada638a 100644 --- a/tests/auto/compositor/mockclient.h +++ b/tests/auto/compositor/compositor/mockclient.h diff --git a/tests/auto/compositor/mockseat.cpp b/tests/auto/compositor/compositor/mockseat.cpp index 29c4a4e13..29c4a4e13 100644 --- a/tests/auto/compositor/mockseat.cpp +++ b/tests/auto/compositor/compositor/mockseat.cpp diff --git a/tests/auto/compositor/mockseat.h b/tests/auto/compositor/compositor/mockseat.h index 1c6d324c2..1c6d324c2 100644 --- a/tests/auto/compositor/mockseat.h +++ b/tests/auto/compositor/compositor/mockseat.h diff --git a/tests/auto/compositor/testcompositor.cpp b/tests/auto/compositor/compositor/testcompositor.cpp index 733bea5b3..733bea5b3 100644 --- a/tests/auto/compositor/testcompositor.cpp +++ b/tests/auto/compositor/compositor/testcompositor.cpp diff --git a/tests/auto/compositor/testcompositor.h b/tests/auto/compositor/compositor/testcompositor.h index 8eeb7ade6..8eeb7ade6 100644 --- a/tests/auto/compositor/testcompositor.h +++ b/tests/auto/compositor/compositor/testcompositor.h diff --git a/tests/auto/compositor/testkeyboardgrabber.cpp b/tests/auto/compositor/compositor/testkeyboardgrabber.cpp index a3aa42ac2..a3aa42ac2 100644 --- a/tests/auto/compositor/testkeyboardgrabber.cpp +++ b/tests/auto/compositor/compositor/testkeyboardgrabber.cpp diff --git a/tests/auto/compositor/testkeyboardgrabber.h b/tests/auto/compositor/compositor/testkeyboardgrabber.h index 0ef595987..0ef595987 100644 --- a/tests/auto/compositor/testkeyboardgrabber.h +++ b/tests/auto/compositor/compositor/testkeyboardgrabber.h diff --git a/tests/auto/compositor/testseat.cpp b/tests/auto/compositor/compositor/testseat.cpp index 38227872b..38227872b 100644 --- a/tests/auto/compositor/testseat.cpp +++ b/tests/auto/compositor/compositor/testseat.cpp diff --git a/tests/auto/compositor/testseat.h b/tests/auto/compositor/compositor/testseat.h index 54641c07d..54641c07d 100644 --- a/tests/auto/compositor/testseat.h +++ b/tests/auto/compositor/compositor/testseat.h diff --git a/tests/auto/compositor/tst_compositor.cpp b/tests/auto/compositor/compositor/tst_compositor.cpp index 05e876dd0..05e876dd0 100644 --- a/tests/auto/compositor/tst_compositor.cpp +++ b/tests/auto/compositor/compositor/tst_compositor.cpp diff --git a/tests/global/.gitignore b/tests/global/.gitignore new file mode 100644 index 000000000..7407af1a5 --- /dev/null +++ b/tests/global/.gitignore @@ -0,0 +1 @@ +global.pro |