[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 11/11] ui/cocoa: Comment about modifier key input quirks
From: |
Gerd Hoffmann |
Subject: |
[PULL 11/11] ui/cocoa: Comment about modifier key input quirks |
Date: |
Tue, 16 Mar 2021 06:38:13 +0100 |
From: Akihiko Odaki <akihiko.odaki@gmail.com>
Based-on: <20210310042348.21931-1-akihiko.odaki@gmail.com>
Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
Message-Id: <20210312133212.3131-1-akihiko.odaki@gmail.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
ui/cocoa.m | 38 +++++++++++++++++++++++++++++++++++++-
1 file changed, 37 insertions(+), 1 deletion(-)
diff --git a/ui/cocoa.m b/ui/cocoa.m
index 9da0e884b712..37e1fb52eb4d 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -690,7 +690,43 @@ QemuCocoaView *cocoaView;
NSPoint p = [self screenLocationOfEvent:event];
NSUInteger modifiers = [event modifierFlags];
- // emulate caps lock keydown and keyup
+ /*
+ * Check -[NSEvent modifierFlags] here.
+ *
+ * There is a NSEventType for an event notifying the change of
+ * -[NSEvent modifierFlags], NSEventTypeFlagsChanged but these operations
+ * are performed for any events because a modifier state may change while
+ * the application is inactive (i.e. no events fire) and we don't want to
+ * wait for another modifier state change to detect such a change.
+ *
+ * NSEventModifierFlagCapsLock requires a special treatment. The other
flags
+ * are handled in similar manners.
+ *
+ * NSEventModifierFlagCapsLock
+ * ---------------------------
+ *
+ * If CapsLock state is changed, "up" and "down" events will be fired in
+ * sequence, effectively updates CapsLock state on the guest.
+ *
+ * The other flags
+ * ---------------
+ *
+ * If a flag is not set, fire "up" events for all keys which correspond to
+ * the flag. Note that "down" events are not fired here because the flags
+ * checked here do not tell what exact keys are down.
+ *
+ * If one of the keys corresponding to a flag is down, we rely on
+ * -[NSEvent keyCode] of an event whose -[NSEvent type] is
+ * NSEventTypeFlagsChanged to know the exact key which is down, which has
+ * the following two downsides:
+ * - It does not work when the application is inactive as described above.
+ * - It malfactions *after* the modifier state is changed while the
+ * application is inactive. It is because -[NSEvent keyCode] does not
tell
+ * if the key is up or down, and requires to infer the current state from
+ * the previous state. It is still possible to fix such a malfanction by
+ * completely leaving your hands from the keyboard, which hopefully makes
+ * this implementation usable enough.
+ */
if (!!(modifiers & NSEventModifierFlagCapsLock) !=
qkbd_state_modifier_get(kbd, QKBD_MOD_CAPSLOCK)) {
qkbd_state_key_event(kbd, Q_KEY_CODE_CAPS_LOCK, true);
--
2.29.2
- [PULL 04/11] opengl: Do not convert format with glTexImage2D on OpenGL ES, (continued)
- [PULL 04/11] opengl: Do not convert format with glTexImage2D on OpenGL ES, Gerd Hoffmann, 2021/03/16
- [PULL 03/11] ui: deprecate "password" option for SPICE server, Gerd Hoffmann, 2021/03/16
- [PULL 02/11] ui: introduce "password-secret" option for SPICE server, Gerd Hoffmann, 2021/03/16
- [PULL 07/11] ui: avoid sending framebuffer updates outside client desktop bounds, Gerd Hoffmann, 2021/03/16
- [PULL 08/11] ui: use client width/height in WMVi message, Gerd Hoffmann, 2021/03/16
- [PULL 05/11] ui/cocoa: Do not exit immediately after shutdown, Gerd Hoffmann, 2021/03/16
- [PULL 01/11] ui: introduce "password-secret" option for VNC servers, Gerd Hoffmann, 2021/03/16
- [PULL 10/11] ui: fold qemu_alloc_display in only caller, Gerd Hoffmann, 2021/03/16
- [PULL 09/11] ui: honour the actual guest display dimensions without rounding, Gerd Hoffmann, 2021/03/16
- [PULL 06/11] ui: add more trace points for VNC client/server messages, Gerd Hoffmann, 2021/03/16
- [PULL 11/11] ui/cocoa: Comment about modifier key input quirks,
Gerd Hoffmann <=
- Re: [PULL 00/11] Ui 20210316 patches, Peter Maydell, 2021/03/17