summaryrefslogtreecommitdiffstats
path: root/src/plugins/shellintegration
diff options
context:
space:
mode:
authorJohan Klokkhammer Helsing <johan.helsing@qt.io>2018-05-08 16:31:16 +0200
committerJohan Helsing <johan.helsing@qt.io>2018-05-09 11:04:35 +0000
commitf11c2993d2173d97ab74a36cac5603dff1c32997 (patch)
tree81e76f6dbbe94dbeb7bddbbde09bb31f6d6b85f2 /src/plugins/shellintegration
parent7344822dd3991fa4b914531d7e2a42b1c05c1e9d (diff)
Move xdg-shell-v5 to a plugin
This is the first step in deprecating xdg-shell unstable v5 and making the good names available for the good names for xdg-shell stable. Shell initialization has been refactored slightly, so the QWaylandShellIntegrationFactory actually tries to initialize the shell integration before returning it. Similarly for the factory method of non-plugin shells. Change-Id: I85e60594c4fc03c6f302c04316110aed428d28dc Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Diffstat (limited to 'src/plugins/shellintegration')
-rw-r--r--src/plugins/shellintegration/shellintegration.pro4
-rw-r--r--src/plugins/shellintegration/xdg-shell-v5/main.cpp70
-rw-r--r--src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopup.cpp78
-rw-r--r--src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopup_p.h92
-rw-r--r--src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshell.cpp106
-rw-r--r--src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshell_p.h96
-rw-r--r--src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellintegration.cpp87
-rw-r--r--src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellintegration_p.h80
-rw-r--r--src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgsurface.cpp241
-rw-r--r--src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgsurface_p.h134
-rw-r--r--src/plugins/shellintegration/xdg-shell-v5/xdg-shell-v5.json3
-rw-r--r--src/plugins/shellintegration/xdg-shell-v5/xdg-shell-v5.pro30
12 files changed, 1020 insertions, 1 deletions
diff --git a/src/plugins/shellintegration/shellintegration.pro b/src/plugins/shellintegration/shellintegration.pro
index 9867d2b40..7f465d61b 100644
--- a/src/plugins/shellintegration/shellintegration.pro
+++ b/src/plugins/shellintegration/shellintegration.pro
@@ -1,3 +1,5 @@
TEMPLATE = subdirs
-SUBDIRS += ivi-shell
+SUBDIRS += \
+ ivi-shell \
+ xdg-shell-v5
diff --git a/src/plugins/shellintegration/xdg-shell-v5/main.cpp b/src/plugins/shellintegration/xdg-shell-v5/main.cpp
new file mode 100644
index 000000000..3df1beaf9
--- /dev/null
+++ b/src/plugins/shellintegration/xdg-shell-v5/main.cpp
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Copyright (C) 2017 ITAGE Corporation, author: <yusuke.binsaki@itage.co.jp>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://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 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandxdgshellintegration_p.h"
+
+#include <QtWaylandClient/private/qwaylandshellintegrationplugin_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace QtWaylandClient {
+
+class QWaylandXdgShellV5IntegrationPlugin : public QWaylandShellIntegrationPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID QWaylandShellIntegrationFactoryInterface_iid FILE "xdg-shell-v5.json")
+
+public:
+ QWaylandShellIntegration *create(const QString &key, const QStringList &paramList) override;
+};
+
+QWaylandShellIntegration *QWaylandXdgShellV5IntegrationPlugin::create(const QString &key, const QStringList &paramList)
+{
+ qDebug() << Q_FUNC_INFO;
+ Q_UNUSED(key);
+ Q_UNUSED(paramList);
+ return new QWaylandXdgShellIntegration();
+}
+
+}
+
+QT_END_NAMESPACE
+
+#include "main.moc"
diff --git a/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopup.cpp b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopup.cpp
new file mode 100644
index 000000000..04849355f
--- /dev/null
+++ b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopup.cpp
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://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 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandxdgpopup_p.h"
+
+#include <QtWaylandClient/private/qwaylanddisplay_p.h>
+#include <QtWaylandClient/private/qwaylandwindow_p.h>
+#include <QtWaylandClient/private/qwaylandextendedsurface_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace QtWaylandClient {
+
+QWaylandXdgPopup::QWaylandXdgPopup(struct ::xdg_popup *popup, QWaylandWindow *window)
+ : QWaylandShellSurface(window)
+ , QtWayland::xdg_popup(popup)
+ , m_window(window)
+{
+ if (window->display()->windowExtension())
+ m_extendedWindow = new QWaylandExtendedSurface(window);
+}
+
+QWaylandXdgPopup::~QWaylandXdgPopup()
+{
+ xdg_popup_destroy(object());
+ delete m_extendedWindow;
+}
+
+void QWaylandXdgPopup::setType(Qt::WindowType type, QWaylandWindow *transientParent)
+{
+ Q_UNUSED(type);
+ Q_UNUSED(transientParent);
+}
+
+void QWaylandXdgPopup::xdg_popup_popup_done()
+{
+ m_window->window()->close();
+}
+
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopup_p.h b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopup_p.h
new file mode 100644
index 000000000..d9f7deec6
--- /dev/null
+++ b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopup_p.h
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the config.tests of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://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 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $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 "qwayland-xdg-shell.h"
+
+#include <wayland-client.h>
+
+#include <QtWaylandClient/qtwaylandclientglobal.h>
+#include <QtWaylandClient/private/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);
+ ~QWaylandXdgPopup() override;
+
+ void setType(Qt::WindowType type, QWaylandWindow *transientParent) override;
+
+protected:
+ void xdg_popup_popup_done() override;
+
+private:
+ QWaylandExtendedSurface *m_extendedWindow = nullptr;
+ QWaylandWindow *m_window = nullptr;
+};
+
+QT_END_NAMESPACE
+
+}
+
+#endif // QWAYLANDXDGPOPUP_P_H
diff --git a/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshell.cpp b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshell.cpp
new file mode 100644
index 000000000..bd76346d2
--- /dev/null
+++ b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshell.cpp
@@ -0,0 +1,106 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Eurogiciel, author: <philippe.coval@eurogiciel.fr>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the config.tests of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://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 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandxdgshell_p.h"
+#include "qwaylandxdgpopup_p.h"
+#include "qwaylandxdgsurface_p.h"
+
+#include <QtCore/QDebug>
+
+#include <QtWaylandClient/private/qwaylanddisplay_p.h>
+#include <QtWaylandClient/private/qwaylandwindow_p.h>
+#include <QtWaylandClient/private/qwaylandinputdevice_p.h>
+#include <QtWaylandClient/private/qwaylandscreen_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace QtWaylandClient {
+
+QWaylandXdgShell::QWaylandXdgShell(struct ::xdg_shell *shell)
+ : QtWayland::xdg_shell(shell)
+{
+}
+
+QWaylandXdgShell::QWaylandXdgShell(struct ::wl_registry *registry, uint32_t id)
+ : QtWayland::xdg_shell(registry, id, 1)
+{
+ use_unstable_version(QtWayland::xdg_shell::version_current);
+}
+
+QWaylandXdgShell::~QWaylandXdgShell()
+{
+ xdg_shell_destroy(object());
+}
+
+QWaylandXdgSurface *QWaylandXdgShell::createXdgSurface(QWaylandWindow *window)
+{
+ return new QWaylandXdgSurface(this, window);
+}
+
+QWaylandXdgPopup *QWaylandXdgShell::createXdgPopup(QWaylandWindow *window, QWaylandInputDevice *inputDevice)
+{
+ QWaylandWindow *parentWindow = m_popups.empty() ? window->transientParent() : m_popups.last();
+ ::wl_surface *parentSurface = parentWindow->object();
+
+ if (m_popupSerial == 0)
+ m_popupSerial = inputDevice->serial();
+ ::wl_seat *seat = inputDevice->wl_seat();
+
+ QPoint position = window->geometry().topLeft() - parentWindow->geometry().topLeft();
+ int x = position.x() + parentWindow->frameMargins().left();
+ int y = position.y() + parentWindow->frameMargins().top();
+
+ auto popup = new QWaylandXdgPopup(get_xdg_popup(window->object(), parentSurface, seat, m_popupSerial, x, y), window);
+ m_popups.append(window);
+ QObject::connect(popup, &QWaylandXdgPopup::destroyed, [this, window](){
+ m_popups.removeOne(window);
+ if (m_popups.empty())
+ m_popupSerial = 0;
+ });
+ return popup;
+}
+
+void QWaylandXdgShell::xdg_shell_ping(uint32_t serial)
+{
+ pong(serial);
+}
+
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshell_p.h b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshell_p.h
new file mode 100644
index 000000000..9341c7a8f
--- /dev/null
+++ b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshell_p.h
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Eurogiciel, author: <philippe.coval@eurogiciel.fr>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the config.tests of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://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 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDXDGSHELL_H
+#define QWAYLANDXDGSHELL_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 "qwayland-xdg-shell.h"
+
+#include <QtCore/QSize>
+#include <QtCore/QVector>
+
+#include <wayland-client.h>
+
+#include <QtWaylandClient/qtwaylandclientglobal.h>
+#include <QtWaylandClient/private/qwaylandshellsurface_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QWindow;
+
+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);
+ ~QWaylandXdgShell() override;
+
+ QWaylandXdgSurface *createXdgSurface(QWaylandWindow *window);
+ QWaylandXdgPopup *createXdgPopup(QWaylandWindow *window, QWaylandInputDevice *inputDevice);
+
+private:
+ void xdg_shell_ping(uint32_t serial) override;
+
+ QVector<QWaylandWindow *> m_popups;
+ uint m_popupSerial = 0;
+};
+
+QT_END_NAMESPACE
+
+}
+
+#endif // QWAYLANDXDGSHELL_H
diff --git a/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellintegration.cpp b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellintegration.cpp
new file mode 100644
index 000000000..0d0e8aba3
--- /dev/null
+++ b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellintegration.cpp
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://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 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandxdgshellintegration_p.h"
+#include "qwaylandxdgsurface_p.h"
+#include "qwaylandxdgpopup_p.h"
+#include "qwaylandxdgshell_p.h"
+
+#include <QtWaylandClient/private/qwaylandwindow_p.h>
+#include <QtWaylandClient/private/qwaylanddisplay_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace QtWaylandClient {
+
+bool QWaylandXdgShellIntegration::initialize(QWaylandDisplay *display)
+{
+ Q_FOREACH (QWaylandDisplay::RegistryGlobal global, display->globals()) {
+ if (global.interface == QLatin1String("xdg_shell")) {
+ m_xdgShell.reset(new QWaylandXdgShell(display->wl_registry(), global.id));
+ break;
+ }
+ }
+
+ if (!m_xdgShell) {
+ qWarning() << "Couldn't find global xdg_shell for xdg-shell unstable v5";
+ return false;
+ }
+
+ return QWaylandShellIntegration::initialize(display);
+}
+
+QWaylandShellSurface *QWaylandXdgShellIntegration::createShellSurface(QWaylandWindow *window)
+{
+ QWaylandInputDevice *inputDevice = window->display()->lastInputDevice();
+ if (window->window()->type() == Qt::WindowType::Popup && inputDevice)
+ return m_xdgShell->createXdgPopup(window, inputDevice);
+ else
+ return m_xdgShell->createXdgSurface(window);
+}
+
+void QWaylandXdgShellIntegration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
+ if (newFocus && qobject_cast<QWaylandXdgPopup *>(newFocus->shellSurface()))
+ m_display->handleWindowActivated(newFocus);
+ if (oldFocus && qobject_cast<QWaylandXdgPopup *>(oldFocus->shellSurface()))
+ m_display->handleWindowDeactivated(oldFocus);
+}
+
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellintegration_p.h b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellintegration_p.h
new file mode 100644
index 000000000..a3ff86cd7
--- /dev/null
+++ b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellintegration_p.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://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 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $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 "qwaylandxdgshell_p.h"
+
+#include <QtWaylandClient/private/qwaylandshellintegration_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace QtWaylandClient {
+
+class QWaylandXdgShell;
+
+class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgShellIntegration : public QWaylandShellIntegration
+{
+public:
+ QWaylandXdgShellIntegration() {qDebug() << Q_FUNC_INFO;}
+ bool initialize(QWaylandDisplay *display) override;
+ QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+ void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+
+private:
+ QScopedPointer<QWaylandXdgShell> m_xdgShell;
+};
+
+}
+
+QT_END_NAMESPACE
+
+#endif // QWAYLANDXDGSHELLINTEGRATION_P_H
diff --git a/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgsurface.cpp b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgsurface.cpp
new file mode 100644
index 000000000..ec096540a
--- /dev/null
+++ b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgsurface.cpp
@@ -0,0 +1,241 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the config.tests of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://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 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandxdgsurface_p.h"
+#include "qwaylandxdgshell_p.h"
+
+#include <QtWaylandClient/private/qwaylanddisplay_p.h>
+#include <QtWaylandClient/private/qwaylanddisplay_p.h>
+#include <QtWaylandClient/private/qwaylandwindow_p.h>
+#include <QtWaylandClient/private/qwaylandinputdevice_p.h>
+#include <QtWaylandClient/private/qwaylandabstractdecoration_p.h>
+#include <QtWaylandClient/private/qwaylandscreen_p.h>
+#include <QtWaylandClient/private/qwaylandextendedsurface_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace QtWaylandClient {
+
+QWaylandXdgSurface::QWaylandXdgSurface(QWaylandXdgShell *shell, QWaylandWindow *window)
+ : QWaylandShellSurface(window)
+ , QtWayland::xdg_surface(shell->get_xdg_surface(window->object()))
+ , m_window(window)
+ , m_shell(shell)
+{
+ if (window->display()->windowExtension())
+ m_extendedWindow = new QWaylandExtendedSurface(window);
+}
+
+QWaylandXdgSurface::~QWaylandXdgSurface()
+{
+ if (m_acked.states & Qt::WindowActive)
+ window()->display()->handleWindowDeactivated(m_window);
+
+ xdg_surface_destroy(object());
+ delete m_extendedWindow;
+}
+
+void QWaylandXdgSurface::resize(QWaylandInputDevice *inputDevice, enum wl_shell_surface_resize edges)
+{
+ // May need some conversion if types get incompatibles, ATM they're identical
+ enum resize_edge const * const arg = reinterpret_cast<enum resize_edge const * const>(&edges);
+ resize(inputDevice, *arg);
+}
+
+void QWaylandXdgSurface::resize(QWaylandInputDevice *inputDevice, enum resize_edge edges)
+{
+ resize(inputDevice->wl_seat(),
+ inputDevice->serial(),
+ edges);
+}
+
+bool QWaylandXdgSurface::move(QWaylandInputDevice *inputDevice)
+{
+ move(inputDevice->wl_seat(),
+ inputDevice->serial());
+ return true;
+}
+
+void QWaylandXdgSurface::updateTransientParent(QWaylandWindow *parent)
+{
+ if (!parent)
+ return;
+ auto parentXdgSurface = qobject_cast<QWaylandXdgSurface *>(parent->shellSurface());
+ Q_ASSERT(parentXdgSurface);
+ set_parent(parentXdgSurface->object());
+}
+
+void QWaylandXdgSurface::setTitle(const QString & title)
+{
+ return QtWayland::xdg_surface::set_title(title);
+}
+
+void QWaylandXdgSurface::setAppId(const QString & appId)
+{
+ return QtWayland::xdg_surface::set_app_id(appId);
+}
+
+void QWaylandXdgSurface::raise()
+{
+ if (m_extendedWindow)
+ m_extendedWindow->raise();
+}
+
+void QWaylandXdgSurface::lower()
+{
+ if (m_extendedWindow)
+ m_extendedWindow->lower();
+}
+
+void QWaylandXdgSurface::setContentOrientationMask(Qt::ScreenOrientations orientation)
+{
+ if (m_extendedWindow)
+ m_extendedWindow->setContentOrientationMask(orientation);
+}
+
+void QWaylandXdgSurface::setWindowFlags(Qt::WindowFlags flags)
+{
+ if (m_extendedWindow)
+ m_extendedWindow->setWindowFlags(flags);
+}
+
+void QWaylandXdgSurface::sendProperty(const QString &name, const QVariant &value)
+{
+ if (m_extendedWindow)
+ m_extendedWindow->updateGenericProperty(name, value);
+}
+
+void QWaylandXdgSurface::setType(Qt::WindowType type, QWaylandWindow *transientParent)
+{
+ Q_UNUSED(type)
+ if (transientParent)
+ updateTransientParent(transientParent);
+}
+
+void QWaylandXdgSurface::applyConfigure()
+{
+ if (m_pending.isResizing)
+ m_normalSize = m_pending.size;
+ else if (!(m_acked.states & (Qt::WindowMaximized|Qt::WindowFullScreen)))
+ m_normalSize = m_window->window()->frameGeometry().size();
+
+ if ((m_pending.states & Qt::WindowActive) && !(m_acked.states & Qt::WindowActive))
+ m_window->display()->handleWindowActivated(m_window);
+
+ if (!(m_pending.states & Qt::WindowActive) && (m_acked.states & Qt::WindowActive))
+ m_window->display()->handleWindowDeactivated(m_window);
+
+ // TODO: none of the other plugins send WindowActive either, but is it on purpose?
+ Qt::WindowStates statesWithoutActive = m_pending.states & ~Qt::WindowActive;
+
+ m_window->handleWindowStatesChanged(statesWithoutActive);
+ if (!m_pending.size.isEmpty())
+ m_window->resizeFromApplyConfigure(m_pending.size);
+ else if (!m_normalSize.isEmpty())
+ m_window->resizeFromApplyConfigure(m_normalSize);
+ ack_configure(m_pending.serial);
+ m_acked = m_pending;
+}
+
+void QWaylandXdgSurface::requestWindowStates(Qt::WindowStates states)
+{
+ Qt::WindowStates changedStates = m_acked.states ^ states;
+
+ if (changedStates & Qt::WindowMaximized) {
+ if (states & Qt::WindowMaximized)
+ set_maximized();
+ else
+ unset_maximized();
+ }
+
+ if (changedStates & Qt::WindowFullScreen) {
+ if (states & Qt::WindowFullScreen)
+ set_fullscreen(nullptr);
+ else
+ unset_fullscreen();
+ }
+
+ // Minimized state is not reported by the protocol, so always send it
+ if (states & Qt::WindowMinimized) {
+ set_minimized();
+ window()->handleWindowStatesChanged(states & ~Qt::WindowMinimized);
+ }
+}
+
+bool QWaylandXdgSurface::wantsDecorations() const
+{
+ return !(m_pending.states & Qt::WindowFullScreen);
+}
+
+void QWaylandXdgSurface::xdg_surface_configure(int32_t width, int32_t height, struct wl_array *states,uint32_t serial)
+{
+ uint32_t *xdgStates = reinterpret_cast<uint32_t*>(states->data);
+ size_t numStates = states->size / sizeof(uint32_t);
+ m_pending.serial = serial;
+ m_pending.size = QSize(width, height);
+ m_pending.isResizing = false;
+ m_pending.states = Qt::WindowNoState;
+ for (size_t i = 0; i < numStates; i++) {
+ switch (xdgStates[i]) {
+ case XDG_SURFACE_STATE_MAXIMIZED:
+ m_pending.states |= Qt::WindowMaximized;
+ break;
+ case XDG_SURFACE_STATE_FULLSCREEN:
+ m_pending.states |= Qt::WindowFullScreen;
+ break;
+ case XDG_SURFACE_STATE_RESIZING:
+ m_pending.isResizing = true;
+ break;
+ case XDG_SURFACE_STATE_ACTIVATED:
+ m_pending.states |= Qt::WindowActive;
+ break;
+ default:
+ break;
+ }
+ }
+ m_window->applyConfigureWhenPossible();
+}
+
+void QWaylandXdgSurface::xdg_surface_close()
+{
+}
+
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgsurface_p.h b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgsurface_p.h
new file mode 100644
index 000000000..cf4498a83
--- /dev/null
+++ b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgsurface_p.h
@@ -0,0 +1,134 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the config.tests of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://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 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDXDGSURFACE_H
+#define QWAYLANDXDGSURFACE_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 "qwayland-xdg-shell.h"
+
+#include <QtWaylandClient/qtwaylandclientglobal.h>
+#include <QtWaylandClient/private/qwaylandshellsurface_p.h>
+
+#include <QtCore/QSize>
+#include <QtCore/QMargins>
+
+#include <wayland-client.h>
+
+QT_BEGIN_NAMESPACE
+
+class QWindow;
+
+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(QWaylandXdgShell *shell, QWaylandWindow *window);
+ ~QWaylandXdgSurface() override;
+
+ using QtWayland::xdg_surface::resize;
+ void resize(QWaylandInputDevice *inputDevice, enum resize_edge edges);
+
+ void resize(QWaylandInputDevice *inputDevice, enum wl_shell_surface_resize edges) override;
+
+ using QtWayland::xdg_surface::move;
+ bool move(QWaylandInputDevice *inputDevice) override;
+
+ void setTitle(const QString &title) override;
+ void setAppId(const QString &appId) override;
+
+ void raise() override;
+ void lower() override;
+ void setContentOrientationMask(Qt::ScreenOrientations orientation) override;
+ void setWindowFlags(Qt::WindowFlags flags) override;
+ void sendProperty(const QString &name, const QVariant &value) override;
+
+ void setType(Qt::WindowType type, QWaylandWindow *transientParent) override;
+ void applyConfigure() override;
+ void requestWindowStates(Qt::WindowStates states) override;
+ bool wantsDecorations() const override;
+
+private:
+ void updateTransientParent(QWaylandWindow *parent);
+
+private:
+ QWaylandWindow *m_window = nullptr;
+ QWaylandXdgShell* m_shell = nullptr;
+ struct {
+ Qt::WindowStates states = Qt::WindowNoState;
+ bool isResizing = false;
+ QSize size = {0, 0};
+ uint serial = 0;
+ } m_acked, m_pending;
+ QSize m_normalSize;
+ QMargins m_margins;
+ QWaylandExtendedSurface *m_extendedWindow = nullptr;
+
+ void xdg_surface_configure(int32_t width,
+ int32_t height,
+ struct wl_array *states,
+ uint32_t serial) override;
+ void xdg_surface_close() override;
+
+ friend class QWaylandWindow;
+};
+
+QT_END_NAMESPACE
+
+}
+
+#endif // QWAYLANDXDGSURFACE_H
diff --git a/src/plugins/shellintegration/xdg-shell-v5/xdg-shell-v5.json b/src/plugins/shellintegration/xdg-shell-v5/xdg-shell-v5.json
new file mode 100644
index 000000000..ba1ed4489
--- /dev/null
+++ b/src/plugins/shellintegration/xdg-shell-v5/xdg-shell-v5.json
@@ -0,0 +1,3 @@
+{
+ "Keys":[ "xdg-shell-v5" ]
+}
diff --git a/src/plugins/shellintegration/xdg-shell-v5/xdg-shell-v5.pro b/src/plugins/shellintegration/xdg-shell-v5/xdg-shell-v5.pro
new file mode 100644
index 000000000..85052fef6
--- /dev/null
+++ b/src/plugins/shellintegration/xdg-shell-v5/xdg-shell-v5.pro
@@ -0,0 +1,30 @@
+QT += gui-private waylandclient-private
+CONFIG += wayland-scanner
+
+QMAKE_USE += wayland-client
+
+qtConfig(xkbcommon-evdev): \
+ QMAKE_USE += xkbcommon_evdev
+
+WAYLANDCLIENTSOURCES += \
+ ../../../3rdparty/protocol/xdg-shell.xml
+
+HEADERS += \
+ qwaylandxdgpopup_p.h \
+ qwaylandxdgshell_p.h \
+ qwaylandxdgshellintegration_p.h \
+ qwaylandxdgsurface_p.h \
+
+SOURCES += \
+ main.cpp \
+ qwaylandxdgpopup.cpp \
+ qwaylandxdgshell.cpp \
+ qwaylandxdgshellintegration.cpp \
+ qwaylandxdgsurface.cpp \
+
+OTHER_FILES += \
+ xdg-shell-v5.json
+
+PLUGIN_TYPE = wayland-shell-integration
+PLUGIN_CLASS_NAME = QWaylandXdgShellV5IntegrationPlugin
+load(qt_plugin)