FreeRDP
Loading...
Searching...
No Matches
SDL2/sdl_freerdp.hpp
1
20#pragma once
21
22#include <memory>
23#include <thread>
24#include <map>
25#include <atomic>
26
27#include <freerdp/freerdp.h>
28#include <freerdp/client/rdpei.h>
29#include <freerdp/client/rail.h>
30#include <freerdp/client/cliprdr.h>
31#include <freerdp/client/rdpgfx.h>
32
33#include <SDL.h>
34#include <SDL_video.h>
35
36#include "sdl_types.hpp"
37#include "sdl_disp.hpp"
38#include "sdl_kbd.hpp"
39#include "sdl_utils.hpp"
40#include "sdl_window.hpp"
41#include "dialogs/sdl_connection_dialog.hpp"
42
43using SDLSurfacePtr = std::unique_ptr<SDL_Surface, decltype(&SDL_FreeSurface)>;
44using SDLPixelFormatPtr = std::unique_ptr<SDL_PixelFormat, decltype(&SDL_FreeFormat)>;
45
46class SdlAadAuthHelper;
47
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 private:
60 rdpContext* _context;
61
62 public:
63 wLog* log;
64
65 /* SDL */
66 bool fullscreen = false;
67 bool resizeable = false;
68 bool grab_mouse = false;
69 bool grab_kbd = false;
70 bool grab_kbd_enabled = true;
71
72 std::map<Uint32, SdlWindow> windows;
73
74 CriticalSection critical;
75 std::thread thread;
76 WinPREvent initialize;
77 WinPREvent initialized;
78 WinPREvent update_complete;
79 WinPREvent windows_created;
80 int exit_code = -1;
81
82 sdlDispContext disp;
83 sdlInput input;
84
85 SDLSurfacePtr primary;
86 SDLPixelFormatPtr primary_format;
87
88 Uint32 sdl_pixel_format = 0;
89
90 std::unique_ptr<SDLConnectionDialog> connection_dialog;
91
92 std::atomic<bool> rdp_thread_running;
93
94 BOOL update_resizeable(BOOL enable);
95 BOOL update_fullscreen(BOOL enter);
96 BOOL update_minimize();
97
98 [[nodiscard]] rdpContext* context() const;
99 [[nodiscard]] rdpClientContext* common() const;
100
101 [[nodiscard]] std::shared_ptr<SdlAadAuthHelper>& getAadAuthHelper();
102
103 private:
104 std::shared_ptr<SdlAadAuthHelper> _aadAuthHelper;
105};