* [PATCH 1/1] ui/gtk: Added a no-input mode
@ 2023-04-17 23:02 Singh, Satyeshwar
2023-04-18 8:17 ` Daniel P. Berrangé
0 siblings, 1 reply; 2+ messages in thread
From: Singh, Satyeshwar @ 2023-04-17 23:02 UTC (permalink / raw)
To: qemu-devel@nongnu.org
Cc: Kasireddy, Vivek, Kim, Dongwon, kraxel@redhat.com,
marcandre.lureau@redhat.com
In a multi-seat scenario where multiple keyboards and mice are connected
to the host but some are dedicated for the guests only (through pass
through mode) and some are only for the host, there is a strong use case
where a customer does not want a HID device connected to the host to be
able to control the guest.
In such a scenario, neither should we bind any input events to Qemu UI,
nor should we show menu options like "Grab on Hover" or "Grab Input".
This patch adds a GTK command line option called "no-input".
It can be set like this:
gtk,no-input=off/on
If set to off or completely left out, it will default to normal
operation where host HID devices can control the guests. However, if
turned on, then host HID devices will not be able to control the guest
windows.
Signed-off-by: Satyeshwar Singh <satyeshwar.singh@intel.com>
Cc: Dongwon Kim <dongwon.kim@intel.com>
Cc: Vivek Kasireddy <vivek.kasireddy@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
---
qapi/ui.json | 5 ++++-
qemu-options.hx | 4 +++-
ui/gtk.c | 39 +++++++++++++++++++++++++++------------
3 files changed, 34 insertions(+), 14 deletions(-)
diff --git a/qapi/ui.json b/qapi/ui.json
index 98322342f7..cd3ef4678e 100644
--- a/qapi/ui.json
+++ b/qapi/ui.json
@@ -1214,6 +1214,8 @@
# Since 7.1
# @show-menubar: Display the main window menubar. Defaults to "on".
# Since 8.0
+# @no-input: Don't let host's HID devices control the guest. Defaults to "off".
+# Since 8.0
#
# Since: 2.12
##
@@ -1221,7 +1223,8 @@
'data' : { '*grab-on-hover' : 'bool',
'*zoom-to-fit' : 'bool',
'*show-tabs' : 'bool',
- '*show-menubar' : 'bool' } }
+ '*show-menubar' : 'bool',
+ '*no-input' : 'bool' } }
##
# @DisplayEGLHeadless:
diff --git a/qemu-options.hx b/qemu-options.hx
index 59bdf67a2c..a678f66c5d 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -1977,7 +1977,7 @@ DEF("display", HAS_ARG, QEMU_OPTION_display,
#if defined(CONFIG_GTK)
"-display gtk[,full-screen=on|off][,gl=on|off][,grab-on-hover=on|off]\n"
" [,show-tabs=on|off][,show-cursor=on|off][,window-close=on|off]\n"
- " [,show-menubar=on|off]\n"
+ " [,show-menubar=on|off][,no-input=on|off]\n"
#endif
#if defined(CONFIG_VNC)
"-display vnc=<display>[,<optargs>]\n"
@@ -2072,6 +2072,8 @@ SRST
``show-menubar=on|off`` : Display the main window menubar, defaults to "on"
+ ``no-input=on|off`` : Don't let host's HID devices control the guest
+
``curses[,charset=<encoding>]``
Display video output via curses. For graphics device models
which support a text mode, QEMU can display this output using a
diff --git a/ui/gtk.c b/ui/gtk.c
index f16e0f8dee..e58f71358c 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -1967,6 +1967,20 @@ static void gd_connect_vc_gfx_signals(VirtualConsole *vc)
G_CALLBACK(gd_resize_event), vc);
}
#endif
+ if (qemu_console_is_graphic(vc->gfx.dcl.con)) {
+ g_signal_connect(vc->gfx.drawing_area, "configure-event",
+ G_CALLBACK(gd_configure), vc);
+ }
+
+ /*
+ * Don't configure input events if the user has provided an option
+ * for no-input, instead opting for passthrough HID devices to control the
+ * guest.
+ */
+ if (vc->s->opts->u.gtk.has_no_input && vc->s->opts->u.gtk.no_input ) {
+ return;
+ }
+
if (qemu_console_is_graphic(vc->gfx.dcl.con)) {
g_signal_connect(vc->gfx.drawing_area, "event",
G_CALLBACK(gd_event), vc);
@@ -1989,8 +2003,6 @@ static void gd_connect_vc_gfx_signals(VirtualConsole *vc)
G_CALLBACK(gd_focus_in_event), vc);
g_signal_connect(vc->gfx.drawing_area, "focus-out-event",
G_CALLBACK(gd_focus_out_event), vc);
- g_signal_connect(vc->gfx.drawing_area, "configure-event",
- G_CALLBACK(gd_configure), vc);
g_signal_connect(vc->gfx.drawing_area, "grab-broken-event",
G_CALLBACK(gd_grab_broken_event), vc);
} else {
@@ -2228,18 +2240,21 @@ static GtkWidget *gd_create_menu_view(GtkDisplayState *s, DisplayOptions *opts)
s->zoom_fit_item = gtk_check_menu_item_new_with_mnemonic(_("Zoom To _Fit"));
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), s->zoom_fit_item);
- separator = gtk_separator_menu_item_new();
- gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), separator);
- s->grab_on_hover_item = gtk_check_menu_item_new_with_mnemonic(_("Grab On _Hover"));
- gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), s->grab_on_hover_item);
+ if (!s->opts->u.gtk.has_no_input || !s->opts->u.gtk.no_input ) {
+ separator = gtk_separator_menu_item_new();
+ gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), separator);
- s->grab_item = gtk_check_menu_item_new_with_mnemonic(_("_Grab Input"));
- gtk_menu_item_set_accel_path(GTK_MENU_ITEM(s->grab_item),
- "<QEMU>/View/Grab Input");
- gtk_accel_map_add_entry("<QEMU>/View/Grab Input", GDK_KEY_g,
- HOTKEY_MODIFIERS);
- gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), s->grab_item);
+ s->grab_on_hover_item = gtk_check_menu_item_new_with_mnemonic(_("Grab On _Hover"));
+ gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), s->grab_on_hover_item);
+
+ s->grab_item = gtk_check_menu_item_new_with_mnemonic(_("_Grab Input"));
+ gtk_menu_item_set_accel_path(GTK_MENU_ITEM(s->grab_item),
+ "<QEMU>/View/Grab Input");
+ gtk_accel_map_add_entry("<QEMU>/View/Grab Input", GDK_KEY_g,
+ HOTKEY_MODIFIERS);
+ gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), s->grab_item);
+ }
separator = gtk_separator_menu_item_new();
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), separator);
--
2.33.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 1/1] ui/gtk: Added a no-input mode
2023-04-17 23:02 [PATCH 1/1] ui/gtk: Added a no-input mode Singh, Satyeshwar
@ 2023-04-18 8:17 ` Daniel P. Berrangé
0 siblings, 0 replies; 2+ messages in thread
From: Daniel P. Berrangé @ 2023-04-18 8:17 UTC (permalink / raw)
To: Singh, Satyeshwar
Cc: qemu-devel@nongnu.org, Kasireddy, Vivek, Kim, Dongwon,
kraxel@redhat.com, marcandre.lureau@redhat.com
On Mon, Apr 17, 2023 at 11:02:00PM +0000, Singh, Satyeshwar wrote:
> In a multi-seat scenario where multiple keyboards and mice are connected
> to the host but some are dedicated for the guests only (through pass
> through mode) and some are only for the host, there is a strong use case
> where a customer does not want a HID device connected to the host to be
> able to control the guest.
> In such a scenario, neither should we bind any input events to Qemu UI,
> nor should we show menu options like "Grab on Hover" or "Grab Input".
> This patch adds a GTK command line option called "no-input".
> It can be set like this:
> gtk,no-input=off/on
>
> If set to off or completely left out, it will default to normal
> operation where host HID devices can control the guests. However, if
> turned on, then host HID devices will not be able to control the guest
> windows.
>
> Signed-off-by: Satyeshwar Singh <satyeshwar.singh@intel.com>
> Cc: Dongwon Kim <dongwon.kim@intel.com>
> Cc: Vivek Kasireddy <vivek.kasireddy@intel.com>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> qapi/ui.json | 5 ++++-
> qemu-options.hx | 4 +++-
> ui/gtk.c | 39 +++++++++++++++++++++++++++------------
> 3 files changed, 34 insertions(+), 14 deletions(-)
>
> diff --git a/qapi/ui.json b/qapi/ui.json
> index 98322342f7..cd3ef4678e 100644
> --- a/qapi/ui.json
> +++ b/qapi/ui.json
> @@ -1214,6 +1214,8 @@
> # Since 7.1
> # @show-menubar: Display the main window menubar. Defaults to "on".
> # Since 8.0
> +# @no-input: Don't let host's HID devices control the guest. Defaults to "off".
> +# Since 8.0
> #
> # Since: 2.12
> ##
> @@ -1221,7 +1223,8 @@
> 'data' : { '*grab-on-hover' : 'bool',
> '*zoom-to-fit' : 'bool',
> '*show-tabs' : 'bool',
> - '*show-menubar' : 'bool' } }
> + '*show-menubar' : 'bool',
> + '*no-input' : 'bool' } }
We don't generally like negative boolean options.
IOW, we would prefer '*input': 'bool' with the default being
'on' if omitted, of course.
With regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-04-18 8:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-17 23:02 [PATCH 1/1] ui/gtk: Added a no-input mode Singh, Satyeshwar
2023-04-18 8:17 ` Daniel P. Berrangé
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).