From nobody Sun Feb 8 05:41:06 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652291525; cv=none; d=zohomail.com; s=zohoarc; b=cVcS8YzuIEWnJ87EXQxHNt5QX2/K9kcdyqfG+VZL3g+qpoWYl5u11twQz1qY5oOIpzs2qZNleNarQVeZLbvaVGheXAElMvNBWPzq3xja4juHgqdlyxH/vW0a9ZyLONss59MyUYvIDYbXOeOaXz/uG2Pd2aT9CCVPtLcLZNDKUs8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652291525; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=7vHNTpZp+aJW+NFWmBiJyOFUdNmlx3lbxDvIdtsf2AA=; b=iRX4sdyEOS3GoLcsBULqb+e08y5IDA2GEBDjRM0NkPqmVJJTMxTrjaT7m1u5MWz6fXyBH0B/6wAYsMJRSKb8M1iMy77MYFcLbYfc5k8pY6rgiLU0t6vaSVAB8n3UM/+J4j53xYzdEC2A8M7QRpdViFvOAMEo7OKrPApXOAgb5xc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1652291525303763.9710648181846; Wed, 11 May 2022 10:52:05 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-195-D_TAH428PkG7g14AfnWcww-1; Wed, 11 May 2022 13:51:59 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 167B41D96CA1; Wed, 11 May 2022 17:51:57 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 019502026D6A; Wed, 11 May 2022 17:51:57 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id C5511194707A; Wed, 11 May 2022 17:51:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 318391947041 for ; Wed, 11 May 2022 17:51:56 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 02B1640CF8FD; Wed, 11 May 2022 17:51:56 +0000 (UTC) Received: from thuth.com (unknown [10.39.192.202]) by smtp.corp.redhat.com (Postfix) with ESMTP id 71F9340CF8E4; Wed, 11 May 2022 17:51:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652291523; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=7vHNTpZp+aJW+NFWmBiJyOFUdNmlx3lbxDvIdtsf2AA=; b=AwkxQTqVTjJFp3cziOJ2BEGvK4UvxKpDsqCbU8lZKxLaZ+2yhfZW3fUUMCaommlMSg9S2u TyBTrfA/uALdstpqGCY0+/kKve4D5PbtwN58FGI/5WjQxuWkKaNEUVVikKEGpJJTEGgAgZ S6DXAbDrGKybL6iX2KPuOZDQHFCzguQ= X-MC-Unique: D_TAH428PkG7g14AfnWcww-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Thomas Huth To: qemu-devel@nongnu.org, Gerd Hoffmann Subject: [PATCH 2/3] ui: Switch "-display sdl" to use the QAPI parser Date: Wed, 11 May 2022 19:51:46 +0200 Message-Id: <20220511175147.917707-3-thuth@redhat.com> In-Reply-To: <20220511175147.917707-1-thuth@redhat.com> References: <20220511175147.917707-1-thuth@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: libvir-list@redhat.com, Paolo Bonzini , Eric Blake , Markus Armbruster Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652291526877100005 Content-Type: text/plain; charset="utf-8"; x-default="true" 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 Reviewed-by: Daniel P. Berrang=C3=A9 --- 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' } } =20 +## +# @DisplaySDL: +# +# SDL2 display options. +# +# @grab-mod: String with modifier keys that should be pressed together wi= th +# the "G" key to release the mouse grab. Only "lshift-lctrl-la= lt" +# 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' } } } =20 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); } =20 - 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 underscore= s, - * thus they will get replaced by "grab-mod" in the long term - */ -#if defined(CONFIG_SDL) - dpy.type =3D DISPLAY_TYPE_SDL; - while (*opts) { - const char *nextopt; - - if (strstart(opts, ",grab-mod=3D", &nextopt)) { - opts =3D nextopt; - if (strstart(opts, "lshift-lctrl-lalt", &nextopt)) { - alt_grab =3D 1; - } else if (strstart(opts, "rctrl", &nextopt)) { - ctrl_grab =3D 1; - } else { - goto invalid_sdl_args; - } - } else if (strstart(opts, ",window-close=3D", &nextopt)) { - opts =3D nextopt; - dpy.has_window_close =3D true; - if (strstart(opts, "on", &nextopt)) { - dpy.window_close =3D true; - } else if (strstart(opts, "off", &nextopt)) { - dpy.window_close =3D false; - } else { - goto invalid_sdl_args; - } - } else if (strstart(opts, ",show-cursor=3D", &nextopt)) { - opts =3D nextopt; - dpy.has_show_cursor =3D true; - if (strstart(opts, "on", &nextopt)) { - dpy.show_cursor =3D true; - } else if (strstart(opts, "off", &nextopt)) { - dpy.show_cursor =3D false; - } else { - goto invalid_sdl_args; - } - } else if (strstart(opts, ",gl=3D", &nextopt)) { - opts =3D nextopt; - dpy.has_gl =3D true; - if (strstart(opts, "on", &nextopt)) { - dpy.gl =3D DISPLAYGL_MODE_ON; - } else if (strstart(opts, "core", &nextopt)) { - dpy.gl =3D DISPLAYGL_MODE_CORE; - } else if (strstart(opts, "es", &nextopt)) { - dpy.gl =3D DISPLAYGL_MODE_ES; - } else if (strstart(opts, "off", &nextopt)) { - dpy.gl =3D DISPLAYGL_MODE_OFF; - } else { - goto invalid_sdl_args; - } - } else { - invalid_sdl_args: - error_report("invalid SDL option string"); - exit(1); - } - opts =3D nextopt; - } -#else - error_report("SDL display supported is not available in this binar= y"); - 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; =20 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; =20 static int gui_saved_grab; static int gui_fullscreen; @@ -853,6 +855,17 @@ static void sdl2_display_init(DisplayState *ds, Displa= yOptions *o) =20 gui_fullscreen =3D o->has_full_screen && o->full_screen; =20 + if (o->u.sdl.has_grab_mod) { + if (g_str_equal(o->u.sdl.grab_mod, "lshift-lctrl-lalt")) { + alt_grab =3D true; + } else if (g_str_equal(o->u.sdl.grab_mod, "rctrl")) { + ctrl_grab =3D true; + } else { + error_report("Unsupported grab-mod: %s", o->u.sdl.grab_mod); + exit(1); + } + } + for (i =3D 0;; i++) { QemuConsole *con =3D qemu_console_lookup_by_index(i); if (!con) { --=20 2.27.0