qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 1/2] ui/cocoa: Fix absolute input device grabbin


From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH 1/2] ui/cocoa: Fix absolute input device grabbing issue on Mojave
Date: Fri, 7 Jun 2019 18:04:07 +0100

On Tue, 4 Jun 2019 at 10:36, Chen Zhang <address@hidden> wrote:
>
> 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 <address@hidden>
> ---
>  ui/cocoa.m | 43 +++++++++++++++++++++++++++++++++++++++++--
>  1 file changed, 41 insertions(+), 2 deletions(-)
>
> diff --git a/ui/cocoa.m b/ui/cocoa.m
> index 420b2411c1..474d44cb9f 100644
> --- a/ui/cocoa.m
> +++ b/ui/cocoa.m
> @@ -405,6 +405,41 @@ QemuCocoaView *cocoaView;
>      return (p.x > -1 && p.x < screen.width && p.y > -1 && p.y < 
> screen.height);
>  }
>
> +/* Get location of event and convert to virtual screen coordinate */
> +- (CGPoint) screenLocationOfEvent:(NSEvent *)ev
> +{
> +    NSWindow *eventWindow = [ev window];
> +    // XXX: Use CGRect and -convertRectFromScreen: to support macOS 10.10

The "XXX" prefix usually indicates something in the code that
needs to be fixed, but in this case the code is already using
these methods, so it's OK I think?

(I hope to have some time to test these patches this weekend
or next week.)

thanks
-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]