From nobody Fri May 17 11:58:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=mnus.de ARC-Seal: i=1; a=rsa-sha256; t=1612817271; cv=none; d=zohomail.com; s=zohoarc; b=bZdC3dBWgmuuZQWul0g4089WepSunL7SkSw56IJ5AYRmxwEkG1aue6uBdVfz224HHKqaYI5YNVzyanzPYXHO36Nq6umnz81x3ia4zkv+z1uA07cTzHhj0mme0l+096+/UWrkMVbk/zdU4iVCOq5YBl24Y9kFU0o/BJeygmgHYKM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612817271; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=tctGHU32T55MwkvIlqTCVuNjsnqpw09a42lIhbCoodU=; b=QFyylJRqoid2b9X8chK8+Ss0g1ZSTyVMvSHdmyyQ5B4Dg/nVVM3Mf5K/V+6+GjoaZ3AaBoCupnMkr4hs19neg5L254IG+d3jQDy8gprFfivhtuCFiXS3GNLGx/7wdOoM3U/rhVwMOIRT/xePmqJwNdjTLuMM5KzWwdSm7xy0scY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1612817270874660.5074204372612; Mon, 8 Feb 2021 12:47:50 -0800 (PST) Received: from localhost ([::1]:57284 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l9DRl-00057C-NA for importer@patchew.org; Mon, 08 Feb 2021 15:47:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:55428) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l97MX-0008BZ-Un; Mon, 08 Feb 2021 09:18:07 -0500 Received: from zeus.servers.mnus.de ([78.47.191.162]:42258) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l97ME-0006Aa-IZ; Mon, 08 Feb 2021 09:17:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mnus.de; s=mnus.de-helios; t=1612793846; bh=qzLztpuyPxzVmWfrBGfohC9xbS0SByUsKqUn35YWEFM=; h=From:To:Cc:Subject:Date; b=ZcWWdu12YcGGu+HDNteOSvsYJ2VVOhROGaS5bPNzK+qSnNPdWCrZo9AYE2GfuOvQN +a7aAIQxQ7bvJ8ZxeuAaLY2dSIkM8HFpJa/afLb/8qkdCsq7mbuChD6abvLNdvWLqc fM3Dw33VxBrilz9rYKW/5SOzEGYkK2nPfnwxhHRdmnTT49zrLyov7mxMD+vbv0kgD5 V9cd/zjKMXeWElRSYYv6dOfDj7U5AqNJcklyqZWgM6j1BORMmZ6ZpfPLSlR9NNSDm0 40a51OUZfLTPoLoCa9YWpdj6svpD6YbVTbxVkSAcUt43ig8x7LnmnJqkht0X9rlVUk rtqL+tmJ8HBrhsKcBSVnu+U49qLcd6wrSse4UHT4fpzqSvhWyJEc64j7HpJ9jKlSaU qeCpQeg11IZnOhT+dV346GbBoLw3CtHloIc8kph636XabEX76w+7iGfptxmBVkSVfB W5AE17RogUMgyFfbhly2X3HNArWCpwII2+pqYP1HFU6/FpUtBClZuboAxeZ2NDxZyd hk+oVKcWmq+JcAo9wXTpn8r2RCrCNYM9d4dGHbIe7KFuIZ+qxW5vmKXteNG/tdXU5N gQ69wiqQT0/QyiCDj8c7eUTSZBS6nuTf/2Oae5/F0d1SDyQoZZ6L8mYz0rHhKjFU6O 5sAPPrfQUeoWHYoqfSer1p94= From: minus To: qemu-devel@nongnu.org Subject: [PATCH] input-linux: Make grabbing on start configurable Date: Mon, 8 Feb 2021 15:17:24 +0100 Message-Id: <20210208141724.58067-1-minus@mnus.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=78.47.191.162; envelope-from=minus@mnus.de; helo=zeus.servers.mnus.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Mon, 08 Feb 2021 09:34:37 -0500 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-trivial@nongnu.org, minus Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @mnus.de) Content-Type: text/plain; charset="utf-8" Setting grab_on_start=3Doff allows starting a VM on boot that shares the keyboard/mouse of the host but without grabbing it immediately. Signed-off-by: minus --- ui/input-linux.c | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/ui/input-linux.c b/ui/input-linux.c index 05c0c98819..c4f82eaa98 100644 --- a/ui/input-linux.c +++ b/ui/input-linux.c @@ -44,6 +44,7 @@ struct InputLinux { bool grab_request; bool grab_active; bool grab_all; + bool grab_on_start; bool keydown[KEY_CNT]; int keycount; int wheel; @@ -394,11 +395,13 @@ static void input_linux_complete(UserCreatable *uc, E= rror **errp) } =20 qemu_set_fd_handler(il->fd, input_linux_event, NULL, il); - if (il->keycount) { - /* delay grab until all keys are released */ - il->grab_request =3D true; - } else { - input_linux_toggle_grab(il); + if (il->grab_on_start) { + if (il->keycount) { + /* delay grab until all keys are released */ + il->grab_request =3D true; + } else { + input_linux_toggle_grab(il); + } } QTAILQ_INSERT_TAIL(&inputs, il, next); il->initialized =3D true; @@ -450,6 +453,21 @@ static bool input_linux_get_grab_all(Object *obj, Erro= r **errp) return il->grab_all; } =20 +static void input_linux_set_grab_on_start(Object *obj, bool value, + Error **errp) +{ + InputLinux *il =3D INPUT_LINUX(obj); + + il->grab_on_start =3D value; +} + +static bool input_linux_get_grab_on_start(Object *obj, Error **errp) +{ + InputLinux *il =3D INPUT_LINUX(obj); + + return il->grab_on_start; +} + static void input_linux_set_grab_all(Object *obj, bool value, Error **errp) { @@ -490,6 +508,9 @@ static void input_linux_set_grab_toggle(Object *obj, in= t value, =20 static void input_linux_instance_init(Object *obj) { + InputLinux *il =3D INPUT_LINUX(obj); + + il->grab_on_start =3D true; } =20 static void input_linux_class_init(ObjectClass *oc, void *data) @@ -504,6 +525,9 @@ static void input_linux_class_init(ObjectClass *oc, voi= d *data) object_class_property_add_bool(oc, "grab_all", input_linux_get_grab_all, input_linux_set_grab_all); + object_class_property_add_bool(oc, "grab_on_start", + input_linux_get_grab_on_start, + input_linux_set_grab_on_start); object_class_property_add_bool(oc, "repeat", input_linux_get_repeat, input_linux_set_repeat); --=20 2.30.0