[gtk+/xi2: 1114/1239] GdkDevice: Add some compatibility for device->axes.



commit 3f06d80dd56c6186b7bcebd4d5b4655f59cd10eb
Author: Carlos Garnacho <carlos gnome org>
Date:   Fri Sep 11 17:22:37 2009 +0200

    GdkDevice: Add some compatibility for device->axes.
    
    Actual data is stored in the private data, so device->axes is filled in
    in case some application is peeping at the struct directly.

 gdk/gdkdevice.c |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)
---
diff --git a/gdk/gdkdevice.c b/gdk/gdkdevice.c
index 5106e52..f0c3d18 100644
--- a/gdk/gdkdevice.c
+++ b/gdk/gdkdevice.c
@@ -558,6 +558,11 @@ _gdk_device_reset_axes (GdkDevice *device)
 
   for (i = priv->axes->len - 1; i >= 0; i--)
     g_array_remove_index (priv->axes, i);
+
+  g_object_notify (G_OBJECT (device), "n-axes");
+
+  /* This is done for backwards compatibility */
+  g_free (device->axes);
 }
 
 guint
@@ -570,6 +575,7 @@ _gdk_device_add_axis (GdkDevice   *device,
 {
   GdkDevicePrivate *priv;
   GdkAxisInfo axis_info;
+  guint pos;
 
   priv = GDK_DEVICE_GET_PRIVATE (device);
 
@@ -599,10 +605,19 @@ _gdk_device_add_axis (GdkDevice   *device,
 
   priv->axes = g_array_append_val (priv->axes, axis_info);
   device->num_axes = priv->axes->len;
+  pos = device->num_axes - 1;
+
+  /* This is done for backwards compatibility, since the public
+   * struct doesn't actually store the device data.
+   */
+  device->axes = g_realloc (device->axes, sizeof (GdkDeviceAxis) * priv->axes->len);
+  device->axes[pos].use = axis_info.use;
+  device->axes[pos].min = axis_info.min_axis;
+  device->axes[pos].max = axis_info.max_axis;
 
   g_object_notify (G_OBJECT (device), "n-axes");
 
-  return priv->axes->len - 1;
+  return pos;
 }
 
 GdkAxisInfo *



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