From nobody Mon Nov 25 09:20:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1715512544; cv=none; d=zohomail.com; s=zohoarc; b=hhzdtcp9v7j5yO1iRbAIvNxzWvjLcvhRQozOOcY206jGE6b7IM0+DqQZunY/69yQ2+uxsE+pp9osfOzuG41kykYHsY0Z9ahUh9sD/HzP1BY1qLrPmRvm6E4X9K5eplDRT9ZQsiN7Cg/BXmHHT06yPaQ1R+4dbFu7iANwwz9up2w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1715512544; h=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=j3bZmJpvge7F0RjIF+WyHg4jjK08IiARCF7Cz5tQXBE=; b=XkEghIkvkzWV0Gp/i7G+0xMVunzf+p8Xtsxeq7N/ILXMcuTnI7S8wcW3hHKzoITGi+wNmHXuw0rDjkK7E0L8he3iJPvVtb1P8ohcHXcGbU+zWudRT6+3i2tveiOnvaVjJtpvKudMBQ3VTJJTGgySw7uQRHeeG/2DG6OXlJSJTy0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1715512544306597.8780503269194; Sun, 12 May 2024 04:15:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s67AG-0008Ch-Dv; Sun, 12 May 2024 07:14:48 -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 1s67AE-0008C0-Mx for qemu-devel@nongnu.org; Sun, 12 May 2024 07:14:46 -0400 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s67AD-0003jf-B6 for qemu-devel@nongnu.org; Sun, 12 May 2024 07:14:46 -0400 Received: by mail-pg1-x534.google.com with SMTP id 41be03b00d2f7-5dca1efad59so2643951a12.2 for ; Sun, 12 May 2024 04:14:45 -0700 (PDT) Received: from penguin.lxd (113x36x63x49.ap113.ftth.ucom.ne.jp. [113.36.63.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1ef0bf30cbasm60399375ad.126.2024.05.12.04.14.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 May 2024 04:14:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hikalium-com.20230601.gappssmtp.com; s=20230601; t=1715512484; x=1716117284; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=j3bZmJpvge7F0RjIF+WyHg4jjK08IiARCF7Cz5tQXBE=; b=MwOOvMX2RtAwwMl4TOHgD3DA/HLlzGID52OBJIkOC2OLTczEBUAkuVroLQ91wJFcMl 8unznFaP8lgK7ZX+DDnpYjITmVadQvyIc6NNZtuX585qc/Sp+P8dgIwxf+fvBeopC6fD vEL4FMX4dIF98h/tmzxcVHo1hXV0rqZTX5IGCcSk9PpgvpXDVR8tCyFrBL9oCAqwpTyQ TtGlqSLa5PjABk3/Q+pRgqjbp6efUpNRQ1uAYztzpB3WH4sMYGZB6oIvE/YVWt8Qkmgx 3liU7Z60dWBlIod0QzjTUxC5raYRImde7WL+enkNYQbEb7QAq34bdSupaPL5GIug2Uu/ Bzbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715512484; x=1716117284; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=j3bZmJpvge7F0RjIF+WyHg4jjK08IiARCF7Cz5tQXBE=; b=rsZ0xG1Rpmscej0kjkZvqrogiz28h1nHXzv71f7S5YuctK+YP3qSnukr+ohxTM3FKj oA3DNis83NHWXbP3AX0jHilip5dsrpmxq/IqgvQhdQk4FblNO1Z0ey8AMrye25YaICnn KmGyCle/0KOmT5ZuZDnpCffv1OBUBfdZFcCTfLDo2y+M9PGBlgckh7vY6R+VFmCuHZ2X V2LkDn4Fh03t31XK5fhb+OdvJsL1tBrzCNR7kiL4DxwKZYgabGpNXHoA7nLVL/BhHcjD XDdsXfpf18mlRZ3gylInN08aTrATxSHm4CNsDigpKT0gCYL6tK9Iwpn/CXkD9zD/5wmd FWlQ== X-Gm-Message-State: AOJu0Yx6a/jVNSt8ouTD/HvrS/RkenShZBJTvgF8N0DkpBcYOARsLioQ h0oRbcso+alHQ/DYvYtxbWx7AjyfcvAiuFxLmHQ63+yk3OK6Z9nSAEmPQ85OeaMrHnP0jGyd4RS MgP4= X-Google-Smtp-Source: AGHT+IHIpo9aJ1zZZ5Q8Ml0/9aCNa+HK57lJr5lx1JwdWEB0n2i2ltXolPhCzIIK7E6VQ/CjGOeZEA== X-Received: by 2002:a05:6a20:3c94:b0:1af:cd4a:1e0c with SMTP id adf61e73a8af0-1afde0a8d6amr7596315637.9.1715512483851; Sun, 12 May 2024 04:14:43 -0700 (PDT) From: hikalium To: qemu-devel@nongnu.org Cc: hikalium , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v2 1/2] ui/gtk: Add gd_motion_event trace event Date: Sun, 12 May 2024 20:14:34 +0900 Message-Id: <20240512111435.30121-2-hikalium@hikalium.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240512111435.30121-1-hikalium@hikalium.com> References: <20240512090429.29123-1-hikalium@hikalium.com> <20240512111435.30121-1-hikalium@hikalium.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::534; envelope-from=hikalium@hikalium.com; helo=mail-pg1-x534.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 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 @hikalium-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1715512546365100006 Content-Type: text/plain; charset="utf-8" Add gd_motion_event trace event for making it easy to debug gd_motion_event related issues. Signed-off-by: hikalium Acked-by: Marc-Andr=C3=A9 Lureau --- ui/gtk.c | 2 ++ ui/trace-events | 1 + 2 files changed, 3 insertions(+) diff --git a/ui/gtk.c b/ui/gtk.c index 810d7fc796..ebae888d4f 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -911,6 +911,8 @@ static gboolean gd_motion_event(GtkWidget *widget, GdkE= ventMotion *motion, x =3D (motion->x - mx) / vc->gfx.scale_x * ws; y =3D (motion->y - my) / vc->gfx.scale_y * ws; =20 + trace_gd_motion_event(ww, wh, gtk_widget_get_scale_factor(widget), x, = y); + if (qemu_input_is_absolute(vc->gfx.dcl.con)) { if (x < 0 || y < 0 || x >=3D surface_width(vc->gfx.ds) || diff --git a/ui/trace-events b/ui/trace-events index e6a2894303..69ff22955d 100644 --- a/ui/trace-events +++ b/ui/trace-events @@ -28,6 +28,7 @@ gd_ungrab(const char *tab, const char *device) "tab=3D%s,= dev=3D%s" gd_keymap_windowing(const char *name) "backend=3D%s" gd_gl_area_create_context(void *ctx, int major, int minor) "ctx=3D%p, majo= r=3D%d, minor=3D%d" gd_gl_area_destroy_context(void *ctx, void *current_ctx) "ctx=3D%p, curren= t_ctx=3D%p" +gd_motion_event(int ww, int wh, int ws, int x, int y) "ww=3D%d, wh=3D%d, w= s=3D%d, x=3D%d, y=3D%d" =20 # vnc-auth-sasl.c # vnc-auth-vencrypt.c --=20 2.39.2 From nobody Mon Nov 25 09:20:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1715512547; cv=none; d=zohomail.com; s=zohoarc; b=cmtOMaCt2HcDPokYeievAoKKUhu0UHroG5slVvt1+Ui/lLaFhml+XixbmUJ7kzkyKbQwnjAjwb6BlsXPSLbH3sc/WZGekLW0s4YLRYihDkEl/kyFTGlUvwZcf4XexF2j9sl6c9z0Zh3tJXRBAv0Epn6Z8tdvWiOAh1WmWfMbmhk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1715512547; h=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=ybklGZsQ5B6bwbft1vxCvRI45enWgIukMcnmLJbokgY=; b=PhI8MJYtzg4++3HQNIfeme88CNMZpPjEaZ/wKdzhaDqdu+8RpQ5VraSLcZs/vAlA4HkgQaNsJJwuttfjHYRmlUXzSaqbNNWHPcIRbR6VjLVALEoYTs0bcMxpPn8TL2LZQ5opL7o5/atBJlm91ZvTGLRj3tukWAxB9JkAG3XlfsE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1715512547007113.51654299427878; Sun, 12 May 2024 04:15:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s67AI-0008Cx-1G; Sun, 12 May 2024 07:14:50 -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 1s67AG-0008Cl-Ph for qemu-devel@nongnu.org; Sun, 12 May 2024 07:14:48 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s67AF-0003js-8w for qemu-devel@nongnu.org; Sun, 12 May 2024 07:14:48 -0400 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1ec41d82b8bso32973655ad.2 for ; Sun, 12 May 2024 04:14:46 -0700 (PDT) Received: from penguin.lxd (113x36x63x49.ap113.ftth.ucom.ne.jp. [113.36.63.49]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1ef0bf30cbasm60399375ad.126.2024.05.12.04.14.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 May 2024 04:14:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hikalium-com.20230601.gappssmtp.com; s=20230601; t=1715512486; x=1716117286; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ybklGZsQ5B6bwbft1vxCvRI45enWgIukMcnmLJbokgY=; b=ZKk/8r8WAzgEKWfgamIaycNBDQQiAa5Mj626/F78klOU6lnDroLMxeskxC3dkBCnZd bmlJYV1IfjNyadWiFFsmM9Bd7759fHOOp0gmxEvVryNS+oix1ndR/LN6EHGEBKlD7dyS 7/R8nRB7HsHThHaEEsDUCpgxmxZMjfeIF0XQ0a3Fm9XAKeINFVa3X2z48MDTX0/L4+Pd o9P1IO1qIQamN3ETMiL8OT4McZICEXJLZ9vN1qvFqzQkBykWEfF54NhkmQ7z6YG7dkl8 DCva/gdhIMorXA006tO3oRkY7wEaFy4unnT1XjlnbAWv3tc+ehBQSr3zKPJaIf2CJtE8 H09A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715512486; x=1716117286; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ybklGZsQ5B6bwbft1vxCvRI45enWgIukMcnmLJbokgY=; b=QU4khksc22NHa/wUz7Zlshb9Mvbqbssf8wY7hu9/SeIynIC48IUAMio4THxis13Gkb SNbBvzH29tuDFaglrrg1tvexY94lvfe1mqxi7/NkxoJ6H055J29JA5c3vVkNx3gMQPa8 W0VdpayFQhgsn9X0aWzof0cEnG1DLoQs/IwALbKLJBqGatmccXSnXBi9vYwKmJlzr3RA iQaloivsjBeaukKoKLp3SnK5hFZTTdToaUIYr3/w9JieV2xScyUXhm/5M49geO1VicYZ RGMoOriNXG7zPj5tngvzKtxnucmAhtUvjwvl1Fqeah12/8dLJT7dfMKWvMlLlmMIucrP k+pA== X-Gm-Message-State: AOJu0YzM39DFWI1ISwo+O6EoB1/JbcyoVdytAcm0rIJVy8BWD+OTbMPJ K9KHKY+mI2BBFVwOi4iUhRKVq0nEqIJDKn8e/FHbnfEIUTLCNoucw3/0hbv0rsFqjS0CwTDQkEw 7jHc= X-Google-Smtp-Source: AGHT+IHux31aL/ZAZycvpAmP5MGoZma9lT2/RpkMb7FMfbxsDfLkFs6DVIKeWKWxit+u9+XbexDqeQ== X-Received: by 2002:a17:902:d2c9:b0:1e3:f4f1:a2c4 with SMTP id d9443c01a7336-1ef44050d4bmr95859245ad.64.1715512485694; Sun, 12 May 2024 04:14:45 -0700 (PDT) From: hikalium To: qemu-devel@nongnu.org Cc: hikalium , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v2 2/2] ui/gtk: Fix mouse/motion event scaling issue with GTK display backend Date: Sun, 12 May 2024 20:14:35 +0900 Message-Id: <20240512111435.30121-3-hikalium@hikalium.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240512111435.30121-1-hikalium@hikalium.com> References: <20240512090429.29123-1-hikalium@hikalium.com> <20240512111435.30121-1-hikalium@hikalium.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::631; envelope-from=hikalium@hikalium.com; helo=mail-pl1-x631.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 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 @hikalium-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1715512548280100011 Content-Type: text/plain; charset="utf-8" Remove gtk_widget_get_scale_factor() usage from the calculation of the motion events in the GTK backend to make it work correctly on environments that have `gtk_widget_get_scale_factor() !=3D 1`. This scale factor usage had been introduced in the commit f14aab420c and at that time the window size was used for calculating the things and it was working correctly. However, in the commit 2f31663ed4 the logic switched to use the widget size instead of window size and because of the change the usage of scale factor becomes invalid (since widgets use `vc->gfx.scale_{x, y}` for scaling). Tested on Crostini on ChromeOS (15823.51.0) with an external display. Fixes: 2f31663ed4 ("ui/gtk: use widget size for cursor motion event") Fixes: f14aab420c ("ui: fix incorrect pointer position on highdpi with gtk") Signed-off-by: hikalium --- ui/gtk.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/ui/gtk.c b/ui/gtk.c index ebae888d4f..4386198c95 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -887,7 +887,7 @@ static gboolean gd_motion_event(GtkWidget *widget, GdkE= ventMotion *motion, int x, y; int mx, my; int fbh, fbw; - int ww, wh, ws; + int ww, wh; =20 if (!vc->gfx.ds) { return TRUE; @@ -895,11 +895,15 @@ static gboolean gd_motion_event(GtkWidget *widget, Gd= kEventMotion *motion, =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); - ws =3D gtk_widget_get_scale_factor(widget); =20 + /* + * `widget` may not have the same size with the frame buffer. + * In such cases, some paddings are needed around the `vc`. + * 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; @@ -908,8 +912,12 @@ static gboolean gd_motion_event(GtkWidget *widget, Gdk= EventMotion *motion, my =3D (wh - fbh) / 2; } =20 - x =3D (motion->x - mx) / vc->gfx.scale_x * ws; - y =3D (motion->y - my) / vc->gfx.scale_y * ws; + /* + * `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; =20 trace_gd_motion_event(ww, wh, gtk_widget_get_scale_factor(widget), x, = y); =20 --=20 2.39.2