* [PATCH 1/2] ui/cocoa: add option to disable left-command forwarding to guest
@ 2022-01-02 17:41 ` Carwyn Ellis
0 siblings, 0 replies; 14+ messages in thread
From: Carwyn Ellis @ 2022-01-02 17:41 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, peter.maydell, Carwyn Ellis
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>
---
qapi/ui.json | 17 +++++++++++++++++
qemu-options.hx | 12 ++++++++++++
ui/cocoa.m | 8 +++++++-
3 files changed, 36 insertions(+), 1 deletion(-)
diff --git a/qapi/ui.json b/qapi/ui.json
index 2b4371da37..764480e145 100644
--- a/qapi/ui.json
+++ b/qapi/ui.json
@@ -1107,6 +1107,22 @@
'data' : { '*grab-on-hover' : 'bool',
'*zoom-to-fit' : 'bool' } }
+##
+# @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: 6.2.50
+#
+##
+{ '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);
--
2.34.1
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH 1/2] ui/cocoa: add option to disable left-command forwarding to guest
2022-01-02 17:41 ` Carwyn Ellis
(?)
@ 2022-02-18 18:33 ` Akihiko Odaki
-1 siblings, 0 replies; 14+ messages in thread
From: Akihiko Odaki @ 2022-02-18 18:33 UTC (permalink / raw)
To: Carwyn Ellis, qemu-devel; +Cc: qemu-trivial, peter.maydell
Reviewed-by: Akihiko Odaki <akihiko.odaki@gmail.com>
On 2022/01/03 2:41, Carwyn Ellis wrote:
> 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>
> ---
> qapi/ui.json | 17 +++++++++++++++++
> qemu-options.hx | 12 ++++++++++++
> ui/cocoa.m | 8 +++++++-
> 3 files changed, 36 insertions(+), 1 deletion(-)
>
> diff --git a/qapi/ui.json b/qapi/ui.json
> index 2b4371da37..764480e145 100644
> --- a/qapi/ui.json
> +++ b/qapi/ui.json
> @@ -1107,6 +1107,22 @@
> 'data' : { '*grab-on-hover' : 'bool',
> '*zoom-to-fit' : 'bool' } }
>
> +##
> +# @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: 6.2.50
> +#
> +##
> +{ '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);
>
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH 1/2] ui/cocoa: add option to disable left-command forwarding to guest
2022-01-02 17:41 ` Carwyn Ellis
@ 2022-02-18 18:55 ` Peter Maydell
-1 siblings, 0 replies; 14+ messages in thread
From: Peter Maydell @ 2022-02-18 18:55 UTC (permalink / raw)
To: Carwyn Ellis; +Cc: qemu-devel, qemu-trivial, Markus Armbruster, Michael Roth
On Sun, 2 Jan 2022 at 17:42, Carwyn Ellis <carwynellis@gmail.com> wrote:
>
> 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>
Ccing the QAPI folks for review on the QAPI parts of this.
-- PMM
> ---
> qapi/ui.json | 17 +++++++++++++++++
> qemu-options.hx | 12 ++++++++++++
> ui/cocoa.m | 8 +++++++-
> 3 files changed, 36 insertions(+), 1 deletion(-)
>
> diff --git a/qapi/ui.json b/qapi/ui.json
> index 2b4371da37..764480e145 100644
> --- a/qapi/ui.json
> +++ b/qapi/ui.json
> @@ -1107,6 +1107,22 @@
> 'data' : { '*grab-on-hover' : 'bool',
> '*zoom-to-fit' : 'bool' } }
>
> +##
> +# @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: 6.2.50
> +#
> +##
> +{ '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);
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH 1/2] ui/cocoa: add option to disable left-command forwarding to guest
@ 2022-02-18 18:55 ` Peter Maydell
0 siblings, 0 replies; 14+ messages in thread
From: Peter Maydell @ 2022-02-18 18:55 UTC (permalink / raw)
To: Carwyn Ellis; +Cc: qemu-trivial, Michael Roth, qemu-devel, Markus Armbruster
On Sun, 2 Jan 2022 at 17:42, Carwyn Ellis <carwynellis@gmail.com> wrote:
>
> 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>
Ccing the QAPI folks for review on the QAPI parts of this.
-- PMM
> ---
> qapi/ui.json | 17 +++++++++++++++++
> qemu-options.hx | 12 ++++++++++++
> ui/cocoa.m | 8 +++++++-
> 3 files changed, 36 insertions(+), 1 deletion(-)
>
> diff --git a/qapi/ui.json b/qapi/ui.json
> index 2b4371da37..764480e145 100644
> --- a/qapi/ui.json
> +++ b/qapi/ui.json
> @@ -1107,6 +1107,22 @@
> 'data' : { '*grab-on-hover' : 'bool',
> '*zoom-to-fit' : 'bool' } }
>
> +##
> +# @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: 6.2.50
> +#
> +##
> +{ '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);
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH 1/2] ui/cocoa: add option to disable left-command forwarding to guest
2022-02-18 18:55 ` Peter Maydell
@ 2022-02-18 20:21 ` Philippe Mathieu-Daudé via
-1 siblings, 0 replies; 14+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-02-18 20:21 UTC (permalink / raw)
To: Peter Maydell, Carwyn Ellis
Cc: qemu-trivial, Michael Roth, qemu-devel, Markus Armbruster
On 18/2/22 19:55, Peter Maydell wrote:
> On Sun, 2 Jan 2022 at 17:42, Carwyn Ellis <carwynellis@gmail.com> wrote:
>>
>> 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>
>
> Ccing the QAPI folks for review on the QAPI parts of this.
>
> -- PMM
>
>> ---
>> qapi/ui.json | 17 +++++++++++++++++
>> qemu-options.hx | 12 ++++++++++++
>> ui/cocoa.m | 8 +++++++-
>> 3 files changed, 36 insertions(+), 1 deletion(-)
>>
>> diff --git a/qapi/ui.json b/qapi/ui.json
>> index 2b4371da37..764480e145 100644
>> --- a/qapi/ui.json
>> +++ b/qapi/ui.json
>> @@ -1107,6 +1107,22 @@
>> 'data' : { '*grab-on-hover' : 'bool',
>> '*zoom-to-fit' : 'bool' } }
>>
>> +##
>> +# @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: 6.2.50
Not a QAPI folk, but LGTM using 7.0 here instead of 6.2.50 (this the
number of the *released* QEMU version which contains this new type).
>> +#
>> +##
>> +{ '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);
>
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH 1/2] ui/cocoa: add option to disable left-command forwarding to guest
@ 2022-02-18 20:21 ` Philippe Mathieu-Daudé via
0 siblings, 0 replies; 14+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-02-18 20:21 UTC (permalink / raw)
To: Peter Maydell, Carwyn Ellis
Cc: qemu-trivial, Michael Roth, qemu-devel, Markus Armbruster
On 18/2/22 19:55, Peter Maydell wrote:
> On Sun, 2 Jan 2022 at 17:42, Carwyn Ellis <carwynellis@gmail.com> wrote:
>>
>> 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>
>
> Ccing the QAPI folks for review on the QAPI parts of this.
>
> -- PMM
>
>> ---
>> qapi/ui.json | 17 +++++++++++++++++
>> qemu-options.hx | 12 ++++++++++++
>> ui/cocoa.m | 8 +++++++-
>> 3 files changed, 36 insertions(+), 1 deletion(-)
>>
>> diff --git a/qapi/ui.json b/qapi/ui.json
>> index 2b4371da37..764480e145 100644
>> --- a/qapi/ui.json
>> +++ b/qapi/ui.json
>> @@ -1107,6 +1107,22 @@
>> 'data' : { '*grab-on-hover' : 'bool',
>> '*zoom-to-fit' : 'bool' } }
>>
>> +##
>> +# @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: 6.2.50
Not a QAPI folk, but LGTM using 7.0 here instead of 6.2.50 (this the
number of the *released* QEMU version which contains this new type).
>> +#
>> +##
>> +{ '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);
>
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH 1/2] ui/cocoa: add option to disable left-command forwarding to guest
2022-02-18 20:21 ` Philippe Mathieu-Daudé via
@ 2022-03-11 12:46 ` Markus Armbruster
-1 siblings, 0 replies; 14+ messages in thread
From: Markus Armbruster @ 2022-03-11 12:46 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: Peter Maydell, Carwyn Ellis, qemu-trivial, Michael Roth,
qemu-devel
Philippe Mathieu-Daudé <f4bug@amsat.org> writes:
> On 18/2/22 19:55, Peter Maydell wrote:
>> On Sun, 2 Jan 2022 at 17:42, Carwyn Ellis <carwynellis@gmail.com> wrote:
>>>
>>> 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>
>> Ccing the QAPI folks for review on the QAPI parts of this.
>> -- PMM
>>
>>> ---
>>> qapi/ui.json | 17 +++++++++++++++++
>>> qemu-options.hx | 12 ++++++++++++
>>> ui/cocoa.m | 8 +++++++-
>>> 3 files changed, 36 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/qapi/ui.json b/qapi/ui.json
>>> index 2b4371da37..764480e145 100644
>>> --- a/qapi/ui.json
>>> +++ b/qapi/ui.json
>>> @@ -1107,6 +1107,22 @@
>>> 'data' : { '*grab-on-hover' : 'bool',
>>> '*zoom-to-fit' : 'bool' } }
>>>
>>> +##
>>> +# @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: 6.2.50
>
> Not a QAPI folk, but LGTM using 7.0 here instead of 6.2.50 (this the
> number of the *released* QEMU version which contains this new type).
Yes.
>>> +#
>>> +##
>>> +{ '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
In the QAPI schema, @full-screen, @window-close and @show-cursor are
common to all display types. Here, @full-screen is only documented with
gtk, @window-close with gtk and sdl, @show-cursor with gtk, sdl and now
cocoa.
What's going on here?
[...]
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH 1/2] ui/cocoa: add option to disable left-command forwarding to guest
@ 2022-03-11 12:46 ` Markus Armbruster
0 siblings, 0 replies; 14+ messages in thread
From: Markus Armbruster @ 2022-03-11 12:46 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-trivial, Peter Maydell, qemu-devel, Michael Roth,
Carwyn Ellis
Philippe Mathieu-Daudé <f4bug@amsat.org> writes:
> On 18/2/22 19:55, Peter Maydell wrote:
>> On Sun, 2 Jan 2022 at 17:42, Carwyn Ellis <carwynellis@gmail.com> wrote:
>>>
>>> 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>
>> Ccing the QAPI folks for review on the QAPI parts of this.
>> -- PMM
>>
>>> ---
>>> qapi/ui.json | 17 +++++++++++++++++
>>> qemu-options.hx | 12 ++++++++++++
>>> ui/cocoa.m | 8 +++++++-
>>> 3 files changed, 36 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/qapi/ui.json b/qapi/ui.json
>>> index 2b4371da37..764480e145 100644
>>> --- a/qapi/ui.json
>>> +++ b/qapi/ui.json
>>> @@ -1107,6 +1107,22 @@
>>> 'data' : { '*grab-on-hover' : 'bool',
>>> '*zoom-to-fit' : 'bool' } }
>>>
>>> +##
>>> +# @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: 6.2.50
>
> Not a QAPI folk, but LGTM using 7.0 here instead of 6.2.50 (this the
> number of the *released* QEMU version which contains this new type).
Yes.
>>> +#
>>> +##
>>> +{ '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
In the QAPI schema, @full-screen, @window-close and @show-cursor are
common to all display types. Here, @full-screen is only documented with
gtk, @window-close with gtk and sdl, @show-cursor with gtk, sdl and now
cocoa.
What's going on here?
[...]
^ permalink raw reply [flat|nested] 14+ messages in thread