| 1 | // Copyright (C) 2020 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QWAYLANDNATIVEINTERFACE_P_H |
| 5 | #define QWAYLANDNATIVEINTERFACE_P_H |
| 6 | |
| 7 | // |
| 8 | // W A R N I N G |
| 9 | // ------------- |
| 10 | // |
| 11 | // This file is not part of the Qt API. It exists purely as an |
| 12 | // implementation detail. This header file may change from version to |
| 13 | // version without notice, or even be removed. |
| 14 | // |
| 15 | // We mean it. |
| 16 | // |
| 17 | |
| 18 | #include <QVariantMap> |
| 19 | #include <qpa/qplatformnativeinterface.h> |
| 20 | |
| 21 | #include <QtWaylandClient/qtwaylandclientglobal.h> |
| 22 | #include <QtCore/private/qglobal_p.h> |
| 23 | #include <QtCore/qhash.h> |
| 24 | #include <QtGui/qguiapplication_platform.h> |
| 25 | |
| 26 | QT_BEGIN_NAMESPACE |
| 27 | |
| 28 | class QMargins; |
| 29 | |
| 30 | namespace QtWaylandClient { |
| 31 | |
| 32 | class QWaylandIntegration; |
| 33 | class QWaylandScreen; |
| 34 | |
| 35 | class Q_WAYLANDCLIENT_EXPORT QWaylandNativeInterface : public QPlatformNativeInterface, |
| 36 | public QNativeInterface::QWaylandApplication |
| 37 | { |
| 38 | public: |
| 39 | QWaylandNativeInterface(QWaylandIntegration *integration); |
| 40 | void *nativeResourceForIntegration(const QByteArray &resource) override; |
| 41 | void *nativeResourceForWindow(const QByteArray &resourceString, |
| 42 | QWindow *window) override; |
| 43 | void *nativeResourceForScreen(const QByteArray &resourceString, |
| 44 | QScreen *screen) override; |
| 45 | #if QT_CONFIG(opengl) |
| 46 | void *nativeResourceForContext(const QByteArray &resource, QOpenGLContext *context) override; |
| 47 | #endif |
| 48 | NativeResourceForWindowFunction nativeResourceFunctionForWindow(const QByteArray &resource) override; |
| 49 | QVariantMap windowProperties(QPlatformWindow *window) const override; |
| 50 | QVariant windowProperty(QPlatformWindow *window, const QString &name) const override; |
| 51 | QVariant windowProperty(QPlatformWindow *window, const QString &name, const QVariant &defaultValue) const override; |
| 52 | void setWindowProperty(QPlatformWindow *window, const QString &name, const QVariant &value) override; |
| 53 | |
| 54 | void emitWindowPropertyChanged(QPlatformWindow *window, const QString &name); |
| 55 | |
| 56 | // QWaylandApplication interface |
| 57 | wl_display *display() const override; |
| 58 | wl_compositor *compositor() const override; |
| 59 | wl_seat *seat() const override; |
| 60 | wl_keyboard *keyboard() const override; |
| 61 | wl_pointer *pointer() const override; |
| 62 | wl_touch *touch() const override; |
| 63 | uint lastInputSerial() const override; |
| 64 | wl_seat *lastInputSeat() const override; |
| 65 | |
| 66 | private: |
| 67 | static void setWindowMargins(QWindow *window, const QMargins &margins); |
| 68 | |
| 69 | QWaylandIntegration *m_integration = nullptr; |
| 70 | QHash<QPlatformWindow*, QVariantMap> m_windowProperties; |
| 71 | }; |
| 72 | |
| 73 | } |
| 74 | |
| 75 | QT_END_NAMESPACE |
| 76 | |
| 77 | #endif // QWAYLANDNATIVEINTERFACE_P_H |
| 78 | |