[Scummvm-git-logs] scummvm master -> 6fcfdb05144982a8d69e744ace10ca8e1f1254a1
criezy
criezy at scummvm.org
Sat Aug 14 18:12:18 UTC 2021
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
6fcfdb0514 SDL: Fix handling of cursor position on Windows HiDPI
Commit: 6fcfdb05144982a8d69e744ace10ca8e1f1254a1
https://github.com/scummvm/scummvm/commit/6fcfdb05144982a8d69e744ace10ca8e1f1254a1
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2021-08-14T19:11:11+01:00
Commit Message:
SDL: Fix handling of cursor position on Windows HiDPI
Changed paths:
backends/graphics/sdl/sdl-graphics.cpp
diff --git a/backends/graphics/sdl/sdl-graphics.cpp b/backends/graphics/sdl/sdl-graphics.cpp
index f6870a3c47..b7c680b116 100644
--- a/backends/graphics/sdl/sdl-graphics.cpp
+++ b/backends/graphics/sdl/sdl-graphics.cpp
@@ -227,10 +227,19 @@ bool SdlGraphicsManager::notifyMousePosition(Common::Point &mouse) {
mouse.y = CLIP<int16>(mouse.y, 0, _windowHeight - 1);
int showCursor = SDL_DISABLE;
- // DPI aware scaling to mouse position
- float scale = getHiDPIScreenFactor();
- mouse.x = (int)(mouse.x * scale + 0.5f);
- mouse.y = (int)(mouse.y * scale + 0.5f);
+ // Currently on macOS we need to scale the events for HiDPI screen, but on
+ // Windows we do not. We can find out if we need to do it by querying the
+ // SDL window size vs the SDL drawable size.
+ float dpiScale = 1.f;
+#if SDL_VERSION_ATLEAST(2, 0, 0)
+ int windowWidth, windowHeight;
+ SDL_GetWindowSize(_window->getSDLWindow(), &windowWidth, &windowHeight);
+ int realWidth, realHeight;
+ SDL_GL_GetDrawableSize(_window->getSDLWindow(), &realWidth, &realHeight);
+ dpiScale = (float)realWidth / (float)windowWidth;
+#endif
+ mouse.x = (int)(mouse.x * dpiScale + 0.5f);
+ mouse.y = (int)(mouse.y * dpiScale + 0.5f);
bool valid = true;
if (_activeArea.drawRect.contains(mouse)) {
_cursorLastInActiveArea = true;
More information about the Scummvm-git-logs
mailing list