[vino/gnome-3-0] Only send a motion event when the pointer moved



commit 9868907dd858d55bf330faeaede923cb85791db5
Author: Oliver Gerlich <oliver gerlich gmx de>
Date:   Mon Apr 18 18:53:07 2011 +0200

    Only send a motion event when the pointer moved
    
    Only generate a MotionNotify event if the button state did not change or
    if the mouse coordinates have changed. Fixes bug 564520.

 server/vino-input.c |   39 ++++++++++++++++++++++++++++++---------
 1 files changed, 30 insertions(+), 9 deletions(-)
---
diff --git a/server/vino-input.c b/server/vino-input.c
index 3e02071..8efd6cf 100644
--- a/server/vino-input.c
+++ b/server/vino-input.c
@@ -819,18 +819,39 @@ vino_input_handle_pointer_event (GdkScreen *screen,
 				 guint16    y)
 {
 #ifdef VINO_HAVE_XTEST
+  GdkDisplay *gdkdisplay;
   Display *xdisplay;
   guint8   prev_mask = global_input_data.button_mask;
   int      i;
-
-  xdisplay = GDK_DISPLAY_XDISPLAY (gdk_screen_get_display (screen));
-
-  XTestFakeMotionEvent (xdisplay,
-			gdk_screen_get_number (screen),
-			x, y,
-			CurrentTime);
-  
-  dprintf (INPUT, "Injected motion event: %d, %d\n", x, y);
+  gboolean generate_motion_event = FALSE;
+
+  gdkdisplay = gdk_screen_get_display (screen);
+  xdisplay = GDK_DISPLAY_XDISPLAY (gdkdisplay);
+
+  /* Only generate a motion event if the pointer has moved. See GNOME bug
+   * #564520. */
+  if(button_mask != prev_mask)
+  {
+    int curr_x, curr_y;
+    GdkDevice *pointer;
+
+    pointer = gdk_device_manager_get_client_pointer(
+      gdk_display_get_device_manager(gdkdisplay));
+    gdk_device_get_position(pointer, NULL, &curr_x, &curr_y);
+    if(x != curr_x || y != curr_y)
+      generate_motion_event = TRUE;
+  }
+  else
+  {
+    generate_motion_event = TRUE;
+  }
+
+  if(generate_motion_event)
+  {
+    XTestFakeMotionEvent(xdisplay, gdk_screen_get_number(screen), x, y,
+      CurrentTime);
+    dprintf (INPUT, "Injected motion event: %d, %d\n", x, y);
+  }
 
   for (i = 0; i < global_input_data.n_pointer_buttons; i++)
     {



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