ui/cocoa: Fix mouse grabbing in fullscreen mode for relative input device
authorChen Zhang <tgfbeta@me.com>
Tue, 4 Jun 2019 09:36:48 +0000 (17:36 +0800)
committerPeter Maydell <peter.maydell@linaro.org>
Thu, 13 Jun 2019 10:23:22 +0000 (11:23 +0100)
In fullscreen mode, the window property of cocoaView may not be the key
window, and the current implementation would not re-grab cursor by left click
in fullscreen mode after ungrabbed in fullscreen mode with hot-key ctrl-opt-g.

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

Signed-off-by: Chen Zhang <tgfbeta@me.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 2D2F1191-E82F-4B54-A6E7-73FFB953DE93@me.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
ui/cocoa.m

index 73cfafa524cee8a8af4a6f2bb8554e896fbf8c8a..c2984028c57fad9886f951b6fdc7462e083cc2c1 100644 (file)
@@ -902,7 +902,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];
                 }
             }