summaryrefslogtreecommitdiffstats
path: root/src/client/shellintegration
diff options
context:
space:
mode:
authorPaul Olav Tvete <paul.tvete@qt.io>2021-10-18 16:41:12 +0200
committerPaul Olav Tvete <paul.tvete@qt.io>2021-12-02 09:08:40 +0100
commitd89c8920f3b82dd2098971b5a66c4b9c75da5af0 (patch)
treeb7f35e03485f1aa8725e30870f3066b34d24ea94 /src/client/shellintegration
parent0204df32ee7417db3156ef3c70bcf762d7e9fb0a (diff)
Introduce new qt-shell and an API for custom shells
Adds a new API for writing custom shell extensions. This API is supported, but semi-public. Binary compatibility is not guaranteed. Also adds qt-shell, a new shell that maps directly to the QWindow API, and provides functionality that Qt provides on other window systems, such as absolute window positions and window activation. This shell is not intended for use on the desktop. This is a squashed commit of a development branch consisting of approximately 60 changes. Contributors: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> Paul Olav Tvete <paul.tvete@qt.io> Task-number: QTBUG-94330 Task-number: QTBUG-91542 Change-Id: I419b6bd8179fe03e4da47d328c7ff4b4795b8a91 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> Reviewed-by: David Edmundson <davidedmundson@kde.org> Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Diffstat (limited to 'src/client/shellintegration')
-rw-r--r--src/client/shellintegration/qwaylandclientshellapi_p.h60
-rw-r--r--src/client/shellintegration/qwaylandshellintegration.cpp57
-rw-r--r--src/client/shellintegration/qwaylandshellintegration_p.h57
3 files changed, 171 insertions, 3 deletions
diff --git a/src/client/shellintegration/qwaylandclientshellapi_p.h b/src/client/shellintegration/qwaylandclientshellapi_p.h
new file mode 100644
index 000000000..a8863e7d3
--- /dev/null
+++ b/src/client/shellintegration/qwaylandclientshellapi_p.h
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtWaylandClient module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL$
+** 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 General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 or (at your option) 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.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-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDCLIENTSHELLAPI_P_H
+#define QWAYLANDCLIENTSHELLAPI_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.
+//
+
+// N O T E
+// -------
+// This file provides a supported API for creating client-side shell
+// extensions. Source compatibility will be preserved, but we may break
+// forward and backward binary compatibility, even in patch releases.
+//
+// The supported API contains these classes:
+//
+// QtWaylandClient::QWaylandShellSurface
+// QtWaylandClient::QWaylandShellIntegration
+// QtWaylandClient::QWaylandShellIntegrationPlugin
+
+#include "QtWaylandClient/private/qwaylandshellsurface_p.h"
+#include "QtWaylandClient/private/qwaylandshellintegration_p.h"
+#include "QtWaylandClient/private/qwaylandshellintegrationplugin_p.h"
+
+#endif // QWAYLANDCLIENTSHELLAPI_P_H
diff --git a/src/client/shellintegration/qwaylandshellintegration.cpp b/src/client/shellintegration/qwaylandshellintegration.cpp
new file mode 100644
index 000000000..7bc37792f
--- /dev/null
+++ b/src/client/shellintegration/qwaylandshellintegration.cpp
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtWaylandClient module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL$
+** 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 General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 or (at your option) 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.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-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "qwaylandshellintegration_p.h"
+#include <QtWaylandClient/private/qwaylanddisplay_p.h>
+#include <QtWaylandClient/private/qwaylandwindow_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace QtWaylandClient {
+
+wl_surface *QWaylandShellIntegration::wlSurfaceForWindow(QWaylandWindow *window)
+{
+ return window->wlSurface();
+}
+
+bool QWaylandShellIntegration::findGlobal(const QString &interface, wl_registry **registry, uint32_t *id, uint32_t *version)
+{
+ for (QWaylandDisplay::RegistryGlobal &global : m_display->globals()) {
+ if (global.interface == interface) {
+ *registry = m_display->wl_registry();
+ *id = global.id;
+ *version = global.version;
+ return true;
+ }
+ }
+ return false;
+}
+
+}
+
+QT_END_NAMESPACE
diff --git a/src/client/shellintegration/qwaylandshellintegration_p.h b/src/client/shellintegration/qwaylandshellintegration_p.h
index b308ffe25..4de19e786 100644
--- a/src/client/shellintegration/qwaylandshellintegration_p.h
+++ b/src/client/shellintegration/qwaylandshellintegration_p.h
@@ -52,10 +52,19 @@
//
#include <QtWaylandClient/qtwaylandclientglobal.h>
-#include <QtWaylandClient/private/qwaylanddisplay_p.h>
+#include <QtWaylandClient/qwaylandclientextension.h>
+
+
+
+#include <QDebug>
+
+struct wl_surface;
+struct wl_registry;
QT_BEGIN_NAMESPACE
+class QWindow;
+
namespace QtWaylandClient {
class QWaylandWindow;
@@ -68,9 +77,12 @@ public:
QWaylandShellIntegration() {}
virtual ~QWaylandShellIntegration() {}
- virtual bool initialize(QWaylandDisplay *display) {
+ bool initialize(QWaylandDisplay *display) {
m_display = display;
- return true;
+ return initialize();
+ }
+ virtual bool initialize() {
+ return false;
}
virtual QWaylandShellSurface *createShellSurface(QWaylandWindow *window) = 0;
virtual void *nativeResourceForWindow(const QByteArray &resource, QWindow *window) {
@@ -79,10 +91,49 @@ public:
return nullptr;
}
+ static wl_surface *wlSurfaceForWindow(QWaylandWindow *window);
+ bool findGlobal(const QString &interface, wl_registry **registry, uint32_t *id, uint32_t *version);
+
protected:
QWaylandDisplay *m_display = nullptr;
};
+template <typename T>
+class Q_WAYLAND_CLIENT_EXPORT QWaylandShellIntegrationTemplate : public QWaylandShellIntegration, public QWaylandClientExtension
+{
+public:
+ QWaylandShellIntegrationTemplate(const int ver) :
+ QWaylandClientExtension(ver)
+ {
+ }
+
+ bool initialize() override
+ {
+ QWaylandClientExtension::initialize();
+ return isActive();
+ }
+
+ const struct wl_interface *extensionInterface() const override
+ {
+ return T::interface();
+ }
+
+ void bind(struct ::wl_registry *registry, int id, int ver) override
+ {
+ T* instance = static_cast<T *>(this);
+ // Make sure lowest version is used of the supplied version from the
+ // developer and the version specified in the protocol and also the
+ // compositor version.
+ if (this->version() > T::interface()->version) {
+ qWarning("Supplied protocol version to QWaylandClientExtensionTemplate is higher than the version of the protocol, using protocol version instead.");
+ }
+ int minVersion = qMin(ver, qMin(T::interface()->version, this->version()));
+ setVersion(minVersion);
+ instance->init(registry, id, minVersion);
+ }
+};
+
+
}
QT_END_NAMESPACE