FreeRDP
SDL3/sdl_disp.hpp
1 
19 #pragma once
20 
21 #include <freerdp/types.h>
22 #include <freerdp/event.h>
23 #include <freerdp/client/disp.h>
24 
25 #include "sdl_types.hpp"
26 
27 #include <SDL3/SDL.h>
28 
29 class sdlDispContext
30 {
31 
32  public:
33  explicit sdlDispContext(SdlContext* sdl);
34  sdlDispContext(const sdlDispContext& other) = delete;
35  sdlDispContext(sdlDispContext&& other) = delete;
36  ~sdlDispContext();
37 
38  sdlDispContext& operator=(const sdlDispContext& other) = delete;
39  sdlDispContext& operator=(sdlDispContext&& other) = delete;
40 
41  BOOL init(DispClientContext* disp);
42  BOOL uninit(DispClientContext* disp);
43 
44  BOOL handle_display_event(const SDL_DisplayEvent* ev);
45 
46  BOOL handle_window_event(const SDL_WindowEvent* ev);
47 
48  private:
49  UINT DisplayControlCaps(UINT32 maxNumMonitors, UINT32 maxMonitorAreaFactorA,
50  UINT32 maxMonitorAreaFactorB);
51  BOOL set_window_resizable();
52 
53  BOOL sendResize();
54  BOOL settings_changed();
55  BOOL update_last_sent();
56  UINT sendLayout(const rdpMonitor* monitors, size_t nmonitors);
57 
58  BOOL addTimer();
59 
60  static UINT DisplayControlCaps(DispClientContext* disp, UINT32 maxNumMonitors,
61  UINT32 maxMonitorAreaFactorA, UINT32 maxMonitorAreaFactorB);
62  static void OnActivated(void* context, const ActivatedEventArgs* e);
63  static void OnGraphicsReset(void* context, const GraphicsResetEventArgs* e);
64  static Uint32 SDLCALL OnTimer(void* param, SDL_TimerID timerID, Uint32 interval);
65 
66  SdlContext* _sdl = nullptr;
67  DispClientContext* _disp = nullptr;
68  int _lastSentWidth = -1;
69  int _lastSentHeight = -1;
70  UINT64 _lastSentDate = 0;
71  int _targetWidth = -1;
72  int _targetHeight = -1;
73  BOOL _activated = FALSE;
74  BOOL _waitingResize = FALSE;
75  UINT16 _lastSentDesktopOrientation = 0;
76  UINT32 _lastSentDesktopScaleFactor = 0;
77  UINT32 _lastSentDeviceScaleFactor = 0;
78  SDL_TimerID _timer = 0;
79  unsigned _timer_retries = 0;
80 };