From nobody Mon Feb 9 00:54:04 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1625583277; cv=none; d=zohomail.com; s=zohoarc; b=e3PNadliJoStM+dEnFMl1jKhgnwFVt9o/NseB569Hi5gcmBm4d+fhAdLAuuilkfLyNh02+uhTvw77PQCaXRKUvkonKSHo8ZFi7i8R66tSEzy+V+mZjD5qTpuhhx/dzGzZKjLI7+hJ0sbnw8PGKBpAULt0yXHxh5WngE3r2ql/X4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1625583277; 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=M7dTxzPftuuEA7D9Quci9ks31+ssbPZXAfmsnGojLSM=; b=GxqkGbXDe1Yq85LE9FZoG2pzjVVuUnx5p2INiMlMBAxY4WGkCDdcwLJwVuAWRSfM9siFNfOJ6LkkK+c8X5xJ6YImPq1kJeH1teOfdzGXOtxpDv97Rjukmf0kNGr+zO0fVmFVUNAbkh3zBwJEyxuJ4DZbBZ2hpLWKNHQli0okHdg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1625583277501499.70553258375685; Tue, 6 Jul 2021 07:54:37 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-401-9sSuK5x3MlyQKhkn6GYKzA-1; Tue, 06 Jul 2021 10:54:33 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 21AF61023F41; Tue, 6 Jul 2021 14:54:28 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4C025189C7; Tue, 6 Jul 2021 14:54:27 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A12211809C9A; Tue, 6 Jul 2021 14:54:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 166EsPKe013249 for ; Tue, 6 Jul 2021 10:54:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id 37CA05D6CF; Tue, 6 Jul 2021 14:54:25 +0000 (UTC) Received: from thuth.com (ovpn-113-37.ams2.redhat.com [10.36.113.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id 114945D6AD; Tue, 6 Jul 2021 14:54:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625583276; 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=M7dTxzPftuuEA7D9Quci9ks31+ssbPZXAfmsnGojLSM=; b=JMONikRbPZuj0yUyqFHu2i7pFKVrmugaWom46Qxhq90uuGgodszlM03o5KCog5Nm5wK/3K xYCMz+j46yLZ59i85Kl6eiaStPmVJCokZDab4Ss52XYn3fGZqjrAWsSsYm8PXLDBsfdd8p AxC0TFo9TOYAvP7gqGUPRp0ikVCa0EI= X-MC-Unique: 9sSuK5x3MlyQKhkn6GYKzA-1 From: Thomas Huth To: qemu-devel@nongnu.org, Paolo Bonzini Subject: [PATCH 1/3] softmmu/vl: Add a "grab-mod" parameter to the -display sdl option Date: Tue, 6 Jul 2021 16:54:11 +0200 Message-Id: <20210706145413.1449571-2-thuth@redhat.com> In-Reply-To: <20210706145413.1449571-1-thuth@redhat.com> References: <20210706145413.1449571-1-thuth@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: libvir-list@redhat.com, kraxel@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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: 1625583282108100003 Content-Type: text/plain; charset="utf-8" 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. Signed-off-by: Thomas Huth --- 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 8965dabc83..144afad8d1 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -1784,7 +1784,7 @@ DEF("display", HAS_ARG, QEMU_OPTION_display, #endif #if defined(CONFIG_SDL) "-display sdl[,alt_grab=3Don|off][,ctrl_grab=3Don|off][,gl=3Don|core|e= s|off]\n" - " [,show-cursor=3Don|off][,window-close=3Don|off]\n" + " [,grab-mod=3D][,show-cursor=3Don|off][,window-close= =3Don|off]\n" #endif #if defined(CONFIG_GTK) "-display gtk[,full-screen=3Don|off][,gl=3Don|off][,grab-on-hover=3Don= |off]\n" @@ -1830,6 +1830,10 @@ SRST window; see the SDL documentation for other possibilities). Valid parameters are: =20 + ``grab-mod=3D`` : Used to select the modifier keys for toggl= ing + the mouse grabbing in conjunction with the "g" key. `` can be + either `lshift-lctrl-lalt` or `rctrl`. + ``alt_grab=3Don|off`` : Use Control+Alt+Shift-g to toggle mouse gr= abbing =20 ``ctrl_grab=3Don|off`` : Use Right-Control-g to toggle mouse grabb= ing diff --git a/softmmu/vl.c b/softmmu/vl.c index a50c8575a1..506b88b1a2 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -1013,15 +1013,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 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; =20 - if (strstart(opts, ",alt_grab=3D", &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, ",alt_grab=3D", &nextopt)) { opts =3D nextopt; if (strstart(opts, "on", &nextopt)) { alt_grab =3D 1; --=20 2.27.0