mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-03 17:33:05 +00:00
SDL: Fix mouse clip to game area in HiDPI mode
The mouse position is set in window coordinates, but it's clipped to the game area in drawable area coordinates. Previously, the scaling between these two was not taken into account when calculating the right/bottom edges of the game area. When the clipped mouse position was converted back to window coordinates and rounded to the nearest integer, it could end up on the edge of the game area, not inside of it. This leads to a loop in which the clipped mouse position is outside of the game area and needs to be clipped again. This fixes bug #12646.
This commit is contained in:
parent
2bce7cb25d
commit
ca2405ed05
@ -221,8 +221,14 @@ bool SdlGraphicsManager::notifyMousePosition(Common::Point &mouse) {
|
||||
if (_activeArea.drawRect.contains(mouse)) {
|
||||
_cursorLastInActiveArea = true;
|
||||
} else {
|
||||
mouse.x = CLIP<int>(mouse.x, _activeArea.drawRect.left, _activeArea.drawRect.right - 1);
|
||||
mouse.y = CLIP<int>(mouse.y, _activeArea.drawRect.top, _activeArea.drawRect.bottom - 1);
|
||||
// The right/bottom edges are not part of the drawRect. As the clipping
|
||||
// is done in drawable area coordinates, but the mouse position is set
|
||||
// in window coordinates, we need to subtract as many pixels from the
|
||||
// edges as corresponds to one pixel in the window coordinates.
|
||||
mouse.x = CLIP<int>(mouse.x, _activeArea.drawRect.left,
|
||||
_activeArea.drawRect.right - (int)(1 * dpiScale + 0.5f));
|
||||
mouse.y = CLIP<int>(mouse.y, _activeArea.drawRect.top,
|
||||
_activeArea.drawRect.bottom - (int)(1 * dpiScale + 0.5f));
|
||||
|
||||
if (_window->mouseIsGrabbed() ||
|
||||
// Keep the mouse inside the game area during dragging to prevent an
|
||||
|
Loading…
x
Reference in New Issue
Block a user