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