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 #ifndef KWAYLANDEXTRAS_H
0010 #define KWAYLANDEXTRAS_H
0011 
0012 #include <QObject>
0013 #include <QWindow>
0014 
0015 #include <kwindowsystem_export.h>
0016 
0017 /**
0018  * A collection of functions to do Wayland things
0019  * @since 6.0
0020  */
0021 class KWINDOWSYSTEM_EXPORT KWaylandExtras : public QObject
0022 {
0023     Q_OBJECT
0024 
0025 public:
0026     static KWaylandExtras *self();
0027 
0028     /**
0029      * Requests an xdg_activation_v1 token for a specific window.
0030      *
0031      * @param win window in behalf this request is made
0032      * @param serial of the event that triggered the request
0033      * @param app_id identifier of the application that we are launching
0034      *
0035      * @see lastInputSerial
0036      */
0037     Q_INVOKABLE static void requestXdgActivationToken(QWindow *win, uint32_t serial, const QString &app_id);
0038 
0039     /**
0040      * Offers the seat's current serial
0041      */
0042     Q_INVOKABLE static quint32 lastInputSerial(QWindow *window);
0043 
0044     /**
0045      * Requests to export the given window using xdg_foreign_v2.
0046      *
0047      * @param window The window to export.
0048      *
0049      * @see windowExported
0050      * @since 6.0
0051      */
0052     Q_INVOKABLE static void exportWindow(QWindow *window);
0053 
0054     /**
0055      * Unexport the window previously exported using xdg_foreign_v2.
0056      *
0057      * Asks the compositor to revoke the handle.
0058      *
0059      * @param window The window to unexport.
0060      * @since 6.0
0061      */
0062     Q_INVOKABLE static void unexportWindow(QWindow *window);
0063 
0064 Q_SIGNALS:
0065     /**
0066      * Activation @p token to pass to the client.
0067      *
0068      * @see requestXdgActivationToken
0069      */
0070     void xdgActivationTokenArrived(int serial, const QString &token);
0071 
0072     /**
0073      * Window @p handle to pass to the client.
0074      *
0075      * @param window The window that requested the handle.
0076      * @param handle The handle.
0077      *
0078      * @see exportWindow
0079      * @since 6.0
0080      */
0081     void windowExported(QWindow *window, const QString &handle);
0082 
0083 private:
0084     KWaylandExtras();
0085     ~KWaylandExtras();
0086 
0087     void *d;
0088 };
0089 
0090 #endif