File indexing completed on 2024-04-28 05:36:54

0001 /*
0002  * SPDX-FileCopyrightText: 2018 Red Hat Inc
0003  *
0004  * SPDX-License-Identifier: LGPL-2.0-or-later
0005  *
0006  * SPDX-FileCopyrightText: 2018 Jan Grulich <jgrulich@redhat.com>
0007  */
0008 
0009 #ifndef XDG_DESKTOP_PORTAL_KDE_WAYLAND_INTEGRATION_H
0010 #define XDG_DESKTOP_PORTAL_KDE_WAYLAND_INTEGRATION_H
0011 
0012 #include <QDBusArgument>
0013 #include <QObject>
0014 #include <QPoint>
0015 #include <QScreen>
0016 #include <QSize>
0017 #include <QVariant>
0018 
0019 #include <KWayland/Client/output.h>
0020 #include <screencasting.h>
0021 
0022 namespace KWayland
0023 {
0024 namespace Client
0025 {
0026 class PlasmaWindowManagement;
0027 class ScreencastingSource;
0028 }
0029 }
0030 
0031 class QWindow;
0032 
0033 namespace WaylandIntegration
0034 {
0035 
0036 struct Stream {
0037     ScreencastingStream *stream = nullptr;
0038     uint nodeId;
0039     QVariantMap map;
0040     bool isValid() const
0041     {
0042         return stream != nullptr;
0043     }
0044 
0045     void close();
0046 };
0047 typedef QList<Stream> Streams;
0048 
0049 class WaylandIntegration : public QObject
0050 {
0051     Q_OBJECT
0052 Q_SIGNALS:
0053     void newBuffer(uint8_t *screenData);
0054     void plasmaWindowManagementInitialized();
0055 };
0056 
0057 bool isStreamingEnabled();
0058 bool isStreamingAvailable();
0059 
0060 void acquireStreamingInput(bool acquire);
0061 Stream startStreamingOutput(QScreen *screen, Screencasting::CursorMode mode);
0062 Stream startStreamingWorkspace(Screencasting::CursorMode mode);
0063 Stream startStreamingVirtual(const QString &name, const QSize &size, Screencasting::CursorMode mode);
0064 Stream startStreamingWindow(const QMap<int, QVariant> &win, Screencasting::CursorMode mode);
0065 Stream startStreamingRegion(const QRect &region, Screencasting::CursorMode mode);
0066 void stopStreaming(uint node);
0067 
0068 void requestPointerButtonPress(quint32 linuxButton);
0069 void requestPointerButtonRelease(quint32 linuxButton);
0070 void requestPointerMotion(const QSizeF &delta);
0071 void requestPointerMotionAbsolute(uint stream, const QPointF &pos);
0072 void requestPointerAxis(qreal x, qreal y);
0073 void requestPointerAxisDiscrete(Qt::Orientation axis, qreal delta);
0074 
0075 void requestKeyboardKeycode(int keycode, bool state);
0076 void requestKeyboardKeysym(int keysym, bool state);
0077 
0078 void requestTouchDown(quint32 touchPoint, const QPointF &pos);
0079 void requestTouchMotion(quint32 touchPoint, const QPointF &pos);
0080 void requestTouchUp(quint32 touchPoint);
0081 
0082 void setParentWindow(QWindow *window, const QString &parentWindow);
0083 
0084 void init();
0085 
0086 KWayland::Client::PlasmaWindowManagement *plasmaWindowManagement();
0087 
0088 WaylandIntegration *waylandIntegration();
0089 
0090 QDebug operator<<(QDebug dbg, const Stream &c);
0091 
0092 const QDBusArgument &operator<<(QDBusArgument &arg, const Stream &stream);
0093 const QDBusArgument &operator>>(const QDBusArgument &arg, Stream &stream);
0094 }
0095 
0096 Q_DECLARE_METATYPE(WaylandIntegration::Stream)
0097 Q_DECLARE_METATYPE(WaylandIntegration::Streams)
0098 
0099 #endif // XDG_DESKTOP_PORTAL_KDE_WAYLAND_INTEGRATION_H