Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BB1B3C07E95 for ; Wed, 7 Jul 2021 11:06:47 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5E10861182 for ; Wed, 7 Jul 2021 11:06:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5E10861182 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmx.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:54246 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m15OA-0006Eg-JQ for qemu-devel@archiver.kernel.org; Wed, 07 Jul 2021 07:06:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56754) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m15KP-0007aF-Vw for qemu-devel@nongnu.org; Wed, 07 Jul 2021 07:02:54 -0400 Received: from mout.gmx.net ([212.227.15.15]:36999) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m15KE-0003Cs-6k for qemu-devel@nongnu.org; Wed, 07 Jul 2021 07:02:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1625655756; bh=7E/KpRMhlS7a13XKEdSo4vVYrig22uAxisnFUh18KQ8=; h=X-UI-Sender-Class:Subject:To:Cc:References:From:Date:In-Reply-To; b=KrQNM5bqWaxsrje7Kwb1zLNrOPWQHV3RrJ9zreAcS/lKD5A2aA/LfWxw9+4nGA7nX gUvV3GKga4MHufdSBsst5ZMWzBaBrUc3DfwcXD9qNIZlS67fvmz0kY7mIAG/sCv7nW pwCJhmS70gTB8fJLNHCGgxSKkW/0qCy1qH5cIHxA= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.188.43] ([88.130.62.247]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MacSe-1lUUas2oFm-00c7w1; Wed, 07 Jul 2021 13:02:36 +0200 Subject: Re: [PATCH] ui/gtk: Fix relative mouse with multiple monitors To: qemu-devel@nongnu.org References: <20210629132410.286813-1-denniswoelfing@gmx.de> From: =?UTF-8?Q?Dennis_W=c3=b6lfing?= Message-ID: Date: Wed, 7 Jul 2021 13:02:34 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210629132410.286813-1-denniswoelfing@gmx.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:K1QCMp2bosdDNoPHPF7Rmg7MU7r6bEZNSSyFG3o2pUS2jvCxHRv Re9fixeIFI4GcInyLw/tT2ffMyFOsHtdMkx8ipuP3wtFAavRpBDVV6KRXrLRcfSs8drHNmc Itx5kjVOG/BQ5juQQkfC7wyJmWZBAvYvR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fx6A6suZZGLedlRlcF9vQhpgi XFqciRdFydk/2QMZzq5T3x7W2jHvaqS3YHDAlYPu2C8Qyjlv1eQl6H8T+BrMSfkr5mYM70iNf ALA1v+m2mZSsxl8kT6okRU8ewv3E6WBdMSQqezcxQkVVcAKycpxaKW9Pj4ZxnEgfZ69epNu+Z xSES3nOhL2OTdBxb7wsHCgPtZFpT4wwh3iT/7AcrL1t7A5uU5IiYNErwQCa7PW3Igq/WTfbUQ hYESU= Received-SPF: pass client-ip=212.227.15.15; envelope-from=denniswoelfing@gmx.de; helo=mout.gmx.net X-Spam_score_int: 14 X-Spam_score: 1.4 X-Spam_bar: + X-Spam_report: (1.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001, NICE_REPLY_A=-0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Ping https://lore.kernel.org/qemu-devel/20210629132410.286813-1-denniswoelfing@= gmx.de On 29.06.21 15:24, Dennis W=C3=B6lfing wrote: > To handle relative mouse input the event handler needs to move the mouse > away from the screen edges. Failing to do so results in the mouse > getting stuck at invisible walls. However the current implementation for > this is broken on hosts with multiple monitors. > > With multiple monitors the mouse can be located outside of the current > monitor which is not handled by the current code. Also the monitor > itself might be located at coordinates different from (0, 0). > > Signed-off-by: Dennis W=C3=B6lfing > --- > ui/gtk.c | 21 +++++++++------------ > 1 file changed, 9 insertions(+), 12 deletions(-) > > diff --git a/ui/gtk.c b/ui/gtk.c > index 98046f577b..5258532b19 100644 > --- a/ui/gtk.c > +++ b/ui/gtk.c > @@ -865,33 +865,30 @@ static gboolean gd_motion_event(GtkWidget *widget,= GdkEventMotion *motion, > GdkWindow *win =3D gtk_widget_get_window(widget); > GdkMonitor *monitor =3D gdk_display_get_monitor_at_window(dpy,= win); > GdkRectangle geometry; > - int screen_width, screen_height; > > int x =3D (int)motion->x_root; > int y =3D (int)motion->y_root; > > gdk_monitor_get_geometry(monitor, &geometry); > - screen_width =3D geometry.width; > - screen_height =3D geometry.height; > > /* In relative mode check to see if client pointer hit > - * one of the screen edges, and if so move it back by > + * one of the monitor edges, and if so move it back by > * 200 pixels. This is important because the pointer > * in the server doesn't correspond 1-for-1, and so > * may still be only half way across the screen. Without > * this warp, the server pointer would thus appear to hit > * an invisible wall */ > - if (x =3D=3D 0) { > - x +=3D 200; > + if (x <=3D geometry.x) { > + x =3D geometry.x + 200; > } > - if (y =3D=3D 0) { > - y +=3D 200; > + if (y <=3D geometry.y) { > + y =3D geometry.y + 200; > } > - if (x =3D=3D (screen_width - 1)) { > - x -=3D 200; > + if (x - geometry.x >=3D (geometry.width - 1)) { > + x =3D geometry.x + (geometry.width - 1) - 200; > } > - if (y =3D=3D (screen_height - 1)) { > - y -=3D 200; > + if (y - geometry.y >=3D (geometry.height - 1)) { > + y =3D geometry.y + (geometry.height - 1) - 200; > } > > if (x !=3D (int)motion->x_root || y !=3D (int)motion->y_root) = { > -- > 2.32.0 >