Skip to content

Commit 0fffbfb

Browse files
authored
Merge pull request FreeRDP#11946 from akallabeth/revert-smart-sizing
Revert smart sizing
2 parents 2726b95 + 03fc896 commit 0fffbfb

File tree

1 file changed

+36
-4
lines changed

1 file changed

+36
-4
lines changed

client/SDL/SDL3/sdl_freerdp.cpp

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,31 @@ static bool sdl_draw_to_window_rect(SdlContext* sdl, SdlWindow& window, SDL_Surf
325325
return true;
326326
}
327327

328+
static bool sdl_draw_to_window_scaled_rect(SdlContext* sdl, SdlWindow& window, SDL_Surface* surface,
329+
const SDL_Rect& srcRect)
330+
{
331+
SDL_Rect dstRect = srcRect;
332+
sdl_scale_coordinates(sdl, window.id(), &dstRect.x, &dstRect.y, FALSE, TRUE);
333+
sdl_scale_coordinates(sdl, window.id(), &dstRect.w, &dstRect.h, FALSE, TRUE);
334+
return window.blit(surface, srcRect, dstRect);
335+
}
336+
337+
static BOOL sdl_draw_to_window_scaled_rect(SdlContext* sdl, SdlWindow& window, SDL_Surface* surface,
338+
const std::vector<SDL_Rect>& rects = {})
339+
{
340+
if (rects.empty())
341+
{
342+
return sdl_draw_to_window_scaled_rect(sdl, window, surface,
343+
{ 0, 0, surface->w, surface->h });
344+
}
345+
for (const auto& srcRect : rects)
346+
{
347+
if (!sdl_draw_to_window_scaled_rect(sdl, window, surface, srcRect))
348+
return FALSE;
349+
}
350+
return TRUE;
351+
}
352+
328353
static BOOL sdl_draw_to_window(SdlContext* sdl, SdlWindow& window,
329354
const std::vector<SDL_Rect>& rects = {})
330355
{
@@ -339,6 +364,7 @@ static BOOL sdl_draw_to_window(SdlContext* sdl, SdlWindow& window,
339364

340365
auto size = window.rect();
341366

367+
auto surface = sdl->primary.get();
342368
if (freerdp_settings_get_bool(context->settings, FreeRDP_SmartSizing))
343369
{
344370
window.setOffsetX(0);
@@ -351,11 +377,17 @@ static BOOL sdl_draw_to_window(SdlContext* sdl, SdlWindow& window,
351377
{
352378
window.setOffsetY((size.h - gdi->height) / 2);
353379
}
380+
if (!sdl_draw_to_window_scaled_rect(sdl, window, surface, rects))
381+
return FALSE;
354382
}
355-
auto surface = sdl->primary.get();
356-
if (!sdl_draw_to_window_rect(sdl, window, surface, { window.offsetX(), window.offsetY() },
357-
rects))
358-
return FALSE;
383+
else
384+
{
385+
386+
if (!sdl_draw_to_window_rect(sdl, window, surface, { window.offsetX(), window.offsetY() },
387+
rects))
388+
return FALSE;
389+
}
390+
359391
window.updateSurface();
360392
return TRUE;
361393
}

0 commit comments

Comments
 (0)