From patchwork Mon Mar 8 14:34:49 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Webb X-Patchwork-Id: 47117 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 15C7BB7CE8 for ; Tue, 9 Mar 2010 01:38:06 +1100 (EST) Received: from localhost ([127.0.0.1]:56359 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Noe47-0006VO-Hz for incoming@patchwork.ozlabs.org; Mon, 08 Mar 2010 09:36:15 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Noe2r-0006V9-6j for qemu-devel@nongnu.org; Mon, 08 Mar 2010 09:34:57 -0500 Received: from [199.232.76.173] (port=34478 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Noe2p-0006Uy-Dx for qemu-devel@nongnu.org; Mon, 08 Mar 2010 09:34:55 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1Noe2o-0001n1-7p for qemu-devel@nongnu.org; Mon, 08 Mar 2010 09:34:55 -0500 Received: from alpha.arachsys.com ([91.203.57.7]:47139) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Noe2n-0001mm-VD for qemu-devel@nongnu.org; Mon, 08 Mar 2010 09:34:54 -0500 Received: from [83.104.159.199] (helo=miranda.arachsys.com) by alpha.arachsys.com with esmtpa (Exim 4.52) id 1Noe2l-0003gc-4T; Mon, 08 Mar 2010 14:34:51 +0000 Received: from chris by miranda.arachsys.com with local (Exim 4.52) id 1Noe2j-00014i-Tg; Mon, 08 Mar 2010 14:34:49 +0000 Date: Mon, 8 Mar 2010 14:34:49 +0000 From: Chris Webb To: qemu-devel@nongnu.org, kvm@vger.kernel.org Message-ID: <20100308143449.GA4084@arachsys.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20100306085332.GF7180@arachsys.com> User-Agent: Mutt/1.5.20 (2009-06-14) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Cc: Subject: [Qemu-devel] [PATCH] Fix SIGFPE for vnc display of width/height = 1 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org During boot, the screen gets resized to height 1 and a mouse click at this point will cause a division by zero when calculating the absolute pointer position from the pixel (x, y). Return a click in the middle of the screen instead in this case. Signed-off-by: Chris Webb --- vnc.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/vnc.c b/vnc.c index 01353a9..676a707 100644 --- a/vnc.c +++ b/vnc.c @@ -1457,8 +1457,10 @@ static void pointer_event(VncState *vs, int button_mask, int x, int y) dz = 1; if (vs->absolute) { - kbd_mouse_event(x * 0x7FFF / (ds_get_width(vs->ds) - 1), - y * 0x7FFF / (ds_get_height(vs->ds) - 1), + kbd_mouse_event(ds_get_width(vs->ds) > 1 ? + x * 0x7FFF / (ds_get_width(vs->ds) - 1) : 0x4000, + ds_get_height(vs->ds) > 1 ? + y * 0x7FFF / (ds_get_height(vs->ds) - 1) : 0x4000, dz, buttons); } else if (vnc_has_feature(vs, VNC_FEATURE_POINTER_TYPE_CHANGE)) { x -= 0x7FFF;