Changeset View
Changeset View
Standalone View
Standalone View
src/waylandintegration.h
Show All 20 Lines | |||||
21 | #ifndef XDG_DESKTOP_PORTAL_KDE_WAYLAND_INTEGRATION_H | 21 | #ifndef XDG_DESKTOP_PORTAL_KDE_WAYLAND_INTEGRATION_H | ||
22 | #define XDG_DESKTOP_PORTAL_KDE_WAYLAND_INTEGRATION_H | 22 | #define XDG_DESKTOP_PORTAL_KDE_WAYLAND_INTEGRATION_H | ||
23 | 23 | | |||
24 | #include <QObject> | 24 | #include <QObject> | ||
25 | #include <QPoint> | 25 | #include <QPoint> | ||
26 | #include <QSize> | 26 | #include <QSize> | ||
27 | #include <QVariant> | 27 | #include <QVariant> | ||
28 | 28 | | |||
29 | #if HAVE_PIPEWIRE_SUPPORT | 29 | #include <KWayland/Client/output.h> | ||
30 | #include <gbm.h> | | |||
31 | #include <epoxy/egl.h> | | |||
32 | #include <epoxy/gl.h> | | |||
33 | #endif | | |||
34 | 30 | | |||
35 | namespace KWayland { | 31 | namespace KWayland { | ||
36 | namespace Client { | 32 | namespace Client { | ||
37 | class PlasmaWindowManagement; | 33 | class PlasmaWindowManagement; | ||
34 | class ScreencastingSource; | ||||
38 | } | 35 | } | ||
39 | } | 36 | } | ||
40 | 37 | | |||
41 | namespace WaylandIntegration | 38 | namespace WaylandIntegration | ||
42 | { | 39 | { | ||
43 | #if HAVE_PIPEWIRE_SUPPORT | | |||
44 | struct EGLStruct { | | |||
45 | QList<QByteArray> extensions; | | |||
46 | EGLDisplay display = EGL_NO_DISPLAY; | | |||
47 | EGLContext context = EGL_NO_CONTEXT; | | |||
48 | }; | | |||
49 | 40 | | |||
50 | class WaylandOutput | 41 | class WaylandOutput | ||
51 | { | 42 | { | ||
52 | public: | 43 | public: | ||
53 | enum OutputType { | 44 | enum OutputType { | ||
54 | Laptop, | 45 | Laptop, | ||
55 | Monitor, | 46 | Monitor, | ||
56 | Television | 47 | Television | ||
57 | }; | 48 | }; | ||
58 | void setManufacturer(const QString &manufacturer) { m_manufacturer = manufacturer; } | 49 | QString manufacturer() const { return m_output->manufacturer(); } | ||
59 | QString manufacturer() const { return m_manufacturer; } | 50 | QString model() const { return m_output->model(); } | ||
60 | 51 | QPoint globalPosition() const { return m_output->globalPosition(); } | |||
61 | void setModel(const QString &model) { m_model = model; } | 52 | QSize resolution() const { return m_output->pixelSize(); } | ||
62 | QString model() const { return m_model; } | | |||
63 | | ||||
64 | void setGlobalPosition(const QPoint &pos) { m_globalPosition = pos; } | | |||
65 | QPoint globalPosition() const { return m_globalPosition; } | | |||
66 | | ||||
67 | void setResolution(const QSize &resolution) { m_resolution = resolution; } | | |||
68 | QSize resolution() const { return m_resolution; } | | |||
69 | | ||||
70 | void setOutputType(const QString &type); | | |||
71 | OutputType outputType() const { return m_outputType; } | 53 | OutputType outputType() const { return m_outputType; } | ||
72 | 54 | | |||
55 | QSharedPointer<KWayland::Client::Output> output() const { return m_output; } | ||||
56 | void setOutput(const QSharedPointer<KWayland::Client::Output> &output) { | ||||
57 | m_output = output; | ||||
58 | setOutputType(output->model()); | ||||
59 | } | ||||
60 | | ||||
73 | void setWaylandOutputName(int outputName) { m_waylandOutputName = outputName; } | 61 | void setWaylandOutputName(int outputName) { m_waylandOutputName = outputName; } | ||
74 | int waylandOutputName() const { return m_waylandOutputName; } | 62 | int waylandOutputName() const { return m_waylandOutputName; } | ||
75 | 63 | | |||
76 | void setWaylandOutputVersion(int outputVersion) { m_waylandOutputVersion = outputVersion; } | 64 | void setWaylandOutputVersion(int outputVersion) { m_waylandOutputVersion = outputVersion; } | ||
77 | int waylandOutputVersion() const { return m_waylandOutputVersion; } | 65 | int waylandOutputVersion() const { return m_waylandOutputVersion; } | ||
78 | 66 | | |||
79 | private: | 67 | private: | ||
80 | QString m_manufacturer; | 68 | void setOutputType(const QString &model); | ||
81 | QString m_model; | 69 | OutputType m_outputType = Monitor; | ||
82 | QPoint m_globalPosition; | 70 | QSharedPointer<KWayland::Client::Output> m_output; | ||
83 | QSize m_resolution; | | |||
84 | OutputType m_outputType; | | |||
85 | 71 | | |||
86 | // Needed for later output binding | 72 | // Needed for later output binding | ||
87 | int m_waylandOutputName; | 73 | int m_waylandOutputName; | ||
88 | int m_waylandOutputVersion; | 74 | int m_waylandOutputVersion; | ||
89 | }; | 75 | }; | ||
90 | #endif | | |||
91 | 76 | | |||
92 | class WaylandIntegration : public QObject | 77 | class WaylandIntegration : public QObject | ||
93 | { | 78 | { | ||
94 | Q_OBJECT | 79 | Q_OBJECT | ||
95 | Q_SIGNALS: | 80 | Q_SIGNALS: | ||
96 | #if HAVE_PIPEWIRE_SUPPORT | | |||
97 | void newBuffer(uint8_t *screenData); | 81 | void newBuffer(uint8_t *screenData); | ||
98 | #endif | | |||
99 | void plasmaWindowManagementInitialized(); | 82 | void plasmaWindowManagementInitialized(); | ||
100 | }; | 83 | }; | ||
101 | 84 | | |||
102 | #if HAVE_PIPEWIRE_SUPPORT | | |||
103 | const char * formatGLError(GLenum err); | | |||
104 | | ||||
105 | void authenticate(); | 85 | void authenticate(); | ||
106 | 86 | | |||
107 | bool isEGLInitialized(); | | |||
108 | bool isStreamingEnabled(); | 87 | bool isStreamingEnabled(); | ||
109 | 88 | | |||
110 | void startStreamingInput(); | 89 | void startStreamingInput(); | ||
111 | bool startStreaming(quint32 outputName); | 90 | bool startStreamingOutput(quint32 outputName); | ||
112 | void stopStreaming(); | 91 | bool startStreamingWindow(quint32 winid); | ||
92 | void stopAllStreaming(); | ||||
113 | 93 | | |||
114 | void requestPointerButtonPress(quint32 linuxButton); | 94 | void requestPointerButtonPress(quint32 linuxButton); | ||
115 | void requestPointerButtonRelease(quint32 linuxButton); | 95 | void requestPointerButtonRelease(quint32 linuxButton); | ||
116 | void requestPointerMotion(const QSizeF &delta); | 96 | void requestPointerMotion(const QSizeF &delta); | ||
117 | void requestPointerMotionAbsolute(const QPointF &pos); | 97 | void requestPointerMotionAbsolute(const QPointF &pos); | ||
118 | void requestPointerAxisDiscrete(Qt::Orientation axis, qreal delta); | 98 | void requestPointerAxisDiscrete(Qt::Orientation axis, qreal delta); | ||
119 | 99 | | |||
120 | void requestKeyboardKeycode(int keycode, bool state); | 100 | void requestKeyboardKeycode(int keycode, bool state); | ||
121 | 101 | | |||
122 | EGLStruct egl(); | | |||
123 | QMap<quint32, WaylandOutput> screens(); | 102 | QMap<quint32, WaylandOutput> screens(); | ||
124 | QVariant streams(); | 103 | QVariant streams(); | ||
125 | #endif | 104 | | ||
126 | void init(); | 105 | void init(); | ||
127 | 106 | | |||
128 | KWayland::Client::PlasmaWindowManagement *plasmaWindowManagement(); | 107 | KWayland::Client::PlasmaWindowManagement *plasmaWindowManagement(); | ||
129 | 108 | | |||
130 | WaylandIntegration *waylandIntegration(); | 109 | WaylandIntegration *waylandIntegration(); | ||
131 | } | 110 | } | ||
132 | 111 | | |||
133 | #endif // XDG_DESKTOP_PORTAL_KDE_WAYLAND_INTEGRATION_H | 112 | #endif // XDG_DESKTOP_PORTAL_KDE_WAYLAND_INTEGRATION_H | ||
134 | 113 | | |||
135 | 114 | |