[gtk+/wip/events: 4/11] x11: Use the new event sequence to store axis values



commit ccb18ddc567b8dfd341d480a57bdcbef5fa9ddb7
Author: Benjamin Otte <otte redhat com>
Date:   Mon Mar 5 14:29:06 2012 +0100

    x11: Use the new event sequence to store axis values
    
    This way, we can put the correct number into the event.touch.axes member
    instead of random 0s when values didn't change.
    
    Somebody should do the same thing for buttons.

 gdk/x11/gdkdevicemanager-xi2.c |   20 +++++++++++++++++---
 1 files changed, 17 insertions(+), 3 deletions(-)
---
diff --git a/gdk/x11/gdkdevicemanager-xi2.c b/gdk/x11/gdkdevicemanager-xi2.c
index 2ac5682..eee1da7 100644
--- a/gdk/x11/gdkdevicemanager-xi2.c
+++ b/gdk/x11/gdkdevicemanager-xi2.c
@@ -863,6 +863,7 @@ set_user_time (GdkEvent *event)
 
 static gdouble *
 translate_axes (GdkDevice       *device,
+                gdouble         *saved_values,
                 gdouble          x,
                 gdouble          y,
                 GdkWindow       *window,
@@ -874,16 +875,22 @@ translate_axes (GdkDevice       *device,
 
   g_object_get (device, "n-axes", &n_axes, NULL);
 
-  axes = g_new0 (gdouble, n_axes);
+  axes = g_new (gdouble, n_axes);
   vals = valuators->values;
 
-  for (i = 0; i < valuators->mask_len * 8; i++)
+  for (i = 0; i < MIN (valuators->mask_len * 8, n_axes); i++)
     {
       GdkAxisUse use;
       gdouble val;
 
       if (!XIMaskIsSet (valuators->mask, i))
-        continue;
+        {
+          if (saved_values)
+            axes[i] = saved_values[i];
+          else
+            axes[i] = 0.0;
+          continue;
+        }
 
       use = gdk_device_get_axis_use (device, i);
       val = *vals++;
@@ -906,6 +913,9 @@ translate_axes (GdkDevice       *device,
           _gdk_device_translate_axis (device, i, val, &axes[i]);
           break;
         }
+
+      if (saved_values)
+        saved_values[i] = axes[i];
     }
 
   return axes;
@@ -1275,6 +1285,7 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
             gdk_event_set_source_device (event, source_device);
 
             event->button.axes = translate_axes (event->button.device,
+                                                 NULL,
                                                  event->button.x,
                                                  event->button.y,
                                                  event->button.window,
@@ -1378,6 +1389,7 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
         event->motion.is_hint = FALSE;
 
         event->motion.axes = translate_axes (event->motion.device,
+                                             NULL,
                                              event->motion.x,
                                              event->motion.y,
                                              event->motion.window,
@@ -1442,6 +1454,7 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
           }
 
         event->touch.axes = translate_axes (event->touch.device,
+                                            event->touch.sequence->axes,
                                             event->touch.x,
                                             event->touch.y,
                                             event->touch.window,
@@ -1516,6 +1529,7 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
           }
 
         event->touch.axes = translate_axes (event->touch.device,
+                                            event->touch.sequence->axes,
                                             event->touch.x,
                                             event->touch.y,
                                             event->touch.window,



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