diff options
author | Thomas Huth <thuth@redhat.com> | 2021-08-25 11:20:21 +0200 |
---|---|---|
committer | Thomas Huth <thuth@redhat.com> | 2021-09-06 10:00:14 +0200 |
commit | 8e8e844be48d6e367e523ac418a83a3046cdebfa (patch) | |
tree | c820a6c6cfd7c9d6fe5ddbed7820df88cb34006c /softmmu | |
parent | bf6a61855654a306d6256d9fd55813ae1ee914cc (diff) |
softmmu/vl: Add a "grab-mod" parameter to the -display sdl option
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>
Diffstat (limited to 'softmmu')
-rw-r--r-- | softmmu/vl.c | 15 |
1 files changed, 12 insertions, 3 deletions
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; |