waylandintegration.h 3.41 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/*
 * Copyright © 2018 Red Hat, Inc
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
 *
 * Authors:
 *       Jan Grulich <jgrulich@redhat.com>
 */

#ifndef XDG_DESKTOP_PORTAL_KDE_WAYLAND_INTEGRATION_H
#define XDG_DESKTOP_PORTAL_KDE_WAYLAND_INTEGRATION_H

#include <QObject>
Jan Grulich's avatar
Jan Grulich committed
25
#include <QPoint>
26
#include <QSize>
27
#include <QVariant>
28

29
30
#include <KWayland/Client/output.h>
#include <screencasting.h>
31

Jan Grulich's avatar
Jan Grulich committed
32
33
34
namespace KWayland {
    namespace Client {
        class PlasmaWindowManagement;
35
        class ScreencastingSource;
Jan Grulich's avatar
Jan Grulich committed
36
37
38
    }
}

39
40
namespace WaylandIntegration
{
Jan Grulich's avatar
Jan Grulich committed
41

42
43
44
45
46
47
48
49
class WaylandOutput
{
public:
    enum OutputType {
        Laptop,
        Monitor,
        Television
    };
50
51
52
53
    QString manufacturer() const { return m_output->manufacturer(); }
    QString model() const { return m_output->model(); }
    QPoint globalPosition() const { return m_output->globalPosition(); }
    QSize resolution() const { return m_output->pixelSize(); }
54
55
    OutputType outputType() const { return m_outputType; }

56
57
58
59
60
61
    QSharedPointer<KWayland::Client::Output> output() const { return m_output; }
    void setOutput(const QSharedPointer<KWayland::Client::Output> &output) {
        m_output = output;
        setOutputType(output->model());
    }

62
63
64
65
66
67
68
    void setWaylandOutputName(int outputName) { m_waylandOutputName = outputName; }
    int waylandOutputName() const { return m_waylandOutputName; }

    void setWaylandOutputVersion(int outputVersion) { m_waylandOutputVersion = outputVersion; }
    int waylandOutputVersion() const { return m_waylandOutputVersion; }

private:
69
70
71
    void setOutputType(const QString &model);
    OutputType m_outputType = Monitor;
    QSharedPointer<KWayland::Client::Output> m_output;
72
73
74
75
76
77
78
79
80
81
82

    // Needed for later output binding
    int m_waylandOutputName;
    int m_waylandOutputVersion;
};

class WaylandIntegration : public QObject
{
    Q_OBJECT
Q_SIGNALS:
    void newBuffer(uint8_t *screenData);
Jan Grulich's avatar
Jan Grulich committed
83
    void plasmaWindowManagementInitialized();
84
};
85

Jan Grulich's avatar
Jan Grulich committed
86
    void authenticate();
87

Jan Grulich's avatar
Jan Grulich committed
88
    bool isStreamingEnabled();
89
    bool isStreamingAvailable();
90

91
    void startStreamingInput();
92
93
94
    bool startStreamingOutput(quint32 outputName, Screencasting::CursorMode mode);
    bool startStreamingWindow(const QByteArray &winid);
    void stopAllStreaming();
95

Jan Grulich's avatar
Jan Grulich committed
96
97
98
99
100
101
    void requestPointerButtonPress(quint32 linuxButton);
    void requestPointerButtonRelease(quint32 linuxButton);
    void requestPointerMotion(const QSizeF &delta);
    void requestPointerMotionAbsolute(const QPointF &pos);
    void requestPointerAxisDiscrete(Qt::Orientation axis, qreal delta);

102
103
    void requestKeyboardKeycode(int keycode, bool state);

104
    QMap<quint32, WaylandOutput> screens();
105
    QVariant streams();
106

107
108
109
    void init();

    KWayland::Client::PlasmaWindowManagement *plasmaWindowManagement();
110
111
112
113
114
115
116

    WaylandIntegration *waylandIntegration();
}

#endif // XDG_DESKTOP_PORTAL_KDE_WAYLAND_INTEGRATION_H