Opened 3 years ago

Closed 2 years ago

#12646 closed defect (fixed)

PORTS: MACOS: Mac OS loss of mouse focus with OpenGL

Reported by: aculotarpa Owned by:
Priority: normal Component: Port: Mac OS X
Version: Keywords: Mac OS X, OpenGL, Mouse
Cc: Game:

Description

ScummVM 2.3.0git18941-g0ff7411a1d (Jun 19 2021 04:43:04)
Intel x64
macOS Big Sur 11.4
iMac (Retina 5K, 27-inch, 2017) 3,4 GHz Intel Core i5 quad-core
Radeon Pro 570 4 GB

OpenGL renderer

With every game, every time I drag the mouse to the border of the game viewport I loss the focus on ScummVM. In windowed mode I can drag the mouse inside the windows, when in fullscreen I have to invoke Exposé and click on the ScummVM desktop to regain mouse focus.
With Lost in Time I sometime loss the focus simply by right-clicking, and the mouse teleport himself outside the viewport.
This occurs only in game, in the ScummVM GUI anything works fine.
Any other software scaler works fine.

2.2.0 stable works fine.
2.2.1pre229-g4e0b1ca02d (Mar 17 2021 11:26:26) works fine.

Change History (9)

comment:1 by aculotarpa, 3 years ago

Update
ScummVM 2.3.0git20086-g6e9b182da2 (Jul 3 2021 05:01:14)

When in OpenGL fullscreen, anytime the cursor reach the border of the game viewport it disappears, but if i drag the mouse to the center of the screen 2 or 3 times it appears again and works flawlessy.

comment:2 by criezy, 3 years ago

I can't reproduce this issue.
When I move the cursor to the border of the game viewport, both in window mode and in fullscreen mode, the focus remains on the ScummVM window.

However I do have a strange behaviour in fullscreen mode with the mouse cursor that seems to rebound on the border. For example when I move the mouse cursor to the left border, it moves back a few pixel to the right (and down) when it hits the border. In windowed mode everything seems to work properly.

comment:3 by criezy, 3 years ago

The behaviour I described in my previous comment is now fixed (bug #12822).

It might be worth checking if you can still reproduce the issue you described. With a bit of luck it might be fixed as well.

comment:4 by aculotarpa, 3 years ago

No, unfortunately it was not fixed in ScummVM 2.3.0git22318-g7088115942 (Aug 20 2021 04:33:20)

Whenever the mouse reach the right side of the the game viewport in fullscreen OpenGL, ScummVM loose the focus and I have to invoke Exposé to regain it.

There is a change in Lost in Time behaviour.
When right-clicking, the contextual menu appears a little lower and righter from where I clicked, and the mouse teleport itself over the first item on the contextual menu.

Changing aspect aspect ratio correction on and off as per #12822 has no effect, and the launcher never had any offset problem.

comment:5 by aculotarpa, 3 years ago

Hi, the bug is still present in ScummVM 2.5.0 (Oct 3 2021 21:01:15) stable release.
I did some further test and discovered only few OpenGL fullscreen stretch modes are affected.

default, fit, stretch, fit_force_aspect work without any issue.

center, pixel-perfect, even-pixels show the defect.

If I drag the mouse on the right limit of the viewport several time the cursor eventually get stuck and ScummVM seems to freeze. Any ScummVM input via mouse or keyboard get ignored, but os shortcuts (Exposé, volume, Mission Control) still work. The music (both midi and ogg) continues to play.
If I change desktop (via Command+Tab, Exposé, Mission Control) then come back to ScummVM, the game unfreezes, until I drag the mouse to the far right several time again.

Window mode works without any issue.

comment:6 by sev-, 3 years ago

Summary: Mac OS loss of mouse focus with OpenGLPORTS: MACOS: Mac OS loss of mouse focus with OpenGL

comment:7 by kalkie, 3 years ago

I've submitted a PR for fixing this issue:
https://github.com/scummvm/scummvm/pull/3699

There was an off-by-one kind of error in clipping the mouse coordinates to the game's viewport in scaled HiDPI mode. At least MacOS is affected, but based on comments in https://github.com/libsdl-org/SDL/issues/2119, also iOS and Wayland have similar scaled HiDPI support.

If the mouse gets out of the game's viewport on right/bottom side, the off-by-one error causes the cursor to be set on the outside edge of the viewport, not inside of it. This leads into a loop, where the mouse is again detected to be outside of the viewport, reset on the edge again, etc., making the game freeze.

This only happens with the OpenGL graphics mode, because the SDL Surface mode doesn't support HiDPI mode. There are quite a few workarounds for the issue, in addition to changing the graphics mode. One could disable mouse capture (Ctrl+m) or change to one of the stretch modes filling the entire screen with the game. If the game's viewport fills the whole window, the cursor cannot get outside of the allowed area, thus avoiding the issue.

comment:8 by aculotarpa, 3 years ago

As per ScummVM 2.6.0git3372-gfa9f8850bfa (Mar 3 2022 04:29:27) the problem seems fixed on MacOS.
I have tried all OpenGL fullscreen stretch modes without any mouse issue.

ScummVM 2.6.0git3372-gfa9f8850bfa (Mar 3 2022 04:29:27)
Intel x64
macOS Monterey 12.2.1
iMac (Retina 5K, 27-inch, 2017) 3,4 GHz Intel Core i5 quad-core
Radeon Pro 570 4 GB

comment:9 by lephilousophe, 2 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.