* [Qemu-devel] [PATCH v2] ui/cocoa.m: prevent stuck command key when going into full screen mode
@ 2018-07-03 2:00 John Arbuckle
2018-07-24 11:39 ` Peter Maydell
0 siblings, 1 reply; 2+ messages in thread
From: John Arbuckle @ 2018-07-03 2:00 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>
---
v2 changes:
Code changes now confined to the handleEvent: method.
ui/cocoa.m | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/ui/cocoa.m b/ui/cocoa.m
index 2991ed4..9be4811 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -637,6 +637,7 @@ QemuCocoaView *cocoaView;
int buttons = 0;
int keycode = 0;
bool mouse_event = false;
+ static bool switched_to_fullscreen = false;
NSPoint p = [event locationInWindow];
switch ([event type]) {
@@ -681,7 +682,11 @@ QemuCocoaView *cocoaView;
keycode == Q_KEY_CODE_NUM_LOCK) {
[self toggleStatefulModifier:keycode];
} else if (qemu_console_is_graphic(NULL)) {
- [self toggleModifier:keycode];
+ if (switched_to_fullscreen) {
+ switched_to_fullscreen = false;
+ } else {
+ [self toggleModifier:keycode];
+ }
}
}
@@ -691,6 +696,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 to switch to full screen mode.
+ */
+ if (keycode == Q_KEY_CODE_F) {
+ switched_to_fullscreen = true;
+ }
[NSApp sendEvent:event];
return;
}
--
2.7.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH v2] ui/cocoa.m: prevent stuck command key when going into full screen mode
2018-07-03 2:00 [Qemu-devel] [PATCH v2] ui/cocoa.m: prevent stuck command key when going into full screen mode John Arbuckle
@ 2018-07-24 11:39 ` Peter Maydell
0 siblings, 0 replies; 2+ messages in thread
From: Peter Maydell @ 2018-07-24 11:39 UTC (permalink / raw)
To: John Arbuckle; +Cc: QEMU Developers
On 3 July 2018 at 03:00, 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. 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>
> ---
I feel like there might be a more elegant way to handle this
(surely the NSEventTypeFlagsChanged event can have some way
to query the current state of the modifier flags even if it's
got a keycode value? the current code which has different
approaches for "have a keycode" vs not seems a bit fragile),
but this fix should work. Applied to master for 3.0, thanks.
-- PMM
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-07-24 11:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-03 2:00 [Qemu-devel] [PATCH v2] ui/cocoa.m: prevent stuck command key when going into full screen mode John Arbuckle
2018-07-24 11:39 ` Peter Maydell
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).