From 8cc4735d74a1ce89c5fceb48b021872c8c563174 Mon Sep 17 00:00:00 2001 From: Frank Praznik Date: Sun, 29 Dec 2024 17:58:05 -0500 Subject: [PATCH] wayland: Don't override the min/max values when scaling to the screen The point/pixel conversion functions should return zero when passed zero, or the min/max calculations can break. --- src/video/wayland/SDL_waylandwindow.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/video/wayland/SDL_waylandwindow.c b/src/video/wayland/SDL_waylandwindow.c index 9a93c706ef..d8de865b03 100644 --- a/src/video/wayland/SDL_waylandwindow.c +++ b/src/video/wayland/SDL_waylandwindow.c @@ -60,12 +60,12 @@ static int PointToPixel(SDL_Window *window, int point) * Wayland scale units are in units of 1/120, so the offset is required to correct for * rounding errors when using certain scale values. */ - return SDL_max((int)SDL_lround((double)point * GetWindowScale(window) + 1e-6), 1); + return point ? SDL_max((int)SDL_lround((double)point * GetWindowScale(window) + 1e-6), 1) : 0; } static int PixelToPoint(SDL_Window *window, int pixel) { - return SDL_max((int)SDL_lround((double)pixel / GetWindowScale(window)), 1); + return pixel ? SDL_max((int)SDL_lround((double)pixel / GetWindowScale(window)), 1) : 0; } /* According to the Wayland spec: