diff options
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/client.pro | 6 | ||||
-rw-r--r-- | src/client/qwaylanddatadevice.cpp | 7 | ||||
-rw-r--r-- | src/client/qwaylanddisplay.cpp | 54 | ||||
-rw-r--r-- | src/client/qwaylanddisplay_p.h | 7 | ||||
-rw-r--r-- | src/client/qwaylandintegration.cpp | 43 | ||||
-rw-r--r-- | src/client/qwaylandintegration_p.h | 1 | ||||
-rw-r--r-- | src/client/qwaylandshellsurface_p.h | 1 | ||||
-rw-r--r-- | src/client/qwaylandwindow.cpp | 5 | ||||
-rw-r--r-- | src/client/qwaylandwindow_p.h | 2 | ||||
-rw-r--r-- | src/client/qwaylandwlshellintegration.cpp | 62 | ||||
-rw-r--r-- | src/client/qwaylandwlshellintegration_p.h | 72 | ||||
-rw-r--r-- | src/client/qwaylandwlshellsurface.cpp | 10 | ||||
-rw-r--r-- | src/client/qwaylandxdgpopup_p.cpp | 61 | ||||
-rw-r--r-- | src/client/qwaylandxdgpopup_p.h | 79 | ||||
-rw-r--r-- | src/client/qwaylandxdgshell.cpp | 19 | ||||
-rw-r--r-- | src/client/qwaylandxdgshell_p.h | 6 | ||||
-rw-r--r-- | src/client/qwaylandxdgshellintegration.cpp | 67 | ||||
-rw-r--r-- | src/client/qwaylandxdgshellintegration_p.h | 73 | ||||
-rw-r--r-- | src/client/qwaylandxdgsurface.cpp | 9 | ||||
-rw-r--r-- | src/client/qwaylandxdgsurface_p.h | 6 |
20 files changed, 531 insertions, 59 deletions
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; |