[gtk+/xi2] GdkDeviceManagerXI: Fill in the missing GdkDevice properties.



commit ac0f4f40f97342051149be52f4f8b1c6007dbd95
Author: Carlos Garnacho <carlos gnome org>
Date:   Fri Oct 2 18:43:07 2009 +0200

    GdkDeviceManagerXI: Fill in the missing GdkDevice properties.

 gdk/x11/gdkdevicemanager-xi.c |   31 ++++++++++++++++++++++++++-----
 1 files changed, 26 insertions(+), 5 deletions(-)
---
diff --git a/gdk/x11/gdkdevicemanager-xi.c b/gdk/x11/gdkdevicemanager-xi.c
index cd588be..5911ebd 100644
--- a/gdk/x11/gdkdevicemanager-xi.c
+++ b/gdk/x11/gdkdevicemanager-xi.c
@@ -215,21 +215,42 @@ translate_class_info (GdkDevice   *device,
 }
 
 static GdkDevice *
-create_device (GdkDisplay  *display,
-               XDeviceInfo *info)
+create_device (GdkDeviceManager *device_manager,
+               GdkDisplay       *display,
+               XDeviceInfo      *info)
 {
+  GdkInputSource input_source;
   GdkDevice *device;
+  gchar *tmp_name;
 
   if (info->use != IsXExtensionPointer &&
       info->use != IsXExtensionKeyboard)
     return NULL;
 
+  tmp_name = g_ascii_strdown (info->name, -1);
+
+  if (g_str_has_suffix (tmp_name, "pointer"))
+    input_source = GDK_SOURCE_MOUSE;
+  else if (strcmp (tmp_name, "wacom") == 0 ||
+           strcmp (tmp_name, "pen") == 0)
+    input_source = GDK_SOURCE_PEN;
+  else if (strcmp (tmp_name, "eraser") == 0)
+    input_source = GDK_SOURCE_ERASER;
+  else if (strcmp (tmp_name, "cursor") == 0)
+    input_source = GDK_SOURCE_CURSOR;
+  else
+    input_source = GDK_SOURCE_PEN;
+
+  g_free (tmp_name);
+
   device = g_object_new (GDK_TYPE_DEVICE_XI,
                          "name", info->name,
-                         "input-source", GDK_SOURCE_MOUSE,
+                         "type", GDK_DEVICE_TYPE_FLOATING,
+                         "input-source", input_source,
                          "input-mode", GDK_MODE_DISABLED,
                          "has-cursor", FALSE,
                          "display", display,
+                         "device-manager", device_manager,
                          "device-id", info->id,
                          NULL);
   translate_class_info (device, info);
@@ -253,8 +274,8 @@ gdk_device_manager_xi_constructed (GObject *object)
     {
       GdkDevice *device;
 
-      device = create_device (display, &devices[i]);
-
+      device = create_device (GDK_DEVICE_MANAGER (object),
+                              display, &devices[i]);
       if (device)
         {
           priv->devices = g_list_prepend (priv->devices, device);



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