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 private:
85 rdpContext* _context;
86 std::atomic<bool> _connected = false;
87 bool _cursor_visible = true;
88 rdpPointer* _cursor = nullptr;
89 std::vector<SDL_DisplayID> _monitorIds;
90 std::mutex _queue_mux;
91 std::queue<std::vector<SDL_Rect>> _queue;
92
93 public:
94 wLog* log;
95
96 /* SDL */
97 bool fullscreen = false;
98 bool resizeable = false;
99 bool grab_mouse = false;
100 bool grab_kbd = false;
101
102 std::map<Uint32, SdlWindow> windows;
103
104 CriticalSection critical;
105 std::thread thread;
106 WinPREvent initialize;
107 WinPREvent initialized;
108 WinPREvent windows_created;
109 int exit_code = -1;
110
111 sdlDispContext disp;
112 sdlInput input;
113 sdlClip clip;
114
115 SDLSurfacePtr primary;
116
117 SDL_PixelFormat sdl_pixel_format = SDL_PIXELFORMAT_UNKNOWN;
118
119 std::atomic<bool> rdp_thread_running;
121};
object that handles clipboard context for the SDL3 client
Definition sdl_clip.hpp:89