FreeRDP
Loading...
Searching...
No Matches
SDL3/sdl_window.hpp
1
20#pragma once
21
22#include <string>
23#include <vector>
24
25#include <SDL3/SDL.h>
26
27#include <freerdp/settings_types.h>
28
29class SdlWindow
30{
31 public:
32 [[nodiscard]] static SdlWindow create(SDL_DisplayID id, const std::string& title, Uint32 flags,
33 Uint32 width = 0, Uint32 height = 0);
34
35 SdlWindow(SdlWindow&& other) noexcept;
36 SdlWindow(const SdlWindow& other) = delete;
37 virtual ~SdlWindow();
38
39 SdlWindow& operator=(const SdlWindow& other) = delete;
40 SdlWindow& operator=(SdlWindow&& other) = delete;
41
42 [[nodiscard]] SDL_WindowID id() const;
43 [[nodiscard]] SDL_DisplayID displayIndex() const;
44 [[nodiscard]] SDL_Rect rect() const;
45 [[nodiscard]] SDL_Rect bounds() const;
46 [[nodiscard]] SDL_Window* window() const;
47
48 [[nodiscard]] Sint32 offsetX() const;
49 void setOffsetX(Sint32 x);
50
51 void setOffsetY(Sint32 y);
52 [[nodiscard]] Sint32 offsetY() const;
53
54 [[nodiscard]] rdpMonitor monitor(bool isPrimary) const;
55
56 [[nodiscard]] float scale() const;
57 [[nodiscard]] SDL_DisplayOrientation orientation() const;
58
59 [[nodiscard]] bool grabKeyboard(bool enable);
60 [[nodiscard]] bool grabMouse(bool enable);
61 void setBordered(bool bordered);
62 void raise();
63 void resizeable(bool use);
64 void fullscreen(bool enter);
65 void minimize();
66
67 [[nodiscard]] bool resize(const SDL_Point& size);
68
69 [[nodiscard]] bool drawRect(SDL_Surface* surface, SDL_Point offset, const SDL_Rect& srcRect);
70 [[nodiscard]] bool drawRects(SDL_Surface* surface, SDL_Point offset,
71 const std::vector<SDL_Rect>& rects = {});
72 [[nodiscard]] bool drawScaledRect(SDL_Surface* surface, const SDL_FPoint& scale,
73 const SDL_Rect& srcRect);
74
75 [[nodiscard]] bool drawScaledRects(SDL_Surface* surface, const SDL_FPoint& scale,
76 const std::vector<SDL_Rect>& rects = {});
77
78 [[nodiscard]] bool fill(Uint8 r = 0x00, Uint8 g = 0x00, Uint8 b = 0x00, Uint8 a = 0xff);
79 [[nodiscard]] bool blit(SDL_Surface* surface, const SDL_Rect& src, SDL_Rect& dst);
80 void updateSurface();
81
82 protected:
83 SdlWindow(const std::string& title, const SDL_Rect& rect, Uint32 flags);
84
85 private:
86 SDL_Window* _window = nullptr;
87 Sint32 _offset_x = 0;
88 Sint32 _offset_y = 0;
89};