KWindowSystem

kwaylandextras.cpp
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#include "kwaylandextras.h"
10
11#include "kwindowsystem.h"
12#include "kwindowsystem_p.h"
13
14#include <QTimer>
15
16KWaylandExtras::KWaylandExtras()
17 : QObject()
18{
19}
20
21KWaylandExtras::~KWaylandExtras() = default;
22
23KWaylandExtras *KWaylandExtras::self()
24{
25 static KWaylandExtras instance;
26 return &instance;
27}
28
29void KWaylandExtras::requestXdgActivationToken(QWindow *window, uint32_t serial, const QString &app_id)
30{
31 auto dv2 = dynamic_cast<KWindowSystemPrivateV2 *>(KWindowSystem::d_func());
32 if (!dv2) {
33 // Ensure that xdgActivationTokenArrived is always emitted asynchronously
34 QTimer::singleShot(0, [serial] {
35 Q_EMIT KWaylandExtras::self()->xdgActivationTokenArrived(serial, {});
36 });
37
38 return;
39 }
40 dv2->requestToken(window, serial, app_id);
41}
42
44{
45 auto dv2 = dynamic_cast<KWindowSystemPrivateV2 *>(KWindowSystem::d_func());
46 if (!dv2) {
47 return 0;
48 }
49 return dv2->lastInputSerial(window);
50}
51
53{
54 if (auto dv2 = dynamic_cast<KWindowSystemPrivateV2 *>(KWindowSystem::d_func())) {
55 dv2->exportWindow(window);
56 }
57}
58
60{
61 if (auto dv2 = dynamic_cast<KWindowSystemPrivateV2 *>(KWindowSystem::d_func())) {
62 dv2->unexportWindow(window);
63 }
64}
65
66#include "moc_kwaylandextras.cpp"
A collection of functions to do Wayland things.
void xdgActivationTokenArrived(int serial, const QString &token)
Activation token to pass to the client.
static Q_INVOKABLE void requestXdgActivationToken(QWindow *win, uint32_t serial, const QString &app_id)
Requests an xdg_activation_v1 token for a specific window.
static Q_INVOKABLE void unexportWindow(QWindow *window)
Unexport the window previously exported using xdg_foreign_v2.
static Q_INVOKABLE void exportWindow(QWindow *window)
Requests to export the given window using xdg_foreign_v2.
static Q_INVOKABLE quint32 lastInputSerial(QWindow *window)
Offers the seat's current serial.
Q_EMITQ_EMIT
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 11:51:19 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.