[gtk+] quartz: re-introduce _gdk_quartz_display_list_devices



commit b638515ae00fac29c3a448553be04ca62c399c5e
Author: Kristian Rietveld <kris gtk org>
Date:   Wed Dec 22 16:05:12 2010 +0100

    quartz: re-introduce _gdk_quartz_display_list_devices

 gdk/quartz/gdkdisplay-quartz.c |   70 +++++++++++++++++++++++++++++++++++++++-
 gdk/quartz/gdkprivate-quartz.h |    1 -
 2 files changed, 69 insertions(+), 2 deletions(-)
---
diff --git a/gdk/quartz/gdkdisplay-quartz.c b/gdk/quartz/gdkdisplay-quartz.c
index 1b60f37..fed8c79 100644
--- a/gdk/quartz/gdkdisplay-quartz.c
+++ b/gdk/quartz/gdkdisplay-quartz.c
@@ -44,6 +44,56 @@ _gdk_device_manager_new (GdkDisplay *display)
                        NULL);
 }
 
+static void
+gdk_quartz_display_init_input (GdkDisplay *display)
+{
+  GdkQuartzDisplay *display_quartz;
+  GdkDeviceManager *device_manager;
+  GList *list, *l;
+
+  display_quartz = GDK_QUARTZ_DISPLAY (display);
+  device_manager = gdk_display_get_device_manager (_gdk_display);
+
+  /* For backwards compabitility, just add floating devices that are
+   * not keyboards.
+   */
+  list = gdk_device_manager_list_devices (device_manager,
+                                          GDK_DEVICE_TYPE_FLOATING);
+  for (l = list; l; l = l->next)
+    {
+      GdkDevice *device = l->data;
+
+      if (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
+        continue;
+
+      display_quartz->input_devices = g_list_prepend (display_quartz->input_devices,
+                                                      g_object_ref (l->data));
+    }
+
+  g_list_free (list);
+
+  /* Now set "core" pointer to the first master device that is a pointer. */
+  list = gdk_device_manager_list_devices (device_manager,
+                                          GDK_DEVICE_TYPE_MASTER);
+
+  for (l = list; l; l = l->next)
+    {
+      GdkDevice *device = list->data;
+
+      if (gdk_device_get_source (device) != GDK_SOURCE_MOUSE)
+        continue;
+
+      display->core_pointer = device;
+      break;
+    }
+
+  /* Add the core pointer to the devices list */
+  display_quartz->input_devices = g_list_prepend (display_quartz->input_devices,
+                                                  g_object_ref (display->core_pointer));
+
+  g_list_free (list);
+}
+
 GdkDisplay *
 _gdk_quartz_display_open (const gchar *display_name)
 {
@@ -64,7 +114,7 @@ _gdk_quartz_display_open (const gchar *display_name)
 
   _gdk_quartz_events_init ();
 
-  _gdk_quartz_input_init ();
+  gdk_quartz_display_init_input (_gdk_display);
 
 #if 0
   /* FIXME: Remove the #if 0 when we have these functions */
@@ -181,6 +231,14 @@ gdk_quartz_display_supports_composite (GdkDisplay *display)
   return FALSE;
 }
 
+static GList *
+_gdk_quartz_display_list_devices (GdkDisplay *display)
+{
+  g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
+
+  return GDK_QUARTZ_DISPLAY (display)->input_devices;
+}
+
 gulong
 _gdk_quartz_display_get_next_serial (GdkDisplay *display)
 {
@@ -199,15 +257,25 @@ _gdk_quartz_display_init (GdkQuartzDisplay *display)
 static void
 _gdk_quartz_display_dispose (GObject *object)
 {
+  GdkQuartzDisplay *display_quartz = GDK_QUARTZ_DISPLAY (object);
+
   _gdk_quartz_display_manager_remove_display (gdk_display_manager_get (),
                                               GDK_DISPLAY_OBJECT (object));
 
+  g_list_foreach (display_quartz->input_devices,
+                  (GFunc) g_object_run_dispose, NULL);
+
   G_OBJECT_CLASS (_gdk_quartz_display_parent_class)->dispose (object);
 }
 
 static void
 _gdk_quartz_display_finalize (GObject *object)
 {
+  GdkQuartzDisplay *display_quartz = GDK_QUARTZ_DISPLAY (object);
+
+  g_list_foreach (display_quartz->input_devices, (GFunc) g_object_unref, NULL);
+  g_list_free (display_quartz->input_devices);
+
   G_OBJECT_CLASS (_gdk_quartz_display_parent_class)->finalize (object);
 }
 
diff --git a/gdk/quartz/gdkprivate-quartz.h b/gdk/quartz/gdkprivate-quartz.h
index 378cf1e..958d79e 100644
--- a/gdk/quartz/gdkprivate-quartz.h
+++ b/gdk/quartz/gdkprivate-quartz.h
@@ -129,7 +129,6 @@ GdkDragContext * _gdk_quartz_window_drag_begin   (GdkWindow   *window,
 
 void     _gdk_quartz_display_sync         (GdkDisplay *display);
 void     _gdk_quartz_display_flush        (GdkDisplay *display);
-GList *  _gdk_quartz_display_list_devices (GdkDisplay *display);
 void     _gdk_quartz_display_queue_events (GdkDisplay *display);
 gboolean _gdk_quartz_display_has_pending  (GdkDisplay *display);
 



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