FreeRDP
Loading...
Searching...
No Matches
SDL3/sdl_freerdp.hpp
1
20#pragma once
21
22#include <memory>
23#include <thread>
24#include <map>
25#include <atomic>
26#include <queue>
27#include <mutex>
28
29#include <freerdp/freerdp.h>
30#include <freerdp/client/rdpei.h>
31#include <freerdp/client/rail.h>
32#include <freerdp/client/cliprdr.h>
33#include <freerdp/client/rdpgfx.h>
34
35#include <SDL3/SDL.h>
36#include <SDL3/SDL_video.h>
37
38#include "sdl_types.hpp"
39#include "sdl_disp.hpp"
40#include "sdl_kbd.hpp"
41#include "sdl_clip.hpp"
42#include "sdl_utils.hpp"
43#include "sdl_window.hpp"
44#include "dialogs/sdl_connection_dialog_wrapper.hpp"
45
46using SDLSurfacePtr = std::unique_ptr<SDL_Surface, decltype(&SDL_DestroySurface)>;
47
48class SdlContext
49{
50 public:
51 explicit SdlContext(rdpContext* context);
52 SdlContext(const SdlContext& other) = delete;
53 SdlContext(SdlContext&& other) = delete;
54 ~SdlContext() = default;
55
56 SdlContext& operator=(const SdlContext& other) = delete;
57 SdlContext& operator=(SdlContext&& other) = delete;
58
59 [[nodiscard]] bool redraw(bool suppress = false) const;
60
61 void setConnected(bool val);
62 [[nodiscard]] bool isConnected() const;
63
64 [[nodiscard]] bool update_resizeable(bool enable);
65 [[nodiscard]] bool update_fullscreen(bool enter);
66 [[nodiscard]] bool update_minimize();
67
68 [[nodiscard]] rdpContext* context() const;
69 [[nodiscard]] rdpClientContext* common() const;
70
71 void setCursor(rdpPointer* cursor);
72 [[nodiscard]] rdpPointer* cursor() const;
73
74 void setMonitorIds(const std::vector<SDL_DisplayID>& ids);
75 const std::vector<SDL_DisplayID>& monitorIds() const;
76 int64_t monitorId(uint32_t index) const;
77
78 void push(std::vector<SDL_Rect>&& rects);
79 std::vector<SDL_Rect> pop();
80
81 void setHasCursor(bool val);
82 [[nodiscard]] bool hasCursor() const;
83
84 void setMetadata();
85
86 private:
87 rdpContext* _context;
88 std::atomic<bool> _connected = false;
89 bool _cursor_visible = true;
90 rdpPointer* _cursor = nullptr;
91 std::vector<SDL_DisplayID> _monitorIds;
92 std::mutex _queue_mux;
93 std::queue<std::vector<SDL_Rect>> _queue;
94
95 public:
96 wLog* log;
97
98 /* SDL */
99 bool fullscreen = false;
100 bool resizeable = false;
101 bool grab_mouse = false;
102 bool grab_kbd = false;
103
104 std::map<Uint32, SdlWindow> windows;
105
106 CriticalSection critical;
107 std::thread thread;
108 WinPREvent initialize;
109 WinPREvent initialized;
110 WinPREvent windows_created;
111 int exit_code = -1;
112
113 sdlDispContext disp;
114 sdlInput input;
115 sdlClip clip;
116
117 SDLSurfacePtr primary;
118
119 SDL_PixelFormat sdl_pixel_format = SDL_PIXELFORMAT_UNKNOWN;
120
121 std::atomic<bool> rdp_thread_running;
123};
object that handles clipboard context for the SDL3 client
Definition sdl_clip.hpp:89