From a5a45fdae16dbae164eb3f3a5ca9113e89851761 Mon Sep 17 00:00:00 2001 From: Matthew Stewart Date: Sun, 8 Jul 2018 15:44:02 -0400 Subject: [PATCH] SDL: Clip mouse range in convertVirtualToWindow --- backends/graphics/windowed.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/backends/graphics/windowed.h b/backends/graphics/windowed.h index 40ae561df17..b725ca08b42 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(windowX, targetX, targetX + targetWidth - 1), + CLIP(windowY, targetY, targetY + targetHeight - 1)); } /** @@ -132,7 +135,7 @@ protected: int virtualY = ((y - sourceY) * targetHeight + sourceHeight / 2) / sourceHeight; return Common::Point(CLIP(virtualX, 0, targetWidth - 1), - CLIP(virtualY, 0, targetHeight - 1)); + CLIP(virtualY, 0, targetHeight - 1)); } /**