File indexing completed on 2024-11-10 04:57:12

0001 /*
0002     SPDX-FileCopyrightText: 2019 Martin Flöser <mgraesslin@kde.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005 */
0006 #include "windowsystem.h"
0007 
0008 #include <KWaylandExtras>
0009 #include <KWindowSystem>
0010 
0011 #include <QGuiApplication>
0012 #include <QWindow>
0013 #include <wayland/display.h>
0014 #include <wayland/seat.h>
0015 #include <wayland_server.h>
0016 #include <window.h>
0017 #include <workspace.h>
0018 #include <xdgactivationv1.h>
0019 
0020 Q_DECLARE_METATYPE(NET::WindowType)
0021 
0022 namespace KWin
0023 {
0024 
0025 WindowSystem::WindowSystem()
0026     : QObject()
0027     , KWindowSystemPrivateV2()
0028 {
0029 }
0030 
0031 void WindowSystem::activateWindow(QWindow *win, long int time)
0032 {
0033     // KWin cannot activate own windows
0034 }
0035 
0036 void WindowSystem::setShowingDesktop(bool showing)
0037 {
0038     // KWin should not use KWindowSystem to set showing desktop state
0039 }
0040 
0041 bool WindowSystem::showingDesktop()
0042 {
0043     // KWin should not use KWindowSystem for showing desktop state
0044     return false;
0045 }
0046 
0047 void WindowSystem::requestToken(QWindow *win, uint32_t serial, const QString &appId)
0048 {
0049     auto seat = KWin::waylandServer()->seat();
0050     auto token = KWin::waylandServer()->xdgActivationIntegration()->requestPrivilegedToken(nullptr, seat->display()->serial(), seat, appId);
0051     // Ensure that xdgActivationTokenArrived is always emitted asynchronously
0052     QTimer::singleShot(0, [serial, token] {
0053         Q_EMIT KWaylandExtras::self()->xdgActivationTokenArrived(serial, token);
0054     });
0055 }
0056 
0057 void WindowSystem::setCurrentToken(const QString &token)
0058 {
0059     // KWin cannot activate own windows
0060 }
0061 
0062 quint32 WindowSystem::lastInputSerial(QWindow *window)
0063 {
0064     auto w = workspace()->findInternal(window);
0065     if (!w) {
0066         return 0;
0067     }
0068     return w->lastUsageSerial();
0069 }
0070 
0071 void WindowSystem::exportWindow(QWindow *window)
0072 {
0073     Q_UNUSED(window);
0074 }
0075 
0076 void WindowSystem::unexportWindow(QWindow *window)
0077 {
0078     Q_UNUSED(window);
0079 }
0080 
0081 void WindowSystem::setMainWindow(QWindow *window, const QString &handle)
0082 {
0083     Q_UNUSED(window);
0084     Q_UNUSED(handle);
0085 }
0086 }
0087 
0088 #include "moc_windowsystem.cpp"