diff options
author | Matthew Stewart | 2018-06-25 00:38:08 -0400 |
---|---|---|
committer | Thierry Crozat | 2018-07-08 22:30:31 +0100 |
commit | a382a6dd303a97a0f813eb2f86bc93f27ef83aa9 (patch) | |
tree | dd233c919cc25810998cf16701b4276803a3bfa5 | |
parent | 8c2f9dec26e2bcd4b975246732782d0c823037d1 (diff) | |
download | scummvm-rg350-a382a6dd303a97a0f813eb2f86bc93f27ef83aa9.tar.gz scummvm-rg350-a382a6dd303a97a0f813eb2f86bc93f27ef83aa9.tar.bz2 scummvm-rg350-a382a6dd303a97a0f813eb2f86bc93f27ef83aa9.zip |
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".
-rw-r--r-- | backends/graphics/windowed.h | 7 |
1 files changed, 5 insertions, 2 deletions
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<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)); } /** |