shithub: pt2-clone

Download patch

ref: e9b37b836ddad6c588fe2f3e5ec1423398e0397e
parent: d6b1877bed615652629ec7e0409d844c0821b6e8
author: Olav Sørensen <olav.sorensen@live.no>
date: Wed Nov 18 09:40:13 EST 2020

Fix fullscreen mouse bug on multi-monitor setups

--- a/src/pt2_mouse.c
+++ b/src/pt2_mouse.c
@@ -267,20 +267,25 @@
 	}
 
 	if (video.useDesktopMouseCoords)
+	{
 		mouse.buttonState = SDL_GetGlobalMouseState(&mx, &my);
+
+		// convert desktop coords to window coords
+		SDL_GetWindowPosition(video.window, &windowX, &windowY);
+		mx -= windowX;
+		my -= windowY;
+	}
 	else
+	{
 		mouse.buttonState = SDL_GetMouseState(&mx, &my);
+	}
 
 	if (video.fullscreen)
 	{
-		/* If fullscreen without filtering mode, translate coords and warp mouse
-		** inside the render space.
-		** Fullscreen + filtering mode takes up 100% of the screen area used, so no
-		** need to translate coords in that mode.
-		*/
-
+		// centered fullscreen mode (not stretched) needs further coord translation
 		if (!config.fullScreenStretch)
 		{
+			// if software mouse is enabled, warp mouse inside render space
 			if (!config.hwMouse)
 			{
 				bool warpMouse = false;
@@ -315,16 +320,6 @@
 			mx -= video.renderX;
 			my -= video.renderY;
 		}
-	}
-	else if (video.useDesktopMouseCoords)
-	{
-		// convert desktop coords to window coords
-
-		// (a call to this function is really fast in windowed mode)
-		SDL_GetWindowPosition(video.window, &windowX, &windowY);
-
-		mx -= windowX;
-		my -= windowY;
 	}
 
 	// multiply coords by video upscaling factors (don't round)