[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 11/13] softmmu/vl: Add a "grab-mod" parameter to the -display sdl
From: |
Thomas Huth |
Subject: |
[PULL 11/13] softmmu/vl: Add a "grab-mod" parameter to the -display sdl option |
Date: |
Thu, 2 Sep 2021 14:49:09 +0200 |
The -display sdl option is not using QAPI internally yet, and uses hand-
crafted parsing instead (see parse_display() in vl.c), which is quite
ugly, since most of the other code is using the QAPIfied DisplayOption
already. Unfortunately, the "alt_grab" and "ctrl_grab" use underscores in
their names which has recently been forbidden in new QAPI code, so
a straight conversion is not possible. While we could add some exceptions
to the QAPI schema parser for this, the way these parameters have been
designed was maybe a bad idea anyway: First, it's not possible to enable
both parameters at the same time, thus instead of two boolean parameters
it would be better to have only one multi-choice parameter instead.
Second, the naming is also somewhat unfortunate since the "alt_grab"
parameter is not about the ALT key, but rather about the left SHIFT key
that has to be used additionally when the parameter is enabled.
So instead of trying to QAPIfy "alt_grab" and "ctrl_grab", let's rather
introduce an alternative to these parameters instead, a new parameter
called "grab-mod" which can either be set to "lshift-lctrl-lalt" or to
"rctrl". In case we ever want to support additional modes later, we can
then also simply extend the list of supported strings here.
Message-Id: <20210825092023.81396-2-thuth@redhat.com>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
qemu-options.hx | 6 +++++-
softmmu/vl.c | 15 ++++++++++++---
2 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/qemu-options.hx b/qemu-options.hx
index 83aa59a920..0bff756ded 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -1834,7 +1834,7 @@ DEF("display", HAS_ARG, QEMU_OPTION_display,
#endif
#if defined(CONFIG_SDL)
"-display sdl[,alt_grab=on|off][,ctrl_grab=on|off][,gl=on|core|es|off]\n"
- " [,show-cursor=on|off][,window-close=on|off]\n"
+ "
[,grab-mod=<mod>][,show-cursor=on|off][,window-close=on|off]\n"
#endif
#if defined(CONFIG_GTK)
"-display gtk[,full-screen=on|off][,gl=on|off][,grab-on-hover=on|off]\n"
@@ -1880,6 +1880,10 @@ SRST
window; see the SDL documentation for other possibilities).
Valid parameters are:
+ ``grab-mod=<mods>`` : Used to select the modifier keys for toggling
+ the mouse grabbing in conjunction with the "g" key. `<mods>` can be
+ either `lshift-lctrl-lalt` or `rctrl`.
+
``alt_grab=on|off`` : Use Control+Alt+Shift-g to toggle mouse grabbing
``ctrl_grab=on|off`` : Use Right-Control-g to toggle mouse grabbing
diff --git a/softmmu/vl.c b/softmmu/vl.c
index ea05bb39c5..2176e3c5ae 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -1017,15 +1017,24 @@ static void parse_display(const char *p)
* parse_display_qapi() due to some options not in
* DisplayOptions, specifically:
* - ctrl_grab + alt_grab
- * Not clear yet what happens to them long-term. Should
- * replaced by something better or deprecated and dropped.
+ * They can't be moved into the QAPI since they use underscores,
+ * thus they will get replaced by "grab-mod" in the long term
*/
#if defined(CONFIG_SDL)
dpy.type = DISPLAY_TYPE_SDL;
while (*opts) {
const char *nextopt;
- if (strstart(opts, ",alt_grab=", &nextopt)) {
+ if (strstart(opts, ",grab-mod=", &nextopt)) {
+ opts = nextopt;
+ if (strstart(opts, "lshift-lctrl-lalt", &nextopt)) {
+ alt_grab = 1;
+ } else if (strstart(opts, "rctrl", &nextopt)) {
+ ctrl_grab = 1;
+ } else {
+ goto invalid_sdl_args;
+ }
+ } else if (strstart(opts, ",alt_grab=", &nextopt)) {
opts = nextopt;
if (strstart(opts, "on", &nextopt)) {
alt_grab = 1;
--
2.27.0
- [PULL 00/13] Testing, build system and misc patches, Thomas Huth, 2021/09/02
- [PULL 02/13] libqtest: check for g_setenv() failure, Thomas Huth, 2021/09/02
- [PULL 04/13] gitlab-ci: Remove superfluous "dnf install" statement, Thomas Huth, 2021/09/02
- [PULL 03/13] gitlab-ci: Merge "build-disabled" with "build-without-default-features", Thomas Huth, 2021/09/02
- [PULL 01/13] docs: add definitions of terms for CI/testing, Thomas Huth, 2021/09/02
- [PULL 08/13] meson.build: Don't use internal libfdt if the user requested the system libfdt, Thomas Huth, 2021/09/02
- [PULL 06/13] gitlab-ci: Don't try to use the system libfdt in the debian job, Thomas Huth, 2021/09/02
- [PULL 05/13] gitlab-ci: Fix ..._RUNNER_AVAILABLE variables and document them, Thomas Huth, 2021/09/02
- [PULL 07/13] meson.build: Fix the check for a usable libfdt, Thomas Huth, 2021/09/02
- [PULL 11/13] softmmu/vl: Add a "grab-mod" parameter to the -display sdl option,
Thomas Huth <=
- [PULL 12/13] softmmu/vl: Deprecate the old grab options, Thomas Huth, 2021/09/02
- [PULL 09/13] configure / meson: Move the GBM handling to meson.build, Thomas Huth, 2021/09/02
- [PULL 13/13] softmmu/vl: Deprecate the -sdl and -curses option, Thomas Huth, 2021/09/02
- [PULL 10/13] scripts: Remove the "show-fixed-bugs.sh" file, Thomas Huth, 2021/09/02
- Re: [PULL 00/13] Testing, build system and misc patches, Peter Maydell, 2021/09/03
- Re: [PULL 00/13] Testing, build system and misc patches, Thomas Huth, 2021/09/03
- Re: [PULL 00/13] Testing, build system and misc patches, Alex Bennée, 2021/09/03
- Re: [PULL 00/13] Testing, build system and misc patches, Peter Maydell, 2021/09/03
- Re: [PULL 00/13] Testing, build system and misc patches, Thomas Huth, 2021/09/06
- Re: [PULL 00/13] Testing, build system and misc patches, Paolo Bonzini, 2021/09/06