FreeRDP
Loading...
Searching...
No Matches
SdlWindow Class Reference

#include <sdl_window.hpp>

Public Member Functions

 SdlWindow (const std::string &title, Sint32 startupX, Sint32 startupY, Sint32 width, Sint32 height, Uint32 flags)
 
 SdlWindow (const SdlWindow &other)=delete
 
 SdlWindow (SdlWindow &&other) noexcept
 
SdlWindowoperator= (const SdlWindow &other)=delete
 
SdlWindowoperator= (SdlWindow &&other)=delete
 
Uint32 id () const
 
int displayIndex () const
 
SDL_Rect rect () const
 
SDL_Window * window () const
 
Sint32 offsetX () const
 
void setOffsetX (Sint32 x)
 
void setOffsetY (Sint32 y)
 
Sint32 offsetY () const
 
bool grabKeyboard (bool enable)
 
bool grabMouse (bool enable)
 
void setBordered (bool bordered)
 
void raise ()
 
void resizeable (bool use)
 
void fullscreen (bool enter)
 
void minimize ()
 
bool fill (Uint8 r=0x00, Uint8 g=0x00, Uint8 b=0x00, Uint8 a=0xff)
 
bool blit (SDL_Surface *surface, SDL_Rect src, SDL_Rect &dst)
 
void updateSurface ()
 
 SdlWindow (SdlWindow &&other) noexcept
 
 SdlWindow (const SdlWindow &other)=delete
 
SdlWindowoperator= (const SdlWindow &other)=delete
 
SdlWindowoperator= (SdlWindow &&other)=delete
 
SDL_WindowID id () const
 
SDL_DisplayID displayIndex () const
 
SDL_Rect rect () const
 
SDL_Rect bounds () const
 
SDL_Window * window () const
 
Sint32 offsetX () const
 
void setOffsetX (Sint32 x)
 
void setOffsetY (Sint32 y)
 
Sint32 offsetY () const
 
rdpMonitor monitor (bool isPrimary) const
 
void setMonitor (rdpMonitor monitor)
 
float scale () const
 
SDL_DisplayOrientation orientation () const
 
bool grabKeyboard (bool enable)
 
bool grabMouse (bool enable)
 
void setBordered (bool bordered)
 
void raise ()
 
void resizeable (bool use)
 
void fullscreen (bool enter, bool forceOriginalDisplay)
 
void minimize ()
 
bool resize (const SDL_Point &size)
 
bool drawRect (SDL_Surface *surface, SDL_Point offset, const SDL_Rect &srcRect)
 
bool drawRects (SDL_Surface *surface, SDL_Point offset, const std::vector< SDL_Rect > &rects={})
 
bool drawScaledRect (SDL_Surface *surface, const SDL_FPoint &scale, const SDL_Rect &srcRect)
 
bool drawScaledRects (SDL_Surface *surface, const SDL_FPoint &scale, const std::vector< SDL_Rect > &rects={})
 
bool fill (Uint8 r=0x00, Uint8 g=0x00, Uint8 b=0x00, Uint8 a=0xff)
 
bool blit (SDL_Surface *surface, const SDL_Rect &src, SDL_Rect &dst)
 
void updateSurface ()
 

Static Public Member Functions

static SdlWindow create (SDL_DisplayID id, const std::string &title, Uint32 flags, Uint32 width=0, Uint32 height=0)
 
static rdpMonitor query (SDL_DisplayID id, bool forceAsPrimary=false)
 

Protected Types

enum  HighDPIMode { MODE_INVALID , MODE_NONE , MODE_WINDOWS , MODE_MACOS }
 

Protected Member Functions

 SdlWindow (SDL_DisplayID id, const std::string &title, const SDL_Rect &rect, Uint32 flags)
 

Static Protected Member Functions

static bool fill (SDL_Window *window, Uint8 r=0x00, Uint8 g=0x00, Uint8 b=0x00, Uint8 a=0xff)
 
static rdpMonitor query (SDL_Window *window, SDL_DisplayID id, bool forceAsPrimary=false)
 
static SDL_Rect rect (SDL_Window *window, bool forceAsPrimary=false)
 
static SDL_Rect rect (SDL_DisplayID id, bool forceAsPrimary=false)
 
static enum HighDPIMode isHighDPIWindowsMode (SDL_Window *window)
 

Detailed Description

FreeRDP: A Remote Desktop Protocol Implementation SDL Client

Copyright 2023 Armin Novak armin.nosp@m..nov.nosp@m.ak@th.nosp@m.inca.nosp@m.st.co.nosp@m.m Copyright 2023 Thincast Technologies GmbH

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Definition at line 25 of file SDL2/sdl_window.hpp.

Member Enumeration Documentation

◆ HighDPIMode

enum SdlWindow::HighDPIMode
protected

Definition at line 94 of file SDL3/sdl_window.hpp.

95 {
96 MODE_INVALID,
97 MODE_NONE,
98 MODE_WINDOWS,
99 MODE_MACOS
100 };

Constructor & Destructor Documentation

◆ SdlWindow() [1/3]

SdlWindow::SdlWindow ( const std::string &  title,
Sint32  startupX,
Sint32  startupY,
Sint32  width,
Sint32  height,
Uint32  flags 
)

FreeRDP: A Remote Desktop Protocol Implementation SDL Client

Copyright 2023 Armin Novak armin.nosp@m..nov.nosp@m.ak@th.nosp@m.inca.nosp@m.st.co.nosp@m.m Copyright 2023 Thincast Technologies GmbH

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Definition at line 23 of file SDL2/sdl_window.cpp.

25 : _window(SDL_CreateWindow(title.c_str(), startupX, startupY, width, height, flags))
26{
27}

◆ SdlWindow() [2/3]

SdlWindow::SdlWindow ( SdlWindow &&  other)
noexcept

Definition at line 29 of file SDL2/sdl_window.cpp.

30 : _window(other._window), _offset_x(other._offset_x), _offset_y(other._offset_y)
31{
32 other._window = nullptr;
33}

◆ ~SdlWindow()

SdlWindow::~SdlWindow ( )

Definition at line 35 of file SDL2/sdl_window.cpp.

36{
37 SDL_DestroyWindow(_window);
38}

◆ SdlWindow() [3/3]

SdlWindow::SdlWindow ( SDL_DisplayID  id,
const std::string &  title,
const SDL_Rect &  rect,
Uint32  flags 
)
protected

FreeRDP: A Remote Desktop Protocol Implementation SDL Client

Copyright 2023 Armin Novak armin.nosp@m..nov.nosp@m.ak@th.nosp@m.inca.nosp@m.st.co.nosp@m.m Copyright 2023 Thincast Technologies GmbH

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Definition at line 29 of file SDL3/sdl_window.cpp.

31 : _displayID(id)
32{
33 auto props = SDL_CreateProperties();
34 SDL_SetStringProperty(props, SDL_PROP_WINDOW_CREATE_TITLE_STRING, title.c_str());
35 SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_X_NUMBER, rect.x);
36 SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_Y_NUMBER, rect.y);
37 SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_WIDTH_NUMBER, rect.w);
38 SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_HEIGHT_NUMBER, rect.h);
39
40 if (flags & SDL_WINDOW_HIGH_PIXEL_DENSITY)
41 SDL_SetBooleanProperty(props, SDL_PROP_WINDOW_CREATE_HIGH_PIXEL_DENSITY_BOOLEAN, true);
42
43 if (flags & SDL_WINDOW_FULLSCREEN)
44 SDL_SetBooleanProperty(props, SDL_PROP_WINDOW_CREATE_FULLSCREEN_BOOLEAN, true);
45
46 if (flags & SDL_WINDOW_BORDERLESS)
47 SDL_SetBooleanProperty(props, SDL_PROP_WINDOW_CREATE_BORDERLESS_BOOLEAN, true);
48
49 _window = SDL_CreateWindowWithProperties(props);
50 SDL_DestroyProperties(props);
51
52 auto sc = scale();
53 const int iscale = static_cast<int>(sc * 100.0f);
54 auto w = 100 * rect.w / iscale;
55 auto h = 100 * rect.h / iscale;
56 std::ignore = resize({ w, h });
57 SDL_SetHint(SDL_HINT_APP_NAME, "");
58 std::ignore = SDL_SyncWindow(_window);
59
60 _monitor = query(_window, id, true);
61}

Member Function Documentation

◆ blit() [1/2]

bool SdlWindow::blit ( SDL_Surface *  surface,
const SDL_Rect &  src,
SDL_Rect &  dst 
)

Definition at line 377 of file SDL3/sdl_window.cpp.

378{
379 auto screen = SDL_GetWindowSurface(_window);
380 if (!screen || !surface)
381 return false;
382 if (!SDL_SetSurfaceClipRect(surface, &srcRect))
383 return true;
384 if (!SDL_SetSurfaceClipRect(screen, &dstRect))
385 return true;
386 if (!SDL_BlitSurfaceScaled(surface, &srcRect, screen, &dstRect, SDL_SCALEMODE_LINEAR))
387 {
388 SDL_LogError(SDL_LOG_CATEGORY_RENDER, "SDL_BlitScaled: %s", SDL_GetError());
389 return false;
390 }
391 return true;
392}

◆ blit() [2/2]

bool SdlWindow::blit ( SDL_Surface *  surface,
SDL_Rect  src,
SDL_Rect &  dst 
)

Definition at line 187 of file SDL2/sdl_window.cpp.

188{
189 auto screen = SDL_GetWindowSurface(_window);
190 if (!screen || !surface)
191 return false;
192 if (!SDL_SetClipRect(surface, &srcRect))
193 return true;
194 if (!SDL_SetClipRect(screen, &dstRect))
195 return true;
196 auto rc = SDL_BlitScaled(surface, &srcRect, screen, &dstRect);
197 if (rc != 0)
198 {
199 SDL_LogError(SDL_LOG_CATEGORY_RENDER, "SDL_BlitScaled: %s [%d]", sdl_error_string(rc), rc);
200 }
201 return rc == 0;
202}

◆ bounds()

SDL_Rect SdlWindow::bounds ( ) const

Definition at line 94 of file SDL3/sdl_window.cpp.

95{
96 SDL_Rect rect = {};
97 if (_window)
98 {
99 if (!SDL_GetWindowPosition(_window, &rect.x, &rect.y))
100 return {};
101 if (!SDL_GetWindowSize(_window, &rect.w, &rect.h))
102 return {};
103 }
104 return rect;
105}

◆ create()

SdlWindow SdlWindow::create ( SDL_DisplayID  id,
const std::string &  title,
Uint32  flags,
Uint32  width = 0,
Uint32  height = 0 
)
static

Definition at line 399 of file SDL3/sdl_window.cpp.

401{
402 flags |= SDL_WINDOW_HIGH_PIXEL_DENSITY;
403
404 SDL_Rect rect = { static_cast<int>(SDL_WINDOWPOS_CENTERED_DISPLAY(id)),
405 static_cast<int>(SDL_WINDOWPOS_CENTERED_DISPLAY(id)), static_cast<int>(width),
406 static_cast<int>(height) };
407
408 if ((flags & SDL_WINDOW_FULLSCREEN) != 0)
409 {
410 std::ignore = SDL_GetDisplayBounds(id, &rect);
411 }
412
413 SdlWindow window{ id, title, rect, flags };
414
415 if ((flags & (SDL_WINDOW_FULLSCREEN)) != 0)
416 {
417 window.setOffsetX(rect.x);
418 window.setOffsetY(rect.y);
419 }
420
421 return window;
422}

◆ displayIndex()

SDL_DisplayID SdlWindow::displayIndex ( ) const

Definition at line 47 of file SDL2/sdl_window.cpp.

48{
49 if (!_window)
50 return 0;
51 return SDL_GetWindowDisplayIndex(_window);
52}

◆ drawRect()

bool SdlWindow::drawRect ( SDL_Surface *  surface,
SDL_Point  offset,
const SDL_Rect &  srcRect 
)

Definition at line 221 of file SDL3/sdl_window.cpp.

222{
223 WINPR_ASSERT(surface);
224 SDL_Rect dstRect = { offset.x + srcRect.x, offset.y + srcRect.y, srcRect.w, srcRect.h };
225 return blit(surface, srcRect, dstRect);
226}

◆ drawRects()

bool SdlWindow::drawRects ( SDL_Surface *  surface,
SDL_Point  offset,
const std::vector< SDL_Rect > &  rects = {} 
)

Definition at line 228 of file SDL3/sdl_window.cpp.

230{
231 if (rects.empty())
232 {
233 return drawRect(surface, offset, { 0, 0, surface->w, surface->h });
234 }
235 for (auto& srcRect : rects)
236 {
237 if (!drawRect(surface, offset, srcRect))
238 return false;
239 }
240 return true;
241}

◆ drawScaledRect()

bool SdlWindow::drawScaledRect ( SDL_Surface *  surface,
const SDL_FPoint &  scale,
const SDL_Rect &  srcRect 
)

Definition at line 243 of file SDL3/sdl_window.cpp.

245{
246 SDL_Rect dstRect = srcRect;
247 dstRect.x = static_cast<Sint32>(static_cast<float>(dstRect.x) * scale.x);
248 dstRect.w = static_cast<Sint32>(static_cast<float>(dstRect.w) * scale.x);
249 dstRect.y = static_cast<Sint32>(static_cast<float>(dstRect.y) * scale.y);
250 dstRect.h = static_cast<Sint32>(static_cast<float>(dstRect.h) * scale.y);
251 return blit(surface, srcRect, dstRect);
252}

◆ drawScaledRects()

bool SdlWindow::drawScaledRects ( SDL_Surface *  surface,
const SDL_FPoint &  scale,
const std::vector< SDL_Rect > &  rects = {} 
)

Definition at line 254 of file SDL3/sdl_window.cpp.

256{
257 if (rects.empty())
258 {
259 return drawScaledRect(surface, scale, { 0, 0, surface->w, surface->h });
260 }
261 for (const auto& srcRect : rects)
262 {
263 if (!drawScaledRect(surface, scale, srcRect))
264 return false;
265 }
266 return true;
267}

◆ fill() [1/2]

bool SdlWindow::fill ( SDL_Window *  window,
Uint8  r = 0x00,
Uint8  g = 0x00,
Uint8  b = 0x00,
Uint8  a = 0xff 
)
staticprotected

Definition at line 274 of file SDL3/sdl_window.cpp.

275{
276 auto surface = SDL_GetWindowSurface(window);
277 if (!surface)
278 return false;
279 SDL_Rect rect = { 0, 0, surface->w, surface->h };
280 auto color = SDL_MapSurfaceRGBA(surface, r, g, b, a);
281
282 return SDL_FillSurfaceRect(surface, &rect, color);
283}

◆ fill() [2/2]

bool SdlWindow::fill ( Uint8  r = 0x00,
Uint8  g = 0x00,
Uint8  b = 0x00,
Uint8  a = 0xff 
)

Definition at line 175 of file SDL2/sdl_window.cpp.

176{
177 auto surface = SDL_GetWindowSurface(_window);
178 if (!surface)
179 return false;
180 SDL_Rect rect = { 0, 0, surface->w, surface->h };
181 auto color = SDL_MapRGBA(surface->format, r, g, b, a);
182
183 SDL_FillRect(surface, &rect, color);
184 return true;
185}

◆ fullscreen() [1/2]

void SdlWindow::fullscreen ( bool  enter)

Definition at line 131 of file SDL2/sdl_window.cpp.

132{
133 auto curFlags = SDL_GetWindowFlags(_window);
134
135 if (enter)
136 {
137 if (!(curFlags & SDL_WINDOW_BORDERLESS))
138 {
139 auto idx = SDL_GetWindowDisplayIndex(_window);
140 SDL_DisplayMode mode = {};
141 SDL_GetCurrentDisplayMode(idx, &mode);
142
143 SDL_RestoreWindow(_window); // Maximize so we can see the caption and
144 // bits
145 SDL_SetWindowBordered(_window, SDL_FALSE);
146 SDL_SetWindowPosition(_window, 0, 0);
147#if SDL_VERSION_ATLEAST(2, 0, 16)
148 SDL_SetWindowAlwaysOnTop(_window, SDL_TRUE);
149#endif
150 SDL_RaiseWindow(_window);
151 SDL_SetWindowSize(_window, mode.w, mode.h);
152 }
153 }
154 else
155 {
156 if (curFlags & SDL_WINDOW_BORDERLESS)
157 {
158
159 SDL_SetWindowBordered(_window, SDL_TRUE);
160#if SDL_VERSION_ATLEAST(2, 0, 16)
161 SDL_SetWindowAlwaysOnTop(_window, SDL_FALSE);
162#endif
163 SDL_RaiseWindow(_window);
164 SDL_MinimizeWindow(_window); // Maximize so we can see the caption and bits
165 SDL_MaximizeWindow(_window); // Maximize so we can see the caption and bits
166 }
167 }
168}

◆ fullscreen() [2/2]

void SdlWindow::fullscreen ( bool  enter,
bool  forceOriginalDisplay 
)

Definition at line 194 of file SDL3/sdl_window.cpp.

195{
196 if (enter && forceOriginalDisplay && _displayID != 0)
197 {
198 /* Move the window to the desired display. We should not wait
199 * for the window to be moved, because some backends can refuse
200 * the move. The intent of moving the window is enough for SDL
201 * to decide which display will be used for fullscreen. */
202 SDL_Rect rect = {};
203 std::ignore = SDL_GetDisplayBounds(_displayID, &rect);
204 std::ignore = SDL_SetWindowPosition(_window, rect.x, rect.y);
205 }
206 std::ignore = SDL_SetWindowFullscreen(_window, enter);
207 std::ignore = SDL_SyncWindow(_window);
208}

◆ grabKeyboard()

bool SdlWindow::grabKeyboard ( bool  enable)

Definition at line 90 of file SDL2/sdl_window.cpp.

91{
92 if (!_window)
93 return false;
94#if SDL_VERSION_ATLEAST(2, 0, 16)
95 SDL_SetWindowKeyboardGrab(_window, enable ? SDL_TRUE : SDL_FALSE);
96 return true;
97#else
98 SDL_LogError(SDL_LOG_CATEGORY_INPUT, "Keyboard grabbing not supported by SDL2 < 2.0.16");
99 return false;
100#endif
101}

◆ grabMouse()

bool SdlWindow::grabMouse ( bool  enable)

Definition at line 103 of file SDL2/sdl_window.cpp.

104{
105 if (!_window)
106 return false;
107#if SDL_VERSION_ATLEAST(2, 0, 16)
108 SDL_SetWindowMouseGrab(_window, enable ? SDL_TRUE : SDL_FALSE);
109#else
110 SDL_SetWindowGrab(_window, enable ? SDL_TRUE : SDL_FALSE);
111#endif
112 return true;
113}

◆ id()

SDL_WindowID SdlWindow::id ( ) const

Definition at line 40 of file SDL2/sdl_window.cpp.

41{
42 if (!_window)
43 return 0;
44 return SDL_GetWindowID(_window);
45}

◆ isHighDPIWindowsMode()

SdlWindow::HighDPIMode SdlWindow::isHighDPIWindowsMode ( SDL_Window *  window)
staticprotected

Definition at line 352 of file SDL3/sdl_window.cpp.

353{
354 if (!window)
355 return MODE_INVALID;
356
357 const auto id = SDL_GetDisplayForWindow(window);
358 if (id == 0)
359 return MODE_INVALID;
360
361 const auto cs = SDL_GetDisplayContentScale(id);
362 const auto ds = SDL_GetWindowDisplayScale(window);
363 const auto pd = SDL_GetWindowPixelDensity(window);
364
365 /* mac os x style, but no HighDPI display */
366 if ((cs == 1.0f) && (ds == 1.0f) && (pd == 1.0f))
367 return MODE_NONE;
368
369 /* mac os x style HighDPI */
370 if ((cs == 1.0f) && (ds > 1.0f) && (pd > 1.0f))
371 return MODE_MACOS;
372
373 /* rest is windows style */
374 return MODE_WINDOWS;
375}

◆ minimize()

void SdlWindow::minimize ( )

Definition at line 170 of file SDL2/sdl_window.cpp.

171{
172 SDL_MinimizeWindow(_window);
173}

◆ monitor()

rdpMonitor SdlWindow::monitor ( bool  isPrimary) const

Definition at line 132 of file SDL3/sdl_window.cpp.

133{
134 auto m = _monitor;
135 if (isPrimary)
136 {
137 m.x = 0;
138 m.y = 0;
139 }
140 return m;
141}

◆ offsetX()

Sint32 SdlWindow::offsetX ( ) const

Definition at line 70 of file SDL2/sdl_window.cpp.

71{
72 return _offset_x;
73}

◆ offsetY()

Sint32 SdlWindow::offsetY ( ) const

Definition at line 85 of file SDL2/sdl_window.cpp.

86{
87 return _offset_y;
88}

◆ orientation()

SDL_DisplayOrientation SdlWindow::orientation ( ) const

Definition at line 153 of file SDL3/sdl_window.cpp.

154{
155 const auto did = displayIndex();
156 return SDL_GetCurrentDisplayOrientation(did);
157}

◆ query() [1/2]

rdpMonitor SdlWindow::query ( SDL_DisplayID  id,
bool  forceAsPrimary = false 
)
static

Definition at line 450 of file SDL3/sdl_window.cpp.

451{
452 std::unique_ptr<SDL_Window, void (*)(SDL_Window*)> window(createDummy(id), SDL_DestroyWindow);
453 if (!window)
454 return {};
455
456 std::unique_ptr<SDL_Renderer, void (*)(SDL_Renderer*)> renderer(
457 SDL_CreateRenderer(window.get(), nullptr), SDL_DestroyRenderer);
458
459 if (!SDL_SyncWindow(window.get()))
460 return {};
461
462 SDL_Event event{};
463 while (SDL_PollEvent(&event))
464 ;
465
466 return query(window.get(), id, forceAsPrimary);
467}

◆ query() [2/2]

rdpMonitor SdlWindow::query ( SDL_Window *  window,
SDL_DisplayID  id,
bool  forceAsPrimary = false 
)
staticprotected

Definition at line 285 of file SDL3/sdl_window.cpp.

286{
287 if (!window)
288 return {};
289
290 const auto& r = rect(window, forceAsPrimary);
291 const float factor = SDL_GetWindowDisplayScale(window);
292 const float dpi = std::roundf(factor * 100.0f);
293
294 WINPR_ASSERT(r.w > 0);
295 WINPR_ASSERT(r.h > 0);
296
297 const auto primary = SDL_GetPrimaryDisplay();
298 const auto orientation = SDL_GetCurrentDisplayOrientation(id);
299 const auto rdp_orientation = sdl::utils::orientaion_to_rdp(orientation);
300
301 rdpMonitor monitor{};
302 monitor.orig_screen = id;
303 monitor.x = r.x;
304 monitor.y = r.y;
305 monitor.width = r.w;
306 monitor.height = r.h;
307 monitor.is_primary = forceAsPrimary || (id == primary);
308 monitor.attributes.desktopScaleFactor = static_cast<UINT32>(dpi);
309 monitor.attributes.deviceScaleFactor = 100;
310 monitor.attributes.orientation = rdp_orientation;
311 monitor.attributes.physicalWidth = WINPR_ASSERTING_INT_CAST(uint32_t, r.w);
312 monitor.attributes.physicalHeight = WINPR_ASSERTING_INT_CAST(uint32_t, r.h);
313
314 const auto cat = SDL_LOG_CATEGORY_APPLICATION;
315 SDL_LogDebug(cat, "monitor.orig_screen %" PRIu32, monitor.orig_screen);
316 SDL_LogDebug(cat, "monitor.x %" PRId32, monitor.x);
317 SDL_LogDebug(cat, "monitor.y %" PRId32, monitor.y);
318 SDL_LogDebug(cat, "monitor.width %" PRId32, monitor.width);
319 SDL_LogDebug(cat, "monitor.height %" PRId32, monitor.height);
320 SDL_LogDebug(cat, "monitor.is_primary %" PRIu32, monitor.is_primary);
321 SDL_LogDebug(cat, "monitor.attributes.desktopScaleFactor %" PRIu32,
322 monitor.attributes.desktopScaleFactor);
323 SDL_LogDebug(cat, "monitor.attributes.deviceScaleFactor %" PRIu32,
324 monitor.attributes.deviceScaleFactor);
325 SDL_LogDebug(cat, "monitor.attributes.orientation %s",
326 freerdp_desktop_rotation_flags_to_string(monitor.attributes.orientation));
327 SDL_LogDebug(cat, "monitor.attributes.physicalWidth %" PRIu32,
328 monitor.attributes.physicalWidth);
329 SDL_LogDebug(cat, "monitor.attributes.physicalHeight %" PRIu32,
330 monitor.attributes.physicalHeight);
331 return monitor;
332}

◆ raise()

void SdlWindow::raise ( )

Definition at line 121 of file SDL2/sdl_window.cpp.

122{
123 SDL_RaiseWindow(_window);
124}

◆ rect() [1/3]

SDL_Rect SdlWindow::rect ( ) const

Definition at line 54 of file SDL2/sdl_window.cpp.

55{
56 SDL_Rect rect = {};
57 if (_window)
58 {
59 SDL_GetWindowPosition(_window, &rect.x, &rect.y);
60 SDL_GetWindowSize(_window, &rect.w, &rect.h);
61 }
62 return rect;
63}

◆ rect() [2/3]

SDL_Rect SdlWindow::rect ( SDL_DisplayID  id,
bool  forceAsPrimary = false 
)
staticprotected

Definition at line 469 of file SDL3/sdl_window.cpp.

470{
471 std::unique_ptr<SDL_Window, void (*)(SDL_Window*)> window(createDummy(id), SDL_DestroyWindow);
472 if (!window)
473 return {};
474
475 std::unique_ptr<SDL_Renderer, void (*)(SDL_Renderer*)> renderer(
476 SDL_CreateRenderer(window.get(), nullptr), SDL_DestroyRenderer);
477
478 if (!SDL_SyncWindow(window.get()))
479 return {};
480
481 SDL_Event event{};
482 while (SDL_PollEvent(&event))
483 ;
484
485 return rect(window.get(), forceAsPrimary);
486}

◆ rect() [3/3]

SDL_Rect SdlWindow::rect ( SDL_Window *  window,
bool  forceAsPrimary = false 
)
staticprotected

Definition at line 334 of file SDL3/sdl_window.cpp.

335{
336 SDL_Rect rect = {};
337 if (!window)
338 return {};
339
340 if (!forceAsPrimary)
341 {
342 if (!SDL_GetWindowPosition(window, &rect.x, &rect.y))
343 return {};
344 }
345
346 if (!SDL_GetWindowSizeInPixels(window, &rect.w, &rect.h))
347 return {};
348
349 return rect;
350}

◆ resize()

bool SdlWindow::resize ( const SDL_Point &  size)

Definition at line 216 of file SDL3/sdl_window.cpp.

217{
218 return SDL_SetWindowSize(_window, size.x, size.y);
219}

◆ resizeable()

void SdlWindow::resizeable ( bool  use)

Definition at line 126 of file SDL2/sdl_window.cpp.

127{
128 SDL_SetWindowResizable(_window, use ? SDL_TRUE : SDL_FALSE);
129}

◆ scale()

float SdlWindow::scale ( ) const

Definition at line 148 of file SDL3/sdl_window.cpp.

149{
150 return SDL_GetWindowDisplayScale(_window);
151}

◆ setBordered()

void SdlWindow::setBordered ( bool  bordered)

Definition at line 115 of file SDL2/sdl_window.cpp.

116{
117 if (_window)
118 SDL_SetWindowBordered(_window, bordered ? SDL_TRUE : SDL_FALSE);
119}

◆ setMonitor()

void SdlWindow::setMonitor ( rdpMonitor  monitor)

Definition at line 143 of file SDL3/sdl_window.cpp.

144{
145 _monitor = monitor;
146}

◆ setOffsetX()

void SdlWindow::setOffsetX ( Sint32  x)

Definition at line 75 of file SDL2/sdl_window.cpp.

76{
77 _offset_x = x;
78}

◆ setOffsetY()

void SdlWindow::setOffsetY ( Sint32  y)

Definition at line 80 of file SDL2/sdl_window.cpp.

81{
82 _offset_y = y;
83}

◆ updateSurface()

void SdlWindow::updateSurface ( )

Definition at line 204 of file SDL2/sdl_window.cpp.

205{
206 SDL_UpdateWindowSurface(_window);
207}

◆ window()

SDL_Window * SdlWindow::window ( ) const

Definition at line 65 of file SDL2/sdl_window.cpp.

66{
67 return _window;
68}

The documentation for this class was generated from the following files: