+#
+##
+{ 'struct' : 'DisplayCocoa',
+ 'data' : { '*left-command-key' : 'bool' } }
+
##
# @DisplayEGLHeadless:
#
@@ -1254,6 +1270,7 @@
'discriminator' : 'type',
'data' : {
'gtk': { 'type': 'DisplayGTK', 'if': 'CONFIG_GTK' },
+ 'cocoa': { 'type': 'DisplayCocoa', 'if': 'CONFIG_COCOA' },
'curses': { 'type': 'DisplayCurses', 'if': 'CONFIG_CURSES' },
'egl-headless': { 'type': 'DisplayEGLHeadless',
'if': { 'all': ['CONFIG_OPENGL', 'CONFIG_GBM'] } },
diff --git a/qemu-options.hx b/qemu-options.hx
index fd1f8135fb..6fa9c38c83 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -1912,6 +1912,9 @@ DEF("display", HAS_ARG, QEMU_OPTION_display,
#if defined(CONFIG_DBUS_DISPLAY)
"-display dbus[,addr=<dbusaddr>]\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
"-display none\n"
" select display backend type\n"
@@ -1999,6 +2002,15 @@ SRST
``charset=CP850`` for IBM CP850 encoding. The default is
``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>]``
Offload all OpenGL operations to a local DRI device. For any
graphical display, this display needs to be paired with either
diff --git a/ui/cocoa.m b/ui/cocoa.m
index 69745c483b..01045d6698 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -95,6 +95,7 @@ static DisplayChangeListener dcl = {
};
static int last_buttons;
static int cursor_hide = 1;
+static int left_command_key_enabled = 1;
static int gArgc;
static char **gArgv;
@@ -834,7 +835,8 @@ QemuCocoaView *cocoaView;
/* Don't pass command key changes to guest unless mouse is
grabbed */
case kVK_Command:
if (isMouseGrabbed &&
- !!(modifiers & NSEventModifierFlagCommand)) {
+ !!(modifiers & NSEventModifierFlagCommand) &&
+ left_command_key_enabled) {
[self toggleKey:Q_KEY_CODE_META_L];
}
break;
@@ -2054,6 +2056,10 @@ static void cocoa_display_init(DisplayState *ds,
DisplayOptions *opts)
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_displaychangelistener(&dcl);