From nobody Sat May 11 23:31:23 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1710942864; cv=none; d=zohomail.com; s=zohoarc; b=Xpoyd86eytbqKBS5OqtjKz/h+251yiml8MQen0WUGiNiJdr7Cr2xyPe4QXyDcay0M/DXnR51IitVDXHEBQpx8qfSnJQjir65a48ECQ0oPf4nBixeY79AqCYzCXwInaepChwvdM0LhUPRArDlS08wWSCUeOb20TVetojvDL7y9zY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710942864; 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=agJBu9J6N8asAV/WLtQ5Jh7JQFUv6f6AIgaGkCGIgAQ=; b=MMUcnCpifXtkiOyRXW9YjIPszCg0FB80muuKhyX1aJRqQ4MYJqyN+2DE9I4Le/YB22hHNHk6yODv6uhOqmyvm/oazP57LVq0RiP4NXonZ0ANZQUVqOPRttJWL+VcQBdxULCXKa+M7km5SW9Vlnk62WRVkkikKlLrfEsl2Rrvux0= 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1710942864554510.312914898416; Wed, 20 Mar 2024 06:54:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rmwOR-00040J-VH; Wed, 20 Mar 2024 09:54: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 1rmwOQ-0003yB-7I for qemu-devel@nongnu.org; Wed, 20 Mar 2024 09:54:10 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rmwOO-00008J-RT for qemu-devel@nongnu.org; Wed, 20 Mar 2024 09:54:09 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-529-3OJ0933QMzSwG9sGGt2-kw-1; Wed, 20 Mar 2024 09:54:05 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 85D85101A588; Wed, 20 Mar 2024 13:54:05 +0000 (UTC) Received: from localhost (unknown [10.39.208.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3FAF9492BD4; Wed, 20 Mar 2024 13:54:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710942848; h=from:from: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; bh=agJBu9J6N8asAV/WLtQ5Jh7JQFUv6f6AIgaGkCGIgAQ=; b=F0wYeYOG3JMB7/ZuxlRdTj/zYrC6OCdSmydik0YTsp5ji7EKtP2+OBMR1J9ugbF/ih2j5b zbjMab1gmeJ0ELBMNBgFZMJeLvRUbuG6PEJ35hl2d/HBl9ZWCpyY5TaoHh3+qWRzv4IZHw bG8/wJbZXZn1FYEtrXZ1PSseY5BqLeU= X-MC-Unique: 3OJ0933QMzSwG9sGGt2-kw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , "Michael S. Tsirkin" , Peter Maydell , Gerd Hoffmann , Akihiko Odaki , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 1/5] ui/vc: Do not inherit the size of active console Date: Wed, 20 Mar 2024 17:53:45 +0400 Message-ID: <20240320135349.2139402-2-marcandre.lureau@redhat.com> In-Reply-To: <20240320135349.2139402-1-marcandre.lureau@redhat.com> References: <20240320135349.2139402-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 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=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.417, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-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 @redhat.com) X-ZM-MESSAGEID: 1710942866090100002 From: Akihiko Odaki 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 Message-Id: <20240319-console-v2-1-3fd6feef321a@daynix.com> --- 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 9c13cc2981..f22c8e23c2 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 Sat May 11 23:31:23 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1710942923; cv=none; d=zohomail.com; s=zohoarc; b=I4e1NahWk47qzvEK/EYH4AUfn+Q7Y4csdYH6QeZ8wWi2BhC6gcKX69F7kHH1Oos9eoE7FgfEbc/ChWMV3abepgnY2J1bnCk/0ajfJHs61ngGq7cQpM8NE/fjHoh4Fyo9VUUmd4wDFvJ+sDR3OJyu5oHsnnmJZjMd51lNyYVweO0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710942923; 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=LS1W3pnEANMqrFyxGYWHsBrgCl9/zTnLL3xr58UeMCk=; b=BZ7AGbcEb3mSAdDJLtbZHvOSevnO245r9mFZw3H+3gHMcjjQMMZc7j9VBV2+xs+TcT81YbPxJKZIRKc80tGvbd4v8qPukpvDWKPwaIVbRjn7R3eJnbXVbqLiBXibbYSjouBls/kjTjfmQhuqt8PVuXnJ8kNlssUE1adU1k/JhyM= 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1710942923513867.4986104109444; Wed, 20 Mar 2024 06:55:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rmwOc-00041X-6C; Wed, 20 Mar 2024 09:54:22 -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 1rmwOa-00041L-Rg for qemu-devel@nongnu.org; Wed, 20 Mar 2024 09:54:20 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rmwOZ-0000AO-Bu for qemu-devel@nongnu.org; Wed, 20 Mar 2024 09:54:20 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-418-XWfW41nLP-28htymPsncMg-1; Wed, 20 Mar 2024 09:54:14 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 34D5338157A0; Wed, 20 Mar 2024 13:54:14 +0000 (UTC) Received: from localhost (unknown [10.39.208.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5651A492BCA; Wed, 20 Mar 2024 13:54:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710942858; h=from:from: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; bh=LS1W3pnEANMqrFyxGYWHsBrgCl9/zTnLL3xr58UeMCk=; b=Krmie0KBFsxEk9LqCRDYVe2FyG53fQdbwnOZbusr7hXlRAeh25VRKGjbIhw88sZNKK4n5K 2/MR+cx4cwAPx2rqxeNmJ1MV6lb/EBD5xgm08umCj+pVv5GGqDQDmceJscI1htqlxOvEWD mwDnPLricj/6VZMXECZDufKqcxTApCk= X-MC-Unique: XWfW41nLP-28htymPsncMg-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , "Michael S. Tsirkin" , Peter Maydell , Gerd Hoffmann , Akihiko Odaki , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 2/5] ui/vnc: Do not use console_select() Date: Wed, 20 Mar 2024 17:53:46 +0400 Message-ID: <20240320135349.2139402-3-marcandre.lureau@redhat.com> In-Reply-To: <20240320135349.2139402-1-marcandre.lureau@redhat.com> References: <20240320135349.2139402-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 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=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.417, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-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 @redhat.com) X-ZM-MESSAGEID: 1710942924242100001 From: Akihiko Odaki 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 Reviewed-by: Marc-Andr=C3=A9 Lureau Message-Id: <20240319-console-v2-2-3fd6feef321a@daynix.com> --- 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 a4a49ffc64..3729d2db29 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_default(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 fb79776128..1f37b932eb 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 832055675c..fbc1b9b8b5 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_default(void) +{ + QemuConsole *con; + + QTAILQ_FOREACH(con, &consoles, next) { + if (QEMU_IS_GRAPHIC_CONSOLE(con)) { + return con; + } + } + return QTAILQ_FIRST(&consoles); +} + QemuConsole *qemu_console_lookup_by_index(unsigned int index) { QemuConsole *con; diff --git a/ui/kbd-state.c b/ui/kbd-state.c index 62d42a7a22..52ed28b8a8 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 fc12b343e2..b3fd78022b 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_default(); } =20 if (con !=3D vd->dcl.con) { --=20 2.44.0 From nobody Sat May 11 23:31:23 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1710942899; cv=none; d=zohomail.com; s=zohoarc; b=POp4YyD2uv7hiIC2+fWaNJrI7tTXaEaLI1wxiYR0bcr7FCafSRtBVkK55MQoMyhs1G14CILd/k6d+5FI/ZqXUWJHExTczeVfM4WDsnU64qqdyh2HHdEWPpiJQNvX1j6mIGtQEKwLVNcr5hbVxCj86O/CMBWP8kxqx1wqmyxzwCM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710942899; 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=hd7LmA408dvHfo5kRnbpaogkLqac1ZzU7woAzEbOZcM=; b=CYoCGOahLJMWGeKdan3OMtrDnV/CDt0dZShmflqATE5oDbrZZjLhJ7mXIffaO8IVawV1b+itMJ4AAhVHxWhfJxx9GLVZGa2ZbSSEJX5hA13kzMBmJl4/xGuljfy5z5aq+t+Yfcyr+X1EAcX4rkWdyLryAo1n+ktQbObbOuEHelA= 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1710942899886350.4866806759237; Wed, 20 Mar 2024 06:54:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rmwOm-0004Be-Op; Wed, 20 Mar 2024 09:54:32 -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 1rmwOl-0004Ai-6a for qemu-devel@nongnu.org; Wed, 20 Mar 2024 09:54:31 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rmwOj-0000BA-6O for qemu-devel@nongnu.org; Wed, 20 Mar 2024 09:54:30 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-453-qbo5EUDpP7OV8an0IpsA-A-1; Wed, 20 Mar 2024 09:54:25 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A7A7381A285; Wed, 20 Mar 2024 13:54:22 +0000 (UTC) Received: from localhost (unknown [10.39.208.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1B286492BCA; Wed, 20 Mar 2024 13:54:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710942868; h=from:from: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; bh=hd7LmA408dvHfo5kRnbpaogkLqac1ZzU7woAzEbOZcM=; b=a9bk0C5Ce1qyqJlzp6G0FSzdlTM1gs9KFg+135shxW25f2Xq+HEtro9kQepG7mAGgpuNOp KHWYnqovmOqB0JW0oRxYudDRfh2otNyV80tFYvhIKHxdvqBxOjPlUKe0b0t/cqtMD2lQt2 8LfBzUpaetLQUrWljRLQC7BybNsbM4Y= X-MC-Unique: qbo5EUDpP7OV8an0IpsA-A-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , "Michael S. Tsirkin" , Peter Maydell , Gerd Hoffmann , Akihiko Odaki , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 3/5] ui/cocoa: Do not use console_select() Date: Wed, 20 Mar 2024 17:53:47 +0400 Message-ID: <20240320135349.2139402-4-marcandre.lureau@redhat.com> In-Reply-To: <20240320135349.2139402-1-marcandre.lureau@redhat.com> References: <20240320135349.2139402-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 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=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.417, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-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 @redhat.com) X-ZM-MESSAGEID: 1710942900285100001 From: Akihiko Odaki 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 Reviewed-by: Marc-Andr=C3=A9 Lureau Message-Id: <20240319-console-v2-3-3fd6feef321a@daynix.com> --- ui/cocoa.m | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index fa879d7dcd..810751cf26 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_default(); + 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 Sat May 11 23:31:23 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1710942928; cv=none; d=zohomail.com; s=zohoarc; b=Gd0RU/ZFbYtPQe195ankqnmE7NEp8u4DK3niZ0vhmAG+7qIGzuVXnykzAKQcJ3QRJQNY9G3PdgBFyzX9gjS3yH1qWWQUOLa3NcT10GzxlEBONARt0sHytDzwrV0qed/nd2y8V+sv7fS3NgA39H7J/xzrW4o4qEg0tJgQDG/CKqU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710942928; 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=SHEnHfylghBzIMQGOk7vhNe9UGGywR41T/OdqdkcH5Y=; b=JAWfChNfCbjY41X6SbJBA5fnmrJ4Upf4JLgI9zzVL/S9JR46wDM6UcTlA1KPV4WJGdUygdvcMnXDs7hWlTbFrZPNW8xXutBZQ9LVcjnAVl33Yauyq39GdRqxjvBxlQjp5s5N2UQbIdj0hiARNW9zMoRI2mmuN7/9Nu4ZtEGLev4= 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1710942928226545.3701059411676; Wed, 20 Mar 2024 06:55:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rmwOs-0004C8-4e; Wed, 20 Mar 2024 09:54:38 -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 1rmwOn-0004Bl-Se for qemu-devel@nongnu.org; Wed, 20 Mar 2024 09:54:33 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rmwOl-0000Bf-Bi for qemu-devel@nongnu.org; Wed, 20 Mar 2024 09:54:33 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-146-YTBdF8YTNPCXojFr9TXJWA-1; Wed, 20 Mar 2024 09:54:29 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 182D5887E41; Wed, 20 Mar 2024 13:54:29 +0000 (UTC) Received: from localhost (unknown [10.39.208.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9C47F200E1B2; Wed, 20 Mar 2024 13:54:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710942870; h=from:from: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; bh=SHEnHfylghBzIMQGOk7vhNe9UGGywR41T/OdqdkcH5Y=; b=cANmPU+Inn8WyiRkVgAh4K38p4iSjBrtRsye+nxOqdy/Gy7PUDw0ohAnYZa3vjAuKj23kD d+EUxOSypK/5pRMfc5XE4OO+nPj8lyKig2pKWTZ5I19wp7AVvpEHMwuI28qZzAw5cIQb+x YbEdr7XRLaGieKFE91ECm3SEQxlC4Yk= X-MC-Unique: YTBdF8YTNPCXojFr9TXJWA-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , "Michael S. Tsirkin" , Peter Maydell , Gerd Hoffmann , Akihiko Odaki , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 4/5] ui/curses: Do not use console_select() Date: Wed, 20 Mar 2024 17:53:48 +0400 Message-ID: <20240320135349.2139402-5-marcandre.lureau@redhat.com> In-Reply-To: <20240320135349.2139402-1-marcandre.lureau@redhat.com> References: <20240320135349.2139402-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 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=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.417, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-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 @redhat.com) X-ZM-MESSAGEID: 1710942930283100003 From: Akihiko Odaki ui/curses is the only user of console_select(). Move the implementation to ui/curses. Signed-off-by: Akihiko Odaki Reviewed-by: Marc-Andr=C3=A9 Lureau Message-Id: <20240319-console-v2-4-3fd6feef321a@daynix.com> --- 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 3729d2db29..0bc7a00ac0 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 88569ed2cc..43ceb8122f 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 2afc52329f..b63e2fb234 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 f22c8e23c2..899fa11c94 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 fbc1b9b8b5..43226c5c14 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 8bde8c5cf7..ec61615f7c 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_default(); dcl->ops =3D &dcl_ops; register_displaychangelistener(dcl); =20 --=20 2.44.0 From nobody Sat May 11 23:31:23 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1710942941; cv=none; d=zohomail.com; s=zohoarc; b=Ndp/BnsxTLn8EdVWjfttcPDCWCWnj2Ul1cDpckpb4W9aCxGRKhlG80wMIOQW8uBN+qZdU+3qKyUd2M9Iec6OpjeiJJa5PhpVZq2TIyzqpPrw6+MPr4YZ6XXv66aZQQ6ofWynvbI7kLQgjswbKcQmx8PsMnTku9jg2lsdMQtcA6M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710942941; 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=vfM5qhRsMgeZ9ObyeIq+96OOE4ZTxePrPvMEn3jqxjU=; b=RSJOnJfFgtC2mCecp/59lfkNamf3GMBGCrpwKTctS1nYYtjEPct741gcS00QYKNm1RbYKjLl6jUZzaRr5LKbA23/k0L31qH7lu6nQ/6XHdKjAyWpGqIcCng4DYsSKDfKZVRGj9NXfLRUKt5TLtqLiHr8znIuyQNiLj9zqe+rkqQ= 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1710942941602135.54424066849253; Wed, 20 Mar 2024 06:55:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rmwPg-0005RB-JH; Wed, 20 Mar 2024 09:55:30 -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 1rmwPD-0005Db-LD for qemu-devel@nongnu.org; Wed, 20 Mar 2024 09:55:01 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rmwPC-0000Ep-3h for qemu-devel@nongnu.org; Wed, 20 Mar 2024 09:54:59 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-145-DXKRI6AjNiOnw40HDfCFeA-1; Wed, 20 Mar 2024 09:54:53 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 73FAE186E28B; Wed, 20 Mar 2024 13:54:53 +0000 (UTC) Received: from localhost (unknown [10.39.208.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2781140C6DB7; Wed, 20 Mar 2024 13:54:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710942897; h=from:from: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; bh=vfM5qhRsMgeZ9ObyeIq+96OOE4ZTxePrPvMEn3jqxjU=; b=T5DmBOLSRovj4rtUzNFS5JU8g9X//6H812308xCj6rxGKJ5VBhXVpBNznkmHnwKqnvgUl4 q4nYtRgtuxOIP+55Sf/1ZIYhnx3Y9AW/qVdR3+vtpD/dOHrZhUT950f6g7olv1cpXp6Cap 23hzu+e1dgsmvakQwR3z/rFWi2RjkrE= X-MC-Unique: DXKRI6AjNiOnw40HDfCFeA-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , "Michael S. Tsirkin" , Peter Maydell , Gerd Hoffmann , Akihiko Odaki , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 5/5] ui: compile dbus-display1.c with -fPIC as necessary Date: Wed, 20 Mar 2024 17:53:49 +0400 Message-ID: <20240320135349.2139402-6-marcandre.lureau@redhat.com> In-Reply-To: <20240320135349.2139402-1-marcandre.lureau@redhat.com> References: <20240320135349.2139402-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 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=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.417, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-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 @redhat.com) X-ZM-MESSAGEID: 1710942942331100001 From: Marc-Andr=C3=A9 Lureau Building dbus-display1.c explicitly as a static library drops -fPIC by default, which may not be correct if it ends up linked to a shared library. Let the target decide how to build the unit, with or without -fPIC. This makes commit 186acfbaf7 ("tests/qtest: Depend on dbus_display1_dep") no longer relevant, as dbus-display1.c will be recompiled. Fixes: c172136ea33 ("meson: ensure dbus-display generated code is built before other units") Reported-by: Olaf Hering Reviewed-by: Michael Tokarev Signed-off-by: Marc-Andr=C3=A9 Lureau --- ui/meson.build | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ui/meson.build b/ui/meson.build index 0b7e2b6f6b..a5ce22a678 100644 --- a/ui/meson.build +++ b/ui/meson.build @@ -90,8 +90,7 @@ if dbus_display '--interface-prefix', 'org.qemu.= ', '--c-namespace', 'QemuDBus', '--generate-c-code', '@BASENAME@= ']) - dbus_display1_lib =3D static_library('dbus-display1', dbus_display1, dep= endencies: gio) - dbus_display1_dep =3D declare_dependency(link_with: dbus_display1_lib, s= ources: dbus_display1[0]) + dbus_display1_dep =3D declare_dependency(sources: dbus_display1, depende= ncies: gio) dbus_ss.add(when: [gio, dbus_display1_dep], if_true: [files( 'dbus-chardev.c', --=20 2.44.0