Skip to content

Commit

Permalink
ui/cocoa: Fix mouse grabbing in fullscreen mode for relative input de…
Browse files Browse the repository at this point in the history
…vice

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>
  • Loading branch information
zhangchn authored and pm215 committed Jun 13, 2019
1 parent 2044dff commit 8e23e34
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ui/cocoa.m
Expand Up @@ -902,7 +902,12 @@ - (bool) handleEventLocked:(NSEvent *)event
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];
}
}
Expand Down

0 comments on commit 8e23e34

Please sign in to comment.