diff mbox series

[RESEND,2/2] ui/cocoa: Fix mouse grabbing in fullscreen mode for relative input device

Message ID C73C2019-CB01-4E30-8D17-02F7EA044BDE@me.com (mailing list archive)
State New, archived
Headers show
Series ui/cocoa: Fix absolute and relative input issues on Mojave | expand

Commit Message

Zhijian Li (Fujitsu)" via April 28, 2019, 3:32 a.m. UTC
In fullscreen mode, the window property of cocoaView may not be the key
window, and the current implementation would not grab mouse in fullscreen
mode after user ungrabs cursor in fullscreen mode with hot-key, and left
clicks the relative input devices to re-grab it.

This patch used value of isFullscreen as a short-cirtuit condition for
relative input device grabbing.

Signed-off-by: Chen Zhang <tgfbeta@me.com <mailto:tgfbeta@me.com>>
---
ui/cocoa.m | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/ui/cocoa.m b/ui/cocoa.m
index 474d44cb9f..aa7cf07368 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -901,7 +901,12 @@  QemuCocoaView *cocoaView;
        case NSEventTypeLeftMouseUp:
            mouse_event = true;
            if (!isMouseGrabbed && [self screenContainsPoint:p]) {
-                if([[self window] isKeyWindow]) {
+                /*
+                 * In fullscreen mode, the window of cocoaView may not be the
+                 * key window, therefore the position relative to the virtual
+                 * screen alone will be sufficient.
+                 */
+                if(isFullscreen || [[self window] isKeyWindow]) {
                    [self grabMouse];
                }
            }