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