From 1b577a755e1e0495838486568fa0f7afd2926729 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Sat, 14 Feb 2026 09:38:22 +0100 Subject: [PATCH 1/4] [client,sdl] add toString for SDL_Rect --- client/SDL/SDL3/sdl_utils.cpp | 15 +++++++++++++++ client/SDL/SDL3/sdl_utils.hpp | 2 ++ 2 files changed, 17 insertions(+) diff --git a/client/SDL/SDL3/sdl_utils.cpp b/client/SDL/SDL3/sdl_utils.cpp index 436033106..49401d970 100644 --- a/client/SDL/SDL3/sdl_utils.cpp +++ b/client/SDL/SDL3/sdl_utils.cpp @@ -474,6 +474,21 @@ namespace sdl::utils return ss.str(); } + + std::string toString(SDL_Rect rect) + { + std::stringstream ss; + ss << "SDL_Rect{" << rect.x << "x" << rect.y << "-" << rect.w << "x" << rect.h << "}"; + return ss.str(); + } + + std::string toString(SDL_FRect rect) + { + std::stringstream ss; + ss << "SDL_Rect{" << rect.x << "x" << rect.y << "-" << rect.w << "x" << rect.h << "}"; + return ss.str(); + } + } // namespace sdl::utils namespace sdl::error diff --git a/client/SDL/SDL3/sdl_utils.hpp b/client/SDL/SDL3/sdl_utils.hpp index b4b449406..92ad4ec4d 100644 --- a/client/SDL/SDL3/sdl_utils.hpp +++ b/client/SDL/SDL3/sdl_utils.hpp @@ -86,6 +86,8 @@ namespace sdl::utils [[nodiscard]] std::string toString(SDL_DisplayOrientation orientation); [[nodiscard]] std::string toString(const SDL_DisplayMode* mode); [[nodiscard]] std::string toString(Uint32 type); + [[nodiscard]] std::string toString(SDL_Rect rect); + [[nodiscard]] std::string toString(SDL_FRect rect); [[nodiscard]] UINT32 orientaion_to_rdp(SDL_DisplayOrientation orientation); From 07bf4e9c100b5e94c59b8eb06246ea445921f6c3 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Sat, 14 Feb 2026 09:29:47 +0100 Subject: [PATCH 2/4] [client,sdl] improve cursor updates * use std::unique_ptr for temporary SDL_Surface (ease up cleanup) * better logging of errors (add full surface details) --- client/SDL/SDL3/sdl_pointer.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/client/SDL/SDL3/sdl_pointer.cpp b/client/SDL/SDL3/sdl_pointer.cpp index 322269190..07d95a510 100644 --- a/client/SDL/SDL3/sdl_pointer.cpp +++ b/client/SDL/SDL3/sdl_pointer.cpp @@ -170,31 +170,33 @@ bool sdl_Pointer_Set_Process(SdlContext* sdl) const auto hidpi_scale = sdl->pixelToScreen(fw->id(), SDL_FPoint{ static_cast(ptr->image->w), static_cast(ptr->image->h) }); - auto normal = SDL_CreateSurface(static_cast(hidpi_scale.x), - static_cast(hidpi_scale.y), ptr->image->format); + std::unique_ptr normal{ + SDL_CreateSurface(static_cast(hidpi_scale.x), static_cast(hidpi_scale.y), + ptr->image->format), + SDL_DestroySurface + }; assert(normal); - if (!SDL_BlitSurfaceScaled(ptr->image, nullptr, normal, nullptr, + if (!SDL_BlitSurfaceScaled(ptr->image, nullptr, normal.get(), nullptr, SDL_ScaleMode::SDL_SCALEMODE_LINEAR)) { WLog_Print(sdl->getWLog(), WLOG_ERROR, "SDL_BlitSurfaceScaled failed"); return false; } - if (!SDL_AddSurfaceAlternateImage(normal, ptr->image)) + if (!SDL_AddSurfaceAlternateImage(normal.get(), ptr->image)) { WLog_Print(sdl->getWLog(), WLOG_ERROR, "SDL_AddSurfaceAlternateImage failed"); return false; } - ptr->cursor = SDL_CreateColorCursor(normal, static_cast(pos.x), static_cast(pos.y)); + ptr->cursor = + SDL_CreateColorCursor(normal.get(), static_cast(pos.x), static_cast(pos.y)); if (!ptr->cursor) { - WLog_Print(sdl->getWLog(), WLOG_ERROR, "SDL_CreateColorCursor(%fx%f) failed", - static_cast(pos.x), static_cast(pos.y)); + WLog_Print(sdl->getWLog(), WLOG_ERROR, "SDL_CreateColorCursor(display:%s, pixel:%s} failed", + sdl::utils::toString(pos).c_str(), sdl::utils::toString(orig).c_str()); return false; } - SDL_DestroySurface(normal); - if (!SDL_SetCursor(ptr->cursor)) { WLog_Print(sdl->getWLog(), WLOG_ERROR, "SDL_SetCursor failed"); From 3503be620a771e3a774fc0a3561d111c57f90cdd Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Sat, 14 Feb 2026 09:40:36 +0100 Subject: [PATCH 3/4] [client,sdl] log cursor scale --- client/SDL/SDL3/sdl_pointer.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/client/SDL/SDL3/sdl_pointer.cpp b/client/SDL/SDL3/sdl_pointer.cpp index 07d95a510..c7aeb94a2 100644 --- a/client/SDL/SDL3/sdl_pointer.cpp +++ b/client/SDL/SDL3/sdl_pointer.cpp @@ -127,7 +127,10 @@ bool sdl_Pointer_Set_Process(SdlContext* sdl) const Uint32 id = SDL_GetWindowID(window); - auto pos = sdl->pixelToScreen(id, SDL_FRect{ ix, iy, isw, ish }); + const SDL_FRect orig{ ix, iy, isw, ish }; + auto pos = sdl->pixelToScreen(id, orig); + WLog_Print(sdl->getWLog(), WLOG_DEBUG, "cursor scale: pixel:%s, display:%s", + sdl::utils::toString(orig).c_str(), sdl::utils::toString(pos).c_str()); sdl_Pointer_Clear(ptr); From 52cd9884103064c29b406b69dad5642d9e0f1c9f Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Sat, 14 Feb 2026 10:03:23 +0100 Subject: [PATCH 4/4] [client,sdl] fix cursor surface creation * Pass the pixel width and height to SDL_CreateSurface * Pass display scaled hotspot to SDL_CreateColorCursor --- client/SDL/SDL3/sdl_pointer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/SDL/SDL3/sdl_pointer.cpp b/client/SDL/SDL3/sdl_pointer.cpp index c7aeb94a2..ebc5ac39e 100644 --- a/client/SDL/SDL3/sdl_pointer.cpp +++ b/client/SDL/SDL3/sdl_pointer.cpp @@ -135,7 +135,7 @@ bool sdl_Pointer_Set_Process(SdlContext* sdl) sdl_Pointer_Clear(ptr); ptr->image = - SDL_CreateSurface(static_cast(pos.w), static_cast(pos.h), sdl->pixelFormat()); + SDL_CreateSurface(static_cast(orig.w), static_cast(orig.h), sdl->pixelFormat()); if (!ptr->image) { WLog_Print(sdl->getWLog(), WLOG_ERROR, "SDL_CreateSurface failed");