[gtk+/overlay-heuristics: 8/8] Track only motion



commit 426d6e8241ce44823d21267526eb83a6d0609908
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Nov 28 14:12:49 2014 -0500

    Track only motion
    
    The fact that the buttons right above the touchpad actually report
    events for the trackpoint puts a wrench into the current device
    tracking idea. I always use those buttons together with the touchpad,
    so I constantly change the current device between touchpad and
    trackpoint, which ruins the experience.
    
    To overcome this problem, use only motion events for the current
    tracking, eliminating the problem, but making this tracking less
    generally useful. It is really tailored towards overlay scrolling
    now.

 gdk/gdkdevice.c        |   12 ++++++------
 gdk/gdkdevice.h        |    2 +-
 gdk/gdkdevicemanager.c |    9 ++++++++-
 gdk/gdkdeviceprivate.h |    4 ++--
 gdk/gdkevents.c        |    5 +++--
 5 files changed, 20 insertions(+), 12 deletions(-)
---
diff --git a/gdk/gdkdevice.c b/gdk/gdkdevice.c
index d8b66f1..6c38322 100644
--- a/gdk/gdkdevice.c
+++ b/gdk/gdkdevice.c
@@ -1760,18 +1760,18 @@ gdk_device_get_last_event_window (GdkDevice *device)
 }
 
 /**
- * gdk_device_get_time:
+ * gdk_device_get_motion_time:
  * @device: a #GdkDevice
  *
- * Returns the timestamp of the last event involving this device that GDK has
- * received.
+ * Returns the timestamp of the last motion event involving this device
+ * that GDK has received.
  *
  * Returns: the timestamp of the last event for this device
  *
  * Since: 3.16
  */
 guint32
-gdk_device_get_time (GdkDevice *device)
+gdk_device_get_motion_time (GdkDevice *device)
 {
   g_return_val_if_fail (GDK_IS_DEVICE (device), 0);
 
@@ -1779,8 +1779,8 @@ gdk_device_get_time (GdkDevice *device)
 }
 
 void
-_gdk_device_set_time (GdkDevice *device,
-                      guint32    time)
+_gdk_device_set_motion_time (GdkDevice *device,
+                             guint32    time)
 {
   if (time > device->time)
     {
diff --git a/gdk/gdkdevice.h b/gdk/gdkdevice.h
index 8e238ed..b46cc55 100644
--- a/gdk/gdkdevice.h
+++ b/gdk/gdkdevice.h
@@ -275,7 +275,7 @@ GDK_AVAILABLE_IN_3_12
 GdkWindow *gdk_device_get_last_event_window (GdkDevice *device);
 
 GDK_AVAILABLE_IN_3_16
-guint32    gdk_device_get_time       (GdkDevice *device);
+guint32    gdk_device_get_motion_time (GdkDevice *device);
 
 G_END_DECLS
 
diff --git a/gdk/gdkdevicemanager.c b/gdk/gdkdevicemanager.c
index e7e16b5..02a6396 100644
--- a/gdk/gdkdevicemanager.c
+++ b/gdk/gdkdevicemanager.c
@@ -186,6 +186,13 @@ gdk_device_manager_class_init (GdkDeviceManagerClass *klass)
                                                         G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
                                                         G_PARAM_STATIC_STRINGS));
 
+  /**
+   * GdkDeviceManager:current-device:
+   *
+   * The device that we have most recently seen a motion event for.
+   *
+   * Since: 3.16
+   */
   g_object_class_install_property (object_class,
                                    PROP_CURRENT_DEVICE,
                                    g_param_spec_object ("current-device",
@@ -383,7 +390,7 @@ _gdk_device_manager_update_current_device (GdkDeviceManager *device_manager,
 
   if (device_manager->current_device == NULL ||
       device == NULL ||
-      gdk_device_get_time (device) >= gdk_device_get_time (device_manager->current_device))
+      gdk_device_get_motion_time (device) >= gdk_device_get_motion_time (device_manager->current_device))
     {
       device_manager->current_device = device;
       g_object_notify (G_OBJECT (device_manager), "current-device");
diff --git a/gdk/gdkdeviceprivate.h b/gdk/gdkdeviceprivate.h
index 53a9cbb..53dc161 100644
--- a/gdk/gdkdeviceprivate.h
+++ b/gdk/gdkdeviceprivate.h
@@ -174,8 +174,8 @@ GdkWindow * _gdk_device_window_at_position    (GdkDevice        *device,
                                                GdkModifierType  *mask,
                                                gboolean          get_toplevel);
 
-void _gdk_device_set_time (GdkDevice *device,
-                           guint32    time);
+void _gdk_device_set_motion_time (GdkDevice *device,
+                                  guint32    time);
 
 G_END_DECLS
 
diff --git a/gdk/gdkevents.c b/gdk/gdkevents.c
index 00ca18a..0430f37 100644
--- a/gdk/gdkevents.c
+++ b/gdk/gdkevents.c
@@ -1482,6 +1482,7 @@ gdk_event_set_device (GdkEvent  *event,
     {
     case GDK_MOTION_NOTIFY:
       event->motion.device = device;
+      _gdk_device_set_motion_time (device, gdk_event_get_time (event));
       break;
     case GDK_BUTTON_PRESS:
     case GDK_2BUTTON_PRESS:
@@ -1505,7 +1506,6 @@ gdk_event_set_device (GdkEvent  *event,
     default:
       break;
     }
-  _gdk_device_set_time (device, gdk_event_get_time (event));
 }
 
 /**
@@ -1631,7 +1631,8 @@ gdk_event_set_source_device (GdkEvent  *event,
   private = (GdkEventPrivate *) event;
 
   private->source_device = device;
-  _gdk_device_set_time (device, gdk_event_get_time (event));
+  if (event->type == GDK_MOTION_NOTIFY)
+    _gdk_device_set_motion_time (device, gdk_event_get_time (event));
 }
 
 /**


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