[PATCH spice-gtk] Fix non-tablet non-vd-agent erratic mouse motion RH#1285378

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

This is a proposal fix for this Spice bug:
https://bugzilla.redhat.com/show_bug.cgi?id=1285378



Thank you,
Steph
Fix non-tablet non-guest-agent erratic mouse motion RH#1285378

https://bugzilla.redhat.com/show_bug.cgi?id=1285378

https://bugzilla.redhat.com/show_bug.cgi?id=1285378#c21 provides Wayland
pointer interface but (1) my patch below does not require Wayland server and
(2) not all users already run Wayland due to various incompatibilities.

Tested with some downloaded MS-Windows 8 beta after removing tablet virtual
device. Fedora 26 with removed virtual tablet device does not reproduce the
problem as it still runs in SPICE_MOUSE_MODE_CLIENT mode.

Signed-off-by: Marie Stephanie Alesna <istephielicious@xxxxxxxxx>
--
 src/spice-widget-priv.h |  2 ++
 src/spice-widget.c      | 14 ++++++++++----
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/spice-widget-priv.h b/src/spice-widget-priv.h
index 1189cbb..728879c 100644
--- a/src/spice-widget-priv.h
+++ b/src/spice-widget-priv.h
@@ -105,6 +105,8 @@ struct _SpiceDisplayPrivate {
     GdkCursor               *show_cursor;
     int                     mouse_last_x;
     int                     mouse_last_y;
+    gdouble                 mouse_delta_x;
+    gdouble                 mouse_delta_y;
     int                     mouse_guest_x;
     int                     mouse_guest_y;
 
diff --git a/src/spice-widget.c b/src/spice-widget.c
index fb94e94..8052b77 100644
--- a/src/spice-widget.c
+++ b/src/spice-widget.c
@@ -1146,6 +1146,8 @@ static void try_mouse_grab(SpiceDisplay *display)
 
     d->mouse_last_x = -1;
     d->mouse_last_y = -1;
+    d->mouse_delta_x = 0;
+    d->mouse_delta_y = 0;
 }
 
 static void mouse_wrap(SpiceDisplay *display, GdkEventMotion *motion)
@@ -1169,12 +1171,15 @@ static void mouse_wrap(SpiceDisplay *display, GdkEventMotion *motion)
 
     if (xr != (gint)motion->x_root || yr != (gint)motion->y_root) {
         GdkWindow *window = gtk_widget_get_window(GTK_WIDGET(display));
-        /* FIXME: we try our best to ignore that next pointer move event.. */
+
+        /* We need to compensate the move induced by gdk_device_warp.
+           We cannot just ignore the next pointer move event as it may include
+           additional user moves. */
         gdk_display_sync(gdk_screen_get_display(screen));
 
         gdk_device_warp(spice_gdk_window_get_pointing_device(window), screen, xr, yr);
-        d->mouse_last_x = -1;
-        d->mouse_last_y = -1;
+        d->mouse_delta_x += xr - motion->x_root;
+        d->mouse_delta_y += yr - motion->y_root;
     }
 #endif
 
@@ -1983,7 +1988,8 @@ static gboolean motion_event(GtkWidget *widget, GdkEventMotion *motion)
         try_keyboard_grab(display);
     }
 
-    transform_input(display, motion->x, motion->y, &x, &y);
+    transform_input(display, motion->x - d->mouse_delta_x,
+                    motion->y - d->mouse_delta_y, &x, &y);
 
     switch (d->mouse_mode) {
     case SPICE_MOUSE_MODE_CLIENT:
-- 
2.13.5

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]