shithub: ft²

Download patch

ref: d9f3b8e36558b0825787c14c6512d975afa4cf5b
parent: 17ac33dc875bb058794df9d3ca2b0274f3cd9e54
author: Olav Sørensen <olav.sorensen@live.no>
date: Mon Jul 11 17:53:51 EDT 2022

More fixes and code cleanup

--- a/src/ft2_video.c
+++ b/src/ft2_video.c
@@ -308,8 +308,8 @@
 			if (dXUpscale != 0.0) video.renderW = (int32_t)(video.renderW / dXUpscale);
 			if (dYUpscale != 0.0) video.renderH = (int32_t)(video.renderH / dYUpscale);
 
-			video.renderX = (video.displayW - video.renderW) >> 1;
-			video.renderY = (video.displayH - video.renderH) >> 1;
+			video.renderX = (video.displayW - video.renderW) / 2;
+			video.renderY = (video.displayH - video.renderH) / 2;
 		}
 	}
 	else
@@ -321,8 +321,8 @@
 	}
 
 	// for mouse cursor creation
-	video.xScale = (uint32_t)round(video.renderW * (1.0 / SCREEN_W));
-	video.yScale = (uint32_t)round(video.renderH * (1.0 / SCREEN_H));
+	video.xScale = (uint32_t)round(video.renderW / (double)SCREEN_W);
+	video.yScale = (uint32_t)round(video.renderH / (double)SCREEN_H);
 
 	createMouseCursors();
 }
@@ -1029,6 +1029,12 @@
 	if (!setupSprites())
 		return false;
 
+	// Workaround: SDL_GetGlobalMouseState() doesn't work with KMSDRM/Wayland
+	video.useDesktopMouseCoords = true;
+	const char *videoDriver = SDL_GetCurrentVideoDriver();
+	if (videoDriver != NULL && (strcmp("KMSDRM", videoDriver) == 0 || strcmp("wayland", videoDriver) == 0))
+		video.useDesktopMouseCoords = false;
+
 	updateRenderSizeVars();
 	updateMouseScaling();
 
@@ -1036,12 +1042,6 @@
 		SDL_ShowCursor(SDL_TRUE);
 	else
 		SDL_ShowCursor(SDL_FALSE);
-
-	// Workaround: SDL_GetGlobalMouseState() doesn't work with KMSDRM/Wayland
-	video.useDesktopMouseCoords = true;
-	const char *videoDriver = SDL_GetCurrentVideoDriver();
-	if (videoDriver != NULL && (strcmp("KMSDRM", videoDriver) == 0 || strcmp("wayland", videoDriver) == 0))
-		video.useDesktopMouseCoords = false;
 
 	SDL_SetRenderDrawColor(video.renderer, 0, 0, 0, SDL_ALPHA_OPAQUE);
 	return true;