cocoa: keyboard quality of life
v5 cover cocoa: keyboard quality of life
From: Gustavo Noronha Silva <[email protected]>
v5 addresses the casting issue pointed out by Akihiko Odaki. Sorry it took me so long to update the patches, but here they are! Hopefully we can get them in now ;D
Btw I also changed my email address slightly (.dev.br instead of .eti.br).
-----
This series adds two new options to the cocoa display:
- full-grab causes it to use a global tap to steal system combos away from Mac OS X, so they can be handled by the VM
- swap-option-command does what it says on the tin; while that is something you can do at the Mac OS X level or even supported by some keyboards, it is much more convenient to have qemu put Meta/Super and Alt where they belong if you are running a non-Mac VM
Both are off by default. For full-grab in particular, it is off also because unfortunately it needs accessibility permissions for input grabbing, so it requires more deliberate action by the user anyway.
Gustavo Noronha Silva (2):
ui/cocoa: capture all keys and combos when mouse is grabbed ui/cocoa: add option to swap Option and Command
qapi/ui.json | 22 +++++++++ qemu-options.hx | 4 ++ ui/cocoa.m | 129 ++++++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 146 insertions(+), 9 deletions(-)
Signature · 1 line
2.30.1 (Apple Git-130)
PATCH v5 1/2 ui/cocoa: capture all keys and combos when mouse is grabbed
From: Gustavo Noronha Silva <[email protected]>
Applications such as Gnome may use Alt-Tab and Super-Tab for different purposes, some use Ctrl-arrows so we want to allow qemu to handle everything when it captures the mouse/keyboard.
However, Mac OS handles some combos like Command-Tab and Ctrl-arrows at an earlier part of the event handling chain, not letting qemu see it.
We add a global Event Tap that allows qemu to see all events when the mouse is grabbed. Note that this requires additional permissions.
See:
https://developer.apple.com/documentation/coregraphics/1454426-cgeventtapcreate?language=objc#discussion
https://support.apple.com/en-in/guide/mac-help/mh32356/mac
--- qapi/ui.json | 16 ++++++++++++ qemu-options.hx | 3 +++ ui/cocoa.m | 65 ++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 83 insertions(+), 1 deletion(-)
qapi/ui.json +16 -0
@@ -1092,6 +1092,21 @@ { 'struct' : 'DisplayCurses', 'data' : { '*charset' : 'str' } } +## +# @DisplayCocoa: +# +# Cocoa display options. +# +# @full-grab: Capture all key presses, including system combos. This +# requires accessibility permissions, since it performs +# a global grab on key events. (default: off) +# See https://support.apple.com/en-in/guide/mac-help/mh32356/mac +# +# Since: 6.1 +## +{ 'struct' : 'DisplayCocoa', + 'data' : { '*full-grab' : 'bool' } } + ## # @DisplayType: #
@@ -1165,6 +1180,7 @@ 'discriminator' : 'type', 'data' : { 'gtk': { 'type': 'DisplayGTK', 'if': 'defined(CONFIG_GTK)' }, + 'cocoa': { 'type': 'DisplayCocoa', 'if': 'defined(CONFIG_COCOA)' }, 'curses': { 'type': 'DisplayCurses', 'if': 'defined(CONFIG_CURSES)' }, 'egl-headless': { 'type': 'DisplayEGLHeadless', 'if': 'defined(CONFIG_OPENGL) && defined(CONFIG_GBM)' }
qemu-options.hx +3 -0
@@ -1796,6 +1796,9 @@ DEF("display", HAS_ARG, QEMU_OPTION_display, #if defined(CONFIG_CURSES) "-display curses[,charset=<encoding>]\n" #endif +#if defined(CONFIG_COCOA) + "-display cocoa[,full_grab=on|off]\n" +#endif #if defined(CONFIG_OPENGL) "-display egl-headless[,rendernode=<file>]\n" #endif
ui/cocoa.m +64 -1
110 lines not on this page · raw message
Signature · 1 line
2.30.1 (Apple Git-130)
PATCH v5 2/2 ui/cocoa: add option to swap Option and Command
In reply to [email protected]From: Gustavo Noronha Silva <[email protected]>
On Mac OS X the Option key maps to Alt and Command to Super/Meta. This change swaps them around so that Alt is the key closer to the space bar and Meta/Super is between Control and Alt, like on non-Mac keyboards.
It is a cocoa display option, disabled by default.
--- qapi/ui.json | 8 ++++++- qemu-options.hx | 3 ++- ui/cocoa.m | 64 ++++++++++++++++++++++++++++++++++++++++++------- 3 files changed, 65 insertions(+), 10 deletions(-)
qapi/ui.json +7 -1
@@ -1102,10 +1102,16 @@ # a global grab on key events. (default: off) # See https://support.apple.com/en-in/guide/mac-help/mh32356/mac # +# @swap-option-command: Swap the Option and Command keys so that their key +# codes match their position on non-Mac keyboards and +# you can use Meta/Super and Alt where you expect them. +# (default: off) +# # Since: 6.1 ## { 'struct' : 'DisplayCocoa', - 'data' : { '*full-grab' : 'bool' } } + 'data' : { '*full-grab' : 'bool', + '*swap-option-command' : 'bool' } } ## # @DisplayType:
qemu-options.hx +2 -1
@@ -1797,7 +1797,8 @@ DEF("display", HAS_ARG, QEMU_OPTION_display, "-display curses[,charset=<encoding>]\n" #endif #if defined(CONFIG_COCOA) - "-display cocoa[,full_grab=on|off]\n" + "-display cocoa[,full-grab=on|off]\n" + " [,swap-option-command=on|off]\n" #endif #if defined(CONFIG_OPENGL) "-display egl-headless[,rendernode=<file>]\n"
ui/cocoa.m +56 -8
131 lines not on this page · raw message
Signature · 1 line
2.30.1 (Apple Git-130)