File indexing completed on 2024-06-23 05:24:05

0001 // SPDX-FileCopyrightText: 2023 Arjen Hiemstra <ahiemstra@heimr.nl>
0002 //
0003 // SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0004 
0005 #pragma once
0006 
0007 #include <chrono>
0008 #include <memory>
0009 #include <optional>
0010 
0011 #include <QImage>
0012 #include <QObject>
0013 #include <QPoint>
0014 
0015 #include "krdp_export.h"
0016 
0017 namespace KRdp
0018 {
0019 
0020 class RdpConnection;
0021 
0022 /**
0023  * Encapsulates cursor-specific parts of the RDP protocol.
0024  *
0025  * Cursor information is sent separately from the video stream. We need to keep
0026  * track of some state, most importantly which cursor images have already been
0027  * sent so we don't have to re-send those. This class takes care of doing that
0028  * and the actual sending.
0029  */
0030 class KRDP_EXPORT Cursor : public QObject
0031 {
0032     Q_OBJECT
0033 
0034 public:
0035     struct CursorUpdate {
0036         QPoint hotspot;
0037         QImage image;
0038 
0039         uint32_t cacheId = 0;
0040         std::chrono::steady_clock::time_point lastUsed;
0041 
0042         bool operator==(const CursorUpdate &other) const;
0043     };
0044 
0045     enum class CursorType {
0046         Hidden,
0047         SystemDefault,
0048         Image,
0049     };
0050 
0051     Cursor(RdpConnection *session);
0052     ~Cursor();
0053 
0054     void update(const CursorUpdate &update);
0055 
0056 private:
0057     void setCursorType(CursorType type);
0058 
0059     class Private;
0060     const std::unique_ptr<Private> d;
0061 };
0062 
0063 }
0064 
0065 size_t qHash(const KRdp::Cursor::CursorUpdate &update, size_t seed = 0);