ui/cocoa: Fix absolute input device grabbing issue on Mojave
commit2044dff87004b9b0faf1c8299491b258332c6887
authorChen Zhang <tgfbeta@me.com>
Tue, 4 Jun 2019 09:36:00 +0000 (4 17:36 +0800)
committerPeter Maydell <peter.maydell@linaro.org>
Thu, 13 Jun 2019 10:23:22 +0000 (13 11:23 +0100)
tree454a57b2727288bec36b7be61e9a067195d3986d
parentfe18911af739d292ad2e62c6699a705a08302fca
ui/cocoa: Fix absolute input device grabbing issue on Mojave

On Mojave, absolute input device, i.e. tablet, had trouble re-grabbing
the cursor in re-entry into the virtual screen area. In some cases,
the `window` property of NSEvent object was nil after cursor exiting from
window, hinting that the `-locationInWindow` method would return value in
screen coordinates. The current implementation used raw locations from
NSEvent without considering whether the value was for the window coordinates
or the macOS screen coordinates, nor the zooming factor for Zoom-to-Fit in
fullscreen mode.

In fullscreen mode, the fullscreen cocoa window might not be the key
window, therefore the location of event in virtual coordinates should
suffice.

This patches fixed boundary check methods for cursor in normal
and fullscreen with/without Zoom-to-Fit in Mojave.

Note: CGRect, -convertRectToScreen: and -convertRectFromScreen: were
used in coordinates conversion for compatibility reason.

Signed-off-by: Chen Zhang <tgfbeta@me.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: FA3FBC4F-5379-4118-B997-58FE05CC58F9@me.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
ui/cocoa.m