FreeRDP
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 
43 using SDLSurfacePtr = std::unique_ptr<SDL_Surface, decltype(&SDL_FreeSurface)>;
44 using SDLPixelFormatPtr = std::unique_ptr<SDL_PixelFormat, decltype(&SDL_FreeFormat)>;
45 
47 {
48  public:
49  explicit SdlContext(rdpContext* context);
50  SdlContext(const SdlContext& other) = delete;
51  SdlContext(SdlContext&& other) = delete;
52 
53  SdlContext& operator=(const SdlContext& other) = delete;
54  SdlContext& operator=(SdlContext&& other) = delete;
55 
56  private:
57  rdpContext* _context;
58 
59  public:
60  wLog* log;
61 
62  /* SDL */
63  bool fullscreen = false;
64  bool resizeable = false;
65  bool grab_mouse = false;
66  bool grab_kbd = false;
67  bool grab_kbd_enabled = true;
68 
69  std::map<Uint32, SdlWindow> windows;
70 
71  CriticalSection critical;
72  std::thread thread;
73  WinPREvent initialize;
74  WinPREvent initialized;
75  WinPREvent update_complete;
76  WinPREvent windows_created;
77  int exit_code = -1;
78 
79  sdlDispContext disp;
80  sdlInput input;
81 
82  SDLSurfacePtr primary;
83  SDLPixelFormatPtr primary_format;
84 
85  Uint32 sdl_pixel_format = 0;
86 
87  std::unique_ptr<SDLConnectionDialog> connection_dialog;
88 
89  std::atomic<bool> rdp_thread_running;
90 
91  BOOL update_resizeable(BOOL enable);
92  BOOL update_fullscreen(BOOL enter);
93  BOOL update_minimize();
94 
95  [[nodiscard]] rdpContext* context() const;
96  [[nodiscard]] rdpClientContext* common() const;
97 };