ui/cocoa: add option to disable left-command forwarding to guest
When switching between guest and host on a Mac using command-tab the command key is sent to the guest which can trigger functionality in the guest OS. Specifying left-command-key=off disables forwarding this key to the guest. Defaults to enabled. Also updated the cocoa display documentation to reference the new left-command-key option along with the existing show-cursor option. Signed-off-by: Carwyn Ellis <carwynellis@gmail.com> Reviewed-by: Akihiko Odaki <akihiko.odaki@gmail.com> [PMD: Set QAPI structure @since tag to 7.0] Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
This commit is contained in:
parent
9459262dc4
commit
48941a52c2
18
qapi/ui.json
18
qapi/ui.json
|
@ -1260,6 +1260,23 @@
|
||||||
{ 'struct' : 'DisplayCurses',
|
{ 'struct' : 'DisplayCurses',
|
||||||
'data' : { '*charset' : 'str' } }
|
'data' : { '*charset' : 'str' } }
|
||||||
|
|
||||||
|
##
|
||||||
|
# @DisplayCocoa:
|
||||||
|
#
|
||||||
|
# Cocoa display options.
|
||||||
|
#
|
||||||
|
# @left-command-key: Enable/disable forwarding of left command key to
|
||||||
|
# guest. Allows command-tab window switching on the
|
||||||
|
# host without sending this key to the guest when
|
||||||
|
# "off". Defaults to "on"
|
||||||
|
#
|
||||||
|
# Since: 7.0
|
||||||
|
##
|
||||||
|
{ 'struct': 'DisplayCocoa',
|
||||||
|
'data': {
|
||||||
|
'*left-command-key': 'bool'
|
||||||
|
} }
|
||||||
|
|
||||||
##
|
##
|
||||||
# @DisplayType:
|
# @DisplayType:
|
||||||
#
|
#
|
||||||
|
@ -1338,6 +1355,7 @@
|
||||||
'discriminator' : 'type',
|
'discriminator' : 'type',
|
||||||
'data' : {
|
'data' : {
|
||||||
'gtk': { 'type': 'DisplayGTK', 'if': 'CONFIG_GTK' },
|
'gtk': { 'type': 'DisplayGTK', 'if': 'CONFIG_GTK' },
|
||||||
|
'cocoa': { 'type': 'DisplayCocoa', 'if': 'CONFIG_COCOA' },
|
||||||
'curses': { 'type': 'DisplayCurses', 'if': 'CONFIG_CURSES' },
|
'curses': { 'type': 'DisplayCurses', 'if': 'CONFIG_CURSES' },
|
||||||
'egl-headless': { 'type': 'DisplayEGLHeadless',
|
'egl-headless': { 'type': 'DisplayEGLHeadless',
|
||||||
'if': { 'all': ['CONFIG_OPENGL', 'CONFIG_GBM'] } },
|
'if': { 'all': ['CONFIG_OPENGL', 'CONFIG_GBM'] } },
|
||||||
|
|
|
@ -1922,6 +1922,9 @@ DEF("display", HAS_ARG, QEMU_OPTION_display,
|
||||||
#if defined(CONFIG_DBUS_DISPLAY)
|
#if defined(CONFIG_DBUS_DISPLAY)
|
||||||
"-display dbus[,addr=<dbusaddr>]\n"
|
"-display dbus[,addr=<dbusaddr>]\n"
|
||||||
" [,gl=on|core|es|off][,rendernode=<file>]\n"
|
" [,gl=on|core|es|off][,rendernode=<file>]\n"
|
||||||
|
#endif
|
||||||
|
#if defined(CONFIG_COCOA)
|
||||||
|
"-display cocoa[,show-cursor=on|off][,left-command-key=on|off]\n"
|
||||||
#endif
|
#endif
|
||||||
"-display none\n"
|
"-display none\n"
|
||||||
" select display backend type\n"
|
" select display backend type\n"
|
||||||
|
@ -2009,6 +2012,15 @@ SRST
|
||||||
``charset=CP850`` for IBM CP850 encoding. The default is
|
``charset=CP850`` for IBM CP850 encoding. The default is
|
||||||
``CP437``.
|
``CP437``.
|
||||||
|
|
||||||
|
``cocoa``
|
||||||
|
Display video output in a Cocoa window. Mac only. This interface
|
||||||
|
provides drop-down menus and other UI elements to configure and
|
||||||
|
control the VM during runtime. Valid parameters are:
|
||||||
|
|
||||||
|
``show-cursor=on|off`` : Force showing the mouse cursor
|
||||||
|
|
||||||
|
``left-command-key=on|off`` : Disable forwarding left command key to host
|
||||||
|
|
||||||
``egl-headless[,rendernode=<file>]``
|
``egl-headless[,rendernode=<file>]``
|
||||||
Offload all OpenGL operations to a local DRI device. For any
|
Offload all OpenGL operations to a local DRI device. For any
|
||||||
graphical display, this display needs to be paired with either
|
graphical display, this display needs to be paired with either
|
||||||
|
|
|
@ -95,6 +95,7 @@ static DisplayChangeListener dcl = {
|
||||||
};
|
};
|
||||||
static int last_buttons;
|
static int last_buttons;
|
||||||
static int cursor_hide = 1;
|
static int cursor_hide = 1;
|
||||||
|
static int left_command_key_enabled = 1;
|
||||||
|
|
||||||
static int gArgc;
|
static int gArgc;
|
||||||
static char **gArgv;
|
static char **gArgv;
|
||||||
|
@ -853,7 +854,8 @@ QemuCocoaView *cocoaView;
|
||||||
/* Don't pass command key changes to guest unless mouse is grabbed */
|
/* Don't pass command key changes to guest unless mouse is grabbed */
|
||||||
case kVK_Command:
|
case kVK_Command:
|
||||||
if (isMouseGrabbed &&
|
if (isMouseGrabbed &&
|
||||||
!!(modifiers & NSEventModifierFlagCommand)) {
|
!!(modifiers & NSEventModifierFlagCommand) &&
|
||||||
|
left_command_key_enabled) {
|
||||||
[self toggleKey:Q_KEY_CODE_META_L];
|
[self toggleKey:Q_KEY_CODE_META_L];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -2002,6 +2004,10 @@ static void cocoa_display_init(DisplayState *ds, DisplayOptions *opts)
|
||||||
cursor_hide = 0;
|
cursor_hide = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (opts->u.cocoa.has_left_command_key && !opts->u.cocoa.left_command_key) {
|
||||||
|
left_command_key_enabled = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// register vga output callbacks
|
// register vga output callbacks
|
||||||
register_displaychangelistener(&dcl);
|
register_displaychangelistener(&dcl);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue