From: Thomas Huth <thuth@redhat.com>
To: qemu-devel@nongnu.org, Gerd Hoffmann <kraxel@redhat.com>
Cc: Markus Armbruster <armbru@redhat.com>,
Eric Blake <eblake@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
libvir-list@redhat.com
Subject: [PATCH 2/3] ui: Switch "-display sdl" to use the QAPI parser
Date: Wed, 11 May 2022 19:51:46 +0200 [thread overview]
Message-ID: <20220511175147.917707-3-thuth@redhat.com> (raw)
In-Reply-To: <20220511175147.917707-1-thuth@redhat.com>
The "-display sdl" option still uses a hand-crafted parser for its
parameters since some of them used underscores which is forbidden
in QAPI. Now that the problematic parameters have been removed, we can
switch to use the QAPI parser instead.
This introduces the new "DisplaySDL" QAPI struct that is used to hold
the parameters that are unique to the SDL display. The only specific
parameter is currently "grab-mod" which is modeled as a string, so that
it could be extended for other arbitrary modifiers later more easily.
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
qapi/ui.json | 17 +++++++++-
include/sysemu/sysemu.h | 2 --
softmmu/globals.c | 2 --
softmmu/vl.c | 70 +----------------------------------------
ui/sdl2.c | 13 ++++++++
5 files changed, 30 insertions(+), 74 deletions(-)
diff --git a/qapi/ui.json b/qapi/ui.json
index 059302a5ef..511ade44f2 100644
--- a/qapi/ui.json
+++ b/qapi/ui.json
@@ -1309,6 +1309,20 @@
'*swap-opt-cmd': 'bool'
} }
+##
+# @DisplaySDL:
+#
+# SDL2 display options.
+#
+# @grab-mod: String with modifier keys that should be pressed together with
+# the "G" key to release the mouse grab. Only "lshift-lctrl-lalt"
+# and "rctrl" are currently supported.
+#
+# Since: 7.1
+##
+{ 'struct' : 'DisplaySDL',
+ 'data' : { '*grab-mod' : 'str' } }
+
##
# @DisplayType:
#
@@ -1391,7 +1405,8 @@
'curses': { 'type': 'DisplayCurses', 'if': 'CONFIG_CURSES' },
'egl-headless': { 'type': 'DisplayEGLHeadless',
'if': { 'all': ['CONFIG_OPENGL', 'CONFIG_GBM'] } },
- 'dbus': { 'type': 'DisplayDBus', 'if': 'CONFIG_DBUS_DISPLAY' }
+ 'dbus': { 'type': 'DisplayDBus', 'if': 'CONFIG_DBUS_DISPLAY' },
+ 'sdl': { 'type': 'DisplaySDL', 'if': 'CONFIG_SDL' }
}
}
diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index 360a408edf..7cca797450 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -42,8 +42,6 @@ extern int graphic_depth;
extern int display_opengl;
extern const char *keyboard_layout;
extern int win2k_install_hack;
-extern int alt_grab;
-extern int ctrl_grab;
extern int graphic_rotate;
extern int old_param;
extern int boot_menu;
diff --git a/softmmu/globals.c b/softmmu/globals.c
index 98b64e0492..12611c2a7a 100644
--- a/softmmu/globals.c
+++ b/softmmu/globals.c
@@ -50,8 +50,6 @@ QEMUOptionRom option_rom[MAX_OPTION_ROMS];
int nb_option_roms;
int old_param;
const char *qemu_name;
-int alt_grab;
-int ctrl_grab;
unsigned int nb_prom_envs;
const char *prom_envs[MAX_PROM_ENVS];
int boot_menu;
diff --git a/softmmu/vl.c b/softmmu/vl.c
index fdf797270c..90a0a4d393 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -1045,75 +1045,7 @@ static void parse_display(const char *p)
exit(0);
}
- if (strstart(p, "sdl", &opts)) {
- /*
- * sdl DisplayType needs hand-crafted parser instead of
- * parse_display_qapi() due to some options not in
- * DisplayOptions, specifically:
- * - ctrl_grab + alt_grab
- * 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, ",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, ",window-close=", &nextopt)) {
- opts = nextopt;
- dpy.has_window_close = true;
- if (strstart(opts, "on", &nextopt)) {
- dpy.window_close = true;
- } else if (strstart(opts, "off", &nextopt)) {
- dpy.window_close = false;
- } else {
- goto invalid_sdl_args;
- }
- } else if (strstart(opts, ",show-cursor=", &nextopt)) {
- opts = nextopt;
- dpy.has_show_cursor = true;
- if (strstart(opts, "on", &nextopt)) {
- dpy.show_cursor = true;
- } else if (strstart(opts, "off", &nextopt)) {
- dpy.show_cursor = false;
- } else {
- goto invalid_sdl_args;
- }
- } else if (strstart(opts, ",gl=", &nextopt)) {
- opts = nextopt;
- dpy.has_gl = true;
- if (strstart(opts, "on", &nextopt)) {
- dpy.gl = DISPLAYGL_MODE_ON;
- } else if (strstart(opts, "core", &nextopt)) {
- dpy.gl = DISPLAYGL_MODE_CORE;
- } else if (strstart(opts, "es", &nextopt)) {
- dpy.gl = DISPLAYGL_MODE_ES;
- } else if (strstart(opts, "off", &nextopt)) {
- dpy.gl = DISPLAYGL_MODE_OFF;
- } else {
- goto invalid_sdl_args;
- }
- } else {
- invalid_sdl_args:
- error_report("invalid SDL option string");
- exit(1);
- }
- opts = nextopt;
- }
-#else
- error_report("SDL display supported is not available in this binary");
- exit(1);
-#endif
- } else if (strstart(p, "vnc", &opts)) {
+ if (strstart(p, "vnc", &opts)) {
/*
* vnc isn't a (local) DisplayType but a protocol for remote
* display access.
diff --git a/ui/sdl2.c b/ui/sdl2.c
index d3741f9b75..18c63e1fc9 100644
--- a/ui/sdl2.c
+++ b/ui/sdl2.c
@@ -40,6 +40,8 @@ static struct sdl2_console *sdl2_console;
static SDL_Surface *guest_sprite_surface;
static int gui_grab; /* if true, all keyboard/mouse events are grabbed */
+static bool alt_grab;
+static bool ctrl_grab;
static int gui_saved_grab;
static int gui_fullscreen;
@@ -853,6 +855,17 @@ static void sdl2_display_init(DisplayState *ds, DisplayOptions *o)
gui_fullscreen = o->has_full_screen && o->full_screen;
+ if (o->u.sdl.has_grab_mod) {
+ if (g_str_equal(o->u.sdl.grab_mod, "lshift-lctrl-lalt")) {
+ alt_grab = true;
+ } else if (g_str_equal(o->u.sdl.grab_mod, "rctrl")) {
+ ctrl_grab = true;
+ } else {
+ error_report("Unsupported grab-mod: %s", o->u.sdl.grab_mod);
+ exit(1);
+ }
+ }
+
for (i = 0;; i++) {
QemuConsole *con = qemu_console_lookup_by_index(i);
if (!con) {
--
2.27.0
next prev parent reply other threads:[~2022-05-11 17:58 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-11 17:51 [PATCH 0/3] ui: Remove deprecated sdl parameters and switch to QAPI parser Thomas Huth
2022-05-11 17:51 ` [PATCH 1/3] ui: Remove deprecated parameters of the "-display sdl" option Thomas Huth
2022-05-12 8:16 ` Daniel P. Berrangé
2022-05-11 17:51 ` Thomas Huth [this message]
2022-05-12 8:20 ` [PATCH 2/3] ui: Switch "-display sdl" to use the QAPI parser Daniel P. Berrangé
2022-05-12 12:16 ` Markus Armbruster
2022-05-17 8:34 ` Thomas Huth
2022-05-17 9:08 ` Markus Armbruster
2022-05-17 9:49 ` Paolo Bonzini
2022-05-17 11:19 ` Markus Armbruster
2022-05-17 13:18 ` Thomas Huth
2022-05-11 17:51 ` [PATCH 3/3] ui: Remove deprecated options "-sdl" and "-curses" Thomas Huth
2022-05-12 8:21 ` Daniel P. Berrangé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220511175147.917707-3-thuth@redhat.com \
--to=thuth@redhat.com \
--cc=armbru@redhat.com \
--cc=eblake@redhat.com \
--cc=kraxel@redhat.com \
--cc=libvir-list@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.