FreeRDP
SDL2/sdl_utils.hpp
1 
20 #pragma once
21 
22 #include <winpr/synch.h>
23 #include <winpr/wlog.h>
24 
25 #include <SDL.h>
26 #include <string>
27 #include <vector>
28 
30 {
31  public:
33  CriticalSection(const CriticalSection& other) = delete;
34  CriticalSection(CriticalSection&& other) = delete;
35  ~CriticalSection();
36 
37  CriticalSection& operator=(const CriticalSection& other) = delete;
38  CriticalSection& operator=(const CriticalSection&& other) = delete;
39 
40  void lock();
41  void unlock();
42 
43  private:
44  CRITICAL_SECTION _section{};
45 };
46 
48 {
49  public:
50  explicit WinPREvent(bool initial = false);
51  ~WinPREvent();
52 
53  void set();
54  void clear();
55  [[nodiscard]] bool isSet() const;
56 
57  [[nodiscard]] HANDLE handle() const;
58 
59  private:
60  HANDLE _handle;
61 };
62 
63 enum
64 {
65  SDL_USEREVENT_UPDATE = SDL_USEREVENT + 1,
66  SDL_USEREVENT_CREATE_WINDOWS,
67  SDL_USEREVENT_WINDOW_RESIZEABLE,
68  SDL_USEREVENT_WINDOW_FULLSCREEN,
69  SDL_USEREVENT_WINDOW_MINIMIZE,
70  SDL_USEREVENT_POINTER_NULL,
71  SDL_USEREVENT_POINTER_DEFAULT,
72  SDL_USEREVENT_POINTER_POSITION,
73  SDL_USEREVENT_POINTER_SET,
74  SDL_USEREVENT_QUIT,
75  SDL_USEREVENT_CERT_DIALOG,
76  SDL_USEREVENT_SHOW_DIALOG,
77  SDL_USEREVENT_AUTH_DIALOG,
78  SDL_USEREVENT_SCARD_DIALOG,
79  SDL_USEREVENT_RETRY_DIALOG,
80 
81  SDL_USEREVENT_CERT_RESULT,
82  SDL_USEREVENT_SHOW_RESULT,
83  SDL_USEREVENT_AUTH_RESULT,
84  SDL_USEREVENT_SCARD_RESULT
85 };
86 
87 typedef struct
88 {
89  Uint32 type;
90  Uint32 timestamp;
91  char* title;
92  char* user;
93  char* domain;
94  char* password;
95  Sint32 result;
97 
98 BOOL sdl_push_user_event(Uint32 type, ...);
99 
100 bool sdl_push_quit();
101 
102 std::string sdl_window_event_str(Uint8 ev);
103 const char* sdl_event_type_str(Uint32 type);
104 const char* sdl_error_string(Uint32 res);
105 
106 #define sdl_log_error(res, log, what) sdl_log_error_ex(res, log, what, __FILE__, __LINE__, __func__)
107 BOOL sdl_log_error_ex(Uint32 res, wLog* log, const char* what, const char* file, size_t line,
108  const char* fkt);