From a382a6dd303a97a0f813eb2f86bc93f27ef83aa9 Mon Sep 17 00:00:00 2001 From: Matthew Stewart Date: Mon, 25 Jun 2018 00:38:08 -0400 Subject: 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". --- backends/graphics/windowed.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'backends/graphics') diff --git a/backends/graphics/windowed.h b/backends/graphics/windowed.h index 4732ea9708..40ae561df1 100644 --- a/backends/graphics/windowed.h +++ b/backends/graphics/windowed.h @@ -128,8 +128,11 @@ protected: x = CLIP(x, sourceX, sourceMaxX); y = CLIP(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(virtualX, 0, targetWidth - 1), + CLIP(virtualY, 0, targetHeight - 1)); } /** -- cgit v1.2.3