[gtk+] x11: Don't keep two lists of devices internally



commit 7013406167f87a4410ccd504773814eb06221e08
Author: Benjamin Otte <otte redhat com>
Date:   Sun Jan 16 14:47:59 2011 +0100

    x11: Don't keep two lists of devices internally

 gdk/x11/gdkdevicemanager-xi2.c |   48 ++++++++-------------------------------
 1 files changed, 10 insertions(+), 38 deletions(-)
---
diff --git a/gdk/x11/gdkdevicemanager-xi2.c b/gdk/x11/gdkdevicemanager-xi2.c
index c7e8f85..fa04873 100644
--- a/gdk/x11/gdkdevicemanager-xi2.c
+++ b/gdk/x11/gdkdevicemanager-xi2.c
@@ -42,8 +42,7 @@ struct _GdkX11DeviceManagerXI2
 
   GHashTable *id_table;
 
-  GList *master_devices;
-  GList *slave_devices;
+  GList *devices;
 
   GdkDevice *client_pointer;
 
@@ -309,12 +308,7 @@ add_device (GdkX11DeviceManagerXI2 *device_manager,
                         GINT_TO_POINTER (dev->deviceid),
                         g_object_ref (device));
 
-  if (dev->use == XIMasterPointer || dev->use == XIMasterKeyboard)
-    device_manager->master_devices = g_list_append (device_manager->master_devices, device);
-  else if (dev->use == XISlavePointer || dev->use == XISlaveKeyboard || dev->use == XIFloatingSlave)
-    device_manager->slave_devices = g_list_append (device_manager->slave_devices, device);
-  else
-    g_warning ("Unhandled device: %s\n", gdk_device_get_name (device));
+  device_manager->devices = g_list_append (device_manager->devices, device);
 
   if (emit_signal)
     {
@@ -349,8 +343,7 @@ remove_device (GdkX11DeviceManagerXI2 *device_manager,
 
   if (device)
     {
-      device_manager->master_devices = g_list_remove (device_manager->master_devices, device);
-      device_manager->slave_devices = g_list_remove (device_manager->slave_devices, device);
+      device_manager->devices = g_list_remove (device_manager->devices, device);
 
       g_signal_emit_by_name (device_manager, "device-removed", device);
 
@@ -469,11 +462,8 @@ gdk_x11_device_manager_xi2_dispose (GObject *object)
 
   device_manager = GDK_X11_DEVICE_MANAGER_XI2 (object);
 
-  g_list_free_full (device_manager->master_devices, g_object_unref);
-  device_manager->master_devices = NULL;
-
-  g_list_free_full (device_manager->slave_devices, g_object_unref);
-  device_manager->slave_devices = NULL;
+  g_list_free_full (device_manager->devices, g_object_unref);
+  device_manager->devices = NULL;
 
   if (device_manager->id_table)
     {
@@ -489,34 +479,16 @@ gdk_x11_device_manager_xi2_list_devices (GdkDeviceManager *device_manager,
                                          GdkDeviceType     type)
 {
   GdkX11DeviceManagerXI2 *device_manager_xi2;
-  GList *list = NULL;
+  GList *cur, *list = NULL;
 
   device_manager_xi2 = GDK_X11_DEVICE_MANAGER_XI2 (device_manager);
 
-  switch (type)
+  for (cur = device_manager_xi2->devices; cur; cur = cur->next)
     {
-    case GDK_DEVICE_TYPE_MASTER:
-      list = g_list_copy (device_manager_xi2->master_devices);
-      break;
-    case GDK_DEVICE_TYPE_SLAVE:
-    case GDK_DEVICE_TYPE_FLOATING:
-      {
-        GList *devs = device_manager_xi2->slave_devices;
-
-        while (devs)
-          {
-            GdkDevice *dev;
+      GdkDevice *dev = cur->data;
 
-            dev = devs->data;
-            devs = devs->next;
-
-            if (type == gdk_device_get_device_type (dev))
-              list = g_list_prepend (list, dev);
-          }
-      }
-      break;
-    default:
-      g_assert_not_reached ();
+      if (type == gdk_device_get_device_type (dev))
+        list = g_list_prepend (list, dev);
     }
 
   return list;



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