KWin
Loading...
Searching...
No Matches
screencast_v1.cpp
Go to the documentation of this file.
1/*
2 SPDX-FileCopyrightText: 2020 Aleix Pol Gonzalez <aleixpol@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5*/
6
7#include "screencast_v1.h"
8#include "display.h"
9#include "output.h"
10
11#include <QDebug>
12#include <QRect>
13
14#include "qwayland-server-zkde-screencast-unstable-v1.h"
15
16namespace KWin
17{
18static int s_version = 3;
19
20class ScreencastStreamV1InterfacePrivate : public QtWaylandServer::zkde_screencast_stream_unstable_v1
21{
22public:
27
29 {
30 if (!stopped) {
31 Q_EMIT q->finished();
32 }
33
34 q->deleteLater();
35 }
36
37 void zkde_screencast_stream_unstable_v1_close(Resource *resource) override
38 {
39 Q_EMIT q->finished();
40 stopped = true;
41 wl_resource_destroy(resource->handle);
42 }
43
44 bool stopped = false;
46};
47
48ScreencastStreamV1Interface::ScreencastStreamV1Interface(QObject *parent)
49 : QObject(parent)
51{
52}
53
55
57{
58 d->send_created(nodeid);
59}
60
62{
63 d->send_failed(error);
64}
65
67{
68 if (!d->stopped) {
69 d->send_closed();
70 }
71}
72
73class ScreencastV1InterfacePrivate : public QtWaylandServer::zkde_screencast_unstable_v1
74{
75public:
77 : QtWaylandServer::zkde_screencast_unstable_v1(*display, s_version)
78 , q(q)
79 {
80 }
81
82 ScreencastStreamV1Interface *createStream(Resource *resource, quint32 streamid) const
83 {
84 auto stream = new ScreencastStreamV1Interface(q);
85 stream->d->init(resource->client(), streamid, resource->version());
86 return stream;
87 }
88
89 void zkde_screencast_unstable_v1_stream_output(Resource *resource, uint32_t streamid, struct ::wl_resource *output, uint32_t pointer) override
90 {
92 }
93
94 void zkde_screencast_unstable_v1_stream_window(Resource *resource, uint32_t streamid, const QString &uuid, uint32_t pointer) override
95 {
96 Q_EMIT q->windowScreencastRequested(createStream(resource, streamid), uuid, ScreencastV1Interface::CursorMode(pointer));
97 }
99 uint32_t streamid,
100 const QString &name,
101 int32_t width,
102 int32_t height,
103 wl_fixed_t scale,
104 uint32_t pointer) override
105 {
106 Q_EMIT q->virtualOutputScreencastRequested(createStream(resource, streamid),
107 name,
108 {width, height},
109 wl_fixed_to_double(scale),
111 }
112
113 void zkde_screencast_unstable_v1_stream_region(QtWaylandServer::zkde_screencast_unstable_v1::Resource *resource,
114 uint32_t stream,
115 int32_t x,
116 int32_t y,
117 uint32_t width,
118 uint32_t height,
119 wl_fixed_t scale,
120 uint32_t pointer) override
121 {
122 Q_EMIT q->regionScreencastRequested(createStream(resource, stream),
123 {x, y, int(width), int(height)},
124 wl_fixed_to_double(scale),
126 }
127
128 void zkde_screencast_unstable_v1_destroy(Resource *resource) override
129 {
130 wl_resource_destroy(resource->handle);
131 }
132
134};
135
137 : QObject(parent)
138 , d(new ScreencastV1InterfacePrivate(display, this))
139{
140}
141
143
144} // namespace KWin
145
146#include "moc_screencast_v1.cpp"
Class holding the Wayland server display loop.
Definition display.h:34
static OutputInterface * get(wl_resource *native)
Definition output.cpp:320
void sendFailed(const QString &error)
void zkde_screencast_stream_unstable_v1_close(Resource *resource) override
ScreencastStreamV1InterfacePrivate(ScreencastStreamV1Interface *q)
ScreencastStreamV1Interface *const q
void zkde_screencast_stream_unstable_v1_destroy_resource(Resource *resource) override
ScreencastV1Interface(Display *display, QObject *parent=nullptr)
void virtualOutputScreencastRequested(ScreencastStreamV1Interface *stream, const QString &name, const QSize &size, double scaling, CursorMode mode)
void outputScreencastRequested(ScreencastStreamV1Interface *stream, OutputInterface *output, CursorMode mode)
void regionScreencastRequested(ScreencastStreamV1Interface *stream, const QRect &geometry, qreal scaling, CursorMode mode)
void windowScreencastRequested(ScreencastStreamV1Interface *stream, const QString &winid, CursorMode mode)
void zkde_screencast_unstable_v1_stream_window(Resource *resource, uint32_t streamid, const QString &uuid, uint32_t pointer) override
ScreencastV1InterfacePrivate(Display *display, ScreencastV1Interface *q)
void zkde_screencast_unstable_v1_stream_virtual_output(Resource *resource, uint32_t streamid, const QString &name, int32_t width, int32_t height, wl_fixed_t scale, uint32_t pointer) override
ScreencastStreamV1Interface * createStream(Resource *resource, quint32 streamid) const
void zkde_screencast_unstable_v1_destroy(Resource *resource) override
void zkde_screencast_unstable_v1_stream_output(Resource *resource, uint32_t streamid, struct ::wl_resource *output, uint32_t pointer) override
ScreencastV1Interface *const q
void zkde_screencast_unstable_v1_stream_region(QtWaylandServer::zkde_screencast_unstable_v1::Resource *resource, uint32_t stream, int32_t x, int32_t y, uint32_t width, uint32_t height, wl_fixed_t scale, uint32_t pointer) override