From nobody Sun May 12 08:28:50 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 ARC-Seal: i=1; a=rsa-sha256; t=1710748798; cv=none; d=zohomail.com; s=zohoarc; b=EJjDtohHqqBohpMfCrSbpzM/cKGTZ80YD8dCDBlHp9teuASqswEFjqIk535OclK5R5P1H/uEh+nXhg9bLTeEdhsBX+hvQMswfdu7t2F/ATanhpWoNfKdOJj6VlkpiuVyl+t1E2GV/H0HbYIRhnwhoRouZFfNgQrrLlF0kCznPX0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710748798; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=bqiVcWk+QPelPVCWArv8qjPW16I407GHPXqES+lc6zE=; b=iWFZLcUfAQ6bz1JISlw2ZYdojEqfKSCTZlulWNevu7n8d3HniKIif50ddRi55tFFetv7Ego07lP2HhBSi7IP3XA1FksK/418oCbuPZCSYK85dHg5dprkV5zjOkU1S1qws62fggEK4Km7PTPIrPChitpHLdBIM2a8EHi/Rr13VFI= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1710748798034343.9974647856051; Mon, 18 Mar 2024 00:59:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rm7t6-0006Gy-S2; Mon, 18 Mar 2024 03:58:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rm7sX-00062v-Ij for qemu-devel@nongnu.org; Mon, 18 Mar 2024 03:57:53 -0400 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rm7sW-0000kS-7Q for qemu-devel@nongnu.org; Mon, 18 Mar 2024 03:57:53 -0400 Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-6e6adc557b6so3817435b3a.2 for ; Mon, 18 Mar 2024 00:57:51 -0700 (PDT) Received: from localhost ([157.82.200.213]) by smtp.gmail.com with UTF8SMTPSA id m24-20020a63f618000000b005e43cb66a7asm6652825pgh.87.2024.03.18.00.57.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 18 Mar 2024 00:57:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1710748670; x=1711353470; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=bqiVcWk+QPelPVCWArv8qjPW16I407GHPXqES+lc6zE=; b=u//WHzeKc6oGSu2/8I3ToM9iXnSR1OTiLhNsuq6zo9Nw2DfRR6duUUZiJCtOQ66lsf +7EIdW/EDGFlzunZGFoC86m94RZpAZgVTaH1NQk6Nq/UwdGfwRwprLJBZE+ZNr4ynxK6 BceEjVYgH0+cLjAPKhE7eZ+HxFZlKSJSdtRPl0dCbPePKJbT1Y2gYvtIOpygCHhxNA5x buMis4Wa5BpBPfL99y0y3kCdNTQ2m765w29V9SSenvy3NdSVzX3QfHNspAh6Tn+e5HqP 6VGO9+l0Ugr7IaGUSj2HSBzkehrlOvxbvWDS86ST0fpODSH/Ev7VuAzfKQEITISvGJTH Aw6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710748670; x=1711353470; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bqiVcWk+QPelPVCWArv8qjPW16I407GHPXqES+lc6zE=; b=FbnBxPmEaAUaLK2J0SQSzzQKCr5KuPIKuMsycceq6gX84JK0CLtf+SNz4igUKHi1XJ uuldZSWW8wJWIsYgixXN9IbJnCOOh1/qqyQ8zsnOGZaHQ3ffPrYQXefVV4EC+scvZ4Jn v94xaExBJy1ysroRjvVq9lSRG8y7JpOB3xve4VKJ9fTC8qcwhPG6hPsQEsVR9YDzQ4D2 8rxx9KCazDXk7KUcxC86cGENjQXaRS/7hCoboiL+3hvOniOS4BowxWe0jT3Sk8rJ6fLw mRU8lC4Thx4VU6bl2xu184veqZ5G7PXfQeygw44C4yUvdiOumfxNgbEVbnASxQyexAg2 I8OA== X-Gm-Message-State: AOJu0YzvOwA2dXwfSARJEbYvi4Jo4KkUprerU8aRi7JchcqClAqv41/o jdaxaWA5P19o5DTbIj5K/KuyPqYYZnMaqinAK5DYUybGFXpRxHE6JvlalM4/ASo= X-Google-Smtp-Source: AGHT+IFx4IOT08QmWZ798sWG1j7X/yo8oscEfc0l1dGvHIJ+plR7oN3ri1yHNyYjGFzikAyQjPCbwQ== X-Received: by 2002:aa7:9805:0:b0:6e6:f1f0:c55d with SMTP id e5-20020aa79805000000b006e6f1f0c55dmr11919650pfl.4.1710748670476; Mon, 18 Mar 2024 00:57:50 -0700 (PDT) From: Akihiko Odaki Date: Mon, 18 Mar 2024 16:57:42 +0900 Subject: [PATCH 1/4] ui/vc: Do not inherit the size of active console MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240318-console-v1-1-f4efbfa71253@daynix.com> References: <20240318-console-v1-0-f4efbfa71253@daynix.com> In-Reply-To: <20240318-console-v1-0-f4efbfa71253@daynix.com> To: Gerd Hoffmann , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Cc: qemu-devel@nongnu.org, Akihiko Odaki X-Mailer: b4 0.12.3 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: none client-ip=2607:f8b0:4864:20::430; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x430.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1710748799485100001 A chardev-vc used to inherit the size of a graphic console when its size not explicitly specified, but it often did not make sense. If a chardev-vc is instantiated during the startup, the active graphic console has no content at the time, so it will have the size of graphic console placeholder, which contains no useful information. It's better to have the standard size of text console instead. Signed-off-by: Akihiko Odaki Reviewed-by: Marc-Andr=C3=A9 Lureau --- ui/console-vc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/console-vc.c b/ui/console-vc.c index 9c13cc2981b0..f22c8e23c2ed 100644 --- a/ui/console-vc.c +++ b/ui/console-vc.c @@ -990,8 +990,8 @@ static void vc_chr_open(Chardev *chr, trace_console_txt_new(width, height); if (width =3D=3D 0 || height =3D=3D 0) { s =3D QEMU_TEXT_CONSOLE(object_new(TYPE_QEMU_TEXT_CONSOLE)); - width =3D qemu_console_get_width(NULL, 80 * FONT_WIDTH); - height =3D qemu_console_get_height(NULL, 24 * FONT_HEIGHT); + width =3D 80 * FONT_WIDTH; + height =3D 24 * FONT_HEIGHT; } else { s =3D QEMU_TEXT_CONSOLE(object_new(TYPE_QEMU_FIXED_TEXT_CONSOLE)); } --=20 2.44.0 From nobody Sun May 12 08:28:50 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 ARC-Seal: i=1; a=rsa-sha256; t=1710748703; cv=none; d=zohomail.com; s=zohoarc; b=J7BcJzl+mUaIqn8NwwtubsOxJQeSv6krmNIFq7CmIaD+NcQepEC0xefwl1WZfDhqp/vYnrxjXD7XdnjJuXQCLsMHVsS+fY0l1CfNfthyBCPqT1yCAnOy5NFdhwIe4OCRCJfWCInohB002tC0C18vtX8AnJdM/Z3uJovJWQP9lvY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710748703; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=hERtPiZgCeqACgFTci0jEGy9KY185zaVUTdb0UYq/LI=; b=kyB2wx7nqHJwUJ6gHLHg5t99Aa/yDQzm+2J3L/RTUWaWbWegOs/1GRXQl1rgntaKr0qdQQANY0iBlbL08V/qbeE6tvtyVWs2UOBdG7ptklTaWt1IxCLEmUwOBLh8oyXd/yrKmPCb6OLqJSdByfayW32+d//X2tdiAXmky+lyhdE= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1710748703885167.30704087771835; Mon, 18 Mar 2024 00:58:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rm7so-00069s-5H; Mon, 18 Mar 2024 03:58:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rm7sa-00064d-Ra for qemu-devel@nongnu.org; Mon, 18 Mar 2024 03:57:57 -0400 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rm7sZ-0000l4-5P for qemu-devel@nongnu.org; Mon, 18 Mar 2024 03:57:56 -0400 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-6e6f69e850bso2893755b3a.0 for ; Mon, 18 Mar 2024 00:57:54 -0700 (PDT) Received: from localhost ([157.82.200.213]) by smtp.gmail.com with UTF8SMTPSA id u15-20020a63df0f000000b005dbed0ffb10sm6573214pgg.83.2024.03.18.00.57.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 18 Mar 2024 00:57:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1710748674; x=1711353474; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=hERtPiZgCeqACgFTci0jEGy9KY185zaVUTdb0UYq/LI=; b=wgcqECFGkvn1X+SakINuKJKrVeNKvYvuSCXCb85HfqYdAp8skajr2dqvouWSVn0LZh TpdEb/hAN4F8Asx7Y8KhknH7Bk53ICwm7ukBNx6qdYYOgsFj/Yfle9mVKfeVjj0BQoXw 9Nb7B39dK7LzTXdiVDOYEzGGFzv6L92aj2Z4Pb3e59N5LprqAexHXW+WAk1kFGwP0Lv3 vXQmJMCwG+r99EDimf9Dtq1jz3mX6IZ/lUFre7OaKbQBiNhJX36Qr7m2GgPls+3p9zYK QYuaKq5Fnr8JDnhWqkyofPavI1ZveSSxGZIkdVoQnCxwrqhkXKPFF0dqP4UAqZKFUu/N hwJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710748674; x=1711353474; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hERtPiZgCeqACgFTci0jEGy9KY185zaVUTdb0UYq/LI=; b=wJ51TsD2F5IJZ/1FPt8QMPTFV2TOffdOJTbda6xrJ3VrAxCvemZaSXlylXlM7NLYwT nB1eSzCO7zBQS93b2+7G3s0C8G1yp1fp3yCmHlInq+Gr3pKAazZfqVjzZkOwBMupvnVt Xs7Qg4dBtr08l2dmEnM0Da7pJyOlvhifFMyNKGeX1P5Tn3VEsRjDRVNv5zGwZRk20H7T mh1j5nvr8CD4SGu6Rk0dyF4N8GaBZMlLNTC/8tWb1eZ0t8BTDvCcpUMYoGyoOpB9B7kC /4IfRLb+HaBMDM1yn4ZADmeINHhKQ9F9hLSzSeoJ+92uzcuwYSWZOuywx1Fweu2rQ9LN lx7w== X-Gm-Message-State: AOJu0Yyu8Bak9tmQKw2jBlTGjsZpvTphOnAeSlp7nWSm22MVjwSEwoRq 8FSa6hkbsIpRdAOe3i8YnL7UcjHJfAIkmu3od1hLAVuqXcKI1zP4a33yKTjzo7k= X-Google-Smtp-Source: AGHT+IE2+CRh8fZhFysClsHWHIDlF9xzJxTRNb3mcjStZAHPSzrQm0kIH7bk2o0M459oS2rKvM84Qw== X-Received: by 2002:a05:6a00:816:b0:6e7:2018:aabd with SMTP id m22-20020a056a00081600b006e72018aabdmr4532133pfk.8.1710748673691; Mon, 18 Mar 2024 00:57:53 -0700 (PDT) From: Akihiko Odaki Date: Mon, 18 Mar 2024 16:57:43 +0900 Subject: [PATCH 2/4] ui/vnc: Do not use console_select() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240318-console-v1-2-f4efbfa71253@daynix.com> References: <20240318-console-v1-0-f4efbfa71253@daynix.com> In-Reply-To: <20240318-console-v1-0-f4efbfa71253@daynix.com> To: Gerd Hoffmann , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Cc: qemu-devel@nongnu.org, Akihiko Odaki X-Mailer: b4 0.12.3 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: none client-ip=2607:f8b0:4864:20::434; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x434.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1710748705179100001 console_select() is shared by other displays and a console_select() call from one of them triggers console switching also in ui/curses, circumventing key state reinitialization that needs to be performed in preparation and resulting in stuck keys. Use its internal state to track the current active console to prevent such a surprise console switch. Signed-off-by: Akihiko Odaki --- include/ui/console.h | 1 + include/ui/kbd-state.h | 11 +++++++++++ ui/console.c | 12 ++++++++++++ ui/kbd-state.c | 6 ++++++ ui/vnc.c | 14 +++++++++----- 5 files changed, 39 insertions(+), 5 deletions(-) diff --git a/include/ui/console.h b/include/ui/console.h index a4a49ffc640c..a703f7466499 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -413,6 +413,7 @@ void qemu_console_early_init(void); =20 void qemu_console_set_display_gl_ctx(QemuConsole *con, DisplayGLCtx *ctx); =20 +QemuConsole *qemu_console_lookup_first_graphic_console(void); QemuConsole *qemu_console_lookup_by_index(unsigned int index); QemuConsole *qemu_console_lookup_by_device(DeviceState *dev, uint32_t head= ); QemuConsole *qemu_console_lookup_by_device_name(const char *device_id, diff --git a/include/ui/kbd-state.h b/include/ui/kbd-state.h index fb79776128cf..1f37b932eb62 100644 --- a/include/ui/kbd-state.h +++ b/include/ui/kbd-state.h @@ -99,4 +99,15 @@ bool qkbd_state_modifier_get(QKbdState *kbd, QKbdModifie= r mod); */ void qkbd_state_lift_all_keys(QKbdState *kbd); =20 +/** + * qkbd_state_switch_console: Switch console. + * + * This sends key up events to the previous console for all keys which are= in + * down state to prevent keys being stuck, and remembers the new console. + * + * @kbd: state tracker state. + * @con: new QemuConsole for this state tracker. + */ +void qkbd_state_switch_console(QKbdState *kbd, QemuConsole *con); + #endif /* QEMU_UI_KBD_STATE_H */ diff --git a/ui/console.c b/ui/console.c index 832055675c50..6bf02a23414c 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1325,6 +1325,18 @@ void graphic_console_close(QemuConsole *con) dpy_gfx_replace_surface(con, surface); } =20 +QemuConsole *qemu_console_lookup_first_graphic_console(void) +{ + QemuConsole *con; + + QTAILQ_FOREACH(con, &consoles, next) { + if (QEMU_IS_GRAPHIC_CONSOLE(con)) { + return con; + } + } + return NULL; +} + QemuConsole *qemu_console_lookup_by_index(unsigned int index) { QemuConsole *con; diff --git a/ui/kbd-state.c b/ui/kbd-state.c index 62d42a7a22e1..52ed28b8a89b 100644 --- a/ui/kbd-state.c +++ b/ui/kbd-state.c @@ -117,6 +117,12 @@ void qkbd_state_lift_all_keys(QKbdState *kbd) } } =20 +void qkbd_state_switch_console(QKbdState *kbd, QemuConsole *con) +{ + qkbd_state_lift_all_keys(kbd); + kbd->con =3D con; +} + void qkbd_state_set_delay(QKbdState *kbd, int delay_ms) { kbd->key_delay_ms =3D delay_ms; diff --git a/ui/vnc.c b/ui/vnc.c index fc12b343e254..94564b196ba8 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -1872,12 +1872,16 @@ static void do_key_event(VncState *vs, int down, in= t keycode, int sym) /* QEMU console switch */ switch (qcode) { case Q_KEY_CODE_1 ... Q_KEY_CODE_9: /* '1' to '9' keys */ - if (vs->vd->dcl.con =3D=3D NULL && down && + if (down && qkbd_state_modifier_get(vs->vd->kbd, QKBD_MOD_CTRL) && qkbd_state_modifier_get(vs->vd->kbd, QKBD_MOD_ALT)) { - /* Reset the modifiers sent to the current console */ - qkbd_state_lift_all_keys(vs->vd->kbd); - console_select(qcode - Q_KEY_CODE_1); + QemuConsole *con =3D qemu_console_lookup_by_index(qcode - Q_KE= Y_CODE_1); + if (con) { + unregister_displaychangelistener(&vs->vd->dcl); + qkbd_state_switch_console(vs->vd->kbd, con); + vs->vd->dcl.con =3D con; + register_displaychangelistener(&vs->vd->dcl); + } return; } default: @@ -4206,7 +4210,7 @@ void vnc_display_open(const char *id, Error **errp) goto fail; } } else { - con =3D NULL; + con =3D qemu_console_lookup_first_graphic_console(); } =20 if (con !=3D vd->dcl.con) { --=20 2.44.0 From nobody Sun May 12 08:28:50 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 ARC-Seal: i=1; a=rsa-sha256; t=1710748771; cv=none; d=zohomail.com; s=zohoarc; b=Pdor4sTp/clYG4qZ+gxo61LsxN9rczXFejR6WtRkS+kyEC9PhzfS+LGWbcE+GhxubShSqDUZrgqqi/YnNE15EYuDch0Tz3pd4XNSqzkc58E0MrzLjIabGCtnOocBFhjbww8x0rrS3Zhr+mmtK3PFW33cffPB0c/ZYfDpQiwBd7A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710748771; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=uHUi8VqTqgVwPhjWq614prpGtXiT8mHXsyIaQigbWrM=; b=NvYMWekb5FhR8ISFE2McZMpQx16+ccvG2yTUnVcq1mw8ZzvRTef6xaciQVAdGFul7n0uFMp4vUeuR6DeN739HQ6lAiy6J69QNW3JUNq2LwSKlQ/pboB+Dq6fExlKQ4V9jdMFEhHSv9AM54i35qO/tNFlABiIFl1TV5+hgQScoGs= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1710748771501238.26269030541118; Mon, 18 Mar 2024 00:59:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rm7tB-0006IO-IX; Mon, 18 Mar 2024 03:58:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rm7sf-00066S-0i for qemu-devel@nongnu.org; Mon, 18 Mar 2024 03:58:02 -0400 Received: from mail-oi1-x22f.google.com ([2607:f8b0:4864:20::22f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rm7sd-0000ml-Ac for qemu-devel@nongnu.org; Mon, 18 Mar 2024 03:58:00 -0400 Received: by mail-oi1-x22f.google.com with SMTP id 5614622812f47-3c38855957cso603616b6e.3 for ; Mon, 18 Mar 2024 00:57:57 -0700 (PDT) Received: from localhost ([157.82.200.213]) by smtp.gmail.com with UTF8SMTPSA id gx20-20020a056a001e1400b006e6bcbccda9sm7300248pfb.59.2024.03.18.00.57.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 18 Mar 2024 00:57:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1710748677; x=1711353477; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=uHUi8VqTqgVwPhjWq614prpGtXiT8mHXsyIaQigbWrM=; b=ZgePFq21zbEmeCN3PGzoUsZOehgFOjeWXEQGQpjWBjT2kkgT2CeR9gHUr+ULASATsT TGjjtoJfm6OBCy1vE/65rAhqG/NCFyle6ahFbG9lO3uxdzC5zJDmyRacrjK01D03T6Ht a7B58U0ferwnTq5zyAFv/puazD61trTSMImhVSMlkv/udc40yQScMb/N0BKXm3o3t99R iDXVzK2pjd8oHKnWwyiu/7+owSfWS8cIPz6i7sJbtR02xVo/y8Vz+BAAO5Tndmw2ANE9 tSsuDMOA33HtsL/xEjXcQajq8Z7SrCxUjlUOF4mYY0pK9V5qJGqa9F7S90/SDnlkGVV+ fK9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710748677; x=1711353477; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uHUi8VqTqgVwPhjWq614prpGtXiT8mHXsyIaQigbWrM=; b=KW6GoqsyofEKSuiRx/AcM1D3PKXk0Lksg0sd2RpkJ4ha5zzqnnl8BUL4ODt+Ah60Fm 8bglbi3TtmbSe/DpobvINy1QoFxiQWtNKKRevgERdiJoRtiHQN2oj3Oz4Zk+EdEBkWFU 1HPV87nD7zqy0/effkWWPdE64ONXYMt50yK88MQzqxttvbsdHmfuJrZrrghGJJxOS0ul J8JQsNVOzZimat3wObAykUtJBla1Mtwx3kQGD8hKCqmWJqAbWzOcxbxPUMlxewnHN4IN Ejzh7goFQm1lVpJKR9e96CxtPYCf9tlWU0yNRzhPOpb59rDQNfGSdifUz2cPt9kWacEc bQew== X-Gm-Message-State: AOJu0YwjKclL7NEmCI8Y0oTDAZvlZ8jtO6HVE3s2jTxRSsyR+KYVoqGn BUQOf5Jo71YbiAou5RloHuJ8356Iu6t+CbQpSI1519O8FhdteS6sQtvk7HAmPNc= X-Google-Smtp-Source: AGHT+IHv6VkosOe3kWs3HfNVldDGy6WkoHSWeeGJa9eSDqER0gBAqg2ws1JJCJRQIF05TspdaRC97A== X-Received: by 2002:a05:6808:f93:b0:3c3:84cc:fd6c with SMTP id o19-20020a0568080f9300b003c384ccfd6cmr4040380oiw.3.1710748677009; Mon, 18 Mar 2024 00:57:57 -0700 (PDT) From: Akihiko Odaki Date: Mon, 18 Mar 2024 16:57:44 +0900 Subject: [PATCH 3/4] ui/cocoa: Do not use console_select() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240318-console-v1-3-f4efbfa71253@daynix.com> References: <20240318-console-v1-0-f4efbfa71253@daynix.com> In-Reply-To: <20240318-console-v1-0-f4efbfa71253@daynix.com> To: Gerd Hoffmann , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Cc: qemu-devel@nongnu.org, Akihiko Odaki X-Mailer: b4 0.12.3 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: none client-ip=2607:f8b0:4864:20::22f; envelope-from=akihiko.odaki@daynix.com; helo=mail-oi1-x22f.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1710748773424100001 ui/cocoa needs to update the UI info and reset the keyboard state tracker when switching the console, or the new console will see the stale UI info or keyboard state. Previously, updating the UI info was done with cocoa_switch(), but it is meant to be called when the surface is being replaced, and may be called even when not switching the console. ui/cocoa never reset the keyboard state, which resulted in stuck keys. Add ui/cocoa's own implementation of console_select(), which updates the UI info and resets the keyboard state tracker. Signed-off-by: Akihiko Odaki --- ui/cocoa.m | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index fa879d7dcd4b..47280c0a93be 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -102,6 +102,7 @@ static void cocoa_switch(DisplayChangeListener *dcl, static DisplayChangeListener dcl =3D { .ops =3D &dcl_ops, }; +static QKbdState *kbd; static int cursor_hide =3D 1; static int left_command_key_enabled =3D 1; static bool swap_opt_cmd; @@ -309,7 +310,6 @@ @interface QemuCocoaView : NSView NSTrackingArea *trackingArea; QEMUScreen screen; pixman_image_t *pixman_image; - QKbdState *kbd; BOOL isMouseGrabbed; BOOL isAbsoluteEnabled; CFMachPortRef eventsTap; @@ -361,7 +361,6 @@ - (id)initWithFrame:(NSRect)frameRect =20 screen.width =3D frameRect.size.width; screen.height =3D frameRect.size.height; - kbd =3D qkbd_state_init(dcl.con); #if MAC_OS_X_VERSION_MAX_ALLOWED >=3D MAC_OS_VERSION_14_0 [self setClipsToBounds:YES]; #endif @@ -378,8 +377,6 @@ - (void) dealloc pixman_image_unref(pixman_image); } =20 - qkbd_state_free(kbd); - if (eventsTap) { CFRelease(eventsTap); } @@ -429,6 +426,20 @@ - (void) viewWillMoveToWindow:(NSWindow *)newWindow [self removeTrackingRect]; } =20 +- (void) selectConsoleLocked:(unsigned int)index +{ + QemuConsole *con =3D qemu_console_lookup_by_index(index); + if (!con) { + return; + } + + unregister_displaychangelistener(&dcl); + qkbd_state_switch_console(kbd, con); + dcl.con =3D con; + register_displaychangelistener(&dcl); + [self updateUIInfo]; +} + - (void) hideCursor { if (!cursor_hide) { @@ -718,7 +729,8 @@ - (void) handleMonitorInput:(NSEvent *)event } =20 if (keysym) { - qemu_text_console_put_keysym(NULL, keysym); + QemuTextConsole *con =3D QEMU_TEXT_CONSOLE(dcl.con); + qemu_text_console_put_keysym(con, keysym); } } =20 @@ -898,7 +910,7 @@ - (bool) handleEventLocked:(NSEvent *)event =20 // enable graphic console case '1' ... '9': - console_select(key - '0' - 1); /* ascii math */ + [self selectConsoleLocked:key - '0' - 1]; /* a= scii math */ return true; =20 // release the mouse grab @@ -909,7 +921,7 @@ - (bool) handleEventLocked:(NSEvent *)event } } =20 - if (qemu_console_is_graphic(NULL)) { + if (qemu_console_is_graphic(dcl.con)) { qkbd_state_key_event(kbd, keycode, true); } else { [self handleMonitorInput: event]; @@ -924,7 +936,7 @@ - (bool) handleEventLocked:(NSEvent *)event return true; } =20 - if (qemu_console_is_graphic(NULL)) { + if (qemu_console_is_graphic(dcl.con)) { qkbd_state_key_event(kbd, keycode, false); } return true; @@ -1374,7 +1386,7 @@ - (void)toggleZoomInterpolation:(id) sender - (void)displayConsole:(id)sender { with_bql(^{ - console_select([sender tag]); + [cocoaView selectConsoleLocked:[sender tag]]; }); } =20 @@ -1945,7 +1957,6 @@ static void cocoa_switch(DisplayChangeListener *dcl, pixman_image_ref(image); =20 dispatch_async(dispatch_get_main_queue(), ^{ - [cocoaView updateUIInfo]; [cocoaView switchSurface:image]; }); } @@ -1955,7 +1966,7 @@ static void cocoa_refresh(DisplayChangeListener *dcl) NSAutoreleasePool * pool =3D [[NSAutoreleasePool alloc] init]; =20 COCOA_DEBUG("qemu_cocoa: cocoa_refresh\n"); - graphic_hw_update(NULL); + graphic_hw_update(dcl->con); =20 if (qemu_input_is_absolute(dcl->con)) { dispatch_async(dispatch_get_main_queue(), ^{ @@ -2039,8 +2050,12 @@ static void cocoa_display_init(DisplayState *ds, Dis= playOptions *opts) add_console_menu_entries(); addRemovableDevicesMenuItems(); =20 + dcl.con =3D qemu_console_lookup_first_graphic_console(); + kbd =3D qkbd_state_init(dcl.con); + // register vga output callbacks register_displaychangelistener(&dcl); + [cocoaView updateUIInfo]; =20 qemu_event_init(&cbevent, false); cbowner =3D [[QemuCocoaPasteboardTypeOwner alloc] init]; --=20 2.44.0 From nobody Sun May 12 08:28:50 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 ARC-Seal: i=1; a=rsa-sha256; t=1710748792; cv=none; d=zohomail.com; s=zohoarc; b=R2LLmagv4C87jkxHrhoo/z6JoerLgqmTIyo+yy6tCNLmArytooQn4P0PFNyDNGhKY+wXv5kkGf8z/qzx+wg0+N1R2u0/fAcmR5ZGjtFcyFcPuAyqHmwxq8lNrU214m5FyjGqNgBMX4Xgs939itCm2LlO7seZAdmg87tWxhTV24M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710748792; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=T9xfBrRqDuONd9lto5ZppprYHRr0SaQCj6soj7/vPPg=; b=IXnEmlTlSs3xNuP7MicN57ICB62DYsVBwt/Du/CLflMkk3ce6xjWsUUhQyiL01VDtcQVbszBu22om3wobjCZbht0MFTw4so/9vsyPqdWQ3xElOVXmCXsgIOrjZaeNeywTLsiRkE0Ga2eN1E7vM5IEJo5Ms7xFHkWh9eMgcULSmc= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1710748792166535.0448899199077; Mon, 18 Mar 2024 00:59:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rm7tH-0006L7-C2; Mon, 18 Mar 2024 03:58:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rm7si-000694-Mc for qemu-devel@nongnu.org; Mon, 18 Mar 2024 03:58:05 -0400 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rm7sf-0000n1-UH for qemu-devel@nongnu.org; Mon, 18 Mar 2024 03:58:04 -0400 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1e0189323b4so5783315ad.1 for ; Mon, 18 Mar 2024 00:58:01 -0700 (PDT) Received: from localhost ([157.82.200.213]) by smtp.gmail.com with UTF8SMTPSA id b10-20020a170903228a00b001e026392e9csm1389153plh.51.2024.03.18.00.57.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 18 Mar 2024 00:58:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1710748680; x=1711353480; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=T9xfBrRqDuONd9lto5ZppprYHRr0SaQCj6soj7/vPPg=; b=VFZXTa6reEfMawylPmkNjKJcV18uVa/XVMGWLbhK1nCCZ2Fu/HHtngqVpBmUoR+6XR 2M8Wtqw2w1OUn+rAWrld9kIavgExzEwIfHpWmY1epbTzQXDU5MdaEieJV8Sb7Q+v0ytw sAHbfUCG/UlbLtQSkHm9AJ7V9W6aVHYAElElyQTbHrp+fKjdPJ7nZl3fLEnZJXRHswdl o3XpcyeYTEz/pqzGD5EUcba2neuYVM/xsaodNnlsN/0ZHuoAYPf718UxyjwDduQCDNyD k2E3aegLDQxY0pugQCEPCRyr3e4cHx8Coko8xHZK31hoQNWblHMIvd/A2rl2oVf03rAQ nb0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710748680; x=1711353480; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=T9xfBrRqDuONd9lto5ZppprYHRr0SaQCj6soj7/vPPg=; b=R8dsbGcNlraI2oLKxOJ9KL9qto3MRkqUs362DkG+kTka57GkRF3jnzvqOxT7emxaME zSWLLXJoJUfGCc7KaY8BEJHz/DFSvF+UaE7lVtGtLod/B8AT0vT+C6jKL52ntp8uJT8Q VIjAIjRhlPxUgcdexT/k5W1uLxedzNhLyGgqlPwzPDoyIrQ1QhGBZkVgOEBMmqYz4dmF q7cv0NyNofPBpIqq1rB6qufLWmGNmE1oCNfDD4cszqk10TZWPsDWqMolUSKSLmPN3awL xic8QuP5d0uh1tT1RM39U3AgzcC4MaMWk9PHKTb0KSm/+ijSXvgqOS/6Ndrg01Ks4nbI 69VA== X-Gm-Message-State: AOJu0Yzz9oS0STZW8iV+mpl3CUSBANkA+PefUO/uwtAjxf64CwjX/crK 0ncIQecOMek0mLz+Rrlc8PwoOQ/LE2LLE4d83abF1N1svjouj6fgX1Oiv7b+Okw= X-Google-Smtp-Source: AGHT+IECw4fLZdAt/yp77iKtA4NEdrQbQXl7L7FP8NCDOTIzGqaF3nYxmNmPR4nQWhC5sMuWvXXl9g== X-Received: by 2002:a17:903:124b:b0:1dd:d0e4:23fd with SMTP id u11-20020a170903124b00b001ddd0e423fdmr13204342plh.43.1710748680442; Mon, 18 Mar 2024 00:58:00 -0700 (PDT) From: Akihiko Odaki Date: Mon, 18 Mar 2024 16:57:45 +0900 Subject: [PATCH 4/4] ui/curses: Do not use console_select() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240318-console-v1-4-f4efbfa71253@daynix.com> References: <20240318-console-v1-0-f4efbfa71253@daynix.com> In-Reply-To: <20240318-console-v1-0-f4efbfa71253@daynix.com> To: Gerd Hoffmann , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Cc: qemu-devel@nongnu.org, Akihiko Odaki X-Mailer: b4 0.12.3 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: none client-ip=2607:f8b0:4864:20::62d; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x62d.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1710748793510100001 ui/curses is the only user of console_select(). Move the implementation to ui/curses. Signed-off-by: Akihiko Odaki --- include/ui/console.h | 1 - ui/console-priv.h | 2 +- ui/console-vc-stubs.c | 2 +- ui/console-vc.c | 3 +- ui/console.c | 121 +++++++++-------------------------------------= ---- ui/curses.c | 48 +++++++++++--------- 6 files changed, 51 insertions(+), 126 deletions(-) diff --git a/include/ui/console.h b/include/ui/console.h index a703f7466499..3769179e3b2b 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -433,7 +433,6 @@ int qemu_console_get_window_id(QemuConsole *con); /* Set the low-level window id for the console */ void qemu_console_set_window_id(QemuConsole *con, int window_id); =20 -void console_select(unsigned int index); void qemu_console_resize(QemuConsole *con, int width, int height); DisplaySurface *qemu_console_surface(QemuConsole *con); void coroutine_fn qemu_console_co_wait_update(QemuConsole *con); diff --git a/ui/console-priv.h b/ui/console-priv.h index 88569ed2cc41..43ceb8122f13 100644 --- a/ui/console-priv.h +++ b/ui/console-priv.h @@ -35,7 +35,7 @@ struct QemuConsole { QTAILQ_ENTRY(QemuConsole) next; }; =20 -void qemu_text_console_select(QemuTextConsole *c); +void qemu_text_console_update_size(QemuTextConsole *c); const char * qemu_text_console_get_label(QemuTextConsole *c); void qemu_text_console_update_cursor(void); void qemu_text_console_handle_keysym(QemuTextConsole *s, int keysym); diff --git a/ui/console-vc-stubs.c b/ui/console-vc-stubs.c index 2afc52329f0c..b63e2fb2345f 100644 --- a/ui/console-vc-stubs.c +++ b/ui/console-vc-stubs.c @@ -10,7 +10,7 @@ #include "chardev/char.h" #include "ui/console-priv.h" =20 -void qemu_text_console_select(QemuTextConsole *c) +void qemu_text_console_update_size(QemuTextConsole *c) { } =20 diff --git a/ui/console-vc.c b/ui/console-vc.c index f22c8e23c2ed..899fa11c9485 100644 --- a/ui/console-vc.c +++ b/ui/console-vc.c @@ -958,10 +958,9 @@ static void vc_chr_set_echo(Chardev *chr, bool echo) drv->console->echo =3D echo; } =20 -void qemu_text_console_select(QemuTextConsole *c) +void qemu_text_console_update_size(QemuTextConsole *c) { dpy_text_resize(QEMU_CONSOLE(c), c->width, c->height); - qemu_text_console_update_cursor(); } =20 static void vc_chr_open(Chardev *chr, diff --git a/ui/console.c b/ui/console.c index 6bf02a23414c..d77f509046af 100644 --- a/ui/console.c +++ b/ui/console.c @@ -66,7 +66,6 @@ struct DisplayState { }; =20 static DisplayState *display_state; -static QemuConsole *active_console; static QTAILQ_HEAD(, QemuConsole) consoles =3D QTAILQ_HEAD_INITIALIZER(consoles); =20 @@ -135,7 +134,6 @@ void graphic_hw_update_done(QemuConsole *con) void graphic_hw_update(QemuConsole *con) { bool async =3D false; - con =3D con ? con : active_console; if (!con) { return; } @@ -209,9 +207,6 @@ void qemu_console_set_window_id(QemuConsole *con, int w= indow_id) =20 void graphic_hw_invalidate(QemuConsole *con) { - if (!con) { - con =3D active_console; - } if (con && con->hw_ops->invalidate) { con->hw_ops->invalidate(con->hw); } @@ -219,9 +214,6 @@ void graphic_hw_invalidate(QemuConsole *con) =20 void graphic_hw_text_update(QemuConsole *con, console_ch_t *chardata) { - if (!con) { - con =3D active_console; - } if (con && con->hw_ops->text_update) { con->hw_ops->text_update(con->hw, chardata); } @@ -265,12 +257,12 @@ static void dpy_gfx_update_texture(QemuConsole *con, = DisplaySurface *surface, } =20 static void displaychangelistener_display_console(DisplayChangeListener *d= cl, - QemuConsole *con, Error **errp) { static const char nodev[] =3D "This VM has no graphic display device."; static DisplaySurface *dummy; + QemuConsole *con =3D dcl->con; =20 if (!con || !console_compatible_with(con, dcl, errp)) { if (!dummy) { @@ -305,39 +297,8 @@ static void displaychangelistener_display_console(Disp= layChangeListener *dcl, } } =20 -void console_select(unsigned int index) -{ - DisplayChangeListener *dcl; - QemuConsole *s; - - trace_console_select(index); - s =3D qemu_console_lookup_by_index(index); - if (s) { - DisplayState *ds =3D s->ds; - - active_console =3D s; - QLIST_FOREACH (dcl, &ds->listeners, next) { - if (dcl->con !=3D NULL) { - continue; - } - displaychangelistener_display_console(dcl, s, NULL); - } - - if (QEMU_IS_TEXT_CONSOLE(s)) { - qemu_text_console_select(QEMU_TEXT_CONSOLE(s)); - } - } -} - void qemu_text_console_put_keysym(QemuTextConsole *s, int keysym) { - if (!s) { - if (!QEMU_IS_TEXT_CONSOLE(active_console)) { - return; - } - s =3D QEMU_TEXT_CONSOLE(active_console); - } - qemu_text_console_handle_keysym(s, keysym); } =20 @@ -392,11 +353,6 @@ qemu_console_register(QemuConsole *c) { int i; =20 - if (!active_console || (!QEMU_IS_GRAPHIC_CONSOLE(active_console) && - QEMU_IS_GRAPHIC_CONSOLE(c))) { - active_console =3D c; - } - if (QTAILQ_EMPTY(&consoles)) { c->index =3D 0; QTAILQ_INSERT_TAIL(&consoles, c, next); @@ -751,8 +707,6 @@ dcl_set_graphic_cursor(DisplayChangeListener *dcl, Qemu= GraphicConsole *con) =20 void register_displaychangelistener(DisplayChangeListener *dcl) { - QemuConsole *con; - assert(!dcl->ds); =20 trace_displaychangelistener_register(dcl, dcl->ops->dpy_name); @@ -761,13 +715,12 @@ void register_displaychangelistener(DisplayChangeList= ener *dcl) gui_setup_refresh(dcl->ds); if (dcl->con) { dcl->con->dcls++; - con =3D dcl->con; - } else { - con =3D active_console; } - displaychangelistener_display_console(dcl, con, dcl->con ? &error_fata= l : NULL); - if (QEMU_IS_GRAPHIC_CONSOLE(con)) { - dcl_set_graphic_cursor(dcl, QEMU_GRAPHIC_CONSOLE(con)); + displaychangelistener_display_console(dcl, &error_fatal); + if (QEMU_IS_GRAPHIC_CONSOLE(dcl->con)) { + dcl_set_graphic_cursor(dcl, QEMU_GRAPHIC_CONSOLE(dcl->con)); + } else if (QEMU_IS_TEXT_CONSOLE(dcl->con)) { + qemu_text_console_update_size(QEMU_TEXT_CONSOLE(dcl->con)); } qemu_text_console_update_cursor(); } @@ -805,9 +758,6 @@ static void dpy_set_ui_info_timer(void *opaque) =20 bool dpy_ui_info_supported(const QemuConsole *con) { - if (con =3D=3D NULL) { - con =3D active_console; - } if (con =3D=3D NULL) { return false; } @@ -819,19 +769,11 @@ const QemuUIInfo *dpy_get_ui_info(const QemuConsole *= con) { assert(dpy_ui_info_supported(con)); =20 - if (con =3D=3D NULL) { - con =3D active_console; - } - return &con->ui_info; } =20 int dpy_set_ui_info(QemuConsole *con, QemuUIInfo *info, bool delay) { - if (con =3D=3D NULL) { - con =3D active_console; - } - if (!dpy_ui_info_supported(con)) { return -1; } @@ -870,7 +812,7 @@ void dpy_gfx_update(QemuConsole *con, int x, int y, int= w, int h) } dpy_gfx_update_texture(con, con->surface, x, y, w, h); QLIST_FOREACH(dcl, &s->listeners, next) { - if (con !=3D (dcl->con ? dcl->con : active_console)) { + if (con !=3D dcl->con) { continue; } if (dcl->ops->dpy_gfx_update) { @@ -916,7 +858,7 @@ void dpy_gfx_replace_surface(QemuConsole *con, con->surface =3D new_surface; dpy_gfx_create_texture(con, new_surface); QLIST_FOREACH(dcl, &s->listeners, next) { - if (con !=3D (dcl->con ? dcl->con : active_console)) { + if (con !=3D dcl->con) { continue; } displaychangelistener_gfx_switch(dcl, new_surface, surface ? FALSE= : TRUE); @@ -970,7 +912,7 @@ void dpy_text_cursor(QemuConsole *con, int x, int y) return; } QLIST_FOREACH(dcl, &s->listeners, next) { - if (con !=3D (dcl->con ? dcl->con : active_console)) { + if (con !=3D dcl->con) { continue; } if (dcl->ops->dpy_text_cursor) { @@ -988,7 +930,7 @@ void dpy_text_update(QemuConsole *con, int x, int y, in= t w, int h) return; } QLIST_FOREACH(dcl, &s->listeners, next) { - if (con !=3D (dcl->con ? dcl->con : active_console)) { + if (con !=3D dcl->con) { continue; } if (dcl->ops->dpy_text_update) { @@ -1006,7 +948,7 @@ void dpy_text_resize(QemuConsole *con, int w, int h) return; } QLIST_FOREACH(dcl, &s->listeners, next) { - if (con !=3D (dcl->con ? dcl->con : active_console)) { + if (con !=3D dcl->con) { continue; } if (dcl->ops->dpy_text_resize) { @@ -1028,7 +970,7 @@ void dpy_mouse_set(QemuConsole *c, int x, int y, int o= n) return; } QLIST_FOREACH(dcl, &s->listeners, next) { - if (c !=3D (dcl->con ? dcl->con : active_console)) { + if (c !=3D dcl->con) { continue; } if (dcl->ops->dpy_mouse_set) { @@ -1049,7 +991,7 @@ void dpy_cursor_define(QemuConsole *c, QEMUCursor *cur= sor) return; } QLIST_FOREACH(dcl, &s->listeners, next) { - if (c !=3D (dcl->con ? dcl->con : active_console)) { + if (c !=3D dcl->con) { continue; } if (dcl->ops->dpy_cursor_define) { @@ -1099,7 +1041,7 @@ void dpy_gl_scanout_disable(QemuConsole *con) con->scanout.kind =3D SCANOUT_NONE; } QLIST_FOREACH(dcl, &s->listeners, next) { - if (con !=3D (dcl->con ? dcl->con : active_console)) { + if (con !=3D dcl->con) { continue; } if (dcl->ops->dpy_gl_scanout_disable) { @@ -1126,7 +1068,7 @@ void dpy_gl_scanout_texture(QemuConsole *con, x, y, width, height, d3d_tex2d, }; QLIST_FOREACH(dcl, &s->listeners, next) { - if (con !=3D (dcl->con ? dcl->con : active_console)) { + if (con !=3D dcl->con) { continue; } if (dcl->ops->dpy_gl_scanout_texture) { @@ -1148,7 +1090,7 @@ void dpy_gl_scanout_dmabuf(QemuConsole *con, con->scanout.kind =3D SCANOUT_DMABUF; con->scanout.dmabuf =3D dmabuf; QLIST_FOREACH(dcl, &s->listeners, next) { - if (con !=3D (dcl->con ? dcl->con : active_console)) { + if (con !=3D dcl->con) { continue; } if (dcl->ops->dpy_gl_scanout_dmabuf) { @@ -1164,7 +1106,7 @@ void dpy_gl_cursor_dmabuf(QemuConsole *con, QemuDmaBu= f *dmabuf, DisplayChangeListener *dcl; =20 QLIST_FOREACH(dcl, &s->listeners, next) { - if (con !=3D (dcl->con ? dcl->con : active_console)) { + if (con !=3D dcl->con) { continue; } if (dcl->ops->dpy_gl_cursor_dmabuf) { @@ -1181,7 +1123,7 @@ void dpy_gl_cursor_position(QemuConsole *con, DisplayChangeListener *dcl; =20 QLIST_FOREACH(dcl, &s->listeners, next) { - if (con !=3D (dcl->con ? dcl->con : active_console)) { + if (con !=3D dcl->con) { continue; } if (dcl->ops->dpy_gl_cursor_position) { @@ -1197,7 +1139,7 @@ void dpy_gl_release_dmabuf(QemuConsole *con, DisplayChangeListener *dcl; =20 QLIST_FOREACH(dcl, &s->listeners, next) { - if (con !=3D (dcl->con ? dcl->con : active_console)) { + if (con !=3D dcl->con) { continue; } if (dcl->ops->dpy_gl_release_dmabuf) { @@ -1216,7 +1158,7 @@ void dpy_gl_update(QemuConsole *con, =20 graphic_hw_gl_block(con, true); QLIST_FOREACH(dcl, &s->listeners, next) { - if (con !=3D (dcl->con ? dcl->con : active_console)) { + if (con !=3D dcl->con) { continue; } if (dcl->ops->dpy_gl_update) { @@ -1415,30 +1357,21 @@ static QemuConsole *qemu_graphic_console_lookup_unu= sed(void) =20 QEMUCursor *qemu_console_get_cursor(QemuConsole *con) { - if (con =3D=3D NULL) { - con =3D active_console; - } return QEMU_IS_GRAPHIC_CONSOLE(con) ? QEMU_GRAPHIC_CONSOLE(con)->curso= r : NULL; } =20 bool qemu_console_is_visible(QemuConsole *con) { - return (con =3D=3D active_console) || (con->dcls > 0); + return con->dcls > 0; } =20 bool qemu_console_is_graphic(QemuConsole *con) { - if (con =3D=3D NULL) { - con =3D active_console; - } return con && QEMU_IS_GRAPHIC_CONSOLE(con); } =20 bool qemu_console_is_fixedsize(QemuConsole *con) { - if (con =3D=3D NULL) { - con =3D active_console; - } return con && (QEMU_IS_GRAPHIC_CONSOLE(con) || QEMU_IS_FIXED_TEXT_CONS= OLE(con)); } =20 @@ -1505,17 +1438,11 @@ char *qemu_console_get_label(QemuConsole *con) =20 int qemu_console_get_index(QemuConsole *con) { - if (con =3D=3D NULL) { - con =3D active_console; - } return con ? con->index : -1; } =20 uint32_t qemu_console_get_head(QemuConsole *con) { - if (con =3D=3D NULL) { - con =3D active_console; - } if (con =3D=3D NULL) { return -1; } @@ -1527,9 +1454,6 @@ uint32_t qemu_console_get_head(QemuConsole *con) =20 int qemu_console_get_width(QemuConsole *con, int fallback) { - if (con =3D=3D NULL) { - con =3D active_console; - } if (con =3D=3D NULL) { return fallback; } @@ -1547,9 +1471,6 @@ int qemu_console_get_width(QemuConsole *con, int fall= back) =20 int qemu_console_get_height(QemuConsole *con, int fallback) { - if (con =3D=3D NULL) { - con =3D active_console; - } if (con =3D=3D NULL) { return fallback; } diff --git a/ui/curses.c b/ui/curses.c index 8bde8c5cf7c3..df57c322d384 100644 --- a/ui/curses.c +++ b/ui/curses.c @@ -98,7 +98,7 @@ static void curses_update(DisplayChangeListener *dcl, =20 static void curses_calc_pad(void) { - if (qemu_console_is_fixedsize(NULL)) { + if (qemu_console_is_fixedsize(dcl->con)) { width =3D gwidth; height =3D gheight; } else { @@ -201,7 +201,7 @@ static void curses_cursor_position(DisplayChangeListene= r *dcl, curs_set(1); /* it seems that curs_set(1) must always be called before * curs_set(2) for the latter to have effect */ - if (!qemu_console_is_graphic(NULL)) { + if (!qemu_console_is_graphic(dcl->con)) { curs_set(2); } return; @@ -274,11 +274,11 @@ static void curses_refresh(DisplayChangeListener *dcl) clear(); refresh(); curses_calc_pad(); - graphic_hw_invalidate(NULL); + graphic_hw_invalidate(dcl->con); invalidate =3D 0; } =20 - graphic_hw_text_update(NULL, screen); + graphic_hw_text_update(dcl->con, screen); =20 while (1) { /* while there are any pending key strokes to process */ @@ -318,11 +318,16 @@ static void curses_refresh(DisplayChangeListener *dcl) /* process keys reserved for qemu */ if (keycode >=3D QEMU_KEY_CONSOLE0 && keycode < QEMU_KEY_CONSOLE0 + 9) { - erase(); - wnoutrefresh(stdscr); - console_select(keycode - QEMU_KEY_CONSOLE0); - - invalidate =3D 1; + QemuConsole *con =3D qemu_console_lookup_by_index(= keycode - QEMU_KEY_CONSOLE0); + if (con) { + erase(); + wnoutrefresh(stdscr); + unregister_displaychangelistener(dcl); + dcl->con =3D con; + register_displaychangelistener(dcl); + + invalidate =3D 1; + } continue; } } @@ -354,45 +359,45 @@ static void curses_refresh(DisplayChangeListener *dcl) if (keycode =3D=3D -1) continue; =20 - if (qemu_console_is_graphic(NULL)) { + if (qemu_console_is_graphic(dcl->con)) { /* since terminals don't know about key press and release * events, we need to emit both for each key received */ if (keycode & SHIFT) { - qemu_input_event_send_key_number(NULL, SHIFT_CODE, true); + qemu_input_event_send_key_number(dcl->con, SHIFT_CODE, tru= e); qemu_input_event_send_key_delay(0); } if (keycode & CNTRL) { - qemu_input_event_send_key_number(NULL, CNTRL_CODE, true); + qemu_input_event_send_key_number(dcl->con, CNTRL_CODE, tru= e); qemu_input_event_send_key_delay(0); } if (keycode & ALT) { - qemu_input_event_send_key_number(NULL, ALT_CODE, true); + qemu_input_event_send_key_number(dcl->con, ALT_CODE, true); qemu_input_event_send_key_delay(0); } if (keycode & ALTGR) { - qemu_input_event_send_key_number(NULL, GREY | ALT_CODE, tr= ue); + qemu_input_event_send_key_number(dcl->con, GREY | ALT_CODE= , true); qemu_input_event_send_key_delay(0); } =20 - qemu_input_event_send_key_number(NULL, keycode & KEY_MASK, tru= e); + qemu_input_event_send_key_number(dcl->con, keycode & KEY_MASK,= true); qemu_input_event_send_key_delay(0); - qemu_input_event_send_key_number(NULL, keycode & KEY_MASK, fal= se); + qemu_input_event_send_key_number(dcl->con, keycode & KEY_MASK,= false); qemu_input_event_send_key_delay(0); =20 if (keycode & ALTGR) { - qemu_input_event_send_key_number(NULL, GREY | ALT_CODE, fa= lse); + qemu_input_event_send_key_number(dcl->con, GREY | ALT_CODE= , false); qemu_input_event_send_key_delay(0); } if (keycode & ALT) { - qemu_input_event_send_key_number(NULL, ALT_CODE, false); + qemu_input_event_send_key_number(dcl->con, ALT_CODE, false= ); qemu_input_event_send_key_delay(0); } if (keycode & CNTRL) { - qemu_input_event_send_key_number(NULL, CNTRL_CODE, false); + qemu_input_event_send_key_number(dcl->con, CNTRL_CODE, fal= se); qemu_input_event_send_key_delay(0); } if (keycode & SHIFT) { - qemu_input_event_send_key_number(NULL, SHIFT_CODE, false); + qemu_input_event_send_key_number(dcl->con, SHIFT_CODE, fal= se); qemu_input_event_send_key_delay(0); } } else { @@ -400,7 +405,7 @@ static void curses_refresh(DisplayChangeListener *dcl) if (keysym =3D=3D -1) keysym =3D chr; =20 - qemu_text_console_put_keysym(NULL, keysym); + qemu_text_console_put_keysym(QEMU_TEXT_CONSOLE(dcl->con), keys= ym); } } } @@ -798,6 +803,7 @@ static void curses_display_init(DisplayState *ds, Displ= ayOptions *opts) curses_winch_init(); =20 dcl =3D g_new0(DisplayChangeListener, 1); + dcl->con =3D qemu_console_lookup_first_graphic_console(); dcl->ops =3D &dcl_ops; register_displaychangelistener(dcl); =20 --=20 2.44.0