File indexing completed on 2024-05-05 03:59:59
0001 /* 0002 This file is part of the KDE libraries 0003 SPDX-FileCopyrightText: 2021 Aleix Pol <aleixpol@kde.org> 0004 SPDX-FileCopyrightText: 2023 Nicolas Fella <nicolas.fella@gmx.de> 0005 0006 SPDX-License-Identifier: LGPL-2.1-or-later 0007 */ 0008 0009 #include "kwaylandextras.h" 0010 0011 #include "kwindowsystem.h" 0012 #include "kwindowsystem_p.h" 0013 0014 #include <QTimer> 0015 0016 KWaylandExtras::KWaylandExtras() 0017 : QObject() 0018 { 0019 } 0020 0021 KWaylandExtras::~KWaylandExtras() = default; 0022 0023 KWaylandExtras *KWaylandExtras::self() 0024 { 0025 static KWaylandExtras instance; 0026 return &instance; 0027 } 0028 0029 void KWaylandExtras::requestXdgActivationToken(QWindow *window, uint32_t serial, const QString &app_id) 0030 { 0031 auto dv2 = dynamic_cast<KWindowSystemPrivateV2 *>(KWindowSystem::d_func()); 0032 if (!dv2) { 0033 // Ensure that xdgActivationTokenArrived is always emitted asynchronously 0034 QTimer::singleShot(0, [serial] { 0035 Q_EMIT KWaylandExtras::self()->xdgActivationTokenArrived(serial, {}); 0036 }); 0037 0038 return; 0039 } 0040 dv2->requestToken(window, serial, app_id); 0041 } 0042 0043 quint32 KWaylandExtras::lastInputSerial(QWindow *window) 0044 { 0045 auto dv2 = dynamic_cast<KWindowSystemPrivateV2 *>(KWindowSystem::d_func()); 0046 if (!dv2) { 0047 return 0; 0048 } 0049 return dv2->lastInputSerial(window); 0050 } 0051 0052 void KWaylandExtras::exportWindow(QWindow *window) 0053 { 0054 if (auto dv2 = dynamic_cast<KWindowSystemPrivateV2 *>(KWindowSystem::d_func())) { 0055 dv2->exportWindow(window); 0056 } 0057 } 0058 0059 void KWaylandExtras::unexportWindow(QWindow *window) 0060 { 0061 if (auto dv2 = dynamic_cast<KWindowSystemPrivateV2 *>(KWindowSystem::d_func())) { 0062 dv2->unexportWindow(window); 0063 } 0064 }