All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] ui/cocoa.m: prevent stuck command key when going into full screen mode
@ 2018-06-19  1:58 John Arbuckle
  2018-06-19  5:04 ` no-reply
  2018-07-01 19:30 ` Peter Maydell
  0 siblings, 2 replies; 4+ messages in thread
From: John Arbuckle @ 2018-06-19  1:58 UTC (permalink / raw)
  To: peter.maydell, qemu-devel; +Cc: John Arbuckle

When the user pushes Command-F in QEMU while the mouse is ungrabbed, QEMU
goes into full screen mode. When the user finally releases the command key,
it is sent to the guest as an event. The makes the guest operating system
think the command key is down when it is really up. To prevent this situation
from happening, we simply drop the first command key event after the user has
gone into full screen mode using Command-F.

Signed-off-by: John Arbuckle <programmingkidx@gmail.com>
---
 ui/cocoa.m | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/ui/cocoa.m b/ui/cocoa.m
index 2991ed4..024aba2 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -287,6 +287,7 @@ static void handleAnyDeviceErrors(Error * err)
     BOOL isFullscreen;
     BOOL isAbsoluteEnabled;
     BOOL isMouseDeassociated;
+    BOOL prevent_stuck_command_key;
 }
 - (void) switchSurface:(DisplaySurface *)surface;
 - (void) grabMouse;
@@ -330,7 +331,7 @@ QemuCocoaView *cocoaView;
         screen.bitsPerPixel = 32;
         screen.width = frameRect.size.width;
         screen.height = frameRect.size.height;
-
+        prevent_stuck_command_key = NO;
     }
     return self;
 }
@@ -552,6 +553,14 @@ QemuCocoaView *cocoaView;
 }
 
 - (void) toggleModifier: (int)keycode {
+
+    /* Prevents the command key from being sent to the guest */
+    if ((keycode == Q_KEY_CODE_META_L || keycode == Q_KEY_CODE_META_R) &&
+        prevent_stuck_command_key == YES) {
+        prevent_stuck_command_key = NO;
+        return;
+    }
+
     // Toggle the stored state.
     modifiers_state[keycode] = !modifiers_state[keycode];
     // Send a keyup or keydown depending on the state.
@@ -691,6 +700,13 @@ QemuCocoaView *cocoaView;
 
             // forward command key combos to the host UI unless the mouse is grabbed
             if (!isMouseGrabbed && ([event modifierFlags] & NSEventModifierFlagCommand)) {
+                /*
+                 * Prevent the command key from being stuck down in the guest
+                 * when using Command-F for full screen mode
+                 */
+                if (keycode == Q_KEY_CODE_F) {
+                    prevent_stuck_command_key = YES;
+                }
                 [NSApp sendEvent:event];
                 return;
             }
-- 
2.7.2

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

* Re: [Qemu-devel] [PATCH] ui/cocoa.m: prevent stuck command key when going into full screen mode
  2018-06-19  1:58 [Qemu-devel] [PATCH] ui/cocoa.m: prevent stuck command key when going into full screen mode John Arbuckle
@ 2018-06-19  5:04 ` no-reply
  2018-07-01 19:30 ` Peter Maydell
  1 sibling, 0 replies; 4+ messages in thread
From: no-reply @ 2018-06-19  5:04 UTC (permalink / raw)
  To: programmingkidx; +Cc: famz, peter.maydell, qemu-devel

Hi,

This series failed build test on s390x host. Please find the details below.

N/A. Internal error while reading log file



---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-devel@redhat.com

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

* Re: [Qemu-devel] [PATCH] ui/cocoa.m: prevent stuck command key when going into full screen mode
  2018-06-19  1:58 [Qemu-devel] [PATCH] ui/cocoa.m: prevent stuck command key when going into full screen mode John Arbuckle
  2018-06-19  5:04 ` no-reply
@ 2018-07-01 19:30 ` Peter Maydell
  2018-07-01 22:08   ` Programmingkid
  1 sibling, 1 reply; 4+ messages in thread
From: Peter Maydell @ 2018-07-01 19:30 UTC (permalink / raw)
  To: John Arbuckle; +Cc: QEMU Developers

On 19 June 2018 at 02:58, John Arbuckle <programmingkidx@gmail.com> wrote:
> When the user pushes Command-F in QEMU while the mouse is ungrabbed, QEMU
> goes into full screen mode. When the user finally releases the command key,
> it is sent to the guest as an event.

What is "it" here? This sentences implies that "it" is the key-release
event for the command key, but the following sentence suggests it's
the key-press event.

>The makes the guest operating system
> think the command key is down when it is really up. To prevent this situation
> from happening, we simply drop the first command key event after the user has
> gone into full screen mode using Command-F.
>
> Signed-off-by: John Arbuckle <programmingkidx@gmail.com>
> ---
>  ui/cocoa.m | 18 +++++++++++++++++-
>  1 file changed, 17 insertions(+), 1 deletion(-)
>
> diff --git a/ui/cocoa.m b/ui/cocoa.m
> index 2991ed4..024aba2 100644
> --- a/ui/cocoa.m
> +++ b/ui/cocoa.m
> @@ -287,6 +287,7 @@ static void handleAnyDeviceErrors(Error * err)
>      BOOL isFullscreen;
>      BOOL isAbsoluteEnabled;
>      BOOL isMouseDeassociated;
> +    BOOL prevent_stuck_command_key;
>  }
>  - (void) switchSurface:(DisplaySurface *)surface;
>  - (void) grabMouse;
> @@ -330,7 +331,7 @@ QemuCocoaView *cocoaView;
>          screen.bitsPerPixel = 32;
>          screen.width = frameRect.size.width;
>          screen.height = frameRect.size.height;
> -
> +        prevent_stuck_command_key = NO;
>      }
>      return self;
>  }
> @@ -552,6 +553,14 @@ QemuCocoaView *cocoaView;
>  }
>
>  - (void) toggleModifier: (int)keycode {
> +
> +    /* Prevents the command key from being sent to the guest */
> +    if ((keycode == Q_KEY_CODE_META_L || keycode == Q_KEY_CODE_META_R) &&
> +        prevent_stuck_command_key == YES) {
> +        prevent_stuck_command_key = NO;
> +        return;
> +    }
> +
>      // Toggle the stored state.
>      modifiers_state[keycode] = !modifiers_state[keycode];
>      // Send a keyup or keydown depending on the state.
> @@ -691,6 +700,13 @@ QemuCocoaView *cocoaView;
>
>              // forward command key combos to the host UI unless the mouse is grabbed
>              if (!isMouseGrabbed && ([event modifierFlags] & NSEventModifierFlagCommand)) {
> +                /*
> +                 * Prevent the command key from being stuck down in the guest
> +                 * when using Command-F for full screen mode
> +                 */
> +                if (keycode == Q_KEY_CODE_F) {
> +                    prevent_stuck_command_key = YES;
> +                }
>                  [NSApp sendEvent:event];
>                  return;
>              }
> --
> 2.7.2

I can sort of see why this might work, but the flow of what's
going wrong isn't clear from your commit message, and the
change looks really inelegant.

thanks
-- PMM

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

* Re: [Qemu-devel] [PATCH] ui/cocoa.m: prevent stuck command key when going into full screen mode
  2018-07-01 19:30 ` Peter Maydell
@ 2018-07-01 22:08   ` Programmingkid
  0 siblings, 0 replies; 4+ messages in thread
From: Programmingkid @ 2018-07-01 22:08 UTC (permalink / raw)
  To: Peter Maydell; +Cc: QEMU Developers


On Jul 1, 2018, at 3:30 PM, Peter Maydell wrote:

> On 19 June 2018 at 02:58, John Arbuckle <programmingkidx@gmail.com> wrote:
>> When the user pushes Command-F in QEMU while the mouse is ungrabbed, QEMU
>> goes into full screen mode. When the user finally releases the command key,
>> it is sent to the guest as an event.
> 
> What is "it" here? This sentences implies that "it" is the key-release
> event for the command key, but the following sentence suggests it's
> the key-press event.

It is the key release event for the command key. 

>> The makes the guest operating system
>> think the command key is down when it is really up. To prevent this situation
>> from happening, we simply drop the first command key event after the user has
>> gone into full screen mode using Command-F.
>> 
>> Signed-off-by: John Arbuckle <programmingkidx@gmail.com>
>> ---
>> ui/cocoa.m | 18 +++++++++++++++++-
>> 1 file changed, 17 insertions(+), 1 deletion(-)
>> 
>> diff --git a/ui/cocoa.m b/ui/cocoa.m
>> index 2991ed4..024aba2 100644
>> --- a/ui/cocoa.m
>> +++ b/ui/cocoa.m
>> @@ -287,6 +287,7 @@ static void handleAnyDeviceErrors(Error * err)
>>     BOOL isFullscreen;
>>     BOOL isAbsoluteEnabled;
>>     BOOL isMouseDeassociated;
>> +    BOOL prevent_stuck_command_key;
>> }
>> - (void) switchSurface:(DisplaySurface *)surface;
>> - (void) grabMouse;
>> @@ -330,7 +331,7 @@ QemuCocoaView *cocoaView;
>>         screen.bitsPerPixel = 32;
>>         screen.width = frameRect.size.width;
>>         screen.height = frameRect.size.height;
>> -
>> +        prevent_stuck_command_key = NO;
>>     }
>>     return self;
>> }
>> @@ -552,6 +553,14 @@ QemuCocoaView *cocoaView;
>> }
>> 
>> - (void) toggleModifier: (int)keycode {
>> +
>> +    /* Prevents the command key from being sent to the guest */
>> +    if ((keycode == Q_KEY_CODE_META_L || keycode == Q_KEY_CODE_META_R) &&
>> +        prevent_stuck_command_key == YES) {
>> +        prevent_stuck_command_key = NO;
>> +        return;
>> +    }
>> +
>>     // Toggle the stored state.
>>     modifiers_state[keycode] = !modifiers_state[keycode];
>>     // Send a keyup or keydown depending on the state.
>> @@ -691,6 +700,13 @@ QemuCocoaView *cocoaView;
>> 
>>             // forward command key combos to the host UI unless the mouse is grabbed
>>             if (!isMouseGrabbed && ([event modifierFlags] & NSEventModifierFlagCommand)) {
>> +                /*
>> +                 * Prevent the command key from being stuck down in the guest
>> +                 * when using Command-F for full screen mode
>> +                 */
>> +                if (keycode == Q_KEY_CODE_F) {
>> +                    prevent_stuck_command_key = YES;
>> +                }
>>                 [NSApp sendEvent:event];
>>                 return;
>>             }
>> --
>> 2.7.2
> 
> I can sort of see why this might work, but the flow of what's
> going wrong isn't clear from your commit message, and the
> change looks really inelegant.

What would be a more suitable solution to this problem? I realize using a flag to indicate this situation isn't the prettiest, but it does get the job done. 

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

end of thread, other threads:[~2018-07-01 22:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-19  1:58 [Qemu-devel] [PATCH] ui/cocoa.m: prevent stuck command key when going into full screen mode John Arbuckle
2018-06-19  5:04 ` no-reply
2018-07-01 19:30 ` Peter Maydell
2018-07-01 22:08   ` Programmingkid

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.