ui: Remove deprecated sdl parameters and switch to QAPI parser
v3 cover ui: Remove deprecated sdl parameters and switch to QAPI parser
The "-display sdl" option still uses a hand-crafted parser for its parameters since some of them used underscores which is disliked in QAPI. Now that they've been deprecated and the deprecation period is over, we can remove the problematic parameters and switch to use the QAPI parser instead.
While we're at it, also remove the deprecated "-sdl" and "-curses" options.
v3:
- Fixed some texts according to Markus' and Eric's suggestions
- Renamed the GrabMod enum to HotKeyMod (to not confuse it so easily with GrabToggleKeys)
v2:
- Rebase to current master branch to resolve conflicts in docs/about/*.rst
- Use an enum for the grab-mod parameter instead of a unconstrained string
Thomas Huth (3):
ui: Remove deprecated parameters of the "-display sdl" option
ui: Switch "-display sdl" to use the QAPI parser
ui: Remove deprecated options "-sdl" and "-curses"
docs/about/deprecated.rst | 26 ------- docs/about/removed-features.rst | 27 +++++++ qapi/ui.json | 26 ++++++- include/sysemu/sysemu.h | 2 - softmmu/globals.c | 2 - softmmu/vl.c | 128 +------------------------------- ui/sdl2.c | 10 +++ qemu-options.hx | 56 +------------- 8 files changed, 67 insertions(+), 210 deletions(-)
Signature · 1 line
2.27.0
PATCH v3 1/3 ui: Remove deprecated parameters of the "-display sdl" option
Dropping these deprecated parameters simplifies further refactoring (e.g. QAPIfication is easier without underscores in the name).
--- docs/about/deprecated.rst | 16 ------------- docs/about/removed-features.rst | 17 ++++++++++++++ softmmu/vl.c | 41 +-------------------------------- qemu-options.hx | 32 ++----------------------- 4 files changed, 20 insertions(+), 86 deletions(-)
docs/about/deprecated.rst +0 -16
@@ -81,22 +81,6 @@ the process listing. This is replaced by the new ``password-secret`` option which lets the password be securely provided on the command line using a ``secret`` object instance. -``-display sdl,window_close=...`` (since 6.1) -''''''''''''''''''''''''''''''''''''''''''''' - -Use ``-display sdl,window-close=...`` instead (i.e. with a minus instead of -an underscore between "window" and "close"). - -``-alt-grab`` and ``-display sdl,alt_grab=on`` (since 6.2) -'''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - -Use ``-display sdl,grab-mod=lshift-lctrl-lalt`` instead. - -``-ctrl-grab`` and ``-display sdl,ctrl_grab=on`` (since 6.2) -'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - -Use ``-display sdl,grab-mod=rctrl`` instead. - ``-sdl`` (since 6.2) ''''''''''''''''''''
docs/about/removed-features.rst +17 -0
@@ -370,6 +370,23 @@ The ``opened=on`` option in the command line or QMP ``object-add`` either had no effect (if ``opened`` was the last option) or caused errors. The property is therefore useless and should simply be removed. +``-display sdl,window_close=...`` (removed in 7.1) +'''''''''''''''''''''''''''''''''''''''''''''''''' + +Use ``-display sdl,window-close=...`` instead (i.e. with a minus instead of +an underscore between "window" and "close"). + +``-alt-grab`` and ``-display sdl,alt_grab=on`` (removed in 7.1) +''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + +Use ``-display sdl,grab-mod=lshift-lctrl-lalt`` instead. + +``-ctrl-grab`` and ``-display sdl,ctrl_grab=on`` (removed in 7.1) +''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + +Use ``-display sdl,grab-mod=rctrl`` instead. + + QEMU Machine Protocol (QMP) commands ------------------------------------
softmmu/vl.c +1 -40
59 lines not on this page · raw message
qemu-options.hx +2 -30
@@ -1938,8 +1938,8 @@ DEF("display", HAS_ARG, QEMU_OPTION_display, "-display spice-app[,gl=on|off]\n" #endif #if defined(CONFIG_SDL) - "-display sdl[,alt_grab=on|off][,ctrl_grab=on|off][,gl=on|core|es|off]\n" - " [,grab-mod=<mod>][,show-cursor=on|off][,window-close=on|off]\n" + "-display sdl[,gl=on|core|es|off][,grab-mod=<mod>][,show-cursor=on|off]\n" + " [,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"
@@ -2012,12 +2012,6 @@ SRST 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. - This parameter is deprecated - use ``grab-mod`` instead. - - ``ctrl_grab=on|off`` : Use Right-Control-g to toggle mouse grabbing. - This parameter is deprecated - use ``grab-mod`` instead. - ``gl=on|off|core|es`` : Use OpenGL for displaying ``show-cursor=on|off`` : Force showing the mouse cursor
@@ -2103,28 +2097,6 @@ SRST is displayed in graphical mode. ERST -DEF("alt-grab", 0, QEMU_OPTION_alt_grab, - "-alt-grab use Ctrl-Alt-Shift to grab mouse (instead of Ctrl-Alt)\n", - QEMU_ARCH_ALL) -SRST -``-alt-grab`` - Use Ctrl-Alt-Shift to grab mouse (instead of Ctrl-Alt). Note that - this also affects the special keys (for fullscreen, monitor-mode - switching, etc). This option is deprecated - please use - ``-display sdl,grab-mod=lshift-lctrl-lalt`` instead. -ERST - -DEF("ctrl-grab", 0, QEMU_OPTION_ctrl_grab, - "-ctrl-grab use Right-Ctrl to grab mouse (instead of Ctrl-Alt)\n", - QEMU_ARCH_ALL) -SRST -``-ctrl-grab`` - Use Right-Ctrl to grab mouse (instead of Ctrl-Alt). Note that this - also affects the special keys (for fullscreen, monitor-mode - switching, etc). This option is deprecated - please use - ``-display sdl,grab-mod=rctrl`` instead. -ERST - DEF("sdl", 0, QEMU_OPTION_sdl, "-sdl shorthand for -display sdl\n", QEMU_ARCH_ALL) SRST
Signature · 1 line
2.27.0
PATCH v3 2/3 ui: Switch "-display sdl" to use the QAPI parser
In reply to Thomas HuthThe "-display sdl" option still uses a hand-crafted parser for its parameters since we didn't want to drag an interface we considered somewhat flawed into the QAPI schema. Since the flaws are gone now, it's time to QAPIfy.
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" that is used to specify the required modifier keys to escape from the mouse grabbing mode.
--- qapi/ui.json | 26 ++++++++++++++- include/sysemu/sysemu.h | 2 -- softmmu/globals.c | 2 -- softmmu/vl.c | 70 +---------------------------------------- ui/sdl2.c | 10 ++++++ 5 files changed, 36 insertions(+), 74 deletions(-)
qapi/ui.json +25 -1
@@ -1295,6 +1295,29 @@ '*swap-opt-cmd': 'bool' } } +## +# @HotKeyMod: +# +# Set of modifier keys that need to be held for shortcut key actions. +# +# Since: 7.1 +## +{ 'enum' : 'HotKeyMod', + 'data' : [ 'lctrl-lalt', 'lshift-lctrl-lalt', 'rctrl' ] } + +## +# @DisplaySDL: +# +# SDL2 display options. +# +# @grab-mod: Modifier keys that should be pressed together with the +# "G" key to release the mouse grab. +# +# Since: 7.1 +## +{ 'struct' : 'DisplaySDL', + 'data' : { '*grab-mod' : 'HotKeyMod' } } + ## # @DisplayType: #
@@ -1374,7 +1397,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' } } }
include/sysemu/sysemu.h +0 -2
@@ -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 uint8_t *boot_splash_filedata;
softmmu/globals.c +0 -2
@@ -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 ];uint8_t *boot_splash_filedata;
softmmu/vl.c +1 -69
76 lines not on this page · raw message
ui/sdl2.c +10 -0
@@ -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,14 @@ 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 (o->u.sdl.grab_mod ==HOT_KEY_MOD_LSHIFT_LCTRL_LALT ) { + alt_grab = true; + }else if (o->u.sdl.grab_mod ==HOT_KEY_MOD_RCTRL ) { + ctrl_grab = true; + } + } +for (i =0 ;; i++) {QemuConsole *con =qemu_console_lookup_by_index (i);if (!con) {
Signature · 1 line
2.27.0
Re: [PATCH v3 2/3] ui: Switch "-display sdl" to use the QAPI parser
Quoted 26 lines · Thomas Huth
The "-display sdl" option still uses a hand-crafted parser for its parameters since we didn't want to drag an interface we considered somewhat flawed into the QAPI schema. Since the flaws are gone now, it's time to QAPIfy.
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" that is used to specify the required modifier keys to escape from the mouse grabbing mode.
Signed-off-by Thomas Huth <[email protected]>--- qapi/ui.json | 26 ++++++++++++++- include/sysemu/sysemu.h | 2 -- softmmu/globals.c | 2 -- softmmu/vl.c | 70 +---------------------------------------- ui/sdl2.c | 10 ++++++ 5 files changed, 36 insertions(+), 74 deletions(-)qapi/ui.json +0
-0@@ -1295,6 +1295,29 @@ '*swap-opt-cmd': 'bool' } }
qapi/ui.json line 1306
Quoted 10 lines
qapi/ui.json +9
-0+## +# @HotKeyMod: +# +# Set of modifier keys that need to be held for shortcut key actions. +# +# Since: 7.1 +## +{ 'enum' : 'HotKeyMod', + 'data' : [ 'lctrl-lalt', 'lshift-lctrl-lalt', 'rctrl' ] }
I have a somewhat uneasy feeling about encoding what is essentially a subset of the sets of modifier keys as an enumeration, but it's what we have to do to QAPIfy existing grab-mod.
Quoted 119 lines
qapi/ui.json +16
-1+ +## +# @DisplaySDL: +# +# SDL2 display options. +# +# @grab-mod: Modifier keys that should be pressed together with the +# "G" key to release the mouse grab. +# +# Since: 7.1 +## +{ 'struct' : 'DisplaySDL', + 'data' : { '*grab-mod' : 'HotKeyMod' } } + ## # @DisplayType: #@@ -1374,7 +1397,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' } } }include/sysemu/sysemu.h +0
-2@@ -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 uint8_t *boot_splash_filedata;softmmu/globals.c +0
-2@@ -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 ];uint8_t *boot_splash_filedata;softmmu/vl.c +0
-58@@ -1056,75 +1056,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 {
softmmu/vl.c static void parse_display(const char *p) · line 1126
Quoted 10 lines
softmmu/vl.c +0
-10- 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
When CONFIG_SDL is off, the error message changes from
qemu-system-x86_64: -display sdl: SDL display supported is not available in this binary
to
qemu-system-x86_64: -display sdl: Parameter 'type' does not accept value 'sdl'
I don't mind, but I'd suggest to mention it in the commit message.
Quoted 10 lines
softmmu/vl.c +1
-1- }else if (strstart (p,"vnc" , &opts)) { +if (strstart (p,"vnc" , &opts)) {/* * vnc isn't a (local) DisplayType but a protocol for remote * display access. ui/sdl2.c +0
-0
ui/sdl2.c static struct sdl2_console *sdl2_console; · line 44
Quoted 5 lines
ui/sdl2.c +2
-0@@ -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;
I like that these become internal to sdl2.c.
Quoted 8 lines
ui/sdl2.c +1
-0static int gui_saved_grab;static int gui_fullscreen;@@ -853,6 +855,14 @@ 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) {
ui/sdl2.c static void sdl2_display_init(DisplayState *ds, DisplayOptions *o) · line 868
Quoted 10 lines
ui/sdl2.c +7
-0+if (o->u.sdl.grab_mod ==HOT_KEY_MOD_LSHIFT_LCTRL_LALT ) { + alt_grab = true; + }else if (o->u.sdl.grab_mod ==HOT_KEY_MOD_RCTRL ) { + ctrl_grab = true; + } + } +for (i =0 ;; i++) {QemuConsole *con =qemu_console_lookup_by_index (i);if (!con) {
Re: [PATCH v3 2/3] ui: Switch "-display sdl" to use the QAPI parser
Quoted 29 lines · Markus Armbruster
Quoted 27 lines · Thomas Huth
The "-display sdl" option still uses a hand-crafted parser for its parameters since we didn't want to drag an interface we considered somewhat flawed into the QAPI schema. Since the flaws are gone now, it's time to QAPIfy.
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" that is used to specify the required modifier keys to escape from the mouse grabbing mode.
Signed-off-by Thomas Huth <[email protected]>--- qapi/ui.json | 26 ++++++++++++++- include/sysemu/sysemu.h | 2 -- softmmu/globals.c | 2 -- softmmu/vl.c | 70 +---------------------------------------- ui/sdl2.c | 10 ++++++ 5 files changed, 36 insertions(+), 74 deletions(-)qapi/ui.json +0
-0@@ -1295,6 +1295,29 @@ '*swap-opt-cmd': 'bool' } }
Quoted 13 lines
qapi/ui.json line 1306
Quoted 9 lines
qapi/ui.json +9
-0+## +# @HotKeyMod: +# +# Set of modifier keys that need to be held for shortcut key actions. +# +# Since: 7.1 +## +{ 'enum' : 'HotKeyMod', + 'data' : [ 'lctrl-lalt', 'lshift-lctrl-lalt', 'rctrl' ] }I have a somewhat uneasy feeling about encoding what is essentially a subset of the sets of modifier keys as an enumeration, but it's what we have to do to QAPIfy existing grab-mod.
Well, that's exactly what you suggested here:
https://lists.gnu.org/archive/html/qemu-devel/2022-05/msg03401.html
So I really don't understand your uneasy feeling now?
...
Quoted 79 lines
Quoted 66 lines
softmmu/vl.c +0
-58@@ -1056,75 +1056,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 {softmmu/vl.c static void parse_display(const char *p) · line 1126
Quoted 10 lines
softmmu/vl.c +0
-10- 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 When
CONFIG_SDLis off, the error message changes from
Quoted 7 lines
qemu-system-x86_64: -display sdl: SDL display supported is not available in this binary
to
qemu-system-x86_64: -display sdl: Parameter 'type' does not accept value 'sdl'
I don't mind, but I'd suggest to mention it in the commit message.
I can do that if I have to respin this series for some other reasons. Otherwise, I don't think this really severe enough to justify a v4.
Quoted 3 lines
Reviewed-by Markus Armbruster <[email protected]>
Thanks!
Thomas
Re: [PATCH v3 2/3] ui: Switch "-display sdl" to use the QAPI parser
Quoted 43 lines · Thomas Huth
Quoted 33 lines · Markus Armbruster
Quoted 31 lines · Thomas Huth
The "-display sdl" option still uses a hand-crafted parser for its parameters since we didn't want to drag an interface we considered somewhat flawed into the QAPI schema. Since the flaws are gone now, it's time to QAPIfy.
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" that is used to specify the required modifier keys to escape from the mouse grabbing mode.
Signed-off-by Thomas Huth <[email protected]>--- qapi/ui.json | 26 ++++++++++++++- include/sysemu/sysemu.h | 2 -- softmmu/globals.c | 2 -- softmmu/vl.c | 70 +---------------------------------------- ui/sdl2.c | 10 ++++++ 5 files changed, 36 insertions(+), 74 deletions(-)qapi/ui.json +5
-0@@ -1295,6 +1295,29 @@ '*swap-opt-cmd': 'bool' } } +## +# @HotKeyMod: +# +# Set of modifier keys that need to be held for shortcut key actions. +#Quoted 8 lines
qapi/ui.json line 1306
Quoted 4 lines
qapi/ui.json +4
-0+# Since: 7.1 +## +{ 'enum' : 'HotKeyMod', + 'data' : [ 'lctrl-lalt', 'lshift-lctrl-lalt', 'rctrl' ] }I have a somewhat uneasy feeling about encoding what is essentially a subset of the sets of modifier keys as an enumeration, but it's what we have to do to QAPIfy existing grab-mod.
Quoted 5 lines
Well, that's exactly what you suggested here:
https://lists.gnu.org/archive/html/qemu-devel/2022-05/msg03401.html
So I really don't understand your uneasy feeling now?
I think we should consider what happens if we want to allow arbitrary key combinations in future, consisting of one or more modifiers together witha non-modifier key. For example CtrlL+ShiftL+F12. We won't want to be expressing the combinatorial expansion of all possible key combinations as an enum. Instead I think we would want to have an enum for keycode names and accept an array of them. We already have QKeyCode, so for SDL grab sequence we need to accept an arrray of QKeyCode.
{ 'struct' : 'DisplaySDL',
'data' : { '*grab-mod' : [ 'QKeyCode' ] }Good for QMP but not entirely pretty on the CLI. But we need back compat for existing CLI syntax too, so we would have to use an alternate allowing plain string for the legacy key codes combinations.
IOW we end up needing
{ 'alternate': 'SDLGrabSeq',
'data': { 'grab-mod': 'HotKeyMod',
'grab-keys: [ 'QKeyCode' ] } }{ 'struct' : 'DisplaySDL',
'data' : { '*grab-mod' : [ 'SDLGrabSeq' ] }deprecating 'grab-mod' for a while, eventually leaving just the first example above.
Since IIUC, we can retrofit the alternate after the fact if we decide to allow arbitrary key combos, it means we could safely start with what Thomas proposes
{ 'struct' : 'DisplaySDL',
'data' : { '*grab-mod' : 'HotKeyMod' }and worry about the more general solution another day/month/year
Quoted 92 lines
...
Quoted 78 lines
Quoted 65 lines
softmmu/vl.c +0
-58@@ -1056,75 +1056,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 {softmmu/vl.c static void parse_display(const char *p) · line 1125
Quoted 10 lines
softmmu/vl.c +0
-10- 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 When
CONFIG_SDLis off, the error message changes fromQuoted 7 lines
qemu-system-x86_64: -display sdl: SDL display supported is not available in this binary
to
qemu-system-x86_64: -display sdl: Parameter 'type' does not accept value 'sdl'
I don't mind, but I'd suggest to mention it in the commit message.
I can do that if I have to respin this series for some other reasons. Otherwise, I don't think this really severe enough to justify a v4.
Quoted 1 line
Quoted 8 lines
Quoted 2 lines
Reviewed-by Markus Armbruster <[email protected]>Thanks!
Thomas
With regards,
Daniel
Signature · 3 lines
|: 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 :|
Re: [PATCH v3 2/3] ui: Switch "-display sdl" to use the QAPI parser
Quoted 44 lines · Daniel P. Berrangé
Quoted 43 lines · Thomas Huth
Quoted 41 lines · Markus Armbruster
Quoted 25 lines · Thomas Huth
The "-display sdl" option still uses a hand-crafted parser for its parameters since we didn't want to drag an interface we considered somewhat flawed into the QAPI schema. Since the flaws are gone now, it's time to QAPIfy.
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" that is used to specify the required modifier keys to escape from the mouse grabbing mode.
Signed-off-by Thomas Huth <[email protected]>--- qapi/ui.json | 26 ++++++++++++++- include/sysemu/sysemu.h | 2 -- softmmu/globals.c | 2 -- softmmu/vl.c | 70 +---------------------------------------- ui/sdl2.c | 10 ++++++ 5 files changed, 36 insertions(+), 74 deletions(-)qapi/ui.json +0
-0@@ -1295,6 +1295,29 @@ '*swap-opt-cmd': 'bool'qapi/ui.json line 1305
Quoted 10 lines
qapi/ui.json +9
-0} } +## +# @HotKeyMod: +# +# Set of modifier keys that need to be held for shortcut key actions. +# +# Since: 7.1 +## +{ 'enum' : 'HotKeyMod', + 'data' : [ 'lctrl-lalt', 'lshift-lctrl-lalt', 'rctrl' ] }I have a somewhat uneasy feeling about encoding what is essentially a subset of the sets of modifier keys as an enumeration, but it's what we have to do to QAPIfy existing grab-mod.
Quoted 5 lines
Quoted 5 lines
Well, that's exactly what you suggested here:
https://lists.gnu.org/archive/html/qemu-devel/2022-05/msg03401.html
So I really don't understand your uneasy feeling now?
I did mention the set of modifiers (encoded as list) design alternative. You pointed out that you're merely QAPIfying what we have. Valid point, well taken, I don't want to block that.
Quoted 28 lines
I think we should consider what happens if we want to allow arbitrary key combinations in future, consisting of one or more modifiers together witha non-modifier key. For example CtrlL+ShiftL+F12. We won't want to be expressing the combinatorial expansion of all possible key combinations as an enum. Instead I think we would want to have an enum for keycode names and accept an array of them. We already have QKeyCode, so for SDL grab sequence we need to accept an arrray of QKeyCode.
{ 'struct' : 'DisplaySDL',
'data' : { '*grab-mod' : [ 'QKeyCode' ] }Good for QMP but not entirely pretty on the CLI. But we need back compat for existing CLI syntax too, so we would have to use an alternate allowing plain string for the legacy key codes combinations.
IOW we end up needing
{ 'alternate': 'SDLGrabSeq', 'data': { 'grab-mod': 'HotKeyMod', 'grab-keys: [ 'QKeyCode' ] } }{ 'struct' : 'DisplaySDL',
'data' : { '*grab-mod' : [ 'SDLGrabSeq' ] }deprecating 'grab-mod' for a while, eventually leaving just the first example above.
Quoted 8 lines
Since IIUC, we can retrofit the alternate after the fact if we decide to allow arbitrary key combos, it means we could safely start with what Thomas proposes
{ 'struct' : 'DisplaySDL',
'data' : { '*grab-mod' : 'HotKeyMod' }and worry about the more general solution another day/month/year
Right.
[...]
PATCH v3 3/3 ui: Remove deprecated options "-sdl" and "-curses"
In reply to Thomas HuthWe have "-sdl" and "-curses", but no "-gtk" and no "-cocoa" ... these old-style options are rather confusing than helpful nowadays. Now that the deprecation period is over, let's remove them, so we get a cleaner interface (where "-display" is the only way to select the user interface).
--- docs/about/deprecated.rst | 10 ---------- docs/about/removed-features.rst | 10 ++++++++++ softmmu/vl.c | 19 ------------------- qemu-options.hx | 24 ++---------------------- 4 files changed, 12 insertions(+), 51 deletions(-)
docs/about/deprecated.rst +0 -10
@@ -81,16 +81,6 @@ the process listing. This is replaced by the new ``password-secret`` option which lets the password be securely provided on the command line using a ``secret`` object instance. -``-sdl`` (since 6.2) -'''''''''''''''''''' - -Use ``-display sdl`` instead. - -``-curses`` (since 6.2) -''''''''''''''''''''''' - -Use ``-display curses`` instead. - ``-watchdog`` (since 6.2) '''''''''''''''''''''''''
docs/about/removed-features.rst +10 -0
@@ -386,6 +386,16 @@ Use ``-display sdl,grab-mod=lshift-lctrl-lalt`` instead. Use ``-display sdl,grab-mod=rctrl`` instead. +``-sdl`` (removed in 7.1) +''''''''''''''''''''''''' + +Use ``-display sdl`` instead. + +``-curses`` (removed in 7.1) +'''''''''''''''''''''''''''' + +Use ``-display curses`` instead. + QEMU Machine Protocol (QMP) commands ------------------------------------
softmmu/vl.c +0 -19
@@ -2800,16 +2800,6 @@ void qemu_init(int argc, char **argv, char **envp) nographic = true; dpy.type =DISPLAY_TYPE_NONE ;break ; -case QEMU_OPTION_curses: -warn_report ("-curses is deprecated, " -"use -display curses instead." ); -#ifdef CONFIG_CURSES - dpy.type =DISPLAY_TYPE_CURSES ; -#else -error_report ("curses or iconv support is disabled" ); -exit (1 ); -#endif -break ;case QEMU_OPTION_portrait: graphic_rotate =90 ;break ;
@@ -3176,15 +3166,6 @@ void qemu_init(int argc, char **argv, char **envp) dpy.has_full_screen = true; dpy.full_screen = true;break ; -case QEMU_OPTION_sdl: -warn_report ("-sdl is deprecated, use -display sdl instead." ); -#ifdef CONFIG_SDL - dpy.type =DISPLAY_TYPE_SDL ; -break ; -#else -error_report ("SDL support is disabled" ); -exit (1 ); -#endif case QEMU_OPTION_pidfile: pid_file = optarg;break ;
qemu-options.hx +2 -22
@@ -1981,9 +1981,8 @@ DEF("display", HAS_ARG, QEMU_OPTION_display, , QEMU_ARCH_ALL) SRST ``-display type`` - Select type of display to use. This option is a replacement for the - old style -sdl/-curses/... options. Use ``-display help`` to list - the available display types. Valid values for type are + Select type of display to use. Use ``-display help`` to list the available + display types. Valid values for type are ``spice-app[,gl=on|off]`` Start QEMU as a Spice server and launch the default Spice client
@@ -2085,25 +2084,6 @@ SRST Use C-a h for help on switching between the console and monitor. ERST -DEF("curses", 0, QEMU_OPTION_curses, - "-curses shorthand for -display curses\n", - QEMU_ARCH_ALL) -SRST -``-curses`` - Normally, if QEMU is compiled with graphical window support, it - displays output such as guest graphics, guest console, and the QEMU - monitor in a window. With this option, QEMU can display the VGA - output when in text mode using a curses/ncurses interface. Nothing - is displayed in graphical mode. -ERST - -DEF("sdl", 0, QEMU_OPTION_sdl, - "-sdl shorthand for -display sdl\n", QEMU_ARCH_ALL) -SRST -``-sdl`` - Enable SDL. -ERST - #ifdef CONFIG_SPICE DEF("spice", HAS_ARG, QEMU_OPTION_spice, "-spice [port=port][,tls-port=secured-port][,x509-dir=<dir>]\n"
Signature · 1 line
2.27.0