Received: from eggs.gnu.org ([2001:4830:134:3::10]:59687) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDuGq-0000Ky-Nm for qemu-devel@nongnu.org; Thu, 13 Feb 2014 06:16:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WDuGh-0003FY-Ew for qemu-devel@nongnu.org; Thu, 13 Feb 2014 06:15:56 -0500 Received: from cantor2.suse.de ([195.135.220.15]:53187 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDuGh-0003Et-5U for qemu-devel@nongnu.org; Thu, 13 Feb 2014 06:15:47 -0500 From: Takashi Iwai Date: Thu, 13 Feb 2014 12:15:37 +0100 Message-Id: <1392290139-17250-3-git-send-email-tiwai@suse.de> In-Reply-To: <1392290139-17250-1-git-send-email-tiwai@suse.de> References: <1392290139-17250-1-git-send-email-tiwai@suse.de> Subject: [Qemu-devel] [PATCH 2/4] gtk: Fix the relative pointer tracking mode List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Anthony Liguori The relative pointer tracking mode was still buggy even after the previous fix of the motion-notify-event since the events are filtered out when the pointer moves outside the drawing window due to the boundary check for the absolute mode. This patch fixes the issue by moving the unnecessary boundary check into the if block of absolute mode, and keep the coordinate in the relative mode even if it's outside the drawing area. But this makes the coordinate (last_x, last_y) possibly pointing to (-1,-1), introduce a new flag to indicate the last coordinate has been updated. Reference: https://bugzilla.novell.com/show_bug.cgi?id=849587 Signed-off-by: Takashi Iwai --- ui/gtk.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ui/gtk.c b/ui/gtk.c index 4d5ea8e6bb38..b72272ebac3f 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -148,6 +148,7 @@ typedef struct GtkDisplayState DisplayChangeListener dcl; DisplaySurface *ds; int button_mask; + gboolean last_set; int last_x; int last_y; @@ -604,16 +605,15 @@ static gboolean gd_motion_event(GtkWidget *widget, GdkEventMotion *motion, x = (motion->x - mx) / s->scale_x; y = (motion->y - my) / s->scale_y; - if (x < 0 || y < 0 || - x >= surface_width(s->ds) || - y >= surface_height(s->ds)) { - return TRUE; - } - if (kbd_mouse_is_absolute()) { + if (x < 0 || y < 0 || + x >= surface_width(s->ds) || + y >= surface_height(s->ds)) { + return TRUE; + } dx = x * 0x7FFF / (surface_width(s->ds) - 1); dy = y * 0x7FFF / (surface_height(s->ds) - 1); - } else if (s->last_x == -1 || s->last_y == -1) { + } else if (!s->last_set) { dx = 0; dy = 0; } else { @@ -623,6 +623,7 @@ static gboolean gd_motion_event(GtkWidget *widget, GdkEventMotion *motion, s->last_x = x; s->last_y = y; + s->last_set = TRUE; if (kbd_mouse_is_absolute() || gd_is_grab_active(s)) { kbd_mouse_event(dx, dy, 0, s->button_mask); @@ -661,8 +662,7 @@ static gboolean gd_motion_event(GtkWidget *widget, GdkEventMotion *motion, GdkDisplay *display = gtk_widget_get_display(widget); gdk_display_warp_pointer(display, screen, x, y); #endif - s->last_x = -1; - s->last_y = -1; + s->last_set = FALSE; return FALSE; } } -- 1.8.5.2