From patchwork Mon Nov 12 15:15:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 996483 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42tvXj4Nxbz9s1x for ; Tue, 13 Nov 2018 02:18:29 +1100 (AEDT) Received: from localhost ([::1]:49165 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gMDyt-0005Ve-7Z for incoming@patchwork.ozlabs.org; Mon, 12 Nov 2018 10:18:27 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50240) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gMDwM-0002r6-VN for qemu-devel@nongnu.org; Mon, 12 Nov 2018 10:15:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gMDwH-0001QM-82 for qemu-devel@nongnu.org; Mon, 12 Nov 2018 10:15:50 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47184) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gMDwD-0001Nb-7E for qemu-devel@nongnu.org; Mon, 12 Nov 2018 10:15:43 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 08E348046F for ; Mon, 12 Nov 2018 15:15:39 +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 BDEF5194B7; Mon, 12 Nov 2018 15:15:17 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 065065E189; Mon, 12 Nov 2018 16:15:17 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 12 Nov 2018 16:15:16 +0100 Message-Id: <20181112151516.10012-5-kraxel@redhat.com> In-Reply-To: <20181112151516.10012-1-kraxel@redhat.com> References: <20181112151516.10012-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 12 Nov 2018 15:15:39 +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] [PULL 4/4] 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: libvir-list@redhat.com, Paolo Bonzini , Gerd Hoffmann Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 Message-id: 20181107074949.13805-1-kraxel@redhat.com --- 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; } + window = gtk_widget_get_window(vc->gfx.drawing_area); + ww = gdk_window_get_width(window); + wh = 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 = (double)ww / vc->gfx.w; + vc->gfx.scale_y = (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); - window = gtk_widget_get_window(vc->gfx.drawing_area); - ww = gdk_window_get_width(window); - wh = 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); eglSwapBuffers(qemu_egl_display, vc->gfx.esurface); + + vc->gfx.scale_x = (double)ww / surface_width(vc->gfx.ds); + vc->gfx.scale_y = (double)wh / surface_height(vc->gfx.ds); } } @@ -232,8 +239,8 @@ void gd_egl_cursor_position(DisplayChangeListener *dcl, { VirtualConsole *vc = container_of(dcl, VirtualConsole, gfx.dcl); - vc->gfx.cursor_x = pos_x; - vc->gfx.cursor_y = pos_y; + vc->gfx.cursor_x = pos_x * vc->gfx.scale_x; + vc->gfx.cursor_y = pos_y * vc->gfx.scale_y; } void gd_egl_release_dmabuf(DisplayChangeListener *dcl,