File indexing completed on 2024-04-28 04:58:58

0001 /* This file is part of the KDE project
0002    Copyright (C) 2018 Oleg Chernovskiy <kanedias@xaker.ru>
0003    Copyright (C) 2018-2020 Jan Grulich <jgrulich@redhat.com>
0004 
0005    This program is free software; you can redistribute it and/or
0006    modify it under the terms of the GNU General Public
0007    License as published by the Free Software Foundation; either
0008    version 3 of the License, or (at your option) any later version.
0009 */
0010 #ifndef KRFB_FRAMEBUFFER_XCB_XCB_FRAMEBUFFER_H
0011 #define KRFB_FRAMEBUFFER_XCB_XCB_FRAMEBUFFER_H
0012 
0013 #include "framebuffer.h"
0014 #include <QWidget>
0015 #include <QVariantMap>
0016 
0017 /**
0018  * @brief The PWFrameBuffer class - framebuffer implementation based on XDG Desktop Portal ScreenCast interface.
0019  *        The design relies heavily on a presence of XDG D-Bus service and PipeWire daemon.
0020  *
0021  * @author Oleg Chernovskiy <kanedias@xaker.ru>
0022  */
0023 class PWFrameBuffer: public FrameBuffer
0024 {
0025     Q_OBJECT
0026 public:
0027     using Stream = struct {
0028         uint nodeId;
0029         QVariantMap map;
0030     };
0031     using Streams = QList<Stream>;
0032 
0033     PWFrameBuffer(QObject *parent = nullptr);
0034     virtual ~PWFrameBuffer() override;
0035 
0036     void initDBus();
0037     void startVirtualMonitor(const QString &name, const QSize &resolution, qreal dpr);
0038 
0039     int  depth() override;
0040     int  height() override;
0041     int  width() override;
0042     int  paddedWidth() override;
0043     void getServerFormat(rfbPixelFormat &format) override;
0044     void startMonitor() override;
0045     void stopMonitor() override;
0046     QPoint cursorPosition() override;
0047 
0048     QVariant customProperty(const QString &property) const override;
0049 
0050     bool isValid() const;
0051 
0052 private Q_SLOTS:
0053     void handleXdpSessionCreated(quint32 code, const QVariantMap &results);
0054     void handleXdpDevicesSelected(quint32 code, const QVariantMap &results);
0055     void handleXdpSourcesSelected(quint32 code, const QVariantMap &results);
0056     void handleXdpRemoteDesktopStarted(quint32 code, const QVariantMap &results);
0057 
0058 private:
0059     class Private;
0060     const QScopedPointer<Private> d;
0061 };
0062 
0063 #endif