| 1 | /* |
| 2 | SPDX-FileCopyrightText: 2021 Aleix Pol Gonzalez <aleixpol@kde.org> |
| 3 | |
| 4 | SPDX-License-Identifier: LGPL-2.0-or-later |
| 5 | */ |
| 6 | |
| 7 | #ifndef WAYLANDXDGACTIVATIONV1_P_H |
| 8 | #define WAYLANDXDGACTIVATIONV1_P_H |
| 9 | |
| 10 | #include "qwayland-xdg-activation-v1.h" |
| 11 | |
| 12 | #include <QFuture> |
| 13 | #include <QObject> |
| 14 | #include <QPromise> |
| 15 | #include <QtWaylandClient/QWaylandClientExtension> |
| 16 | |
| 17 | class QWaylandSurface; |
| 18 | |
| 19 | class WaylandXdgActivationTokenV1 : public QObject, public QtWayland::xdg_activation_token_v1 |
| 20 | { |
| 21 | Q_OBJECT |
| 22 | |
| 23 | public: |
| 24 | WaylandXdgActivationTokenV1() |
| 25 | { |
| 26 | m_promise.start(); |
| 27 | } |
| 28 | |
| 29 | ~WaylandXdgActivationTokenV1() override |
| 30 | { |
| 31 | destroy(); |
| 32 | } |
| 33 | |
| 34 | QFuture<QString> future() const |
| 35 | { |
| 36 | return m_promise.future(); |
| 37 | } |
| 38 | |
| 39 | protected: |
| 40 | void xdg_activation_token_v1_done(const QString &token) override |
| 41 | { |
| 42 | m_promise.addResult(result: token); |
| 43 | m_promise.finish(); |
| 44 | |
| 45 | Q_EMIT done(token); |
| 46 | deleteLater(); |
| 47 | } |
| 48 | |
| 49 | Q_SIGNALS: |
| 50 | void done(const QString &token); |
| 51 | |
| 52 | private: |
| 53 | QPromise<QString> m_promise; |
| 54 | }; |
| 55 | |
| 56 | class WaylandXdgActivationV1 : public QWaylandClientExtensionTemplate<WaylandXdgActivationV1>, public QtWayland::xdg_activation_v1 |
| 57 | { |
| 58 | public: |
| 59 | ~WaylandXdgActivationV1() override; |
| 60 | |
| 61 | static WaylandXdgActivationV1 *self(); |
| 62 | |
| 63 | WaylandXdgActivationTokenV1 *requestXdgActivationToken(wl_seat *seat, struct ::wl_surface *surface, uint32_t serial, const QString &app_id); |
| 64 | |
| 65 | private: |
| 66 | WaylandXdgActivationV1(); |
| 67 | }; |
| 68 | |
| 69 | #endif |
| 70 | |