| 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 <QObject> |
| 13 | #include <QWindow> |
| 14 | |
| 15 | #include <kwindowsystem_export.h> |
| 16 | |
| 17 | /*! |
| 18 | * \class KWaylandExtras |
| 19 | * \inmodule KWindowSystem |
| 20 | * \brief A collection of functions to do Wayland things. |
| 21 | * \since 6.0 |
| 22 | */ |
| 23 | class KWINDOWSYSTEM_EXPORT KWaylandExtras : public QObject |
| 24 | { |
| 25 | Q_OBJECT |
| 26 | |
| 27 | public: |
| 28 | /*! |
| 29 | * |
| 30 | */ |
| 31 | static KWaylandExtras *self(); |
| 32 | |
| 33 | /*! |
| 34 | * Requests an xdg_activation_v1 token for a specific window \a win with the given \a app_id. |
| 35 | * |
| 36 | * \a serial Serial of the event that triggered the request. |
| 37 | * |
| 38 | * \sa lastInputSerial |
| 39 | */ |
| 40 | Q_INVOKABLE static void requestXdgActivationToken(QWindow *win, uint32_t serial, const QString &app_id); |
| 41 | |
| 42 | /*! |
| 43 | * Offers the seat's current serial for the given \a window. |
| 44 | */ |
| 45 | Q_INVOKABLE static quint32 lastInputSerial(QWindow *window); |
| 46 | |
| 47 | /*! |
| 48 | * Requests to export the given \a window using xdg_foreign_v2. |
| 49 | * |
| 50 | * \sa windowExported |
| 51 | * \since 6.0 |
| 52 | */ |
| 53 | Q_INVOKABLE static void exportWindow(QWindow *window); |
| 54 | |
| 55 | /*! |
| 56 | * Unexports the \a window previously exported using xdg_foreign_v2. |
| 57 | * |
| 58 | * Asks the compositor to revoke the handle. |
| 59 | * |
| 60 | * \since 6.0 |
| 61 | */ |
| 62 | Q_INVOKABLE static void unexportWindow(QWindow *window); |
| 63 | |
| 64 | Q_SIGNALS: |
| 65 | /*! |
| 66 | * Activation \a token to pass to the client. |
| 67 | * |
| 68 | * \a serial Serial of the event that triggered the request |
| 69 | * |
| 70 | * \sa requestXdgActivationToken |
| 71 | */ |
| 72 | void xdgActivationTokenArrived(int serial, const QString &token); |
| 73 | |
| 74 | /*! |
| 75 | * The \a handle of the given \a window to pass to the client. |
| 76 | * \sa exportWindow |
| 77 | * \since 6.0 |
| 78 | */ |
| 79 | void windowExported(QWindow *window, const QString &handle); |
| 80 | |
| 81 | private: |
| 82 | KWaylandExtras(); |
| 83 | ~KWaylandExtras(); |
| 84 | |
| 85 | void *d; |
| 86 | }; |
| 87 | |
| 88 | #endif |
| 89 | |