From nobody Sat Nov 15 17:50:03 2025 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1748108170; cv=none; d=zohomail.com; s=zohoarc; b=Y7JnT0Wucfg/d07+iW6dHezadyBgOJ50N7JcX4SnHm9QMh85c6xBckhnaPDwiROEGle/ojRVs3yxChDTtbKhvpowGYscDRQLD6STWsCdlD1kYyVZoxdUKxkNvA/gnnHgk2SHESY7yBKsXcPTH03DZYCB/NcYWYPc1TAWoHJR8pk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748108170; 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=Z1BUcCpSr5ctVf8kpo2QU7QmLHfVmuGp/pyUk+dZcBo=; b=QUfcRQf+lzgQNhKdZn98CNx8Bz76qNae5+vniCmYA6CiR03Cg3+vSvTJcItn3HTDlAuzi95Q2USElLog5ZSirn4rajalVhuM6hF7+IVmym1Ohuymv0TOUZibMyWI/+ovSv5Ar4w/iSzCa/ogyFf5hG0EaXvHhuoqRknVxQ57m4Q= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1748108170900833.1186176342876; Sat, 24 May 2025 10:36:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uIsmR-00081R-2l; Sat, 24 May 2025 13:35:31 -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 1uIsmO-0007yd-Kv for qemu-devel@nongnu.org; Sat, 24 May 2025 13:35:29 -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 1uIsmL-0000gm-If for qemu-devel@nongnu.org; Sat, 24 May 2025 13:35:27 -0400 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-371-fkMCyTXLOAap_vAo2cBjXA-1; Sat, 24 May 2025 13:35:22 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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 mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id AA310195608E for ; Sat, 24 May 2025 17:35:21 +0000 (UTC) Received: from localhost (unknown [10.45.242.4]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6EB531944DFF; Sat, 24 May 2025 17:35:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1748108124; 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=Z1BUcCpSr5ctVf8kpo2QU7QmLHfVmuGp/pyUk+dZcBo=; b=B9m4uNNA0YyT7O1Pz6uysgYY1FVT7HG6TZO40FBzLHxQk2IAhP/c/Xk97DnoHInuo1CDEE yMtZUvyYyXDKZphsD5auqTRqGoCFWDrSVem8CNLvWG+IgJQuhjt7A++ylewdjhQF+0sRK/ /atFn1dxgTM3YxpBr4aFCjQR42RWVgg= X-MC-Unique: fkMCyTXLOAap_vAo2cBjXA-1 X-Mimecast-MFC-AGG-ID: fkMCyTXLOAap_vAo2cBjXA_1748108121 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , stefanha@redhat.com Subject: [PULL 01/19] ui/gtk: warn if setting the clipboard failed Date: Sat, 24 May 2025 19:34:54 +0200 Message-ID: <20250524173514.317886-2-marcandre.lureau@redhat.com> In-Reply-To: <20250524173514.317886-1-marcandre.lureau@redhat.com> References: <20250524173514.317886-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.0 on 10.30.177.12 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.298, 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=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: 1748108172190116600 From: Marc-Andr=C3=A9 Lureau Just in case. Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Marc-Andr=C3=A9 Lureau --- ui/gtk-clipboard.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/ui/gtk-clipboard.c b/ui/gtk-clipboard.c index 8d8a636fd1..65d89ec601 100644 --- a/ui/gtk-clipboard.c +++ b/ui/gtk-clipboard.c @@ -19,6 +19,7 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/error-report.h" #include "qemu/main-loop.h" =20 #include "ui/gtk.h" @@ -95,11 +96,13 @@ static void gd_clipboard_update_info(GtkDisplayState *g= d, gtk_clipboard_clear(gd->gtkcb[s]); if (targets) { gd->cbowner[s] =3D true; - gtk_clipboard_set_with_data(gd->gtkcb[s], - targets, n_targets, - gd_clipboard_get_data, - gd_clipboard_clear, - gd); + if (!gtk_clipboard_set_with_data(gd->gtkcb[s], + targets, n_targets, + gd_clipboard_get_data, + gd_clipboard_clear, + gd)) { + warn_report("Failed to set GTK clipboard"); + } =20 gtk_target_table_free(targets, n_targets); } --=20 2.49.0 From nobody Sat Nov 15 17:50:03 2025 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1748108156; cv=none; d=zohomail.com; s=zohoarc; b=lVxGdMyJN65oDgINpZYdkZvbdOZS1sR+Hs8BNHGRaINVn2g/fvlIhrUJRWo6t9KgsWq81T2sqRiCtDjbDAjFjXqfyvZb56yv5VGEnEHScV8UiBp6BHaR1GoBr4wTOJLzxUVnIuIERMD6zge2UcAzUosvYP/iIoUyZAgSL2uPvMY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748108156; 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=D1r7a5cY+zuG6A7VJ15YEEiLalEiBYJ3Mg7pu5TjNWg=; b=A1MnN7LSL/OTDfqD0ndJJrRaQtuVopjAOPJaXSOALX175JepyiNtlOoS5P5nE+qOz1BZMY3T2XIIYOPt3eUsgp6Q1/eYdwFma341m8xT7P4Jb4zibeRmiAXoqbiBUM39KOmCjhwnyTTr0GE/8no1k/6s4yUSpObECdT40GbkcK0= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1748108156967714.1872696685446; Sat, 24 May 2025 10:35:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uIsmS-000823-3H; Sat, 24 May 2025 13:35: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 1uIsmP-00080r-Um for qemu-devel@nongnu.org; Sat, 24 May 2025 13:35:29 -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 1uIsmO-0000hD-Lp for qemu-devel@nongnu.org; Sat, 24 May 2025 13:35:29 -0400 Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-128-yHSImFQAOwuY0JOM6k2n3A-1; Sat, 24 May 2025 13:35:26 -0400 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 15B8B1955DB3 for ; Sat, 24 May 2025 17:35:25 +0000 (UTC) Received: from localhost (unknown [10.45.242.4]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 02FDB19560AB; Sat, 24 May 2025 17:35:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1748108127; 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=D1r7a5cY+zuG6A7VJ15YEEiLalEiBYJ3Mg7pu5TjNWg=; b=F72ORWQeQuRnNJ2lE/qb8GRO2JjrYiHHsomSo3QFb/JZvbfqgziGve4zHLDswCy9DKZYi4 MahHgCWJ0nB/dSBWso5XEYlhnnScBajR0r2dSt/QhuOLLNFgEGDrztvtAL69eBb8NIjEtm WbB5ndw8Pcd3p1RjdzRSP8q3gedjeQk= X-MC-Unique: yHSImFQAOwuY0JOM6k2n3A-1 X-Mimecast-MFC-AGG-ID: yHSImFQAOwuY0JOM6k2n3A_1748108125 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , stefanha@redhat.com Subject: [PULL 02/19] ui/clipboard: use int for selection field Date: Sat, 24 May 2025 19:34:55 +0200 Message-ID: <20250524173514.317886-3-marcandre.lureau@redhat.com> In-Reply-To: <20250524173514.317886-1-marcandre.lureau@redhat.com> References: <20250524173514.317886-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.0 on 10.30.177.15 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.298, 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=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: 1748108158031116600 From: Marc-Andr=C3=A9 Lureau This allows to use a VMSTATE_INT32 field for migration purposes. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Daniel P. Berrang=C3=A9 --- include/ui/clipboard.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/ui/clipboard.h b/include/ui/clipboard.h index ab6acdbd8a..14b6099e73 100644 --- a/include/ui/clipboard.h +++ b/include/ui/clipboard.h @@ -112,7 +112,7 @@ struct QemuClipboardNotify { struct QemuClipboardInfo { uint32_t refcount; QemuClipboardPeer *owner; - QemuClipboardSelection selection; + int selection; /* QemuClipboardSelection */ bool has_serial; uint32_t serial; struct { --=20 2.49.0 From nobody Sat Nov 15 17:50:03 2025 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1748108167; cv=none; d=zohomail.com; s=zohoarc; b=dDFmmtZVK+/2dG4HlgfiOO6nsEiHFVJ+JSZhY1GX4LGzg74CjHaWPKjS/BARQ1g36Iwh5pqMdC3I38eEYSdDykJ8Q8F5ji82jTHWM615BOV512fi+JeO3xB20Yg4GtnOlvkFxNtTg62a3Tb0oWT4VlB+ayMWGML1h4PAfZJpU4E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748108167; 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=FcU2UzgUgmjGurT+mbQ0JWX31VSR3k8SI1q4CZDrBIg=; b=nP3HbwkT7pIHfDTi8xK7YVOpD0D4/ywc0GYzdxe3V9udUl1n4VX0shXpQz27OUA3hOToV2hsR1SmDy35iV4mTCVy1HFy4QC578xYgV9KIq8oVxjFfVGPIMjaVhNCV+CuZ7DGbwLM3r20D+8RaFnatvB9sqlCoynhLc2gpdClDW0= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1748108167317926.5315381055681; Sat, 24 May 2025 10:36:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uIsmV-000842-64; Sat, 24 May 2025 13:35: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 1uIsmT-000829-M6 for qemu-devel@nongnu.org; Sat, 24 May 2025 13:35:33 -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 1uIsmR-0000hb-QX for qemu-devel@nongnu.org; Sat, 24 May 2025 13:35:32 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-191-f546gCtzMVWezvXWshJS3w-1; Sat, 24 May 2025 13:35:29 -0400 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2D3A11800446 for ; Sat, 24 May 2025 17:35:28 +0000 (UTC) Received: from localhost (unknown [10.45.242.4]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6381719560AB; Sat, 24 May 2025 17:35:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1748108131; 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=FcU2UzgUgmjGurT+mbQ0JWX31VSR3k8SI1q4CZDrBIg=; b=cIASB00bO/kcE0qCwDWQ17p0xN/sLp8NW6VMs5FCUwRH7/wt6OQ1HsuEg3UCnP7cijbrRO 728tpPaeHF9u6JuVH2Q9es9CByUKh1TfOSCx8PSh45ELug4IxA946kXu6NCN/1ZDZiM2Cy EoWMnRuHz5SJJbaYD6pwDfzcGvnE7tU= X-MC-Unique: f546gCtzMVWezvXWshJS3w-1 X-Mimecast-MFC-AGG-ID: f546gCtzMVWezvXWshJS3w_1748108128 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , stefanha@redhat.com Subject: [PULL 03/19] ui/clipboard: split out QemuClipboardContent Date: Sat, 24 May 2025 19:34:56 +0200 Message-ID: <20250524173514.317886-4-marcandre.lureau@redhat.com> In-Reply-To: <20250524173514.317886-1-marcandre.lureau@redhat.com> References: <20250524173514.317886-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.0 on 10.30.177.15 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.298, 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=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: 1748108168182116600 From: Marc-Andr=C3=A9 Lureau Allows to use VMSTATE STRUCT in following migration support patch. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Daniel P. Berrang=C3=A9 --- include/ui/clipboard.h | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/include/ui/clipboard.h b/include/ui/clipboard.h index 14b6099e73..88cfff91ef 100644 --- a/include/ui/clipboard.h +++ b/include/ui/clipboard.h @@ -25,6 +25,7 @@ typedef enum QemuClipboardSelection QemuClipboardSelectio= n; typedef struct QemuClipboardPeer QemuClipboardPeer; typedef struct QemuClipboardNotify QemuClipboardNotify; typedef struct QemuClipboardInfo QemuClipboardInfo; +typedef struct QemuClipboardContent QemuClipboardContent; =20 /** * enum QemuClipboardType @@ -97,6 +98,24 @@ struct QemuClipboardNotify { }; }; =20 + +/** + * struct QemuClipboardContent + * + * @available: whether the data is available + * @requested: whether the data was requested + * @size: the size of the @data + * @data: the clipboard data + * + * Clipboard content. + */ +struct QemuClipboardContent { + bool available; + bool requested; + uint32_t size; + void *data; +}; + /** * struct QemuClipboardInfo * @@ -115,12 +134,7 @@ struct QemuClipboardInfo { int selection; /* QemuClipboardSelection */ bool has_serial; uint32_t serial; - struct { - bool available; - bool requested; - size_t size; - void *data; - } types[QEMU_CLIPBOARD_TYPE__COUNT]; + QemuClipboardContent types[QEMU_CLIPBOARD_TYPE__COUNT]; }; =20 /** --=20 2.49.0 From nobody Sat Nov 15 17:50:03 2025 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1748108155; cv=none; d=zohomail.com; s=zohoarc; b=OV4ZXqe00svZOApkB6bm0Qc09n56z/asBH033k3eENhZ/N+NMrHmQCqG9knQrDwCDexV9GeF2lOTvj//RpwarktOwkonWy/97JwwW4KsEtmz2PQ2gO58ZEuDU6VbYpfZGqfinpfy3XyyDv8jhasRVN31mR9scDUP5/lOMYNST2M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748108155; 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=VZuFyNddtzdEXCgFSA8r/ddPt7P6cIbBy3sqMuqzbVo=; b=hdQue9kPzFM6kqUzawLlwiEyYEL6fKpjmX4FUIhC9u0G3klgpuXpiGvG9qBP1V0yGq8uqIqyf3sBLJAwrMSiDMgwR5Za9z+5PxssXQrt/bRSU5UcOP2fhzJfyX1l45zXduRFt9fZ1w5aHAVsdbgrCuuM+hNN/KfpCDU+UlxNUOo= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1748108155568402.6189255001931; Sat, 24 May 2025 10:35:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uIsmb-000863-7W; Sat, 24 May 2025 13:35:41 -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 1uIsmX-00085H-Fy for qemu-devel@nongnu.org; Sat, 24 May 2025 13:35:37 -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 1uIsmU-0000hp-JU for qemu-devel@nongnu.org; Sat, 24 May 2025 13:35:35 -0400 Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-426-NXYsMlOEN_eqfVGEN-C9-w-1; Sat, 24 May 2025 13:35:32 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 86B32195608A for ; Sat, 24 May 2025 17:35:31 +0000 (UTC) Received: from localhost (unknown [10.45.242.4]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 76ADF195608D; Sat, 24 May 2025 17:35:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1748108134; 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=VZuFyNddtzdEXCgFSA8r/ddPt7P6cIbBy3sqMuqzbVo=; b=bKZJ2pNwcBwX1V0mXPaJaNjIkIXozS6GiFKKSf3s2xtGpN8sddbLkxBEQ+6RBww//ZbLMO r6skcSZB2vtsLtdlNIIzzq9N5C3g95CDJxh7fGEIcbjSdPwbp3q619JhEw6LLkwNlZnt0g XlmANWr1J4zYEhSReyUy2qVnRQhY618= X-MC-Unique: NXYsMlOEN_eqfVGEN-C9-w-1 X-Mimecast-MFC-AGG-ID: NXYsMlOEN_eqfVGEN-C9-w_1748108131 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , stefanha@redhat.com Subject: [PULL 04/19] ui/clipboard: add vmstate_cbinfo Date: Sat, 24 May 2025 19:34:57 +0200 Message-ID: <20250524173514.317886-5-marcandre.lureau@redhat.com> In-Reply-To: <20250524173514.317886-1-marcandre.lureau@redhat.com> References: <20250524173514.317886-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.0 on 10.30.177.17 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.298, 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=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: 1748108156086116600 From: Marc-Andr=C3=A9 Lureau Add a VMStateDescriptor for QemuClipboardInfo. Each clipboard owner will have to save its QemuClipboardInfo and reregister its owned clipboard after loading. (the global cbinfo has only pointers to owners, so it can't restore the relation with its owner if it was to handle migration) Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Daniel P. Berrang=C3=A9 --- include/ui/clipboard.h | 3 +++ ui/clipboard.c | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/include/ui/clipboard.h b/include/ui/clipboard.h index 88cfff91ef..62a96ce9ff 100644 --- a/include/ui/clipboard.h +++ b/include/ui/clipboard.h @@ -2,6 +2,7 @@ #define QEMU_CLIPBOARD_H =20 #include "qemu/notify.h" +#include "migration/vmstate.h" =20 /** * DOC: Introduction @@ -27,6 +28,8 @@ typedef struct QemuClipboardNotify QemuClipboardNotify; typedef struct QemuClipboardInfo QemuClipboardInfo; typedef struct QemuClipboardContent QemuClipboardContent; =20 +extern const VMStateDescription vmstate_cbinfo; + /** * enum QemuClipboardType * diff --git a/ui/clipboard.c b/ui/clipboard.c index 132086eb13..f5db60c63d 100644 --- a/ui/clipboard.c +++ b/ui/clipboard.c @@ -7,6 +7,32 @@ static NotifierList clipboard_notifiers =3D =20 static QemuClipboardInfo *cbinfo[QEMU_CLIPBOARD_SELECTION__COUNT]; =20 +static const VMStateDescription vmstate_cbcontent =3D { + .name =3D "clipboard/content", + .version_id =3D 0, + .minimum_version_id =3D 0, + .fields =3D (const VMStateField[]) { + VMSTATE_BOOL(available, QemuClipboardContent), + VMSTATE_BOOL(requested, QemuClipboardContent), + VMSTATE_UINT32(size, QemuClipboardContent), + VMSTATE_VBUFFER_ALLOC_UINT32(data, QemuClipboardContent, 0, 0, siz= e), + VMSTATE_END_OF_LIST() + } +}; + +const VMStateDescription vmstate_cbinfo =3D { + .name =3D "clipboard", + .version_id =3D 0, + .minimum_version_id =3D 0, + .fields =3D (const VMStateField[]) { + VMSTATE_INT32(selection, QemuClipboardInfo), + VMSTATE_BOOL(has_serial, QemuClipboardInfo), + VMSTATE_UINT32(serial, QemuClipboardInfo), + VMSTATE_STRUCT_ARRAY(types, QemuClipboardInfo, QEMU_CLIPBOARD_TYPE= __COUNT, 0, vmstate_cbcontent, QemuClipboardContent), + VMSTATE_END_OF_LIST() + } +}; + void qemu_clipboard_peer_register(QemuClipboardPeer *peer) { notifier_list_add(&clipboard_notifiers, &peer->notifier); --=20 2.49.0 From nobody Sat Nov 15 17:50:03 2025 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1748108287; cv=none; d=zohomail.com; s=zohoarc; b=VB3rEFcuI3qx1ePkqcUDw+yWbvByAP0WgjLK2K/NbbYZhZ0YvDSlzLRxQklhrKz/qKKmugJD3MWY5MmA45eVpIgZFHzr5sdWR5PkrUm0QF5O4B4QV6uR8xVCzqqdfWCYgG7IHO40heF3a6rkfJVO0eVdt5Rloe29dJ1cOyq3GaA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748108287; 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=wRJ+lxAG6BwZurQNM17kJYNnc6LLjMdGBSuT8AZQBgI=; b=AP/F1+cOyi+4/FzX5ZfULbrIxT4uDIYD32C0TILqWAy0miOuA/0rIYKo8xPp7fz54hMWI6ceV0SKihEOF3Pe1yvHqH/JqaX9pW6hg2GiC5UI53DAeuitXfcn7tbr9OHhz7IMRfg7L75bOhxW7WK+QSkwQ6qCv2OZQggvqsWd41c= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1748108287106972.1326969625196; Sat, 24 May 2025 10:38:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uIsmu-0008S3-98; Sat, 24 May 2025 13:36:00 -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 1uIsmd-0008AZ-D4 for qemu-devel@nongnu.org; Sat, 24 May 2025 13:35:47 -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 1uIsmZ-0000iF-B7 for qemu-devel@nongnu.org; Sat, 24 May 2025 13:35:41 -0400 Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-16-TowhQawqMROCceSkYGaJ3g-1; Sat, 24 May 2025 13:35:36 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.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 mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 52497195608A for ; Sat, 24 May 2025 17:35:35 +0000 (UTC) Received: from localhost (unknown [10.45.242.4]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0F3D730001A1; Sat, 24 May 2025 17:35:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1748108138; 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=wRJ+lxAG6BwZurQNM17kJYNnc6LLjMdGBSuT8AZQBgI=; b=HGW81cuRXL89yOkS8V/v0Ycx60JKx+4UoHylexxec6BgXyH55UhVVYtFlF8zerkbStDwwr 1OCcZEY/ljCbHEOL/CE0a1M0Tt/trg0Y4JntiUPjEGvFwJYu4HTN6g6v6WHkvSqea0bzWT 3gNuMreTcQkB4KayJ1sve44T9DxXuEk= X-MC-Unique: TowhQawqMROCceSkYGaJ3g-1 X-Mimecast-MFC-AGG-ID: TowhQawqMROCceSkYGaJ3g_1748108135 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , stefanha@redhat.com Subject: [PULL 05/19] ui/clipboard: delay clipboard update when not running Date: Sat, 24 May 2025 19:34:58 +0200 Message-ID: <20250524173514.317886-6-marcandre.lureau@redhat.com> In-Reply-To: <20250524173514.317886-1-marcandre.lureau@redhat.com> References: <20250524173514.317886-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.30.177.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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.298, 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=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: 1748108287740116600 From: Marc-Andr=C3=A9 Lureau When VM is paused, we shouldn't notify of clipboard changes, similar to how input are being treated. On unsuspend, notify of the current state. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Daniel P. Berrang=C3=A9 --- ui/clipboard.c | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/ui/clipboard.c b/ui/clipboard.c index f5db60c63d..ec00a0b8ec 100644 --- a/ui/clipboard.c +++ b/ui/clipboard.c @@ -1,4 +1,5 @@ #include "qemu/osdep.h" +#include "system/runstate.h" #include "ui/clipboard.h" #include "trace.h" =20 @@ -7,6 +8,10 @@ static NotifierList clipboard_notifiers =3D =20 static QemuClipboardInfo *cbinfo[QEMU_CLIPBOARD_SELECTION__COUNT]; =20 +static VMChangeStateEntry *cb_change_state_entry =3D NULL; + +static bool cb_reset_serial_on_resume =3D false; + static const VMStateDescription vmstate_cbcontent =3D { .name =3D "clipboard/content", .version_id =3D 0, @@ -33,8 +38,32 @@ const VMStateDescription vmstate_cbinfo =3D { } }; =20 +static void qemu_clipboard_change_state(void *opaque, bool running, RunSta= te state) +{ + int i; + + if (!running) { + return; + } + + if (cb_reset_serial_on_resume) { + qemu_clipboard_reset_serial(); + } + + for (i =3D 0; i < QEMU_CLIPBOARD_SELECTION__COUNT; i++) { + if (cbinfo[i]) { + qemu_clipboard_update(cbinfo[i]); + } + } + +} + void qemu_clipboard_peer_register(QemuClipboardPeer *peer) { + if (cb_change_state_entry =3D=3D NULL) { + cb_change_state_entry =3D qemu_add_vm_change_state_handler(qemu_cl= ipboard_change_state, NULL); + } + notifier_list_add(&clipboard_notifiers, &peer->notifier); } =20 @@ -109,7 +138,9 @@ void qemu_clipboard_update(QemuClipboardInfo *info) } } =20 - notifier_list_notify(&clipboard_notifiers, ¬ify); + if (runstate_is_running() || runstate_check(RUN_STATE_SUSPENDED)) { + notifier_list_notify(&clipboard_notifiers, ¬ify); + } =20 if (cbinfo[info->selection] !=3D info) { qemu_clipboard_info_unref(cbinfo[info->selection]); @@ -189,7 +220,12 @@ void qemu_clipboard_reset_serial(void) info->serial =3D 0; } } - notifier_list_notify(&clipboard_notifiers, ¬ify); + + if (runstate_is_running() || runstate_check(RUN_STATE_SUSPENDED)) { + notifier_list_notify(&clipboard_notifiers, ¬ify); + } else { + cb_reset_serial_on_resume =3D true; + } } =20 void qemu_clipboard_set_data(QemuClipboardPeer *peer, --=20 2.49.0 From nobody Sat Nov 15 17:50:03 2025 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1748108258; cv=none; d=zohomail.com; s=zohoarc; b=YBCWsVqKkWAcESQrVKn+nA7BEmnYUVY5HbS6+J8BsIUUvgSZx/+b/oGajkNvKnlKQ1j8Uof8fwWHTqWgxccrvi//sd44j/u/2DeBqaklq1Z2JXGLOMhSk1PDoyR9m7hY/MQa0gFiIqxf/rD55OLQVLsSLQPW0lp3V4in8kBNibQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748108258; 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=YMRYhi5W/AnDv1YeJ78SpK7glietdkKoLVRQ32Wiy6A=; b=c15m2lFSktlsE5jIhvd3fLf/8xQc+PrYSpI6LuK4DR5u7Mf2Of1uB9el+KzZtJH3FO1uFHGUiDVEeSdsqvt3MDbmUV63ARUeCo3PVkF9Uv2qC2BSALnUP97fk2W1FkmngeKwft5PX+szMN3DuWsJ6IluhlCdMZH9Si+J2LatM/I= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1748108258070680.5804816830025; Sat, 24 May 2025 10:37:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uIsmx-00008r-K2; Sat, 24 May 2025 13:36:03 -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 1uIsmh-0008Dr-6l for qemu-devel@nongnu.org; Sat, 24 May 2025 13:35:51 -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 1uIsmd-0000iR-3v for qemu-devel@nongnu.org; Sat, 24 May 2025 13:35:45 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-36-7ap47jsxORa_AX4TVhqZYA-1; Sat, 24 May 2025 13:35:39 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 862D9180045C for ; Sat, 24 May 2025 17:35:38 +0000 (UTC) Received: from localhost (unknown [10.45.242.4]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id DA286195608D; Sat, 24 May 2025 17:35:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1748108141; 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=YMRYhi5W/AnDv1YeJ78SpK7glietdkKoLVRQ32Wiy6A=; b=VtMrHkF/DZklV9i2LZoHBmz/f6MlmIatqwY9Lm0hfYEBPTcuNF8G4chbkPXtO+oMeizqd/ q3tK8Ms7qGeQRL2pMtuDQbet7HWa0O7NoKzgeDyxou4nr0BK5VoTBOB2wMQi+6cvPjOPSB oYIAzkhZgkUrhYZ2GKIi55+r/AtNPsU= X-MC-Unique: 7ap47jsxORa_AX4TVhqZYA-1 X-Mimecast-MFC-AGG-ID: 7ap47jsxORa_AX4TVhqZYA_1748108138 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , stefanha@redhat.com Subject: [PULL 06/19] ui/vdagent: replace Buffer with GByteArray Date: Sat, 24 May 2025 19:34:59 +0200 Message-ID: <20250524173514.317886-7-marcandre.lureau@redhat.com> In-Reply-To: <20250524173514.317886-1-marcandre.lureau@redhat.com> References: <20250524173514.317886-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.0 on 10.30.177.17 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.298, 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=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: 1748108259097116600 From: Marc-Andr=C3=A9 Lureau Buffer is slightly more advanced than GByteArray, since it has a cursor/position. But vdagent code doesn't need it. This simplify a bit the code, and migration state. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Daniel P. Berrang=C3=A9 --- ui/vdagent.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/ui/vdagent.c b/ui/vdagent.c index 04513ded29..4027126b7d 100644 --- a/ui/vdagent.c +++ b/ui/vdagent.c @@ -47,7 +47,7 @@ struct VDAgentChardev { uint32_t msgsize; uint8_t *xbuf; uint32_t xoff, xsize; - Buffer outbuf; + GByteArray *outbuf; =20 /* mouse */ DeviceState mouse_dev; @@ -142,16 +142,16 @@ static void vdagent_send_buf(VDAgentChardev *vd) { uint32_t len; =20 - while (!buffer_empty(&vd->outbuf)) { + while (vd->outbuf->len) { len =3D qemu_chr_be_can_write(CHARDEV(vd)); if (len =3D=3D 0) { return; } - if (len > vd->outbuf.offset) { - len =3D vd->outbuf.offset; + if (len > vd->outbuf->len) { + len =3D vd->outbuf->len; } - qemu_chr_be_write(CHARDEV(vd), vd->outbuf.buffer, len); - buffer_advance(&vd->outbuf, len); + qemu_chr_be_write(CHARDEV(vd), vd->outbuf->data, len); + g_byte_array_remove_range(vd->outbuf, 0, len); } } =20 @@ -166,7 +166,7 @@ static void vdagent_send_msg(VDAgentChardev *vd, VDAgen= tMessage *msg) =20 msg->protocol =3D VD_AGENT_PROTOCOL; =20 - if (vd->outbuf.offset + msgsize > VDAGENT_BUFFER_LIMIT) { + if (vd->outbuf->len + msgsize > VDAGENT_BUFFER_LIMIT) { error_report("buffer full, dropping message"); return; } @@ -177,9 +177,8 @@ static void vdagent_send_msg(VDAgentChardev *vd, VDAgen= tMessage *msg) if (chunk.size > 1024) { chunk.size =3D 1024; } - buffer_reserve(&vd->outbuf, sizeof(chunk) + chunk.size); - buffer_append(&vd->outbuf, &chunk, sizeof(chunk)); - buffer_append(&vd->outbuf, msgbuf + msgoff, chunk.size); + g_byte_array_append(vd->outbuf, (void *)&chunk, sizeof(chunk)); + g_byte_array_append(vd->outbuf, msgbuf + msgoff, chunk.size); msgoff +=3D chunk.size; } vdagent_send_buf(vd); @@ -859,7 +858,7 @@ static void vdagent_disconnect(VDAgentChardev *vd) { trace_vdagent_disconnect(); =20 - buffer_reset(&vd->outbuf); + g_byte_array_set_size(vd->outbuf, 0); vdagent_reset_bufs(vd); vd->caps =3D 0; if (vd->mouse_hs) { @@ -920,7 +919,7 @@ static void vdagent_chr_init(Object *obj) { VDAgentChardev *vd =3D QEMU_VDAGENT_CHARDEV(obj); =20 - buffer_init(&vd->outbuf, "vdagent-outbuf"); + vd->outbuf =3D g_byte_array_new(); error_setg(&vd->migration_blocker, "The vdagent chardev doesn't yet support migration"); } @@ -934,7 +933,7 @@ static void vdagent_chr_fini(Object *obj) if (vd->mouse_hs) { qemu_input_handler_unregister(vd->mouse_hs); } - buffer_free(&vd->outbuf); + g_clear_pointer(&vd->outbuf, g_byte_array_unref); } =20 static const TypeInfo vdagent_chr_type_info =3D { --=20 2.49.0 From nobody Sat Nov 15 17:50:03 2025 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1748108225; cv=none; d=zohomail.com; s=zohoarc; b=f4glvayD/d3GKQCpU1IyM95KvR+SGXmIeN3MF+/hacELmTDam1RSzBjSkqYaUdgel2QXlCUoJeOJPVimKy3gMZ4dIroLAW88qD/IOwdCeRMHo2FZ5VsAqEPFeq1bnDNQIn3emH0h57Xm2/mRJPjG8d4dXZDSSDOd7sJ4wju+e9A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748108225; 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=uX4W6oscBViDkzVCmMiWL2OgGFIZSnMNoIBKHZYTsUQ=; b=n69I8N1+yrvoNOvxgklm8UW1ZKHNmqFDYPDthmSj1k/bFwltY5lQnnEOIdEJEsm5KAGgIAZwFVyV49ncwaXDrX9SP35tR2dHoMt2SxQ3ydWXb/K/94R+i13z0/1iJkf5ivMAA0KBRu1Q8RA4UUV2pemOV3mqEjqe+c3txhToMLI= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1748108225706496.6102438323536; Sat, 24 May 2025 10:37:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uIsmt-0008Q3-IB; Sat, 24 May 2025 13:35:59 -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 1uIsmh-0008Ds-6l for qemu-devel@nongnu.org; Sat, 24 May 2025 13:35:51 -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 1uIsmf-0000ii-1T for qemu-devel@nongnu.org; Sat, 24 May 2025 13:35:46 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-673-jBiUQ04TPvK_5ZgVc5dpkg-1; Sat, 24 May 2025 13:35:42 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C31911800446 for ; Sat, 24 May 2025 17:35:41 +0000 (UTC) Received: from localhost (unknown [10.45.242.4]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id F422D19560AF; Sat, 24 May 2025 17:35:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1748108143; 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=uX4W6oscBViDkzVCmMiWL2OgGFIZSnMNoIBKHZYTsUQ=; b=M0aNwNlaTT8o/lnUZ5KnDREP+B+eDbTF94LecN9wWwC1zlVwfH2idb+nmQrcYHY/Bd3Voq yxmjE7L7Wi4QZ48/Ct6kdIns+28wcYM5NwlyfNXnWsDki45MrbvEUk7t4vAYtN/Yl9kSVh S5/oJjMjWpyH4DGbxA5s0Xef+d6PXqM= X-MC-Unique: jBiUQ04TPvK_5ZgVc5dpkg-1 X-Mimecast-MFC-AGG-ID: jBiUQ04TPvK_5ZgVc5dpkg_1748108141 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , stefanha@redhat.com Subject: [PULL 07/19] ui/vdagent: keep "connected" state Date: Sat, 24 May 2025 19:35:00 +0200 Message-ID: <20250524173514.317886-8-marcandre.lureau@redhat.com> In-Reply-To: <20250524173514.317886-1-marcandre.lureau@redhat.com> References: <20250524173514.317886-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.0 on 10.30.177.40 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.298, 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=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: 1748108226822116600 From: Marc-Andr=C3=A9 Lureau During post-load of migration, virtio will notify of fe_open state. However vdagent code will handle this as a reconnection. This will trigger a connection reset/caps with the agent. Check if the state actually changed before resetting the connection. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Daniel P. Berrang=C3=A9 --- ui/vdagent.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ui/vdagent.c b/ui/vdagent.c index 4027126b7d..210b8c14ca 100644 --- a/ui/vdagent.c +++ b/ui/vdagent.c @@ -40,6 +40,7 @@ struct VDAgentChardev { bool clipboard; =20 /* guest vdagent */ + bool connected; uint32_t caps; VDIChunkHeader chunk; uint32_t chunksize; @@ -858,6 +859,7 @@ static void vdagent_disconnect(VDAgentChardev *vd) { trace_vdagent_disconnect(); =20 + vd->connected =3D false; g_byte_array_set_size(vd->outbuf, 0); vdagent_reset_bufs(vd); vd->caps =3D 0; @@ -876,6 +878,10 @@ static void vdagent_chr_set_fe_open(struct Chardev *ch= r, int fe_open) =20 trace_vdagent_fe_open(fe_open); =20 + if (vd->connected =3D=3D fe_open) { + return; + } + if (!fe_open) { trace_vdagent_close(); vdagent_disconnect(vd); @@ -885,6 +891,7 @@ static void vdagent_chr_set_fe_open(struct Chardev *chr= , int fe_open) return; } =20 + vd->connected =3D true; vdagent_send_caps(vd, true); } =20 --=20 2.49.0 From nobody Sat Nov 15 17:50:03 2025 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1748108287; cv=none; d=zohomail.com; s=zohoarc; b=Mq5EZecJLIiKWkG7yuiZm7y6QpLR6jeI6caiI4WtldG6WD7WLpuv5eyaAUyc0y5dWqyMGEpugJfhKKOeKcy6oO3ArWXG7zQTB3T0LvP49KCPoZtU5SiDsX4iIr/RqnPegAvHLJXznOsfsjufL938uXQwJVtAcAiXTTHHoecU5aU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748108287; 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=7rJw3QVQTA9bB0if4ANHAV4qW4nScS/fUz8P5Ca7OuI=; b=mM9eU7JdSwuWUwUCG0QVXPi98u1xCYcnBaUIYQfJh0W9QdStBXS21YjxvyUaYKiVpBdHZOtyaW0ogmWkGj6cmc+z9VVJOlfcl/Roky8CqlUDmL+coCHDjGtaCdlOT/VEL+EvwrxkwkVSMRNfZE1Ohz8TvZSiMLSvsaWmdVea+pQ= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1748108287629436.27638156116086; Sat, 24 May 2025 10:38:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uIsmu-0008Ul-Uk; Sat, 24 May 2025 13:36:01 -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 1uIsmm-0008Ee-4q for qemu-devel@nongnu.org; Sat, 24 May 2025 13:35:56 -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 1uIsmj-0000jN-St for qemu-devel@nongnu.org; Sat, 24 May 2025 13:35:51 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-532-eOUfVA_pPIqTids8NT6NEA-1; Sat, 24 May 2025 13:35:46 -0400 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3BE9E1800361 for ; Sat, 24 May 2025 17:35:45 +0000 (UTC) Received: from localhost (unknown [10.45.242.4]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2B5AF19560AB; Sat, 24 May 2025 17:35:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1748108149; 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=7rJw3QVQTA9bB0if4ANHAV4qW4nScS/fUz8P5Ca7OuI=; b=Wpy1DQ45SP5ReY5XNAaWF2JOj1XHL4BE/5uTe0u5YhWq0T25OjS4nmLenrDV0jwnD4rZ9J Tl10dDUmMw1jxmz2gwv0tsk50ylcryka5xvepXubQKrKcT1BX1+vaY3Fh6mWWIEGuMLcFl 6dkbXttzIGVSSG9jZ4V3TweVczoOcr0= X-MC-Unique: eOUfVA_pPIqTids8NT6NEA-1 X-Mimecast-MFC-AGG-ID: eOUfVA_pPIqTids8NT6NEA_1748108145 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , stefanha@redhat.com Subject: [PULL 08/19] ui/vdagent: factor out clipboard peer registration Date: Sat, 24 May 2025 19:35:01 +0200 Message-ID: <20250524173514.317886-9-marcandre.lureau@redhat.com> In-Reply-To: <20250524173514.317886-1-marcandre.lureau@redhat.com> References: <20250524173514.317886-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.0 on 10.30.177.15 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.298, 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=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: 1748108289426116600 From: Marc-Andr=C3=A9 Lureau This allows common code reuse during migration. Note that resetting the serial is now done regardless if the clipboard peer was registered or not. This should still be correct. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Daniel P. Berrang=C3=A9 --- ui/vdagent.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/ui/vdagent.c b/ui/vdagent.c index 210b8c14ca..fcbd7b167b 100644 --- a/ui/vdagent.c +++ b/ui/vdagent.c @@ -694,6 +694,18 @@ static void vdagent_chr_open(Chardev *chr, *be_opened =3D true; } =20 +static void vdagent_clipboard_peer_register(VDAgentChardev *vd) +{ + if (vd->cbpeer.notifier.notify !=3D NULL) { + return; + } + + vd->cbpeer.name =3D "vdagent"; + vd->cbpeer.notifier.notify =3D vdagent_clipboard_notify; + vd->cbpeer.request =3D vdagent_clipboard_request; + qemu_clipboard_peer_register(&vd->cbpeer); +} + static void vdagent_chr_recv_caps(VDAgentChardev *vd, VDAgentMessage *msg) { VDAgentAnnounceCapabilities *caps =3D (void *)msg->data; @@ -720,13 +732,9 @@ static void vdagent_chr_recv_caps(VDAgentChardev *vd, = VDAgentMessage *msg) =20 memset(vd->last_serial, 0, sizeof(vd->last_serial)); =20 - if (have_clipboard(vd) && vd->cbpeer.notifier.notify =3D=3D NULL) { + if (have_clipboard(vd)) { qemu_clipboard_reset_serial(); - - vd->cbpeer.name =3D "vdagent"; - vd->cbpeer.notifier.notify =3D vdagent_clipboard_notify; - vd->cbpeer.request =3D vdagent_clipboard_request; - qemu_clipboard_peer_register(&vd->cbpeer); + vdagent_clipboard_peer_register(vd); } } =20 --=20 2.49.0 From nobody Sat Nov 15 17:50:03 2025 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1748108244; cv=none; d=zohomail.com; s=zohoarc; b=NmyHJ2pQZG2sEjuQQR5340T9CWrtiZOOiX7TXknM7AP6h/tEjdsGmdtNErE8UmgqqKugcaAJSKpgQI7gOtgwI7UDNCUpYhqx/KDFlQTeHDYmjJsUUnxEV58bYQNEbRyQTbjhCmTmtgZV1/27NhQt6A9PBMgB2eHnMDLKmKw6Uj4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748108244; 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=XUfnDwYRc5/qq1OUomuApWVfWvzcXVHwfvl96q7zTjo=; b=eRJJGWQjfaOQuHZnnWNIyYiwt1yM/mQJapysUgA6IE7cRx20dnDlwcje5w/hCoMVvfo3Du0VVHho6f6bbl0FeLFZK5s9fROfh1N8jIfeuGw8cS0WwxXpcYMblNX718zAvACZnJo2qKGDRbD/wSCpCx234YGpR48bIDrquMBHlyQ= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1748108243911338.81239185873767; Sat, 24 May 2025 10:37:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uIsmv-00005C-M8; Sat, 24 May 2025 13:36:01 -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 1uIsmn-0008Eq-6r for qemu-devel@nongnu.org; Sat, 24 May 2025 13:35:57 -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 1uIsml-0000jY-Ky for qemu-devel@nongnu.org; Sat, 24 May 2025 13:35:52 -0400 Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-643-7-BnLn_uNxOP5rYZRr7h5Q-1; Sat, 24 May 2025 13:35:48 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2B86519560AA for ; Sat, 24 May 2025 17:35:48 +0000 (UTC) Received: from localhost (unknown [10.45.242.4]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7DB0819560AF; Sat, 24 May 2025 17:35:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1748108151; 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=XUfnDwYRc5/qq1OUomuApWVfWvzcXVHwfvl96q7zTjo=; b=BHgd1IdvfkL9jNJNTjLO20ICU/rF6jiuU4kQbr+P7bM3TEy7SPXhGc3ZSBMAkNXj0rqpzM hcGDJeBud+UyACDYKbGFpahgmCBdpJHTRbqoM6i8JIld2UvqlzjYr1bdvHU9ppBiBHo3xN l2/Whd1x5WZtdE7NoTh1pJs6Ip7Y9Eg= X-MC-Unique: 7-BnLn_uNxOP5rYZRr7h5Q-1 X-Mimecast-MFC-AGG-ID: 7-BnLn_uNxOP5rYZRr7h5Q_1748108148 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , stefanha@redhat.com Subject: [PULL 09/19] ui/vdagent: add migration support Date: Sat, 24 May 2025 19:35:02 +0200 Message-ID: <20250524173514.317886-10-marcandre.lureau@redhat.com> In-Reply-To: <20250524173514.317886-1-marcandre.lureau@redhat.com> References: <20250524173514.317886-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.0 on 10.30.177.40 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.298, 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=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: 1748108251061116600 From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Daniel P. Berrang=C3=A9 --- ui/vdagent.c | 142 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 142 insertions(+) diff --git a/ui/vdagent.c b/ui/vdagent.c index fcbd7b167b..adc8755bd9 100644 --- a/ui/vdagent.c +++ b/ui/vdagent.c @@ -10,6 +10,7 @@ #include "ui/clipboard.h" #include "ui/console.h" #include "ui/input.h" +#include "migration/vmstate.h" #include "trace.h" =20 #include "qapi/qapi-types-char.h" @@ -930,6 +931,146 @@ static void vdagent_chr_class_init(ObjectClass *oc, c= onst void *data) cc->chr_accept_input =3D vdagent_chr_accept_input; } =20 +static int post_load(void *opaque, int version_id) +{ + VDAgentChardev *vd =3D QEMU_VDAGENT_CHARDEV(opaque); + + if (have_mouse(vd) && vd->mouse_hs) { + qemu_input_handler_activate(vd->mouse_hs); + } + + if (have_clipboard(vd)) { + vdagent_clipboard_peer_register(vd); + } + + return 0; +} + +static const VMStateDescription vmstate_chunk =3D { + .name =3D "vdagent/chunk", + .version_id =3D 0, + .minimum_version_id =3D 0, + .fields =3D (const VMStateField[]) { + VMSTATE_UINT32(port, VDIChunkHeader), + VMSTATE_UINT32(size, VDIChunkHeader), + VMSTATE_END_OF_LIST() + } +}; + +static const VMStateDescription vmstate_vdba =3D { + .name =3D "vdagent/bytearray", + .version_id =3D 0, + .minimum_version_id =3D 0, + .fields =3D (const VMStateField[]) { + VMSTATE_UINT32(len, GByteArray), + VMSTATE_VBUFFER_ALLOC_UINT32(data, GByteArray, 0, 0, len), + VMSTATE_END_OF_LIST() + } +}; + +struct CBInfoArray { + uint32_t n; + QemuClipboardInfo cbinfo[QEMU_CLIPBOARD_SELECTION__COUNT]; +}; + +static const VMStateDescription vmstate_cbinfo_array =3D { + .name =3D "cbinfoarray", + .fields =3D (const VMStateField[]) { + VMSTATE_UINT32(n, struct CBInfoArray), + VMSTATE_STRUCT_VARRAY_UINT32(cbinfo, struct CBInfoArray, n, + 0, vmstate_cbinfo, QemuClipboardInfo), + VMSTATE_END_OF_LIST() + } +}; + +static int put_cbinfo(QEMUFile *f, void *pv, size_t size, + const VMStateField *field, JSONWriter *vmdesc) +{ + VDAgentChardev *vd =3D QEMU_VDAGENT_CHARDEV(pv); + struct CBInfoArray cbinfo =3D {}; + int i; + + if (!have_clipboard(vd)) { + return 0; + } + + for (i =3D 0; i < QEMU_CLIPBOARD_SELECTION__COUNT; i++) { + if (qemu_clipboard_peer_owns(&vd->cbpeer, i)) { + cbinfo.cbinfo[cbinfo.n++] =3D *qemu_clipboard_info(i); + } + } + + return vmstate_save_state(f, &vmstate_cbinfo_array, &cbinfo, vmdesc); +} + +static int get_cbinfo(QEMUFile *f, void *pv, size_t size, + const VMStateField *field) +{ + VDAgentChardev *vd =3D QEMU_VDAGENT_CHARDEV(pv); + struct CBInfoArray cbinfo =3D {}; + int i, ret; + + if (!have_clipboard(vd)) { + return 0; + } + + vdagent_clipboard_peer_register(vd); + + ret =3D vmstate_load_state(f, &vmstate_cbinfo_array, &cbinfo, 0); + if (ret) { + return ret; + } + + for (i =3D 0; i < cbinfo.n; i++) { + g_autoptr(QemuClipboardInfo) info =3D + qemu_clipboard_info_new(&vd->cbpeer, cbinfo.cbinfo[i].selectio= n); + /* this will steal clipboard data pointer from cbinfo.types */ + memcpy(info->types, cbinfo.cbinfo[i].types, sizeof(cbinfo.cbinfo[i= ].types)); + qemu_clipboard_update(info); + } + + return 0; +} + +static const VMStateInfo vmstate_cbinfos =3D { + .name =3D "vdagent/cbinfos", + .get =3D get_cbinfo, + .put =3D put_cbinfo, +}; + +static const VMStateDescription vmstate_vdagent =3D { + .name =3D "vdagent", + .version_id =3D 0, + .minimum_version_id =3D 0, + .post_load =3D post_load, + .fields =3D (const VMStateField[]) { + VMSTATE_BOOL(connected, VDAgentChardev), + VMSTATE_UINT32(caps, VDAgentChardev), + VMSTATE_STRUCT(chunk, VDAgentChardev, 0, vmstate_chunk, VDIChunkHe= ader), + VMSTATE_UINT32(chunksize, VDAgentChardev), + VMSTATE_UINT32(msgsize, VDAgentChardev), + VMSTATE_VBUFFER_ALLOC_UINT32(msgbuf, VDAgentChardev, 0, 0, msgsize= ), + VMSTATE_UINT32(xsize, VDAgentChardev), + VMSTATE_UINT32(xoff, VDAgentChardev), + VMSTATE_VBUFFER_ALLOC_UINT32(xbuf, VDAgentChardev, 0, 0, xsize), + VMSTATE_STRUCT_POINTER(outbuf, VDAgentChardev, vmstate_vdba, GByte= Array), + VMSTATE_UINT32(mouse_x, VDAgentChardev), + VMSTATE_UINT32(mouse_y, VDAgentChardev), + VMSTATE_UINT32(mouse_btn, VDAgentChardev), + VMSTATE_UINT32(mouse_display, VDAgentChardev), + VMSTATE_UINT32_ARRAY(last_serial, VDAgentChardev, + QEMU_CLIPBOARD_SELECTION__COUNT), + VMSTATE_UINT32_ARRAY(cbpending, VDAgentChardev, + QEMU_CLIPBOARD_SELECTION__COUNT), + { + .name =3D "cbinfos", + .info =3D &vmstate_cbinfos, + .flags =3D VMS_SINGLE, + }, + VMSTATE_END_OF_LIST() + } +}; + static void vdagent_chr_init(Object *obj) { VDAgentChardev *vd =3D QEMU_VDAGENT_CHARDEV(obj); @@ -937,6 +1078,7 @@ static void vdagent_chr_init(Object *obj) vd->outbuf =3D g_byte_array_new(); error_setg(&vd->migration_blocker, "The vdagent chardev doesn't yet support migration"); + vmstate_register_any(NULL, &vmstate_vdagent, vd); } =20 static void vdagent_chr_fini(Object *obj) --=20 2.49.0 From nobody Sat Nov 15 17:50:03 2025 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1748108218; cv=none; d=zohomail.com; s=zohoarc; b=mhblhnXOyYVdqLAhB7XYhsKqitJsJCncv7TMP4aOR7dNp8Usf09iuqjT1U9Y7mDQr5PxrK7qP63Rsb8M4IDhsu1P3ejJ0MHSxZgPcs5MW54Rq8bJIdViHWzmISMblX1eAJTBiRlbf7tIq2+ePZdi6HZC3GLHxJByUB/w9ci1+Bk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748108218; 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=TkdhgyOb714kh1D6jnvl7f0hAIUjxiJ6emgKevVzWKs=; b=FtvXtMEbAh4+ds9oH7240aKPc4AlmDXAktrWXxPvGFNDVNSHSbal2zN0QLMpZDETDEG2R7zweHh8UqfdPNoFsjW3JgaPZSGND4oWONrz6UlTPAa2U1gykNE95I2gTbtiK6DRXCLxdcm5A5jRftsxcc5uWewsgKea49zB4gf8egQ= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1748108218828409.7013776654884; Sat, 24 May 2025 10:36:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uIsmx-000092-MP; Sat, 24 May 2025 13:36:03 -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 1uIsmq-0008Ib-IN for qemu-devel@nongnu.org; Sat, 24 May 2025 13:35:57 -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 1uIsmp-0000jw-4v for qemu-devel@nongnu.org; Sat, 24 May 2025 13:35:56 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-554-RAZANPQ9PtWC3CTN6yTAkg-1; Sat, 24 May 2025 13:35:52 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.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 mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5FD4218004AD for ; Sat, 24 May 2025 17:35:51 +0000 (UTC) Received: from localhost (unknown [10.45.242.4]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 3BD6930001B5; Sat, 24 May 2025 17:35:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1748108153; 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=TkdhgyOb714kh1D6jnvl7f0hAIUjxiJ6emgKevVzWKs=; b=Uhv0Bd98Z3QsmiJvNdEeW8FzTD4rDUbdpQGcfOKOii2QJgJd17jfTFcwYVO53oWkyBqa6q 6FvwR4G26ulnVcC/KDZF9sP/ONeUKH+uIYXapniDGFv+MjypDcGoDL2XL4fwIlj70uXPoR 89AnTsJiNwyfF6YhCC2UEsDQUMaVwlk= X-MC-Unique: RAZANPQ9PtWC3CTN6yTAkg-1 X-Mimecast-MFC-AGG-ID: RAZANPQ9PtWC3CTN6yTAkg_1748108151 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , stefanha@redhat.com Subject: [PULL 10/19] ui/vdagent: remove migration blocker Date: Sat, 24 May 2025 19:35:03 +0200 Message-ID: <20250524173514.317886-11-marcandre.lureau@redhat.com> In-Reply-To: <20250524173514.317886-1-marcandre.lureau@redhat.com> References: <20250524173514.317886-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.30.177.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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.298, 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=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: 1748108220718116600 From: Marc-Andr=C3=A9 Lureau Fixes: https://issues.redhat.com/browse/RHEL-81894 Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Daniel P. Berrang=C3=A9 --- ui/vdagent.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/ui/vdagent.c b/ui/vdagent.c index adc8755bd9..c0746fe5b1 100644 --- a/ui/vdagent.c +++ b/ui/vdagent.c @@ -6,7 +6,6 @@ #include "qemu/option.h" #include "qemu/units.h" #include "hw/qdev-core.h" -#include "migration/blocker.h" #include "ui/clipboard.h" #include "ui/console.h" #include "ui/input.h" @@ -33,9 +32,6 @@ struct VDAgentChardev { Chardev parent; =20 - /* TODO: migration isn't yet supported */ - Error *migration_blocker; - /* config */ bool mouse; bool clipboard; @@ -673,10 +669,6 @@ static void vdagent_chr_open(Chardev *chr, return; #endif =20 - if (migrate_add_blocker(&vd->migration_blocker, errp) !=3D 0) { - return; - } - vd->mouse =3D VDAGENT_MOUSE_DEFAULT; if (cfg->has_mouse) { vd->mouse =3D cfg->mouse; @@ -1076,8 +1068,6 @@ static void vdagent_chr_init(Object *obj) VDAgentChardev *vd =3D QEMU_VDAGENT_CHARDEV(obj); =20 vd->outbuf =3D g_byte_array_new(); - error_setg(&vd->migration_blocker, - "The vdagent chardev doesn't yet support migration"); vmstate_register_any(NULL, &vmstate_vdagent, vd); } =20 @@ -1085,7 +1075,6 @@ static void vdagent_chr_fini(Object *obj) { VDAgentChardev *vd =3D QEMU_VDAGENT_CHARDEV(obj); =20 - migrate_del_blocker(&vd->migration_blocker); vdagent_disconnect(vd); if (vd->mouse_hs) { qemu_input_handler_unregister(vd->mouse_hs); --=20 2.49.0 From nobody Sat Nov 15 17:50:03 2025 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1748108244; cv=none; d=zohomail.com; s=zohoarc; b=OZCRlj3m2YCkADwAwC/khdxUTj88qNl/CUQa1oDF+YN92LoUAe3XBM0sYr28zi4C94dxJkdJicHjSLunloHRYv0JeqRdGPNwfpXEcILxPbrd8jhjD+YQgKSS3arhKQ5IrGZoiAMefc8jg7z/xQb1A0UK1MX+6AoVWTpKgMrc/SM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748108244; 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=EvfmhXkFKgpdo74Mx0i48lY/oqi/ZCY4LrmYKzh3wB0=; b=TrFvea9FGaCukGQRDkH+e4B7PvdMNAYAMx9kFg5R5feY+G7OmWk/HKhAYtR9GkszfhyeBfGmBZWq78eV0G+cKvAeKwytBT67+MdIHaJBBQsS/zetAOc3BChx5AthfpimRkbenz7zfgRf51k4wbDBFJaMfUqjMlHcOrzBBu8wI7o= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1748108244076673.8643906494609; Sat, 24 May 2025 10:37:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uIsmx-000095-P0; Sat, 24 May 2025 13:36:03 -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 1uIsmt-0008Re-SQ for qemu-devel@nongnu.org; Sat, 24 May 2025 13:36:00 -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 1uIsms-0000kG-6b for qemu-devel@nongnu.org; Sat, 24 May 2025 13:35:59 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-650-1-eYWJV0MuiQ07Hf6nnN1Q-1; Sat, 24 May 2025 13:35:55 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E7E7318004AD; Sat, 24 May 2025 17:35:54 +0000 (UTC) Received: from localhost (unknown [10.45.242.4]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A1C2F19560AD; Sat, 24 May 2025 17:35:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1748108157; 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=EvfmhXkFKgpdo74Mx0i48lY/oqi/ZCY4LrmYKzh3wB0=; b=QoAzyK1NCx9YXuf05deX5Z14rtUmy2WQh8f50pAe0yhXoW16RcJ4Q58r6cEBSbKVyCCg9s guvwouare5ONHgOJ+mWjzJpCCUQrOJNaWIxA9/gkIcpvpHVYJ5xxrxJXJu0wZwoCaEhFeX cnpTwnHYJL7PwgrWG4YLB/K+FwMeZaM= X-MC-Unique: 1-eYWJV0MuiQ07Hf6nnN1Q-1 X-Mimecast-MFC-AGG-ID: 1-eYWJV0MuiQ07Hf6nnN1Q_1748108155 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , stefanha@redhat.com, Weifeng Liu Subject: [PULL 11/19] ui/gtk: Document scale and coordinate handling Date: Sat, 24 May 2025 19:35:04 +0200 Message-ID: <20250524173514.317886-12-marcandre.lureau@redhat.com> In-Reply-To: <20250524173514.317886-1-marcandre.lureau@redhat.com> References: <20250524173514.317886-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.0 on 10.30.177.17 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.298, 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=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: 1748108245317116600 From: Weifeng Liu The existence of multiple scaling factors forces us to deal with various coordinate systems and this would be confusing. It would be beneficial to define the concepts clearly and use consistent representation for variables in different coordinates. Signed-off-by: Weifeng Liu Message-ID: <20250511073337.876650-2-weifeng.liu.z@gmail.com> Acked-by: Gerd Hoffmann Acked-by: Marc-Andr=C3=A9 Lureau --- ui/gtk.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/ui/gtk.c b/ui/gtk.c index 982037b2c0..9f3171abc5 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -800,6 +800,71 @@ void gd_update_monitor_refresh_rate(VirtualConsole *vc= , GtkWidget *widget) #endif } =20 +/** + * DOC: Coordinate handling. + * + * We are coping with sizes and positions in various coordinates and the + * handling of these coordinates is somewhat confusing. It would benefit us + * all if we define these coordinates explicitly and clearly. Besides, it's + * also helpful to follow the same naming convention for variables + * representing values in different coordinates. + * + * I. Definitions + * + * - (guest) buffer coordinate: this is the coordinates that the guest will + * see. The x/y offsets and width/height specified in commands sent by + * guest is basically in buffer coordinate. + * + * - (host) pixel coordinate: this is the coordinate in pixel level on the + * host destop. A window/widget of width 300 in pixel coordinate means it + * occupies 300 pixels horizontally. + * + * - (host) logical window coordinate: the existence of global scaling + * factor in desktop level makes this kind of coordinate play a role. It + * always holds that (logical window size) * (global scale factor) =3D + * (pixel size). + * + * - global scale factor: this is specified in desktop level and is + * typically invariant during the life cycle of the process. Users with + * high-DPI monitors might set this scale, for example, to 2, in order to + * make the UI look larger. + * + * - zooming scale: this can be freely controlled by the QEMU user to zoom + * in/out the guest content. + * + * II. Representation + * + * We'd like to use consistent representation for variables in different + * coordinates: + * - buffer coordinate: prefix fb + * - pixel coordinate: prefix p + * - logical window coordinate: prefix w + * + * For scales: + * - global scale factor: prefix gs + * - zooming scale: prefix scale/s + * + * Example: fbw, pw, ww for width in different coordinates + * + * III. Equation + * + * - fbw * gs * scale_x =3D pw + * - pw =3D gs * ww + * + * Consequently we have + * + * - fbw * scale_x =3D ww + * + * Example: assuming we are running QEMU on a 3840x2160 screen and have set + * global scaling factor to 2, if the guest buffer size is 1920x1080 and t= he + * zooming scale is 0.5, then we have: + * - fbw =3D 1920, fbh =3D 1080 + * - pw =3D 1920, ph =3D 1080 + * - ww =3D 960, wh =3D 540 + * A bonus of this configuration is that we can achieve pixel to pixel + * presentation of the guest content. + */ + static gboolean gd_draw_event(GtkWidget *widget, cairo_t *cr, void *opaque) { VirtualConsole *vc =3D opaque; --=20 2.49.0 From nobody Sat Nov 15 17:50:03 2025 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1748108221; cv=none; d=zohomail.com; s=zohoarc; b=dSU+iX1y+PYB0+5ZUYyf54NVclXSCsv7D4QZZIDjlZntn0dQYbgITsVNn//qB9A3VzVzGqPtgAYLlsZisKeIVPH8NuA8/vcDRqcgDJ90oKTtpHUVNbcvK+YVBJ+VzXhiSelFMY8bmUGfh+9NOmIeIf2kDSriJeEmDrcC0Q53xBo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748108221; 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=qXLWwWzLjnXpYPKr4i5MygBwMi0Y2LvveOpH7vQySWA=; b=jADhcK3e8crNsSEtbDMhyTlIhzJHurIZ3fKLh4zA8EC+eRY7YEFz4GOYjw8fmKyq8ihYfHyk7MHueqsUKi5SduRzlrTDr4RSVLa8SeXeh3fH/MFpLIZQKNZMYuKfPEqJIR+ySjU+jFVzki52AJyVFP1TKdjULLyggqWAuUFBEZY= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1748108221327302.22729461741574; Sat, 24 May 2025 10:37:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uIsn2-0000Ii-9l; Sat, 24 May 2025 13:36:08 -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 1uIsmy-0000D0-Ru for qemu-devel@nongnu.org; Sat, 24 May 2025 13:36:05 -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 1uIsmw-0000ke-GJ for qemu-devel@nongnu.org; Sat, 24 May 2025 13:36:04 -0400 Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-414-B_GPTML5PKyC0L6KSV-fRQ-1; Sat, 24 May 2025 13:35:58 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id ECE8B1956087; Sat, 24 May 2025 17:35:57 +0000 (UTC) Received: from localhost (unknown [10.45.242.4]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 18F5E19560AF; Sat, 24 May 2025 17:35:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1748108162; 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=qXLWwWzLjnXpYPKr4i5MygBwMi0Y2LvveOpH7vQySWA=; b=SBqMtuaMRsA1iNz9kwMZ9XNeJIn39dR91jDyV6ckf2oL7diseyNjaO2Uifx18jiEgTtC2L uuSz+uuLpaQtSdoCrP4niSs6DFhOYfFzCD/OP7x8ghzE8G3e/aP5Qiqmy26zgJ+MSK3amU UDi72ePmXiJZtgGwasksj+O4fg5kTXU= X-MC-Unique: B_GPTML5PKyC0L6KSV-fRQ-1 X-Mimecast-MFC-AGG-ID: B_GPTML5PKyC0L6KSV-fRQ_1748108158 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , stefanha@redhat.com, Weifeng Liu Subject: [PULL 12/19] ui/gtk: Use consistent naming for variables in different coordinates Date: Sat, 24 May 2025 19:35:05 +0200 Message-ID: <20250524173514.317886-13-marcandre.lureau@redhat.com> In-Reply-To: <20250524173514.317886-1-marcandre.lureau@redhat.com> References: <20250524173514.317886-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.0 on 10.30.177.40 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.298, 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=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: 1748108223080116600 From: Weifeng Liu Now that we've documented definitions and presentation of various coordinates, let's enforce the rules. Signed-off-by: Weifeng Liu Message-ID: <20250511073337.876650-3-weifeng.liu.z@gmail.com> Acked-by: Gerd Hoffmann Acked-by: Marc-Andr=C3=A9 Lureau --- ui/gtk-egl.c | 12 +++-- ui/gtk-gl-area.c | 14 ++--- ui/gtk.c | 133 ++++++++++++++++++++++++----------------------- 3 files changed, 82 insertions(+), 77 deletions(-) diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c index f7a428c86a..947c99334b 100644 --- a/ui/gtk-egl.c +++ b/ui/gtk-egl.c @@ -70,16 +70,18 @@ void gd_egl_draw(VirtualConsole *vc) QemuDmaBuf *dmabuf =3D vc->gfx.guest_fb.dmabuf; int fence_fd; #endif - int ww, wh, ws; + int ww, wh, pw, ph, gs; =20 if (!vc->gfx.gls) { return; } =20 window =3D gtk_widget_get_window(vc->gfx.drawing_area); - ws =3D gdk_window_get_scale_factor(window); - ww =3D gdk_window_get_width(window) * ws; - wh =3D gdk_window_get_height(window) * ws; + gs =3D gdk_window_get_scale_factor(window); + ww =3D gdk_window_get_width(window); + wh =3D gdk_window_get_height(window); + pw =3D ww * gs; + ph =3D wh * gs; =20 if (vc->gfx.scanout_mode) { #ifdef CONFIG_GBM @@ -115,7 +117,7 @@ void gd_egl_draw(VirtualConsole *vc) eglMakeCurrent(qemu_egl_display, vc->gfx.esurface, vc->gfx.esurface, vc->gfx.ectx); =20 - surface_gl_setup_viewport(vc->gfx.gls, vc->gfx.ds, ww, wh); + surface_gl_setup_viewport(vc->gfx.gls, vc->gfx.ds, pw, ph); surface_gl_render_texture(vc->gfx.gls, vc->gfx.ds); =20 eglSwapBuffers(qemu_egl_display, vc->gfx.esurface); diff --git a/ui/gtk-gl-area.c b/ui/gtk-gl-area.c index 2c9a0db425..ba9fbec432 100644 --- a/ui/gtk-gl-area.c +++ b/ui/gtk-gl-area.c @@ -42,16 +42,16 @@ void gd_gl_area_draw(VirtualConsole *vc) #ifdef CONFIG_GBM QemuDmaBuf *dmabuf =3D vc->gfx.guest_fb.dmabuf; #endif - int ww, wh, ws, y1, y2; + int pw, ph, gs, y1, y2; =20 if (!vc->gfx.gls) { return; } =20 gtk_gl_area_make_current(GTK_GL_AREA(vc->gfx.drawing_area)); - ws =3D gdk_window_get_scale_factor(gtk_widget_get_window(vc->gfx.drawi= ng_area)); - ww =3D gtk_widget_get_allocated_width(vc->gfx.drawing_area) * ws; - wh =3D gtk_widget_get_allocated_height(vc->gfx.drawing_area) * ws; + gs =3D gdk_window_get_scale_factor(gtk_widget_get_window(vc->gfx.drawi= ng_area)); + pw =3D gtk_widget_get_allocated_width(vc->gfx.drawing_area) * gs; + ph =3D gtk_widget_get_allocated_height(vc->gfx.drawing_area) * gs; =20 if (vc->gfx.scanout_mode) { if (!vc->gfx.guest_fb.framebuffer) { @@ -71,11 +71,11 @@ void gd_gl_area_draw(VirtualConsole *vc) glBindFramebuffer(GL_READ_FRAMEBUFFER, vc->gfx.guest_fb.framebuffe= r); /* GtkGLArea sets GL_DRAW_FRAMEBUFFER for us */ =20 - glViewport(0, 0, ww, wh); + glViewport(0, 0, pw, ph); y1 =3D vc->gfx.y0_top ? 0 : vc->gfx.h; y2 =3D vc->gfx.y0_top ? vc->gfx.h : 0; glBlitFramebuffer(0, y1, vc->gfx.w, y2, - 0, 0, ww, wh, + 0, 0, pw, ph, GL_COLOR_BUFFER_BIT, GL_NEAREST); #ifdef CONFIG_GBM if (dmabuf) { @@ -101,7 +101,7 @@ void gd_gl_area_draw(VirtualConsole *vc) } gtk_gl_area_make_current(GTK_GL_AREA(vc->gfx.drawing_area)); =20 - surface_gl_setup_viewport(vc->gfx.gls, vc->gfx.ds, ww, wh); + surface_gl_setup_viewport(vc->gfx.gls, vc->gfx.ds, pw, ph); surface_gl_render_texture(vc->gfx.gls, vc->gfx.ds); } } diff --git a/ui/gtk.c b/ui/gtk.c index 9f3171abc5..8f5bb4b62e 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -387,16 +387,16 @@ static void *gd_win32_get_hwnd(VirtualConsole *vc) /** DisplayState Callbacks **/ =20 static void gd_update(DisplayChangeListener *dcl, - int x, int y, int w, int h) + int fbx, int fby, int fbw, int fbh) { VirtualConsole *vc =3D container_of(dcl, VirtualConsole, gfx.dcl); GdkWindow *win; - int x1, x2, y1, y2; - int mx, my; - int fbw, fbh; - int ww, wh; + int wx1, wx2, wy1, wy2; + int wx_offset, wy_offset; + int ww_surface, wh_surface; + int ww_widget, wh_widget; =20 - trace_gd_update(vc->label, x, y, w, h); + trace_gd_update(vc->label, fbx, fby, fbw, fbh); =20 if (!gtk_widget_get_realized(vc->gfx.drawing_area)) { return; @@ -405,35 +405,36 @@ static void gd_update(DisplayChangeListener *dcl, if (vc->gfx.convert) { pixman_image_composite(PIXMAN_OP_SRC, vc->gfx.ds->image, NULL, vc->gfx.convert, - x, y, 0, 0, x, y, w, h); + fbx, fby, 0, 0, fbx, fby, fbw, fbh); } =20 - x1 =3D floor(x * vc->gfx.scale_x); - y1 =3D floor(y * vc->gfx.scale_y); + wx1 =3D floor(fbx * vc->gfx.scale_x); + wy1 =3D floor(fby * vc->gfx.scale_y); =20 - x2 =3D ceil(x * vc->gfx.scale_x + w * vc->gfx.scale_x); - y2 =3D ceil(y * vc->gfx.scale_y + h * vc->gfx.scale_y); + wx2 =3D ceil(fbx * vc->gfx.scale_x + fbw * vc->gfx.scale_x); + wy2 =3D ceil(fby * vc->gfx.scale_y + fbh * vc->gfx.scale_y); =20 - fbw =3D surface_width(vc->gfx.ds) * vc->gfx.scale_x; - fbh =3D surface_height(vc->gfx.ds) * vc->gfx.scale_y; + ww_surface =3D surface_width(vc->gfx.ds) * vc->gfx.scale_x; + wh_surface =3D surface_height(vc->gfx.ds) * vc->gfx.scale_y; =20 win =3D gtk_widget_get_window(vc->gfx.drawing_area); if (!win) { return; } - ww =3D gdk_window_get_width(win); - wh =3D gdk_window_get_height(win); + ww_widget =3D gdk_window_get_width(win); + wh_widget =3D gdk_window_get_height(win); =20 - mx =3D my =3D 0; - if (ww > fbw) { - mx =3D (ww - fbw) / 2; + wx_offset =3D wy_offset =3D 0; + if (ww_widget > ww_surface) { + wx_offset =3D (ww_widget - ww_surface) / 2; } - if (wh > fbh) { - my =3D (wh - fbh) / 2; + if (wh_widget > wh_surface) { + wy_offset =3D (wh_widget - wh_surface) / 2; } =20 gtk_widget_queue_draw_area(vc->gfx.drawing_area, - mx + x1, my + y1, (x2 - x1), (y2 - y1)); + wx_offset + wx1, wy_offset + wy1, + (wx2 - wx1), (wy2 - wy1)); } =20 static void gd_refresh(DisplayChangeListener *dcl) @@ -869,8 +870,8 @@ static gboolean gd_draw_event(GtkWidget *widget, cairo_= t *cr, void *opaque) { VirtualConsole *vc =3D opaque; GtkDisplayState *s =3D vc->s; - int mx, my; - int ww, wh; + int wx_offset, wy_offset; + int ww_widget, wh_widget, ww_surface, wh_surface; int fbw, fbh; =20 #if defined(CONFIG_OPENGL) @@ -904,46 +905,47 @@ static gboolean gd_draw_event(GtkWidget *widget, cair= o_t *cr, void *opaque) fbw =3D surface_width(vc->gfx.ds); fbh =3D surface_height(vc->gfx.ds); =20 - ww =3D gdk_window_get_width(gtk_widget_get_window(widget)); - wh =3D gdk_window_get_height(gtk_widget_get_window(widget)); + ww_widget =3D gdk_window_get_width(gtk_widget_get_window(widget)); + wh_widget =3D gdk_window_get_height(gtk_widget_get_window(widget)); =20 if (s->full_screen) { - vc->gfx.scale_x =3D (double)ww / fbw; - vc->gfx.scale_y =3D (double)wh / fbh; + vc->gfx.scale_x =3D (double)ww_widget / fbw; + vc->gfx.scale_y =3D (double)wh_widget / fbh; } else if (s->free_scale) { double sx, sy; =20 - sx =3D (double)ww / fbw; - sy =3D (double)wh / fbh; + sx =3D (double)ww_widget / fbw; + sy =3D (double)wh_widget / fbh; =20 vc->gfx.scale_x =3D vc->gfx.scale_y =3D MIN(sx, sy); } =20 - fbw *=3D vc->gfx.scale_x; - fbh *=3D vc->gfx.scale_y; + ww_surface =3D fbw * vc->gfx.scale_x; + wh_surface =3D fbh * vc->gfx.scale_y; =20 - mx =3D my =3D 0; - if (ww > fbw) { - mx =3D (ww - fbw) / 2; + wx_offset =3D wy_offset =3D 0; + if (ww_widget > ww_surface) { + wx_offset =3D (ww_widget - ww_surface) / 2; } - if (wh > fbh) { - my =3D (wh - fbh) / 2; + if (wh_widget > wh_surface) { + wy_offset =3D (wh_widget - wh_surface) / 2; } =20 - cairo_rectangle(cr, 0, 0, ww, wh); + cairo_rectangle(cr, 0, 0, ww_widget, wh_widget); =20 /* Optionally cut out the inner area where the pixmap will be drawn. This avoids 'flashing' since we're not double-buffering. Note we're using the undocumented behaviour of drawing the rectangle from right to left to cut out the whole */ - cairo_rectangle(cr, mx + fbw, my, - -1 * fbw, fbh); + cairo_rectangle(cr, wx_offset + ww_surface, wy_offset, + -1 * ww_surface, wh_surface); cairo_fill(cr); =20 cairo_scale(cr, vc->gfx.scale_x, vc->gfx.scale_y); cairo_set_source_surface(cr, vc->gfx.surface, - mx / vc->gfx.scale_x, my / vc->gfx.scale_y); + wx_offset / vc->gfx.scale_x, + wy_offset / vc->gfx.scale_y); cairo_paint(cr); =20 return TRUE; @@ -954,19 +956,19 @@ static gboolean gd_motion_event(GtkWidget *widget, Gd= kEventMotion *motion, { VirtualConsole *vc =3D opaque; GtkDisplayState *s =3D vc->s; - int x, y; - int mx, my; - int fbh, fbw; - int ww, wh; + int fbx, fby; + int wx_offset, wy_offset; + int wh_surface, ww_surface; + int ww_widget, wh_widget; =20 if (!vc->gfx.ds) { return TRUE; } =20 - fbw =3D surface_width(vc->gfx.ds) * vc->gfx.scale_x; - fbh =3D surface_height(vc->gfx.ds) * vc->gfx.scale_y; - ww =3D gtk_widget_get_allocated_width(widget); - wh =3D gtk_widget_get_allocated_height(widget); + ww_surface =3D surface_width(vc->gfx.ds) * vc->gfx.scale_x; + wh_surface =3D surface_height(vc->gfx.ds) * vc->gfx.scale_y; + ww_widget =3D gtk_widget_get_allocated_width(widget); + wh_widget =3D gtk_widget_get_allocated_height(widget); =20 /* * `widget` may not have the same size with the frame buffer. @@ -974,41 +976,42 @@ static gboolean gd_motion_event(GtkWidget *widget, Gd= kEventMotion *motion, * To achieve that, `vc` will be displayed at (mx, my) * so that it is displayed at the center of the widget. */ - mx =3D my =3D 0; - if (ww > fbw) { - mx =3D (ww - fbw) / 2; + wx_offset =3D wy_offset =3D 0; + if (ww_widget > ww_surface) { + wx_offset =3D (ww_widget - ww_surface) / 2; } - if (wh > fbh) { - my =3D (wh - fbh) / 2; + if (wh_widget > wh_surface) { + wy_offset =3D (wh_widget - wh_surface) / 2; } =20 /* * `motion` is reported in `widget` coordinates * so translating it to the coordinates in `vc`. */ - x =3D (motion->x - mx) / vc->gfx.scale_x; - y =3D (motion->y - my) / vc->gfx.scale_y; + fbx =3D (motion->x - wx_offset) / vc->gfx.scale_x; + fby =3D (motion->y - wy_offset) / vc->gfx.scale_y; =20 - trace_gd_motion_event(ww, wh, gtk_widget_get_scale_factor(widget), x, = y); + trace_gd_motion_event(ww_widget, wh_widget, + gtk_widget_get_scale_factor(widget), fbx, fby); =20 if (qemu_input_is_absolute(vc->gfx.dcl.con)) { - if (x < 0 || y < 0 || - x >=3D surface_width(vc->gfx.ds) || - y >=3D surface_height(vc->gfx.ds)) { + if (fbx < 0 || fby < 0 || + fbx >=3D surface_width(vc->gfx.ds) || + fby >=3D surface_height(vc->gfx.ds)) { return TRUE; } - qemu_input_queue_abs(vc->gfx.dcl.con, INPUT_AXIS_X, x, + qemu_input_queue_abs(vc->gfx.dcl.con, INPUT_AXIS_X, fbx, 0, surface_width(vc->gfx.ds)); - qemu_input_queue_abs(vc->gfx.dcl.con, INPUT_AXIS_Y, y, + qemu_input_queue_abs(vc->gfx.dcl.con, INPUT_AXIS_Y, fby, 0, surface_height(vc->gfx.ds)); qemu_input_event_sync(); } else if (s->last_set && s->ptr_owner =3D=3D vc) { - qemu_input_queue_rel(vc->gfx.dcl.con, INPUT_AXIS_X, x - s->last_x); - qemu_input_queue_rel(vc->gfx.dcl.con, INPUT_AXIS_Y, y - s->last_y); + qemu_input_queue_rel(vc->gfx.dcl.con, INPUT_AXIS_X, fbx - s->last_= x); + qemu_input_queue_rel(vc->gfx.dcl.con, INPUT_AXIS_Y, fby - s->last_= y); qemu_input_event_sync(); } - s->last_x =3D x; - s->last_y =3D y; + s->last_x =3D fbx; + s->last_y =3D fby; s->last_set =3D TRUE; =20 if (!qemu_input_is_absolute(vc->gfx.dcl.con) && s->ptr_owner =3D=3D vc= ) { --=20 2.49.0 From nobody Sat Nov 15 17:50:03 2025 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1748108175; cv=none; d=zohomail.com; s=zohoarc; b=ctlRzPnl0LQZkjygnz8e86Hx6SOm9BRIPEbbHmYJKAeyT9d/VWuprEib/kdu1Ol7aa93XFYZMPxF2I5XK+kiw0aKZJXdBjmoGxs9W5HWgfeqb4BY8g73dh4f2SzGZ0J5Tm7jdMZ0M0P/XBybBDoI2GmwUx8LYSmW1E8w8Ky0LIM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748108175; 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=JC2wYKSCVTSC9hRt1qKP/ALSipYOkMme8Y7eicj3lBU=; b=JFLb7QgFSY06IyDvQQnTcK0yfjMpVea/gmh7FpwXSfQrDc77Zqn84guWO+kfNGPisSm3tKye12uCfcpa4Sc3l3t9Gq47pSSXssiVVrYzybQsoFRs/aLvWUekaZPmI9RqFm48WJb7jLWZqauaOjex8e7zyYcl+xpkHbrXFpoJgXU= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1748108175413144.83835818781495; Sat, 24 May 2025 10:36:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uIsn3-0000O1-Gn; Sat, 24 May 2025 13:36:09 -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 1uIsn0-0000Ga-FM for qemu-devel@nongnu.org; Sat, 24 May 2025 13:36:06 -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 1uIsmy-0000kp-W9 for qemu-devel@nongnu.org; Sat, 24 May 2025 13:36:06 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-648-GTVondoIPzyRrNp75XieBg-1; Sat, 24 May 2025 13:36:02 -0400 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9A1B418001CC; Sat, 24 May 2025 17:36:01 +0000 (UTC) Received: from localhost (unknown [10.45.242.4]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7629719560AB; Sat, 24 May 2025 17:36:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1748108164; 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=JC2wYKSCVTSC9hRt1qKP/ALSipYOkMme8Y7eicj3lBU=; b=Mjje9fKD3gnD67iCYiL0X+CCXwGy88SvAz1g+wdbAf/SXubIiy+ugCb2wz9YjFHyvdJUMV XKld6cpuqc8NTURXLCa4btl54tQqnkKduly+ZKD26fPo0t24t1syOe9N5exWz5OANsCs8U oMTpJrsYVGB90rxprU0MjZyuTTUsSvw= X-MC-Unique: GTVondoIPzyRrNp75XieBg-1 X-Mimecast-MFC-AGG-ID: GTVondoIPzyRrNp75XieBg_1748108161 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , stefanha@redhat.com, Weifeng Liu Subject: [PULL 13/19] gtk/ui: Introduce helper gd_update_scale Date: Sat, 24 May 2025 19:35:06 +0200 Message-ID: <20250524173514.317886-14-marcandre.lureau@redhat.com> In-Reply-To: <20250524173514.317886-1-marcandre.lureau@redhat.com> References: <20250524173514.317886-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.0 on 10.30.177.15 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.298, 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=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: 1748108176236116600 From: Weifeng Liu The code snippet updating scale_x/scale_y is general and will be used in next patch. Make it a function. Signed-off-by: Weifeng Liu Message-ID: <20250511073337.876650-4-weifeng.liu.z@gmail.com> Acked-by: Gerd Hoffmann Acked-by: Marc-Andr=C3=A9 Lureau --- include/ui/gtk.h | 2 ++ ui/gtk.c | 30 +++++++++++++++++++----------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/include/ui/gtk.h b/include/ui/gtk.h index aa3d637029..d3944046db 100644 --- a/include/ui/gtk.h +++ b/include/ui/gtk.h @@ -224,4 +224,6 @@ int gd_gl_area_make_current(DisplayGLCtx *dgc, /* gtk-clipboard.c */ void gd_clipboard_init(GtkDisplayState *gd); =20 +void gd_update_scale(VirtualConsole *vc, int ww, int wh, int fbw, int fbh); + #endif /* UI_GTK_H */ diff --git a/ui/gtk.c b/ui/gtk.c index 8f5bb4b62e..47af49e387 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -801,6 +801,24 @@ void gd_update_monitor_refresh_rate(VirtualConsole *vc= , GtkWidget *widget) #endif } =20 +void gd_update_scale(VirtualConsole *vc, int ww, int wh, int fbw, int fbh) +{ + if (!vc) { + return; + } + + if (vc->s->full_screen) { + vc->gfx.scale_x =3D (double)ww / fbw; + vc->gfx.scale_y =3D (double)wh / fbh; + } else if (vc->s->free_scale) { + double sx, sy; + + sx =3D (double)ww / fbw; + sy =3D (double)wh / fbh; + + vc->gfx.scale_x =3D vc->gfx.scale_y =3D MIN(sx, sy); + } +} /** * DOC: Coordinate handling. * @@ -908,17 +926,7 @@ static gboolean gd_draw_event(GtkWidget *widget, cairo= _t *cr, void *opaque) ww_widget =3D gdk_window_get_width(gtk_widget_get_window(widget)); wh_widget =3D gdk_window_get_height(gtk_widget_get_window(widget)); =20 - if (s->full_screen) { - vc->gfx.scale_x =3D (double)ww_widget / fbw; - vc->gfx.scale_y =3D (double)wh_widget / fbh; - } else if (s->free_scale) { - double sx, sy; - - sx =3D (double)ww_widget / fbw; - sy =3D (double)wh_widget / fbh; - - vc->gfx.scale_x =3D vc->gfx.scale_y =3D MIN(sx, sy); - } + gd_update_scale(vc, ww_widget, wh_widget, fbw, fbh); =20 ww_surface =3D fbw * vc->gfx.scale_x; wh_surface =3D fbh * vc->gfx.scale_y; --=20 2.49.0 From nobody Sat Nov 15 17:50:03 2025 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1748108267; cv=none; d=zohomail.com; s=zohoarc; b=g9M2PCkFdH1VvQBYZbMqZu/ncmPW3kOg3iBeIV5LgVqPDwEsbbEfji96yoWK/paqWAI/JnuKzcpZsERUElGm+ME2MLMwdliuHSCsSaEnaxlGdjQL4hFa4TKfKUTT3v7LMisq4j6x7Lo8IZgWuZ5Iuvt3a2K5N9O7KJofKFBpJsc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748108267; 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=qabA6fI7lfBv6oSmHnS8NVRxRvlPhisPoCZ35hYdbI0=; b=ZhBgu6ETCCRPP/Wb6GIIHVIjFN02HOOlzwraN0PSMooUWHwuBMZyxajnQhzBmzo9vn89xOnJgc3BNnCJta5ffUVSuCRea7cw4JxatsPgHaBNepG3//fVcwX4Kq92rrbs4YQM7o/V6UZd2BkZdkBUBlbyH1Uyp1lXkDuSPs/uD30= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1748108267835901.6276420432087; Sat, 24 May 2025 10:37:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uIsn8-0000kC-7A; Sat, 24 May 2025 13:36:14 -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 1uIsn5-0000ZI-O7 for qemu-devel@nongnu.org; Sat, 24 May 2025 13:36:11 -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 1uIsn4-0000lA-4A for qemu-devel@nongnu.org; Sat, 24 May 2025 13:36:11 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-516-ObsTDSL8P7O8btT-xAS-gw-1; Sat, 24 May 2025 13:36:05 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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 mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id ED385180036F; Sat, 24 May 2025 17:36:04 +0000 (UTC) Received: from localhost (unknown [10.45.242.4]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0FA801944DFF; Sat, 24 May 2025 17:36:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1748108169; 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=qabA6fI7lfBv6oSmHnS8NVRxRvlPhisPoCZ35hYdbI0=; b=LRm9SEE1+s0ohAXaxP6jcQBgfK7wYamGvgZYiur9tgqMPe4ygJAhZdGDx6sPxKATRxJRfu ol7ToXgRWQmRurGg0nmmGUtW58lGk8Oz7w6RJkjV6DMlhQUjkQtL9LXiKav9FvEIoqME8O se/BpNE0AreL7VKl53GwwgGsmK/T9no= X-MC-Unique: ObsTDSL8P7O8btT-xAS-gw-1 X-Mimecast-MFC-AGG-ID: ObsTDSL8P7O8btT-xAS-gw_1748108165 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , stefanha@redhat.com, Weifeng Liu Subject: [PULL 14/19] ui/gtk: Update scales in fixed-scale mode when rendering GL area Date: Sat, 24 May 2025 19:35:07 +0200 Message-ID: <20250524173514.317886-15-marcandre.lureau@redhat.com> In-Reply-To: <20250524173514.317886-1-marcandre.lureau@redhat.com> References: <20250524173514.317886-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.0 on 10.30.177.12 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.298, 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=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: 1748108269277116600 From: Weifeng Liu When gl=3Don, scale_x and scale_y were set to 1 on startup that didn't reflect the real situation of the scan-out in free scale mode, resulting in incorrect cursor coordinates to be sent when moving the mouse pointer. Simply updating the scales before rendering the image fixes this issue. Signed-off-by: Weifeng Liu Message-ID: <20250511073337.876650-5-weifeng.liu.z@gmail.com> Acked-by: Gerd Hoffmann Acked-by: Marc-Andr=C3=A9 Lureau --- ui/gtk-gl-area.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ui/gtk-gl-area.c b/ui/gtk-gl-area.c index ba9fbec432..db93cd6204 100644 --- a/ui/gtk-gl-area.c +++ b/ui/gtk-gl-area.c @@ -43,6 +43,8 @@ void gd_gl_area_draw(VirtualConsole *vc) QemuDmaBuf *dmabuf =3D vc->gfx.guest_fb.dmabuf; #endif int pw, ph, gs, y1, y2; + int ww, wh; + int fbw, fbh; =20 if (!vc->gfx.gls) { return; @@ -50,8 +52,14 @@ void gd_gl_area_draw(VirtualConsole *vc) =20 gtk_gl_area_make_current(GTK_GL_AREA(vc->gfx.drawing_area)); gs =3D gdk_window_get_scale_factor(gtk_widget_get_window(vc->gfx.drawi= ng_area)); - pw =3D gtk_widget_get_allocated_width(vc->gfx.drawing_area) * gs; - ph =3D gtk_widget_get_allocated_height(vc->gfx.drawing_area) * gs; + fbw =3D surface_width(vc->gfx.ds); + fbh =3D surface_height(vc->gfx.ds); + ww =3D gtk_widget_get_allocated_width(vc->gfx.drawing_area); + wh =3D gtk_widget_get_allocated_height(vc->gfx.drawing_area); + pw =3D ww * gs; + ph =3D wh * gs; + + gd_update_scale(vc, ww, wh, fbw, fbh); =20 if (vc->gfx.scanout_mode) { if (!vc->gfx.guest_fb.framebuffer) { --=20 2.49.0 From nobody Sat Nov 15 17:50:03 2025 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1748108244; cv=none; d=zohomail.com; s=zohoarc; b=EwLwECKAv44f6WXgyJeQmtpAes1j1fraVYapxtq0+T5ZQ5isDcxHx+oGejUtFSbtsnqXRho7PBe73CxW9bQy2tC3ofwibawtDWc4Yhg0oKNastfZgtrukcYF9+rigAnvlwichUsjJLo0gdnopsiehQf2cJdhB7sD4iiIyA8orc4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748108244; 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=1jHlFib1jbqDOGmIU5Jdl45qo+cDKFJf60/0MFNRQ3w=; b=BySOghw3vSYiopn89brAKYlRfWwWmxI1yNK8DmUuupiA4EIP7GNjXZPffkAxkhFWHCb/+Bed4P+P1AsPNizBrm0oAs0ujAoSOs4HVOYxrR6atpcs02hD5CS5auX7m6i+dCqIHCaxRAnhUru/7aUTC9DSSG8WoaxOo6upeSl3bHQ= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1748108244114928.9701788900986; Sat, 24 May 2025 10:37:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uIsnA-0000yI-49; Sat, 24 May 2025 13:36:16 -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 1uIsn7-0000dw-8W for qemu-devel@nongnu.org; Sat, 24 May 2025 13:36:13 -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 1uIsn5-0000lI-LB for qemu-devel@nongnu.org; Sat, 24 May 2025 13:36:12 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-297--bDCd0xNO7W4cPDU3vykjQ-1; Sat, 24 May 2025 13:36:09 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.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 mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id DB2E2180048E; Sat, 24 May 2025 17:36:08 +0000 (UTC) Received: from localhost (unknown [10.45.242.4]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 85CC030001A1; Sat, 24 May 2025 17:36:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1748108171; 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=1jHlFib1jbqDOGmIU5Jdl45qo+cDKFJf60/0MFNRQ3w=; b=hCupxoGd0GrxQeuT+uzqnca3uC9766k3fMa2/Whqv60gpYBIm24hA7dwqihKN/mCuctdfH dYWTe3C2ZM6qsk195gPRArjz1eZW9nO24y+rfr6NX5O4G2gV4iSFN1DGmalTcstuwS52yW 0u4AM6mmhpjTEWhYl9D26m4/75sad1Q= X-MC-Unique: -bDCd0xNO7W4cPDU3vykjQ-1 X-Mimecast-MFC-AGG-ID: -bDCd0xNO7W4cPDU3vykjQ_1748108169 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , stefanha@redhat.com, Weifeng Liu Subject: [PULL 15/19] ui/sdl: Consider scaling in mouse event handling Date: Sat, 24 May 2025 19:35:08 +0200 Message-ID: <20250524173514.317886-16-marcandre.lureau@redhat.com> In-Reply-To: <20250524173514.317886-1-marcandre.lureau@redhat.com> References: <20250524173514.317886-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.30.177.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.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.298, 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=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: 1748108245297116600 From: Weifeng Liu When using sdl display backend, if the window is scaled, incorrect mouse positions will be reported since scaling is not properly handled. Fix it by transforming the positions from window coordinate to guest buffer coordinate. Signed-off-by: Weifeng Liu Message-ID: <20250511073337.876650-6-weifeng.liu.z@gmail.com> Acked-by: Gerd Hoffmann Acked-by: Marc-Andr=C3=A9 Lureau --- ui/sdl2.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/ui/sdl2.c b/ui/sdl2.c index cda4293a53..b00e421f7f 100644 --- a/ui/sdl2.c +++ b/ui/sdl2.c @@ -488,14 +488,14 @@ static void handle_mousemotion(SDL_Event *ev) { int max_x, max_y; struct sdl2_console *scon =3D get_scon_from_window(ev->motion.windowID= ); + int scr_w, scr_h, surf_w, surf_h, x, y, dx, dy; =20 if (!scon || !qemu_console_is_graphic(scon->dcl.con)) { return; } =20 + SDL_GetWindowSize(scon->real_window, &scr_w, &scr_h); if (qemu_input_is_absolute(scon->dcl.con) || absolute_enabled) { - int scr_w, scr_h; - SDL_GetWindowSize(scon->real_window, &scr_w, &scr_h); max_x =3D scr_w - 1; max_y =3D scr_h - 1; if (gui_grab && !gui_fullscreen @@ -509,9 +509,14 @@ static void handle_mousemotion(SDL_Event *ev) sdl_grab_start(scon); } } + surf_w =3D surface_width(scon->surface); + surf_h =3D surface_height(scon->surface); + x =3D (int64_t)ev->motion.x * surf_w / scr_w; + y =3D (int64_t)ev->motion.y * surf_h / scr_h; + dx =3D (int64_t)ev->motion.xrel * surf_w / scr_w; + dy =3D (int64_t)ev->motion.yrel * surf_h / scr_h; if (gui_grab || qemu_input_is_absolute(scon->dcl.con) || absolute_enab= led) { - sdl_send_mouse_event(scon, ev->motion.xrel, ev->motion.yrel, - ev->motion.x, ev->motion.y, ev->motion.state); + sdl_send_mouse_event(scon, dx, dy, x, y, ev->motion.state); } } =20 @@ -520,12 +525,17 @@ static void handle_mousebutton(SDL_Event *ev) int buttonstate =3D SDL_GetMouseState(NULL, NULL); SDL_MouseButtonEvent *bev; struct sdl2_console *scon =3D get_scon_from_window(ev->button.windowID= ); + int scr_w, scr_h, x, y; =20 if (!scon || !qemu_console_is_graphic(scon->dcl.con)) { return; } =20 bev =3D &ev->button; + SDL_GetWindowSize(scon->real_window, &scr_w, &scr_h); + x =3D (int64_t)bev->x * surface_width(scon->surface) / scr_w; + y =3D (int64_t)bev->y * surface_height(scon->surface) / scr_h; + if (!gui_grab && !qemu_input_is_absolute(scon->dcl.con)) { if (ev->type =3D=3D SDL_MOUSEBUTTONUP && bev->button =3D=3D SDL_BU= TTON_LEFT) { /* start grabbing all events */ @@ -537,7 +547,7 @@ static void handle_mousebutton(SDL_Event *ev) } else { buttonstate &=3D ~SDL_BUTTON(bev->button); } - sdl_send_mouse_event(scon, 0, 0, bev->x, bev->y, buttonstate); + sdl_send_mouse_event(scon, 0, 0, x, y, buttonstate); } } =20 --=20 2.49.0 From nobody Sat Nov 15 17:50:03 2025 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1748108218; cv=none; d=zohomail.com; s=zohoarc; b=Wn+BNCVRf+hGOOJwCF9HOmIKtefI3ZD6k5HFmB+Kxzu3RjKQ358vp/a/PBQN+1/Y/AoL9JdiwJqfOjc6efYT6GqP+uhzyJffPdRD3ZS7jzu0JXOGY+QjzeI+8jf8VTj1WdzzCA9XwXv9eEHbtIAg1OZf3ogGk0FM+4UJhfVyga4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748108218; 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=4G0ur/AkT7SipDaNafCzLmxGscCER56Xdc2UIqquo54=; b=bL6BjozppkJheLldGboTdAI+kqE+sKi9cP3UB+DI8tQLbTU9g80iejkKxz6nuikCfJo7NIRyZrWdNRSmRoQSQ5G/mz2pyqllguQH1JFscLIDcb1xp4raBZeBl8pzn5TJtVFlkDBeB8M60arQHjH8st6Z+HzBD2Z5gFiYuQHmMWA= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1748108218343286.11844452892456; Sat, 24 May 2025 10:36:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uIsnF-0001GN-B2; Sat, 24 May 2025 13:36:21 -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 1uIsnC-0001AW-HQ for qemu-devel@nongnu.org; Sat, 24 May 2025 13:36:19 -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 1uIsnB-0000lZ-1u for qemu-devel@nongnu.org; Sat, 24 May 2025 13:36:18 -0400 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-81-Tdvc3Q9sPV2PMoAZiXaKog-1; Sat, 24 May 2025 13:36:13 -0400 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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 mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5D1AE19560BC; Sat, 24 May 2025 17:36:12 +0000 (UTC) Received: from localhost (unknown [10.45.242.4]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 390D91800570; Sat, 24 May 2025 17:36:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1748108176; 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=4G0ur/AkT7SipDaNafCzLmxGscCER56Xdc2UIqquo54=; b=WEJd6rOMEu54RIAnSJF51A/hWDAu0khhxBXgtRWhIZh4d+0pV73fW3AErEc/ruVLvMPLB8 n0CdU+WfFbKMXoA1bV6INtr5iWygiMOYrdNVsvQRj3igZFtmZ3Z4svsEB4FLb21akIWQdi 8jxNri6yaCsE/JLiA/NpH2UBmjNiYEo= X-MC-Unique: Tdvc3Q9sPV2PMoAZiXaKog-1 X-Mimecast-MFC-AGG-ID: Tdvc3Q9sPV2PMoAZiXaKog_1748108172 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , stefanha@redhat.com, Weifeng Liu Subject: [PULL 16/19] ui/gtk: Don't update scale in fixed scale mode in gtk-egl.c Date: Sat, 24 May 2025 19:35:09 +0200 Message-ID: <20250524173514.317886-17-marcandre.lureau@redhat.com> In-Reply-To: <20250524173514.317886-1-marcandre.lureau@redhat.com> References: <20250524173514.317886-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.30.177.93 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.298, 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=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: 1748108218802116600 From: Weifeng Liu Scale shouldn't be changed until user explicitly requests it in fixed scale mode (full-screen=3Dfalse and free-scale=3Dfalse). Use function gd_update_scale to complete scale updating instead. Signed-off-by: Weifeng Liu Message-ID: <20250511073337.876650-7-weifeng.liu.z@gmail.com> Acked-by: Gerd Hoffmann Acked-by: Marc-Andr=C3=A9 Lureau --- ui/gtk-egl.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c index 947c99334b..f8e4f4bc70 100644 --- a/ui/gtk-egl.c +++ b/ui/gtk-egl.c @@ -95,8 +95,9 @@ void gd_egl_draw(VirtualConsole *vc) #endif gd_egl_scanout_flush(&vc->gfx.dcl, 0, 0, vc->gfx.w, vc->gfx.h); =20 - vc->gfx.scale_x =3D (double)ww / surface_width(vc->gfx.ds); - vc->gfx.scale_y =3D (double)wh / surface_height(vc->gfx.ds); + gd_update_scale(vc, ww, wh, + surface_width(vc->gfx.ds), + surface_height(vc->gfx.ds)); =20 glFlush(); #ifdef CONFIG_GBM @@ -122,8 +123,9 @@ void gd_egl_draw(VirtualConsole *vc) =20 eglSwapBuffers(qemu_egl_display, vc->gfx.esurface); =20 - vc->gfx.scale_x =3D (double)ww / surface_width(vc->gfx.ds); - vc->gfx.scale_y =3D (double)wh / surface_height(vc->gfx.ds); + gd_update_scale(vc, ww, wh, + surface_width(vc->gfx.ds), + surface_height(vc->gfx.ds)); =20 glFlush(); } --=20 2.49.0 From nobody Sat Nov 15 17:50:03 2025 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1748108208; cv=none; d=zohomail.com; s=zohoarc; b=jhiK0puRH9pnDsY/pqYM61TqYHYRmI4XrVKzIok0M+fytXx47Kp6MZU25uArdYOhoteb0SmUtuK6r8VLlum3v6jiQtS8Gh5/SH2rCBvAMZMQ06Gkic1EGuIwN8nkOQ2FrrSLHqOrYxVLB/KMbdaUKl8KMZ8fUK8HD+cN/SHDBo4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748108208; 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=NWYf2BeSTPqu7GlOBYoQqbkCpXlL24ybqO9vOsn3aSI=; b=nXDISX5+6hMv0kwV680fvQAnX5f8FEAdxSfOU88fsR+Eqrna7rSrYavm54a0/8+oWlv/gEQjAAd7XQ4g6GdllsJSG815BhaZpENp0KRW2VKG+ZPmVVFR6oY6N+gvVdBAftk6S+oVIgMNU2PDe/o3CTMcRyK+txeo5ttiPc7YRjs= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1748108208385960.3644563944616; Sat, 24 May 2025 10:36:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uIsna-0001zP-A4; Sat, 24 May 2025 13:36:43 -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 1uIsnI-0001Li-1Q for qemu-devel@nongnu.org; Sat, 24 May 2025 13:36:28 -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 1uIsnG-0000lt-Ii for qemu-devel@nongnu.org; Sat, 24 May 2025 13:36:23 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-169-AJGHsgMJNdijRZQkfuLecQ-1; Sat, 24 May 2025 13:36:17 -0400 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 56B01180035C; Sat, 24 May 2025 17:36:15 +0000 (UTC) Received: from localhost (unknown [10.45.242.4]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id AF0CF19560B7; Sat, 24 May 2025 17:36:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1748108181; 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=NWYf2BeSTPqu7GlOBYoQqbkCpXlL24ybqO9vOsn3aSI=; b=biV0/RSU5kPih0xxv35HIYjuPZsDtlVMFlv2iiMciqXKQZeyJ97b0iN1qQYX8d9T+4ToUI 7hLZ5Oe2H2MG2d9Kiccm7+co4UrtsvN7CA46yiadkBTF4aSxbGQuMpQlzNqw3bBEd/m4kO 7IH4xtytPuUNInAkEcB81wlXQC51ql4= X-MC-Unique: AJGHsgMJNdijRZQkfuLecQ-1 X-Mimecast-MFC-AGG-ID: AJGHsgMJNdijRZQkfuLecQ_1748108175 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , stefanha@redhat.com, Weifeng Liu Subject: [PULL 17/19] ui/gtk: Consider scaling when propagating ui info Date: Sat, 24 May 2025 19:35:10 +0200 Message-ID: <20250524173514.317886-18-marcandre.lureau@redhat.com> In-Reply-To: <20250524173514.317886-1-marcandre.lureau@redhat.com> References: <20250524173514.317886-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.0 on 10.30.177.15 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.298, 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=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: 1748108210667116600 From: Weifeng Liu The ui width and height sent to guest is supposed to be in buffer coordinate. Hence conversion is required. If scaling (global window scale and zooming scale) is not respected in non-free-scale mode, window size could keep changing because of the existence of the iteration of the following steps: 1. In resize event or configure event, a size larger (or smaller) than the currently used one might be calculated due to not considering scaling. 2. On reception of the display size change event in guest, the guest might decide to do a mode setting and use the larger (or smaller) mode. 3. When the new guest scan-out command arrives, QEMU would request the window size to change to fit the new buffer size. This will trigger a resize event or a configure event, making us go back to step 1. Signed-off-by: Weifeng Liu Message-ID: <20250511073337.876650-8-weifeng.liu.z@gmail.com> Acked-by: Gerd Hoffmann Acked-by: Marc-Andr=C3=A9 Lureau --- ui/gtk.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/ui/gtk.c b/ui/gtk.c index 47af49e387..8c4a94c8f6 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -772,8 +772,21 @@ static void gd_resize_event(GtkGLArea *area, gint width, gint height, gpointer *opaque) { VirtualConsole *vc =3D (void *)opaque; + double pw =3D width, ph =3D height; + double sx =3D vc->gfx.scale_x, sy =3D vc->gfx.scale_y; + GdkWindow *window =3D gtk_widget_get_window(GTK_WIDGET(area)); + const int gs =3D gdk_window_get_scale_factor(window); =20 - gd_set_ui_size(vc, width, height); + if (!vc->s->free_scale && !vc->s->full_screen) { + pw /=3D sx; + ph /=3D sy; + } + + /** + * width and height here are in pixel coordinate, so we must divide it + * by global window scale (gs) + */ + gd_set_ui_size(vc, pw / gs, ph / gs); } =20 #endif @@ -1836,8 +1849,16 @@ static gboolean gd_configure(GtkWidget *widget, GdkEventConfigure *cfg, gpointer opaque) { VirtualConsole *vc =3D opaque; + const double sx =3D vc->gfx.scale_x, sy =3D vc->gfx.scale_y; + double width =3D cfg->width, height =3D cfg->height; + + if (!vc->s->free_scale && !vc->s->full_screen) { + width /=3D sx; + height /=3D sy; + } + + gd_set_ui_size(vc, width, height); =20 - gd_set_ui_size(vc, cfg->width, cfg->height); return FALSE; } =20 --=20 2.49.0 From nobody Sat Nov 15 17:50:03 2025 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1748108255; cv=none; d=zohomail.com; s=zohoarc; b=JJKBauXwzcn80WpiDBDQ7KpNfncG7TvabY3HwIQq4MMpRsWYUT0as12s47lzoWptr/ZzwZrg+Drdr0oCAnIDnVVwcq3O2hqc2CR0xWDOCClkgDeX3zZjPSWbkkfYNr+yjljlYwUZDCAFYXNDX3Mhz9jmZn4GMV+hqHDhXGhq16s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748108255; 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=OgRH6/eFm+pH+gB1fXJHRpL3xXRtg898YAqKXTAuvZI=; b=NO3mzgc/B7uiMQ/syUZAOTmO2glb1FvJen6XtMoYgu9E9HnBtqeh43nGK3rf49x2ve0doFJs9TvYaskDjEUpubYcDdLFlOiVkoohIIwv3v6Tkj3D7UEel6vVpbDHbddLvrUqFUXhK7g6I8+2y1JlovVpMxVAVp4xtD3GKAABWsI= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1748108255866305.523103281761; Sat, 24 May 2025 10:37:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uIsnW-0001hD-Kg; Sat, 24 May 2025 13:36: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 1uIsnK-0001Ui-6L for qemu-devel@nongnu.org; Sat, 24 May 2025 13:36:30 -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 1uIsnI-0000ly-AP for qemu-devel@nongnu.org; Sat, 24 May 2025 13:36:25 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-392-oVBRJ8vpN9Cj9EJbA8O7Ow-1; Sat, 24 May 2025 13:36:20 -0400 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 338471800873; Sat, 24 May 2025 17:36:19 +0000 (UTC) Received: from localhost (unknown [10.45.242.4]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C09A419560B7; Sat, 24 May 2025 17:36:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1748108183; 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=OgRH6/eFm+pH+gB1fXJHRpL3xXRtg898YAqKXTAuvZI=; b=BEKhVHYhGsPPjrQQoDwWtodCvKJsIm5L/hmnM/wZoOUxN5CHZy6fpupbQYrQoDmmoNG5DW MrBj9zbYJ03QBtOYdhTbJrUEYgn4/0bdcJXV2z6UJ0/LimXVGp3j1Qt5s6arZG6JBBUJEH kzn2Y7jDBXCJd+t+lzqSQDsDT9K1uFg= X-MC-Unique: oVBRJ8vpN9Cj9EJbA8O7Ow-1 X-Mimecast-MFC-AGG-ID: oVBRJ8vpN9Cj9EJbA8O7Ow_1748108179 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , stefanha@redhat.com, Weifeng Liu Subject: [PULL 18/19] ui/gtk-gl-area: Render guest content with padding in fixed-scale mode Date: Sat, 24 May 2025 19:35:11 +0200 Message-ID: <20250524173514.317886-19-marcandre.lureau@redhat.com> In-Reply-To: <20250524173514.317886-1-marcandre.lureau@redhat.com> References: <20250524173514.317886-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.0 on 10.30.177.15 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.298, 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=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: 1748108257167116600 From: Weifeng Liu In fixed-scale mode (zoom-to-fit=3Dfalse), we expect that scale should not change, meaning that if window size is larger than guest surface, padding is supposed to be added to preserve the scale. However, in OpenGL mode (gl=3Don), guest surface is always painted to the whole canvas without any padding. This change tries to fix this bug by adding appropriate padding when drawing surfaces. Signed-off-by: Weifeng Liu Message-ID: <20250511073337.876650-9-weifeng.liu.z@gmail.com> Acked-by: Gerd Hoffmann Acked-by: Marc-Andr=C3=A9 Lureau --- ui/gtk-gl-area.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/ui/gtk-gl-area.c b/ui/gtk-gl-area.c index db93cd6204..8151cc413c 100644 --- a/ui/gtk-gl-area.c +++ b/ui/gtk-gl-area.c @@ -44,7 +44,9 @@ void gd_gl_area_draw(VirtualConsole *vc) #endif int pw, ph, gs, y1, y2; int ww, wh; + int ww_surface, wh_surface; int fbw, fbh; + int wx_offset, wy_offset; =20 if (!vc->gfx.gls) { return; @@ -61,6 +63,17 @@ void gd_gl_area_draw(VirtualConsole *vc) =20 gd_update_scale(vc, ww, wh, fbw, fbh); =20 + ww_surface =3D fbw * vc->gfx.scale_x; + wh_surface =3D fbh * vc->gfx.scale_y; + + wx_offset =3D wy_offset =3D 0; + if (ww > ww_surface) { + wx_offset =3D (ww - ww_surface) / 2; + } + if (wh > wh_surface) { + wy_offset =3D (wh - wh_surface) / 2; + } + if (vc->gfx.scanout_mode) { if (!vc->gfx.guest_fb.framebuffer) { return; @@ -79,11 +92,29 @@ void gd_gl_area_draw(VirtualConsole *vc) glBindFramebuffer(GL_READ_FRAMEBUFFER, vc->gfx.guest_fb.framebuffe= r); /* GtkGLArea sets GL_DRAW_FRAMEBUFFER for us */ =20 + if (wx_offset > 0) { + glEnable(GL_SCISSOR_TEST); + glScissor(0, 0, wx_offset * gs, wh * gs); + glClear(GL_COLOR_BUFFER_BIT); + glScissor((ww - wx_offset) * gs, 0, wx_offset * gs, wh * gs); + glClear(GL_COLOR_BUFFER_BIT); + glDisable(GL_SCISSOR_TEST); + } + if (wy_offset > 0) { + glEnable(GL_SCISSOR_TEST); + glScissor(0, 0, ww * gs, wy_offset * gs); + glClear(GL_COLOR_BUFFER_BIT); + glScissor(0, (wh - wy_offset) * gs, ww * gs, wy_offset * gs); + glClear(GL_COLOR_BUFFER_BIT); + glDisable(GL_SCISSOR_TEST); + } + glViewport(0, 0, pw, ph); y1 =3D vc->gfx.y0_top ? 0 : vc->gfx.h; y2 =3D vc->gfx.y0_top ? vc->gfx.h : 0; glBlitFramebuffer(0, y1, vc->gfx.w, y2, - 0, 0, pw, ph, + wx_offset * gs, wy_offset * gs, + (ww - wx_offset) * gs, (wh - wy_offset) * gs, GL_COLOR_BUFFER_BIT, GL_NEAREST); #ifdef CONFIG_GBM if (dmabuf) { --=20 2.49.0 From nobody Sat Nov 15 17:50:03 2025 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1748108245; cv=none; d=zohomail.com; s=zohoarc; b=XVDVJiUTMjqs2oebe9uKh9kJoKH9Zu4AqIqhaq15Xxvk5YuZGwZCx74tS5ViNR4wNtxuerJCL24vVcrcoeOm6e7c413OuJ8/m4KWogW1LVQmOfbQ50XQ+jvLAsLANDbBWQevCAkZY+6ZS6KqvJb2WiM+4MP2KHuret48cwOKyY0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748108245; 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=4k5+NTFiMxqkyu2x9DOplosPFgVjD9e9EjTHIrElbs8=; b=lEQQETiY7PlQEZE65hNZsYbP9Z1wSAEVQtcWu41ox65THiKoIkNtb9Gd7FHspAoVApoBwWO6OEaLqt+ZXB0FrskXqzQKUyqTL/8iyM2G7dcZj1VrU+hEwbkvjmtULXGPNUl5hT9B45dBspucVrzB3fX/yD02BhfYUaTX0SFnm/g= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1748108245028551.7345030390328; Sat, 24 May 2025 10:37:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uIsne-0002Qa-I7; Sat, 24 May 2025 13:36:46 -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 1uIsnP-0001V3-N3 for qemu-devel@nongnu.org; Sat, 24 May 2025 13:36:34 -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 1uIsnN-0000mG-KJ for qemu-devel@nongnu.org; Sat, 24 May 2025 13:36:31 -0400 Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-694-yd8LuReMMaKhg641XXD6HA-1; Sat, 24 May 2025 13:36:24 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 56061195608A; Sat, 24 May 2025 17:36:23 +0000 (UTC) Received: from localhost (unknown [10.45.242.4]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 157DA195608D; Sat, 24 May 2025 17:36:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1748108187; 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=4k5+NTFiMxqkyu2x9DOplosPFgVjD9e9EjTHIrElbs8=; b=EXNRGO0hBiU2KJq9BUWuKo49/KLFDHJjsPQpCNKkSI2/joALumXgoNX40pKBEFqsaWQ3iD rIgfcxW+CnHUG+B+y7fqKCSHLr4SF21uMAqZpyHEye6VA76EyWKEp0iR4RaCyXW+98KQFb UpSCMMHLA8iMBPGG1cuNqZx+JAXqo+8= X-MC-Unique: yd8LuReMMaKhg641XXD6HA-1 X-Mimecast-MFC-AGG-ID: yd8LuReMMaKhg641XXD6HA_1748108183 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , stefanha@redhat.com, Weifeng Liu Subject: [PULL 19/19] ui/gtk-egl: Render guest content with padding in fixed-scale mode Date: Sat, 24 May 2025 19:35:12 +0200 Message-ID: <20250524173514.317886-20-marcandre.lureau@redhat.com> In-Reply-To: <20250524173514.317886-1-marcandre.lureau@redhat.com> References: <20250524173514.317886-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.0 on 10.30.177.17 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.298, 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=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: 1748108247222116600 From: Weifeng Liu Scaling was not respected when rendering frames in gtk-egl.c (used if gl=3Don and X11 mode). To fix this, add fields x and y to struct egl_fb for x offset and y offset so we can add padding to window. Signed-off-by: Weifeng Liu Message-ID: <20250511073337.876650-10-weifeng.liu.z@gmail.com> Acked-by: Gerd Hoffmann Acked-by: Marc-Andr=C3=A9 Lureau --- include/ui/egl-helpers.h | 4 +++- ui/egl-helpers.c | 10 ++++++++-- ui/gtk-egl.c | 36 +++++++++++++++++++++++++++++++----- ui/sdl2-gl.c | 2 +- 4 files changed, 43 insertions(+), 9 deletions(-) diff --git a/include/ui/egl-helpers.h b/include/ui/egl-helpers.h index fb80e15142..acf993fcf5 100644 --- a/include/ui/egl-helpers.h +++ b/include/ui/egl-helpers.h @@ -17,6 +17,8 @@ extern bool qemu_egl_angle_d3d; typedef struct egl_fb { int width; int height; + int x; + int y; GLuint texture; GLuint framebuffer; bool delete_texture; @@ -26,7 +28,7 @@ typedef struct egl_fb { #define EGL_FB_INIT { 0, } =20 void egl_fb_destroy(egl_fb *fb); -void egl_fb_setup_default(egl_fb *fb, int width, int height); +void egl_fb_setup_default(egl_fb *fb, int width, int height, int x, int y); void egl_fb_setup_for_tex(egl_fb *fb, int width, int height, GLuint texture, bool delete); void egl_fb_setup_new_tex(egl_fb *fb, int width, int height); diff --git a/ui/egl-helpers.c b/ui/egl-helpers.c index 9cda2bbbee..5503a795e4 100644 --- a/ui/egl-helpers.c +++ b/ui/egl-helpers.c @@ -93,14 +93,18 @@ void egl_fb_destroy(egl_fb *fb) =20 fb->width =3D 0; fb->height =3D 0; + fb->x =3D 0; + fb->y =3D 0; fb->texture =3D 0; fb->framebuffer =3D 0; } =20 -void egl_fb_setup_default(egl_fb *fb, int width, int height) +void egl_fb_setup_default(egl_fb *fb, int width, int height, int x, int y) { fb->width =3D width; fb->height =3D height; + fb->x =3D x; + fb->y =3D y; fb->framebuffer =3D 0; /* default framebuffer */ } =20 @@ -145,6 +149,7 @@ void egl_fb_blit(egl_fb *dst, egl_fb *src, bool flip) glBindFramebuffer(GL_READ_FRAMEBUFFER, src->framebuffer); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, dst->framebuffer); glViewport(0, 0, dst->width, dst->height); + glClear(GL_COLOR_BUFFER_BIT); =20 if (src->dmabuf) { x1 =3D qemu_dmabuf_get_x(src->dmabuf); @@ -161,7 +166,8 @@ void egl_fb_blit(egl_fb *dst, egl_fb *src, bool flip) x2 =3D x1 + w; =20 glBlitFramebuffer(x1, y1, x2, y2, - 0, 0, dst->width, dst->height, + dst->x, dst->y, + dst->x + dst->width, dst->y + dst->height, GL_COLOR_BUFFER_BIT, GL_LINEAR); } =20 diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c index f8e4f4bc70..0b787bea25 100644 --- a/ui/gtk-egl.c +++ b/ui/gtk-egl.c @@ -340,7 +340,11 @@ void gd_egl_scanout_flush(DisplayChangeListener *dcl, { VirtualConsole *vc =3D container_of(dcl, VirtualConsole, gfx.dcl); GdkWindow *window; - int ww, wh, ws; + int px_offset, py_offset; + int gs; + int pw_widget, ph_widget, pw_surface, ph_surface; + int ww_widget, wh_widget, ww_surface, wh_surface; + int fbw, fbh; =20 if (!vc->gfx.scanout_mode) { return; @@ -353,10 +357,32 @@ void gd_egl_scanout_flush(DisplayChangeListener *dcl, vc->gfx.esurface, vc->gfx.ectx); =20 window =3D gtk_widget_get_window(vc->gfx.drawing_area); - ws =3D gdk_window_get_scale_factor(window); - ww =3D gdk_window_get_width(window) * ws; - wh =3D gdk_window_get_height(window) * ws; - egl_fb_setup_default(&vc->gfx.win_fb, ww, wh); + gs =3D gdk_window_get_scale_factor(window); + ww_widget =3D gdk_window_get_width(window); + wh_widget =3D gdk_window_get_height(window); + fbw =3D surface_width(vc->gfx.ds); + fbh =3D surface_height(vc->gfx.ds); + + gd_update_scale(vc, ww_widget, wh_widget, fbw, fbh); + + ww_surface =3D fbw * vc->gfx.scale_x; + wh_surface =3D fbh * vc->gfx.scale_y; + pw_widget =3D ww_widget * gs; + ph_widget =3D wh_widget * gs; + pw_surface =3D ww_surface * gs; + ph_surface =3D wh_surface * gs; + + px_offset =3D 0; + py_offset =3D 0; + if (pw_widget > pw_surface) { + px_offset =3D (pw_widget - pw_surface) / 2; + } + if (ph_widget > ph_surface) { + py_offset =3D (ph_widget - ph_surface) / 2; + } + + egl_fb_setup_default(&vc->gfx.win_fb, pw_surface, ph_surface, + px_offset, py_offset); if (vc->gfx.cursor_fb.texture) { egl_texture_blit(vc->gfx.gls, &vc->gfx.win_fb, &vc->gfx.guest_fb, vc->gfx.y0_top); diff --git a/ui/sdl2-gl.c b/ui/sdl2-gl.c index e01d9ab0c7..3be17d1079 100644 --- a/ui/sdl2-gl.c +++ b/ui/sdl2-gl.c @@ -241,7 +241,7 @@ void sdl2_gl_scanout_flush(DisplayChangeListener *dcl, SDL_GL_MakeCurrent(scon->real_window, scon->winctx); =20 SDL_GetWindowSize(scon->real_window, &ww, &wh); - egl_fb_setup_default(&scon->win_fb, ww, wh); + egl_fb_setup_default(&scon->win_fb, ww, wh, 0, 0); egl_fb_blit(&scon->win_fb, &scon->guest_fb, !scon->y0_top); =20 SDL_GL_SwapWindow(scon->real_window); --=20 2.49.0