From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37310) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1amPjV-0004Ka-T8 for qemu-devel@nongnu.org; Sat, 02 Apr 2016 13:53:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1amPjQ-0005OC-T6 for qemu-devel@nongnu.org; Sat, 02 Apr 2016 13:53:13 -0400 Received: from mail-ig0-x244.google.com ([2607:f8b0:4001:c05::244]:33901) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1amPjQ-0005O8-Ms for qemu-devel@nongnu.org; Sat, 02 Apr 2016 13:53:08 -0400 Received: by mail-ig0-x244.google.com with SMTP id mh10so5484325igb.1 for ; Sat, 02 Apr 2016 10:53:08 -0700 (PDT) Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii From: Programmingkid In-Reply-To: Date: Sat, 2 Apr 2016 13:53:05 -0400 Content-Transfer-Encoding: quoted-printable Message-Id: References: <864865FE-CA14-4D3A-8B73-84A2E321CA6C@gmail.com> <81C47134-3F2D-4867-894B-777B286194AC@gmail.com> Subject: Re: [Qemu-devel] [PATCH] ui/cocoa.m: fix sending mouse event to guest List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: qemu-devel qemu-devel On Apr 2, 2016, at 1:35 PM, Peter Maydell wrote: > On 2 April 2016 at 18:25, Programmingkid = wrote: >>=20 >> On Apr 2, 2016, at 1:07 PM, Peter Maydell wrote: >>=20 >>> On 2 April 2016 at 17:56, Programmingkid = wrote: >>>> The mouse down event should not be sent to the guest if the mouse = down event >>>> causes an activation of QEMU. This patch prevents activation clicks = from going >>>> to the guest. >>>>=20 >>>> Signed-off-by: John Arbuckle >>>> --- >>>> ui/cocoa.m | 2 +- >>>> 1 file changed, 1 insertion(+), 1 deletion(-) >>>>=20 >>>> diff --git a/ui/cocoa.m b/ui/cocoa.m >>>> index 60a7c07..07d9c86 100644 >>>> --- a/ui/cocoa.m >>>> +++ b/ui/cocoa.m >>>> @@ -698,7 +698,7 @@ QemuCocoaView *cocoaView; >>>> * call below. We definitely don't want to pass that click = through >>>> * to the guest. >>>> */ >>>> - if ((isMouseGrabbed || [[self window] isKeyWindow]) && >>>> + if ((isMouseGrabbed && [[self window] isKeyWindow]) && >>>> (last_buttons !=3D buttons)) { >>>> static uint32_t bmap[INPUT_BUTTON__MAX] =3D { >>>> [INPUT_BUTTON_LEFT] =3D MOUSE_EVENT_LBUTTON, >>>> -- >>>> 2.7.2 >>>=20 >>> I'm afraid I don't really understand why you think this >>> should change. On the face of it the current code looks right: >>> we pass through the mouse button if: >>> (1) we've got the mouse grab >>> or (2) our window has the focus, even if it's not grabbed >>>=20 >>> I would expect the "activation click" to be "we don't have >>> the mouse grab, and we don't have focus either (some other >>> app is foreground)". >>=20 >> When QEMU's main window is in the background and the user clicks on = it, >> the NSLeftMouseUp case in the handleEvent: method will set the >> isMouseGrabbed variable to true. This means the >> "if ((isMouseGrabbed || [[self window] isKeyWindow]) && >> (last_buttons !=3D buttons))" code will always be true for a left >> mouse button click. The mouse event will be sent to the guest >> when it shouldn't be. >=20 > OK, that sounds like a bug, but this doesn't look like the > right way to fix it, because with your change we won't > pass through the click if this is a click on the window > when it's not in the background. I think logically this is the best solution. If the window is in the = foreground and doesn't have the mouse grabbed, the user can't move the = mouse pointer in the guest. This could cause stuff to be clicked that = might cause undesirable effects.=