From bb8605fa3b03b566ea56ac96f0d50ca2bcbdac97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20B=C3=A1lint=20Misius?= Date: Thu, 5 Oct 2023 21:18:01 +0200 Subject: [PATCH] Fix ubuntu 20.04 pipelines By not using SDL_RenderLogicalToWindow if it's not available. Because of course ubuntu 20.04 has sdl 2.0.10, which of course doesn't yet have SDL_RenderLogicalToWindow which was added in 2.0.18, which is of course needed because of course SDL_SetTextInputRect takes window coordinates rather than logical coordinates. At least official static linux builds are not affected because tpt-libs uses much newer sdl. --- src/PowderToySDL.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/PowderToySDL.cpp b/src/PowderToySDL.cpp index 37b8dc8b5..bb7428d2a 100644 --- a/src/PowderToySDL.cpp +++ b/src/PowderToySDL.cpp @@ -43,14 +43,23 @@ void StopTextInput() void SetTextInputRect(int x, int y, int w, int h) { // Why does SDL_SetTextInputRect not take logical coordinates??? + SDL_Rect rect; +#if SDL_VERSION_ATLEAST(2, 0, 18) int wx, wy, wwx, why; SDL_RenderLogicalToWindow(sdl_renderer, x, y, &wx, &wy); SDL_RenderLogicalToWindow(sdl_renderer, x + w, y + h, &wwx, &why); - SDL_Rect rect; rect.x = wx; rect.y = wy; rect.w = wwx - wx; rect.h = why - wy; +#else + // TODO: use SDL_RenderLogicalToWindow when ubuntu deigns to update to sdl 2.0.18 + auto scale = ui::Engine::Ref().windowFrameOps.scale; + rect.x = x * scale; + rect.y = y * scale; + rect.w = w * scale; + rect.h = h * scale; +#endif SDL_SetTextInputRect(&rect); }