waylandintegration_p.h 3.63 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 25
/*
 * 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_P_H
#define XDG_DESKTOP_PORTAL_KDE_WAYLAND_INTEGRATION_P_H

#include "waylandintegration.h"

26
#include <QDateTime>
27 28
#include <QMap>

29 30
class ScreenCastStream;

31 32 33 34
namespace KWayland {
    namespace Client {
        class ConnectionThread;
        class EventQueue;
Jan Grulich's avatar
Jan Grulich committed
35
        class FakeInput;
36 37 38 39
        class Registry;
        class RemoteAccessManager;
        class RemoteBuffer;
        class Output;
Jan Grulich's avatar
Jan Grulich committed
40 41
        class PlasmaWindow;
        class PlasmaWindowManagement;
42 43 44 45 46 47 48 49 50 51
    }
}

namespace WaylandIntegration
{

class WaylandIntegrationPrivate : public WaylandIntegration::WaylandIntegration
{
    Q_OBJECT
public:
52 53 54 55 56 57
    typedef struct {
        uint nodeId;
        QVariantMap map;
    } Stream;
    typedef QList<Stream> Streams;

58 59 60
    WaylandIntegrationPrivate();
    ~WaylandIntegrationPrivate();

Jan Grulich's avatar
Jan Grulich committed
61
    void authenticate();
62 63 64 65
    void initDrm();
    void initEGL();
    void initWayland();

66
    bool isEGLInitialized() const;
Jan Grulich's avatar
Jan Grulich committed
67
    bool isStreamingEnabled() const;
68

69
    void bindOutput(int outputName, int outputVersion);
70
    void startStreamingInput();
Jan Grulich's avatar
Jan Grulich committed
71
    bool startStreaming(quint32 outputName);
72
    void stopStreaming();
Jan Grulich's avatar
Jan Grulich committed
73 74 75 76 77 78

    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);
79
    void requestKeyboardKeycode(int keycode, bool state);
Jan Grulich's avatar
Jan Grulich committed
80

Jan Grulich's avatar
Jan Grulich committed
81
    EGLStruct egl();
Jan Grulich's avatar
Jan Grulich committed
82
    KWayland::Client::PlasmaWindowManagement *plasmaWindowManagement();
83
    QMap<quint32, WaylandOutput> screens();
84
    QVariant streams();
85 86 87 88 89 90 91 92

protected Q_SLOTS:
    void addOutput(quint32 name, quint32 version);
    void removeOutput(quint32 name);
    void processBuffer(const KWayland::Client::RemoteBuffer *rbuf);
    void setupRegistry();

private:
Jan Grulich's avatar
Jan Grulich committed
93 94
    bool m_eglInitialized = false;
    bool m_streamingEnabled = false;
95
    bool m_streamInput = false;
Jan Grulich's avatar
Jan Grulich committed
96 97
    bool m_registryInitialized = false;
    bool m_waylandAuthenticationRequested = false;
98

99 100
    quint32 m_output;
    QDateTime m_lastFrameTime;
Jan Grulich's avatar
Jan Grulich committed
101
    ScreenCastStream *m_stream = nullptr;
102

Jan Grulich's avatar
Jan Grulich committed
103
    QThread *m_thread = nullptr;
104

Jan Grulich's avatar
Jan Grulich committed
105 106
    QPoint m_streamedScreenPosition;

107 108 109
    QMap<quint32, WaylandOutput> m_outputMap;
    QList<KWayland::Client::Output*> m_bindOutputs;

Jan Grulich's avatar
Jan Grulich committed
110 111 112 113 114 115
    KWayland::Client::ConnectionThread *m_connection = nullptr;
    KWayland::Client::EventQueue *m_queue = nullptr;
    KWayland::Client::FakeInput *m_fakeInput = nullptr;
    KWayland::Client::Registry *m_registry = nullptr;
    KWayland::Client::RemoteAccessManager *m_remoteAccessManager = nullptr;
    KWayland::Client::PlasmaWindowManagement *m_windowManagement = nullptr;
116 117 118

    qint32 m_drmFd = 0; // for GBM buffer mmap
    gbm_device *m_gbmDevice = nullptr; // for passed GBM buffer retrieval
Jan Grulich's avatar
Jan Grulich committed
119 120

    EGLStruct m_egl;
121 122 123 124 125 126 127
};

}

#endif // XDG_DESKTOP_PORTAL_KDE_WAYLAND_INTEGRATION_P_H