From nobody Thu Nov 28 10:37:29 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=1693828633; cv=none; d=zohomail.com; s=zohoarc; b=iDvgrtfjv/nWOJBm3NUjnGO0CaCdv/TlfQn/p2pC+DrtF+oXHzJ3+pZRt5QoU5K8qQGkKCK7FF4fK3Igu7WUNZ2DswxF/4Xq6nTu5R/0riSkv9BaLSmY22BnlaEzxthr+m6RJLngzQY+hBza4MjpBbKySgvvGLTDyb+sw/RzwKA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693828633; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=WSlonkVQyb/g/APCHZ3FvJpzoXXO0zfvYBTUWJHBU+s=; b=C3jRz0pHtMCmLcPa4i2gJWPu84jH3gJn9N6q8UshstskV1I/YOuNgoOep8vVcCPrdUCCgNvBGXkN3qB6f8z38lKVWmgVyo4M7AznlVDLs1+gprx9vE1hEHMyZ+q5cxG/O6r7X6KMBZlhqa/oOD+/vaokx7hpuupJQ8refZorxlc= 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 1693828633261513.9187260281634; Mon, 4 Sep 2023 04:57:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qd8AS-00050c-0q; Mon, 04 Sep 2023 07:54:56 -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 1qd8AO-0004XG-O3 for qemu-devel@nongnu.org; Mon, 04 Sep 2023 07:54:52 -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 1qd8AM-0000J3-5d for qemu-devel@nongnu.org; Mon, 04 Sep 2023 07:54:52 -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.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-651-aCQ_9PeNPDaq5SI8VqB_DA-1; Mon, 04 Sep 2023 07:54:48 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0B1583810D2F for ; Mon, 4 Sep 2023 11:54:48 +0000 (UTC) Received: from localhost (unknown [10.39.208.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id D8F9540C206F; Mon, 4 Sep 2023 11:54:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693828489; 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=WSlonkVQyb/g/APCHZ3FvJpzoXXO0zfvYBTUWJHBU+s=; b=FbyEhpekU7UrIOKfoFUSC5ElG6Wpmk3mBMiBf5KBkblyRWzwwxFaEd/JpugXwRcwCZpTbr s3zre+plodkLZgF6H0563I6T/xaAlz5WotNJQBQw0LxDRUsHZ0C/aw+Kis2R83DakNTBpA HkTim2ksvuNBn/BK30v2SopCq888czU= X-MC-Unique: aCQ_9PeNPDaq5SI8VqB_DA-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Subject: [PULL 29/52] ui/console: move graphic fields to QemuGraphicConsole Date: Mon, 4 Sep 2023 15:52:26 +0400 Message-ID: <20230904115251.4161397-30-marcandre.lureau@redhat.com> In-Reply-To: <20230904115251.4161397-1-marcandre.lureau@redhat.com> References: <20230904115251.4161397-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.1 on 10.11.54.1 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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 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: 1693828635325100003 From: Marc-Andr=C3=A9 Lureau Move fields specific to graphic console to the console subclass. qemu_console_get_head() is adapated to accomodate QemuTextConsole, and always returns 0. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Daniel P. Berrang=C3=A9 Message-Id: <20230830093843.3531473-30-marcandre.lureau@redhat.com> --- ui/console.c | 110 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 64 insertions(+), 46 deletions(-) diff --git a/ui/console.c b/ui/console.c index 335d7ba841..9d884ba02f 100644 --- a/ui/console.c +++ b/ui/console.c @@ -83,17 +83,10 @@ struct QemuConsole { int gl_block; QEMUTimer *gl_unblock_timer; int window_id; - - /* Graphic console state. */ - Object *device; - uint32_t head; QemuUIInfo ui_info; QEMUTimer *ui_timer; - QEMUCursor *cursor; - int cursor_x, cursor_y, cursor_on; const GraphicHwOps *hw_ops; void *hw; - CoQueue dump_queue; =20 QTAILQ_ENTRY(QemuConsole) next; @@ -103,6 +96,12 @@ OBJECT_DEFINE_ABSTRACT_TYPE(QemuConsole, qemu_console, = QEMU_CONSOLE, OBJECT) =20 typedef struct QemuGraphicConsole { QemuConsole parent; + + Object *device; + uint32_t head; + + QEMUCursor *cursor; + int cursor_x, cursor_y, cursor_on; } QemuGraphicConsole; =20 typedef QemuConsoleClass QemuGraphicConsoleClass; @@ -1343,31 +1342,14 @@ qemu_console_finalize(Object *obj) QemuConsole *c =3D QEMU_CONSOLE(obj); =20 /* TODO: check this code path, and unregister from consoles */ - g_clear_pointer(&c->device, object_unref); g_clear_pointer(&c->surface, qemu_free_displaysurface); g_clear_pointer(&c->gl_unblock_timer, timer_free); g_clear_pointer(&c->ui_timer, timer_free); } =20 -static void -qemu_console_prop_get_head(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) -{ - QemuConsole *c =3D QEMU_CONSOLE(obj); - - visit_type_uint32(v, name, &c->head, errp); -} - static void qemu_console_class_init(ObjectClass *oc, void *data) { - object_class_property_add_link(oc, "device", TYPE_DEVICE, - offsetof(QemuConsole, device), - object_property_allow_set_link, - OBJ_PROP_LINK_STRONG); - object_class_property_add(oc, "head", "uint32", - qemu_console_prop_get_head, - NULL, NULL, NULL); } =20 static void @@ -1387,11 +1369,30 @@ qemu_console_init(Object *obj) static void qemu_graphic_console_finalize(Object *obj) { + QemuGraphicConsole *c =3D QEMU_GRAPHIC_CONSOLE(obj); + + g_clear_pointer(&c->device, object_unref); +} + +static void +qemu_graphic_console_prop_get_head(Object *obj, Visitor *v, const char *na= me, + void *opaque, Error **errp) +{ + QemuGraphicConsole *c =3D QEMU_GRAPHIC_CONSOLE(obj); + + visit_type_uint32(v, name, &c->head, errp); } =20 static void qemu_graphic_console_class_init(ObjectClass *oc, void *data) { + object_class_property_add_link(oc, "device", TYPE_DEVICE, + offsetof(QemuGraphicConsole, device), + object_property_allow_set_link, + OBJ_PROP_LINK_STRONG); + object_class_property_add(oc, "head", "uint32", + qemu_graphic_console_prop_get_head, + NULL, NULL, NULL); } =20 static void @@ -1676,6 +1677,16 @@ void qemu_console_set_display_gl_ctx(QemuConsole *co= n, DisplayGLCtx *gl) con->gl =3D gl; } =20 +static void +dcl_set_graphic_cursor(DisplayChangeListener *dcl, QemuGraphicConsole *con) +{ + if (con && con->cursor && dcl->ops->dpy_cursor_define) { + dcl->ops->dpy_cursor_define(dcl, con->cursor); + } + if (con && dcl->ops->dpy_mouse_set) { + dcl->ops->dpy_mouse_set(dcl, con->cursor_x, con->cursor_y, con->cu= rsor_on); + } +} void register_displaychangelistener(DisplayChangeListener *dcl) { QemuConsole *con; @@ -1693,11 +1704,8 @@ void register_displaychangelistener(DisplayChangeLis= tener *dcl) con =3D active_console; } displaychangelistener_display_console(dcl, con, dcl->con ? &error_fata= l : NULL); - if (con && con->cursor && dcl->ops->dpy_cursor_define) { - dcl->ops->dpy_cursor_define(dcl, con->cursor); - } - if (con && dcl->ops->dpy_mouse_set) { - dcl->ops->dpy_mouse_set(dcl, con->cursor_x, con->cursor_y, con->cu= rsor_on); + if (QEMU_IS_GRAPHIC_CONSOLE(con)) { + dcl_set_graphic_cursor(dcl, QEMU_GRAPHIC_CONSOLE(con)); } text_console_update_cursor(NULL); } @@ -1728,8 +1736,9 @@ void unregister_displaychangelistener(DisplayChangeLi= stener *dcl) static void dpy_set_ui_info_timer(void *opaque) { QemuConsole *con =3D opaque; + uint32_t head =3D qemu_console_get_head(con); =20 - con->hw_ops->ui_info(con->hw, con->head, &con->ui_info); + con->hw_ops->ui_info(con->hw, head, &con->ui_info); } =20 bool dpy_ui_info_supported(QemuConsole *con) @@ -1939,19 +1948,20 @@ void dpy_text_resize(QemuConsole *con, int w, int h) } } =20 -void dpy_mouse_set(QemuConsole *con, int x, int y, int on) +void dpy_mouse_set(QemuConsole *c, int x, int y, int on) { - DisplayState *s =3D con->ds; + QemuGraphicConsole *con =3D QEMU_GRAPHIC_CONSOLE(c); + DisplayState *s =3D c->ds; DisplayChangeListener *dcl; =20 con->cursor_x =3D x; con->cursor_y =3D y; con->cursor_on =3D on; - if (!qemu_console_is_visible(con)) { + if (!qemu_console_is_visible(c)) { return; } QLIST_FOREACH(dcl, &s->listeners, next) { - if (con !=3D (dcl->con ? dcl->con : active_console)) { + if (c !=3D (dcl->con ? dcl->con : active_console)) { continue; } if (dcl->ops->dpy_mouse_set) { @@ -1960,18 +1970,19 @@ void dpy_mouse_set(QemuConsole *con, int x, int y, = int on) } } =20 -void dpy_cursor_define(QemuConsole *con, QEMUCursor *cursor) +void dpy_cursor_define(QemuConsole *c, QEMUCursor *cursor) { - DisplayState *s =3D con->ds; + QemuGraphicConsole *con =3D QEMU_GRAPHIC_CONSOLE(c); + DisplayState *s =3D c->ds; DisplayChangeListener *dcl; =20 cursor_unref(con->cursor); con->cursor =3D cursor_ref(cursor); - if (!qemu_console_is_visible(con)) { + if (!qemu_console_is_visible(c)) { return; } QLIST_FOREACH(dcl, &s->listeners, next) { - if (con !=3D (dcl->con ? dcl->con : active_console)) { + if (c !=3D (dcl->con ? dcl->con : active_console)) { continue; } if (dcl->ops->dpy_cursor_define) { @@ -2210,7 +2221,7 @@ QemuConsole *graphic_console_init(DeviceState *dev, u= int32_t head, trace_console_gfx_new(); s =3D (QemuConsole *)object_new(TYPE_QEMU_GRAPHIC_CONSOLE); } - s->head =3D head; + QEMU_GRAPHIC_CONSOLE(s)->head =3D head; graphic_console_set_hwops(s, hw_ops, opaque); if (dev) { object_property_set_link(OBJECT(s), "device", OBJECT(dev), @@ -2328,7 +2339,7 @@ QEMUCursor *qemu_console_get_cursor(QemuConsole *con) if (con =3D=3D NULL) { con =3D active_console; } - return con ? con->cursor : NULL; + return QEMU_IS_GRAPHIC_CONSOLE(con) ? QEMU_GRAPHIC_CONSOLE(con)->curso= r : NULL; } =20 bool qemu_console_is_visible(QemuConsole *con) @@ -2386,21 +2397,22 @@ bool qemu_console_is_multihead(DeviceState *dev) char *qemu_console_get_label(QemuConsole *con) { if (QEMU_IS_GRAPHIC_CONSOLE(con)) { - if (con->device) { + QemuGraphicConsole *c =3D QEMU_GRAPHIC_CONSOLE(con); + if (c->device) { DeviceState *dev; bool multihead; =20 - dev =3D DEVICE(con->device); + dev =3D DEVICE(c->device); multihead =3D qemu_console_is_multihead(dev); if (multihead) { return g_strdup_printf("%s.%d", dev->id ? dev->id : - object_get_typename(con->device), - con->head); + object_get_typename(c->device), + c->head); } else { return g_strdup_printf("%s", dev->id ? dev->id : - object_get_typename(con->device)); + object_get_typename(c->device)); } } return g_strdup("VGA"); @@ -2427,7 +2439,13 @@ uint32_t qemu_console_get_head(QemuConsole *con) if (con =3D=3D NULL) { con =3D active_console; } - return con ? con->head : -1; + if (con =3D=3D NULL) { + return -1; + } + if (QEMU_IS_GRAPHIC_CONSOLE(con)) { + return QEMU_GRAPHIC_CONSOLE(con)->head; + } + return 0; } =20 int qemu_console_get_width(QemuConsole *con, int fallback) --=20 2.41.0