[gtk+/gtk-3-10] x11: Unset GdkX11DeviceXI2 scroll valuators on device change



commit f4a38d30a3e08b608d4449a068599f72d6f29f56
Author: Carlos Garnacho <carlosg gnome org>
Date:   Fri Sep 27 19:32:54 2013 +0200

    x11: Unset GdkX11DeviceXI2 scroll valuators on device change
    
    Scroll valuators were being just appended again and again, leading
    to 1) a growing memory issue anytime a device changed 2) the first
    scroll valuators to stay permanent on the application lifetime, as
    the first stored valuators would always match.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=705203

 gdk/x11/gdkdevice-xi2.c        |    8 ++++++++
 gdk/x11/gdkdevicemanager-xi2.c |    1 +
 gdk/x11/gdkprivate-x11.h       |    2 ++
 3 files changed, 11 insertions(+), 0 deletions(-)
---
diff --git a/gdk/x11/gdkdevice-xi2.c b/gdk/x11/gdkdevice-xi2.c
index 8245fe4..b3289c0 100644
--- a/gdk/x11/gdkdevice-xi2.c
+++ b/gdk/x11/gdkdevice-xi2.c
@@ -876,6 +876,14 @@ _gdk_device_xi2_reset_scroll_valuators (GdkX11DeviceXI2 *device)
     }
 }
 
+void
+_gdk_device_xi2_unset_scroll_valuators (GdkX11DeviceXI2 *device)
+{
+  if (device->scroll_valuators->len > 0)
+    g_array_remove_range (device->scroll_valuators, 0,
+                          device->scroll_valuators->len);
+}
+
 gint
 _gdk_x11_device_xi2_get_id (GdkX11DeviceXI2 *device)
 {
diff --git a/gdk/x11/gdkdevicemanager-xi2.c b/gdk/x11/gdkdevicemanager-xi2.c
index 3481d29..0f20d58 100644
--- a/gdk/x11/gdkdevicemanager-xi2.c
+++ b/gdk/x11/gdkdevicemanager-xi2.c
@@ -765,6 +765,7 @@ handle_device_changed (GdkX11DeviceManagerXI2 *device_manager,
   if (device)
     {
       _gdk_device_reset_axes (device);
+      _gdk_device_xi2_unset_scroll_valuators ((GdkX11DeviceXI2 *) device);
       translate_device_classes (display, device, ev->classes, ev->num_classes);
 
       g_signal_emit_by_name (G_OBJECT (device), "changed");
diff --git a/gdk/x11/gdkprivate-x11.h b/gdk/x11/gdkprivate-x11.h
index 543c42d..fcd6da4 100644
--- a/gdk/x11/gdkprivate-x11.h
+++ b/gdk/x11/gdkprivate-x11.h
@@ -231,6 +231,8 @@ guint    _gdk_x11_device_xi2_translate_state      (XIModifierState *mods_state,
                                                    XIButtonState   *buttons_state,
                                                    XIGroupState    *group_state);
 gint     _gdk_x11_device_xi2_get_id               (GdkX11DeviceXI2 *device);
+void     _gdk_device_xi2_unset_scroll_valuators   (GdkX11DeviceXI2 *device);
+
 
 GdkDevice * _gdk_x11_device_manager_xi2_lookup    (GdkX11DeviceManagerXI2 *device_manager_xi2,
                                                    gint                    device_id);


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