qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] ui/cocoa.m: Prevent activation clicks from going to guest
@ 2015-11-22  1:43 Programmingkid
  2015-11-23 16:06 ` Peter Maydell
  0 siblings, 1 reply; 6+ messages in thread
From: Programmingkid @ 2015-11-22  1:43 UTC (permalink / raw)
  To: qemu-devel qemu-devel; +Cc: Peter Maydell

When QEMU is brought to the foreground, the click event that activates QEMU
should not go to the guest. Accidents happen when they do go to the guest
without giving the user a change to handle them. Buttons are clicked accidently.
Windows are closed accidently. Volumes are unmounted accidently. This patch
prevents these accidents from happening. 

Signed-off-by: John Arbuckle <programmingkidx@gmail.com>

---
 ui/cocoa.m |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/ui/cocoa.m b/ui/cocoa.m
index 1554331..b75c01e 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -669,6 +669,16 @@ QemuCocoaView *cocoaView;
             mouse_event = true;
             break;
         case NSLeftMouseDown:
+            /*
+             * This prevents the click that activates QEMU from being sent to
+             * the guest.
+             */
+            if (!isMouseGrabbed && [self screenContainsPoint:p]) {
+                [self grabMouse];
+                [NSApp sendEvent:event];
+                return;
+            }
+
             if ([event modifierFlags] & NSCommandKeyMask) {
                 buttons |= MOUSE_EVENT_RBUTTON;
             } else {
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH] ui/cocoa.m: Prevent activation clicks from going to guest
  2015-11-22  1:43 [Qemu-devel] [PATCH] ui/cocoa.m: Prevent activation clicks from going to guest Programmingkid
@ 2015-11-23 16:06 ` Peter Maydell
  2015-11-23 17:37   ` Programmingkid
  2015-11-24  3:25   ` Programmingkid
  0 siblings, 2 replies; 6+ messages in thread
From: Peter Maydell @ 2015-11-23 16:06 UTC (permalink / raw)
  To: Programmingkid; +Cc: qemu-devel qemu-devel

On 22 November 2015 at 01:43, Programmingkid <programmingkidx@gmail.com> wrote:
> When QEMU is brought to the foreground, the click event that activates QEMU
> should not go to the guest. Accidents happen when they do go to the guest
> without giving the user a change to handle them. Buttons are clicked accidently.
> Windows are closed accidently. Volumes are unmounted accidently. This patch
> prevents these accidents from happening.
>
> Signed-off-by: John Arbuckle <programmingkidx@gmail.com>

So, I checked how Parallels behaves (this is my go-to check for
"how should a native OSX VM window behave?"), and it works the
same way QEMU does -- left mouse clicks "click through" so they
both raise the window to the front and have the behaviour
indicated by the guest OS.

thanks
-- PMM

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH] ui/cocoa.m: Prevent activation clicks from going to guest
  2015-11-23 16:06 ` Peter Maydell
@ 2015-11-23 17:37   ` Programmingkid
  2015-11-24  3:25   ` Programmingkid
  1 sibling, 0 replies; 6+ messages in thread
From: Programmingkid @ 2015-11-23 17:37 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-devel qemu-devel


On Nov 23, 2015, at 11:06 AM, Peter Maydell wrote:

> On 22 November 2015 at 01:43, Programmingkid <programmingkidx@gmail.com> wrote:
>> When QEMU is brought to the foreground, the click event that activates QEMU
>> should not go to the guest. Accidents happen when they do go to the guest
>> without giving the user a change to handle them. Buttons are clicked accidently.
>> Windows are closed accidently. Volumes are unmounted accidently. This patch
>> prevents these accidents from happening.
>> 
>> Signed-off-by: John Arbuckle <programmingkidx@gmail.com>
> 
> So, I checked how Parallels behaves (this is my go-to check for
> "how should a native OSX VM window behave?"), and it works the
> same way QEMU does -- left mouse clicks "click through" so they
> both raise the window to the front and have the behaviour
> indicated by the guest OS.

What if we were better than Parallels? Apple's own human interface guidelines state that the
activation click should not make any changes to the application.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH] ui/cocoa.m: Prevent activation clicks from going to guest
  2015-11-23 16:06 ` Peter Maydell
  2015-11-23 17:37   ` Programmingkid
@ 2015-11-24  3:25   ` Programmingkid
  2015-11-24  8:56     ` Peter Maydell
  1 sibling, 1 reply; 6+ messages in thread
From: Programmingkid @ 2015-11-24  3:25 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-devel qemu-devel


On Nov 23, 2015, at 11:06 AM, Peter Maydell wrote:

> On 22 November 2015 at 01:43, Programmingkid <programmingkidx@gmail.com> wrote:
>> When QEMU is brought to the foreground, the click event that activates QEMU
>> should not go to the guest. Accidents happen when they do go to the guest
>> without giving the user a change to handle them. Buttons are clicked accidently.
>> Windows are closed accidently. Volumes are unmounted accidently. This patch
>> prevents these accidents from happening.
>> 
>> Signed-off-by: John Arbuckle <programmingkidx@gmail.com>
> 
> So, I checked how Parallels behaves (this is my go-to check for
> "how should a native OSX VM window behave?"), and it works the
> same way QEMU does -- left mouse clicks "click through" so they
> both raise the window to the front and have the behaviour
> indicated by the guest OS.

But doesn't Parallels allow you to move the mouse pointer before activating it? 
QEMU requires the mouse to be grabbed before any movement can take 
place. That makes moving the mouse pointer out of danger before an activation
click impossible.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH] ui/cocoa.m: Prevent activation clicks from going to guest
  2015-11-24  3:25   ` Programmingkid
@ 2015-11-24  8:56     ` Peter Maydell
  2015-11-24 16:46       ` Programmingkid
  0 siblings, 1 reply; 6+ messages in thread
From: Peter Maydell @ 2015-11-24  8:56 UTC (permalink / raw)
  To: Programmingkid; +Cc: qemu-devel qemu-devel

On 24 November 2015 at 03:25, Programmingkid <programmingkidx@gmail.com> wrote:
>
> On Nov 23, 2015, at 11:06 AM, Peter Maydell wrote:
>
>> On 22 November 2015 at 01:43, Programmingkid <programmingkidx@gmail.com> wrote:
>>> When QEMU is brought to the foreground, the click event that activates QEMU
>>> should not go to the guest. Accidents happen when they do go to the guest
>>> without giving the user a change to handle them. Buttons are clicked accidently.
>>> Windows are closed accidently. Volumes are unmounted accidently. This patch
>>> prevents these accidents from happening.
>>>
>>> Signed-off-by: John Arbuckle <programmingkidx@gmail.com>
>>
>> So, I checked how Parallels behaves (this is my go-to check for
>> "how should a native OSX VM window behave?"), and it works the
>> same way QEMU does -- left mouse clicks "click through" so they
>> both raise the window to the front and have the behaviour
>> indicated by the guest OS.
>
> But doesn't Parallels allow you to move the mouse pointer before activating it?
> QEMU requires the mouse to be grabbed before any movement can take
> place. That makes moving the mouse pointer out of danger before an activation
> click impossible.

I'm not entirely sure what you mean. Parallels doesn't show a separate
guest mouse pointer generally: where you click the host mouse pointer
is where the click happens. You can choose where in the guest window you
want to make the activation-and-clickthrough click.

Ah, I think I've just worked it out -- when there's no guest OS
support for absolute mouse positioning (ie you're using an emulated
mouse rather than emulated tablet for input), the guest mouse pointer
will just be wherever in the guest window it was left (perhaps even
underneath the obscuring window), so we will effectively click on that
point, not on wherever the user actually made the activating click.
OK, I'm convinced, we should definitely not do that.

I asked somebody to check VMWare's behaviour as another
data point. Apparently it doesn't do click-through
to the guest window, but it doesn't pass through the
right mouse button either. Your patch only affects leftclicks:
should we suppress other mouse events too?

thanks
-- PMM

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH] ui/cocoa.m: Prevent activation clicks from going to guest
  2015-11-24  8:56     ` Peter Maydell
@ 2015-11-24 16:46       ` Programmingkid
  0 siblings, 0 replies; 6+ messages in thread
From: Programmingkid @ 2015-11-24 16:46 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-devel qemu-devel


On Nov 24, 2015, at 3:56 AM, Peter Maydell wrote:

> On 24 November 2015 at 03:25, Programmingkid <programmingkidx@gmail.com> wrote:
>> 
>> On Nov 23, 2015, at 11:06 AM, Peter Maydell wrote:
>> 
>>> On 22 November 2015 at 01:43, Programmingkid <programmingkidx@gmail.com> wrote:
>>>> When QEMU is brought to the foreground, the click event that activates QEMU
>>>> should not go to the guest. Accidents happen when they do go to the guest
>>>> without giving the user a change to handle them. Buttons are clicked accidently.
>>>> Windows are closed accidently. Volumes are unmounted accidently. This patch
>>>> prevents these accidents from happening.
>>>> 
>>>> Signed-off-by: John Arbuckle <programmingkidx@gmail.com>
>>> 
>>> So, I checked how Parallels behaves (this is my go-to check for
>>> "how should a native OSX VM window behave?"), and it works the
>>> same way QEMU does -- left mouse clicks "click through" so they
>>> both raise the window to the front and have the behaviour
>>> indicated by the guest OS.
>> 
>> But doesn't Parallels allow you to move the mouse pointer before activating it?
>> QEMU requires the mouse to be grabbed before any movement can take
>> place. That makes moving the mouse pointer out of danger before an activation
>> click impossible.
> 
> I'm not entirely sure what you mean. Parallels doesn't show a separate
> guest mouse pointer generally: where you click the host mouse pointer
> is where the click happens. You can choose where in the guest window you
> want to make the activation-and-clickthrough click.
> 
> Ah, I think I've just worked it out -- when there's no guest OS
> support for absolute mouse positioning (ie you're using an emulated
> mouse rather than emulated tablet for input), the guest mouse pointer
> will just be wherever in the guest window it was left (perhaps even
> underneath the obscuring window), so we will effectively click on that
> point, not on wherever the user actually made the activating click.
> OK, I'm convinced, we should definitely not do that.
> 
> I asked somebody to check VMWare's behaviour as another
> data point. Apparently it doesn't do click-through
> to the guest window, but it doesn't pass through the
> right mouse button either. Your patch only affects leftclicks:
> should we suppress other mouse events too?

Suppressing other mouse events does sound logical. Another patch
will be made to do this.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-11-24 16:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-22  1:43 [Qemu-devel] [PATCH] ui/cocoa.m: Prevent activation clicks from going to guest Programmingkid
2015-11-23 16:06 ` Peter Maydell
2015-11-23 17:37   ` Programmingkid
2015-11-24  3:25   ` Programmingkid
2015-11-24  8:56     ` Peter Maydell
2015-11-24 16:46       ` Programmingkid

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).