[Scummvm-git-logs] scummvm master -> a5a45fdae16dbae164eb3f3a5ca9113e89851761

criezy criezy at scummvm.org
Sun Jul 8 23:30:35 CEST 2018


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
a382a6dd30 SDL: Clip mouse range in convertWindowToVirtual
a5a45fdae1 SDL: Clip mouse range in convertVirtualToWindow


Commit: a382a6dd303a97a0f813eb2f86bc93f27ef83aa9
    https://github.com/scummvm/scummvm/commit/a382a6dd303a97a0f813eb2f86bc93f27ef83aa9
Author: Matthew Stewart (stewartmatthew6 at gmail.com)
Date: 2018-07-08T22:30:31+01:00

Commit Message:
SDL: Clip mouse range in convertWindowToVirtual

When the graphics scale was 2x or higher, it was possible for the mouse
to pass the size of the screen specified by "initSize".

Changed paths:
    backends/graphics/windowed.h


diff --git a/backends/graphics/windowed.h b/backends/graphics/windowed.h
index 4732ea9..40ae561 100644
--- a/backends/graphics/windowed.h
+++ b/backends/graphics/windowed.h
@@ -128,8 +128,11 @@ protected:
 		x = CLIP<int>(x, sourceX, sourceMaxX);
 		y = CLIP<int>(y, sourceY, sourceMaxY);
 
-		return Common::Point(((x - sourceX) * targetWidth + sourceWidth / 2) / sourceWidth,
-		                     ((y - sourceY) * targetHeight + sourceHeight / 2) / sourceHeight);
+		int virtualX = ((x - sourceX) * targetWidth + sourceWidth / 2) / sourceWidth;
+		int virtualY = ((y - sourceY) * targetHeight + sourceHeight / 2) / sourceHeight;
+
+		return Common::Point(CLIP<int>(virtualX, 0, targetWidth - 1),
+				             CLIP<int>(virtualY, 0, targetHeight - 1));
 	}
 
 	/**


Commit: a5a45fdae16dbae164eb3f3a5ca9113e89851761
    https://github.com/scummvm/scummvm/commit/a5a45fdae16dbae164eb3f3a5ca9113e89851761
Author: Matthew Stewart (stewartmatthew6 at gmail.com)
Date: 2018-07-08T22:30:31+01:00

Commit Message:
SDL: Clip mouse range in convertVirtualToWindow

Changed paths:
    backends/graphics/windowed.h


diff --git a/backends/graphics/windowed.h b/backends/graphics/windowed.h
index 40ae561..b725ca0 100644
--- a/backends/graphics/windowed.h
+++ b/backends/graphics/windowed.h
@@ -102,8 +102,11 @@ protected:
 			error("convertVirtualToWindow called without a valid draw rect");
 		}
 
-		return Common::Point(targetX + (x * targetWidth + sourceWidth / 2) / sourceWidth,
-		                     targetY + (y * targetHeight + sourceHeight / 2) / sourceHeight);
+		int windowX = targetX + (x * targetWidth + sourceWidth / 2) / sourceWidth;
+		int windowY = targetY + (y * targetHeight + sourceHeight / 2) / sourceHeight;
+
+		return Common::Point(CLIP<int>(windowX, targetX, targetX + targetWidth - 1),
+		                     CLIP<int>(windowY, targetY, targetY + targetHeight - 1));
 	}
 
 	/**
@@ -132,7 +135,7 @@ protected:
 		int virtualY = ((y - sourceY) * targetHeight + sourceHeight / 2) / sourceHeight;
 
 		return Common::Point(CLIP<int>(virtualX, 0, targetWidth - 1),
-				             CLIP<int>(virtualY, 0, targetHeight - 1));
+		                     CLIP<int>(virtualY, 0, targetHeight - 1));
 	}
 
 	/**





More information about the Scummvm-git-logs mailing list