From nobody Mon Apr 29 10:44:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1541577106062590.7105013882561; Tue, 6 Nov 2018 23:51:46 -0800 (PST) Received: from localhost ([::1]:46221 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKIck-0003m8-7R for importer@patchew.org; Wed, 07 Nov 2018 02:51:38 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56429) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKIbJ-00038M-0f for qemu-devel@nongnu.org; Wed, 07 Nov 2018 02:50:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gKIbE-0006Ds-H7 for qemu-devel@nongnu.org; Wed, 07 Nov 2018 02:50:08 -0500 Received: from mx1.redhat.com ([209.132.183.28]:37486) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gKIbD-00065V-HY for qemu-devel@nongnu.org; Wed, 07 Nov 2018 02:50:04 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A826D308A963 for ; Wed, 7 Nov 2018 07:49:59 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-158.ams2.redhat.com [10.36.116.158]) by smtp.corp.redhat.com (Postfix) with ESMTP id F21CD65F75; Wed, 7 Nov 2018 07:49:52 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 255BE93A7; Wed, 7 Nov 2018 08:49:49 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Wed, 7 Nov 2018 08:49:49 +0100 Message-Id: <20181107074949.13805-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Wed, 07 Nov 2018 07:49:59 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] ui/gtk: fix cursor in egl mode X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" In egl mode the scale_x and scale_y variables are not set, so the scaling logic in the mouse motion event handler does not work. Fix that. Also scale the cursor position in gd_egl_cursor_position(). Reported-by: Chen Zhang Signed-off-by: Gerd Hoffmann Tested-by: Chen Zhang --- ui/gtk-egl.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c index a77c25b490..5420c2362b 100644 --- a/ui/gtk-egl.c +++ b/ui/gtk-egl.c @@ -68,8 +68,15 @@ void gd_egl_draw(VirtualConsole *vc) return; } =20 + window =3D gtk_widget_get_window(vc->gfx.drawing_area); + ww =3D gdk_window_get_width(window); + wh =3D gdk_window_get_height(window); + if (vc->gfx.scanout_mode) { gd_egl_scanout_flush(&vc->gfx.dcl, 0, 0, vc->gfx.w, vc->gfx.h); + + vc->gfx.scale_x =3D (double)ww / vc->gfx.w; + vc->gfx.scale_y =3D (double)wh / vc->gfx.h; } else { if (!vc->gfx.ds) { return; @@ -77,13 +84,13 @@ void gd_egl_draw(VirtualConsole *vc) eglMakeCurrent(qemu_egl_display, vc->gfx.esurface, vc->gfx.esurface, vc->gfx.ectx); =20 - window =3D gtk_widget_get_window(vc->gfx.drawing_area); - ww =3D gdk_window_get_width(window); - wh =3D gdk_window_get_height(window); surface_gl_setup_viewport(vc->gfx.gls, vc->gfx.ds, ww, wh); surface_gl_render_texture(vc->gfx.gls, vc->gfx.ds); =20 eglSwapBuffers(qemu_egl_display, vc->gfx.esurface); + + vc->gfx.scale_x =3D (double)ww / surface_width(vc->gfx.ds); + vc->gfx.scale_y =3D (double)wh / surface_height(vc->gfx.ds); } } =20 @@ -232,8 +239,8 @@ void gd_egl_cursor_position(DisplayChangeListener *dcl, { VirtualConsole *vc =3D container_of(dcl, VirtualConsole, gfx.dcl); =20 - vc->gfx.cursor_x =3D pos_x; - vc->gfx.cursor_y =3D pos_y; + vc->gfx.cursor_x =3D pos_x * vc->gfx.scale_x; + vc->gfx.cursor_y =3D pos_y * vc->gfx.scale_y; } =20 void gd_egl_release_dmabuf(DisplayChangeListener *dcl, --=20 2.9.3