File indexing completed on 2024-02-25 17:31:05

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_P_H
0010 #define XDG_DESKTOP_PORTAL_KDE_WAYLAND_INTEGRATION_P_H
0011 
0012 #include "waylandintegration.h"
0013 
0014 #include <QDateTime>
0015 #include <QMap>
0016 #include <QVector>
0017 
0018 class Screencasting;
0019 class ScreencastingStream;
0020 
0021 namespace KWayland
0022 {
0023 namespace Client
0024 {
0025 class ConnectionThread;
0026 class EventQueue;
0027 class Registry;
0028 class PlasmaWindow;
0029 class PlasmaWindowManagement;
0030 class FakeInput;
0031 class RemoteBuffer;
0032 class Output;
0033 class XdgImporter;
0034 }
0035 }
0036 
0037 class QWindow;
0038 
0039 namespace WaylandIntegration
0040 {
0041 class WaylandIntegrationPrivate : public WaylandIntegration::WaylandIntegration
0042 {
0043     Q_OBJECT
0044 public:
0045     WaylandIntegrationPrivate();
0046     ~WaylandIntegrationPrivate() override;
0047 
0048     void initWayland();
0049 
0050     KWayland::Client::PlasmaWindowManagement *plasmaWindowManagement();
0051 
0052 private:
0053     bool m_registryInitialized = false;
0054 
0055     KWayland::Client::Registry *m_registry = nullptr;
0056     KWayland::Client::PlasmaWindowManagement *m_windowManagement = nullptr;
0057     KWayland::Client::XdgImporter *m_xdgImporter = nullptr;
0058 
0059 public:
0060     void authenticate();
0061 
0062     bool isStreamingEnabled() const;
0063     bool isStreamingAvailable() const;
0064 
0065     void acquireStreamingInput(bool acquire);
0066 
0067     Stream startStreamingOutput(quint32 outputName, Screencasting::CursorMode mode);
0068     Stream startStreamingOutput(QScreen *screen, Screencasting::CursorMode mode);
0069     Stream startStreamingWindow(const QMap<int, QVariant> &win, Screencasting::CursorMode mode);
0070     Stream startStreamingWorkspace(Screencasting::CursorMode mode);
0071     Stream startStreamingVirtualOutput(const QString &name, const QSize &size, Screencasting::CursorMode mode);
0072     void stopStreaming(uint32_t nodeid);
0073 
0074     void requestPointerButtonPress(quint32 linuxButton);
0075     void requestPointerButtonRelease(quint32 linuxButton);
0076     void requestPointerMotion(const QSizeF &delta);
0077     void requestPointerMotionAbsolute(uint stream, const QPointF &pos);
0078     void requestPointerAxis(qreal x, qreal y);
0079     void requestPointerAxisDiscrete(Qt::Orientation axis, qreal delta);
0080     void requestKeyboardKeycode(int keycode, bool state);
0081     void requestKeyboardKeysym(int keysym, bool state);
0082     void requestTouchDown(quint32 touchPoint, const QPointF &pos);
0083     void requestTouchMotion(quint32 touchPoint, const QPointF &pos);
0084     void requestTouchUp(quint32 touchPoint);
0085 
0086     QMap<quint32, WaylandOutput> screens();
0087 
0088     void setParentWindow(QWindow *window, const QString &parentHandle);
0089 
0090 protected Q_SLOTS:
0091     void addOutput(quint32 name, quint32 version);
0092     void removeOutput(quint32 name);
0093 
0094 private:
0095     Stream startStreaming(ScreencastingStream *stream, const QVariantMap &streamOptions);
0096     bool eventFilter(QObject *watched, QEvent *event) override;
0097 
0098     uint m_streamInput = 0;
0099     bool m_waylandAuthenticationRequested = false;
0100 
0101     quint32 m_output;
0102     QDateTime m_lastFrameTime;
0103     QVector<Stream> m_streams;
0104 
0105     QMap<quint32, WaylandOutput> m_outputMap;
0106 
0107     KWayland::Client::FakeInput *m_fakeInput = nullptr;
0108     Screencasting *m_screencasting = nullptr;
0109 };
0110 
0111 }
0112 
0113 #endif // XDG_DESKTOP_PORTAL_KDE_WAYLAND_INTEGRATION_P_H