SDL: Fix SDL_SetWindowMouseRect in HiDPI mode

In HiDPI mode, the window coordinates and the drawable area coordinates
might be on a different scale. The allowed mouse area needs to be scaled
accordingly before passing it to SDL_SetWindowMouseRect().

This fixes bug #13152.
This commit is contained in:
Kalle Kietavainen 2022-02-03 23:00:28 +02:00 committed by Thierry Crozat
parent ca2405ed05
commit 31cfac5d6f

View File

@ -168,10 +168,11 @@ void SdlWindow::grabMouse(bool grab) {
}
void SdlWindow::setMouseRect(const Common::Rect &rect) {
grabRect.x = rect.left;
grabRect.y = rect.top;
grabRect.w = rect.width();
grabRect.h = rect.height();
float dpiScale = getSdlDpiScalingFactor();
grabRect.x = (int)(rect.left / dpiScale + 0.5f);
grabRect.y = (int)(rect.top / dpiScale + 0.5f);
grabRect.w = (int)(rect.width() / dpiScale + 0.5f);
grabRect.h = (int)(rect.height() / dpiScale + 0.5f);
#if SDL_VERSION_ATLEAST(2, 0, 18)
if (_inputGrabState || _lastFlags & fullscreenMask) {