From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49160) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WX5M3-0003nI-T4 for qemu-devel@nongnu.org; Mon, 07 Apr 2014 04:56:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WX5Lz-0004gT-8P for qemu-devel@nongnu.org; Mon, 07 Apr 2014 04:56:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:4056) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WX5Lz-0004gL-0d for qemu-devel@nongnu.org; Mon, 07 Apr 2014 04:56:31 -0400 From: Gerd Hoffmann Date: Mon, 7 Apr 2014 10:56:18 +0200 Message-Id: <1396860980-7130-3-git-send-email-kraxel@redhat.com> In-Reply-To: <1396860980-7130-1-git-send-email-kraxel@redhat.com> References: <1396860980-7130-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PULL 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: Takashi Iwai , Gerd Hoffmann , Anthony Liguori From: Takashi Iwai 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 Tested-by: Cole Robinson Reviewed-by: Cole Robinson Tested-by: Michael S. Tsirkin Signed-off-by: Takashi Iwai Signed-off-by: Gerd Hoffmann --- ui/gtk.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ui/gtk.c b/ui/gtk.c index c9f6d24..913cc3f 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -156,6 +156,7 @@ typedef struct GtkDisplayState DisplayChangeListener dcl; DisplaySurface *ds; int button_mask; + gboolean last_set; int last_x; int last_y; @@ -616,25 +617,25 @@ 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 (qemu_input_is_absolute()) { + if (x < 0 || y < 0 || + x >= surface_width(s->ds) || + y >= surface_height(s->ds)) { + return TRUE; + } qemu_input_queue_abs(s->dcl.con, INPUT_AXIS_X, x, surface_width(s->ds)); qemu_input_queue_abs(s->dcl.con, INPUT_AXIS_Y, y, surface_height(s->ds)); qemu_input_event_sync(); - } else if (s->last_x != -1 && s->last_y != -1 && gd_is_grab_active(s)) { + } else if (s->last_set && gd_is_grab_active(s)) { qemu_input_queue_rel(s->dcl.con, INPUT_AXIS_X, x - s->last_x); qemu_input_queue_rel(s->dcl.con, INPUT_AXIS_Y, y - s->last_y); qemu_input_event_sync(); } s->last_x = x; s->last_y = y; + s->last_set = TRUE; if (!qemu_input_is_absolute() && gd_is_grab_active(s)) { GdkScreen *screen = gtk_widget_get_screen(s->drawing_area); @@ -669,8 +670,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.3.1