| 1 | /* |
| 2 | This file is part of the KDE libraries |
| 3 | SPDX-FileCopyrightText: 2021 Aleix Pol <aleixpol@kde.org> |
| 4 | SPDX-FileCopyrightText: 2023 Nicolas Fella <nicolas.fella@gmx.de> |
| 5 | |
| 6 | SPDX-License-Identifier: LGPL-2.1-or-later |
| 7 | */ |
| 8 | |
| 9 | #ifndef KWAYLANDEXTRAS_H |
| 10 | #define KWAYLANDEXTRAS_H |
| 11 | |
| 12 | #include <QFuture> |
| 13 | #include <QObject> |
| 14 | #include <QWindow> |
| 15 | |
| 16 | #include <kwindowsystem_export.h> |
| 17 | |
| 18 | /*! |
| 19 | * \class KWaylandExtras |
| 20 | * \inmodule KWindowSystem |
| 21 | * \brief A collection of functions to do Wayland things. |
| 22 | * \since 6.0 |
| 23 | */ |
| 24 | class KWINDOWSYSTEM_EXPORT KWaylandExtras : public QObject |
| 25 | { |
| 26 | Q_OBJECT |
| 27 | |
| 28 | public: |
| 29 | /*! |
| 30 | * |
| 31 | */ |
| 32 | static KWaylandExtras *self(); |
| 33 | |
| 34 | #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(6, 19) |
| 35 | /*! |
| 36 | * Requests an xdg_activation_v1 token for a specific window \a win with the given \a app_id. |
| 37 | * |
| 38 | * \a serial Serial of the event that triggered the request. |
| 39 | * |
| 40 | * \sa lastInputSerial |
| 41 | * \deprecated [6.19] Use xdgActivationToken() instead. |
| 42 | */ |
| 43 | KWINDOWSYSTEM_DEPRECATED_VERSION(6, 19, "Use xdgActivationToken()" ) |
| 44 | Q_INVOKABLE static void requestXdgActivationToken(QWindow *win, uint32_t serial, const QString &app_id); |
| 45 | #endif |
| 46 | |
| 47 | /*! |
| 48 | * Offers the seat's current serial for the given \a window. |
| 49 | */ |
| 50 | Q_INVOKABLE static quint32 lastInputSerial(QWindow *window); |
| 51 | |
| 52 | /*! |
| 53 | * Requests to export the given \a window using xdg_foreign_v2. |
| 54 | * |
| 55 | * \sa windowExported |
| 56 | * \since 6.0 |
| 57 | */ |
| 58 | Q_INVOKABLE static void exportWindow(QWindow *window); |
| 59 | |
| 60 | /*! |
| 61 | * Unexports the \a window previously exported using xdg_foreign_v2. |
| 62 | * |
| 63 | * Asks the compositor to revoke the handle. |
| 64 | * |
| 65 | * \since 6.0 |
| 66 | */ |
| 67 | Q_INVOKABLE static void unexportWindow(QWindow *window); |
| 68 | |
| 69 | /*! |
| 70 | * Requests an xdg_activation_v1 token for a specific window \a window with the given \a appId. |
| 71 | * The \a serial indicates an event that triggered the request. |
| 72 | * |
| 73 | * \note No xdgActivationTokenArrived() signal will be emitted for this token. |
| 74 | * |
| 75 | * \since 6.19 |
| 76 | */ |
| 77 | static QFuture<QString> xdgActivationToken(QWindow *window, uint32_t serial, const QString &appId); |
| 78 | |
| 79 | /*! |
| 80 | * Requests an xdg_activation_v1 token for a specific window \a window with the given \a appId. |
| 81 | * The last received input serial will be used to request the token. |
| 82 | * |
| 83 | * \note No xdgActivationTokenArrived() signal will be emitted for this token. |
| 84 | * |
| 85 | * \since 6.19 |
| 86 | */ |
| 87 | static QFuture<QString> xdgActivationToken(QWindow *window, const QString &appId); |
| 88 | |
| 89 | /*! |
| 90 | * Assigns the specified \a tag to the given \a window. |
| 91 | * |
| 92 | * \since 6.22 |
| 93 | */ |
| 94 | static void setXdgToplevelTag(QWindow *window, const QString &tag); |
| 95 | |
| 96 | /*! |
| 97 | * Assigns the specified \a description to the given \a window. |
| 98 | * |
| 99 | * \since 6.22 |
| 100 | */ |
| 101 | static void setXdgToplevelDescription(QWindow *window, const QString &description); |
| 102 | |
| 103 | Q_SIGNALS: |
| 104 | #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(6, 19) |
| 105 | /*! |
| 106 | * Activation \a token to pass to the client. |
| 107 | * |
| 108 | * \a serial Serial of the event that triggered the request |
| 109 | * |
| 110 | * \sa requestXdgActivationToken |
| 111 | * \deprecated [6.19] Use xdgActivationToken() instead. |
| 112 | */ |
| 113 | KWINDOWSYSTEM_DEPRECATED_VERSION(6, 19, "Use xdgActivationToken()" ) void xdgActivationTokenArrived(int serial, const QString &token); |
| 114 | #endif |
| 115 | |
| 116 | /*! |
| 117 | * The \a handle of the given \a window to pass to the client. |
| 118 | * \sa exportWindow |
| 119 | * \since 6.0 |
| 120 | */ |
| 121 | void windowExported(QWindow *window, const QString &handle); |
| 122 | |
| 123 | private: |
| 124 | KWaylandExtras(); |
| 125 | ~KWaylandExtras(); |
| 126 | |
| 127 | void *d; |
| 128 | }; |
| 129 | |
| 130 | #endif |
| 131 | |