[gnome-control-center/wip/garnacho/wayland-tablet: 8/31] common: Add generic API to map GdkDevices and GsdDevices



commit ffc7fa535b614238fe9ff4632e475e9574685bc0
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon Jun 6 14:06:57 2016 +0200

    common: Add generic API to map GdkDevices and GsdDevices
    
    Now that we have tablet support in wayland, we can kind of honor
    that in the places we're interested.

 panels/common/gsd-device-manager.c |   32 ++++++++++++++++++++++++++++++++
 panels/common/gsd-device-manager.h |   12 ++++++++----
 2 files changed, 40 insertions(+), 4 deletions(-)
---
diff --git a/panels/common/gsd-device-manager.c b/panels/common/gsd-device-manager.c
index 1737bf3..cd09bd9 100644
--- a/panels/common/gsd-device-manager.c
+++ b/panels/common/gsd-device-manager.c
@@ -415,3 +415,35 @@ gsd_device_get_dimensions (GsdDevice *device,
 
        return priv->width > 0 && priv->height > 0;
 }
+
+GList *
+gsd_device_get_gdk_devices (GsdDeviceManager *manager,
+                           GsdDevice        *device)
+{
+       GsdDeviceManagerClass *klass;
+
+       g_return_val_if_fail (GSD_IS_DEVICE_MANAGER (manager), NULL);
+       g_return_val_if_fail (GSD_IS_DEVICE (device), NULL);
+
+       klass = GSD_DEVICE_MANAGER_GET_CLASS (manager);
+       if (!klass->inverse_lookup)
+               return NULL;
+
+       return klass->inverse_lookup (manager, device);
+}
+
+GsdDevice *
+gsd_device_manager_lookup_gdk_device (GsdDeviceManager *manager,
+                                     GdkDevice        *gdk_device)
+{
+       GsdDeviceManagerClass *klass;
+
+       g_return_val_if_fail (GSD_IS_DEVICE_MANAGER (manager), NULL);
+       g_return_val_if_fail (GDK_IS_DEVICE (gdk_device), NULL);
+
+       klass = GSD_DEVICE_MANAGER_GET_CLASS (manager);
+       if (!klass->lookup_device)
+               return NULL;
+
+       return klass->lookup_device (manager, gdk_device);
+}
diff --git a/panels/common/gsd-device-manager.h b/panels/common/gsd-device-manager.h
index baf46a8..8b02c04 100644
--- a/panels/common/gsd-device-manager.h
+++ b/panels/common/gsd-device-manager.h
@@ -20,6 +20,7 @@
 #ifndef __GSD_DEVICE_MANAGER_H__
 #define __GSD_DEVICE_MANAGER_H__
 
+#include <gdk/gdk.h>
 #include <glib-object.h>
 #include <gio/gio.h>
 
@@ -78,6 +79,11 @@ struct _GsdDeviceManagerClass
                                 GsdDevice        *device);
        void (* device_changed) (GsdDeviceManager *manager,
                                 GsdDevice        *device);
+
+       GsdDevice * (* lookup_device) (GsdDeviceManager *manager,
+                                      GdkDevice        *gdk_device);
+       GList     * (*inverse_lookup) (GsdDeviceManager *manager,
+                                      GsdDevice        *device);
 };
 
 GType             gsd_device_get_type                (void) G_GNUC_CONST;
@@ -98,12 +104,10 @@ gboolean      gsd_device_get_dimensions  (GsdDevice  *device,
                                               guint      *width,
                                               guint      *height);
 
-#ifdef GDK_WINDOWING_X11
-GdkDevice **      gsd_device_get_gdk_devices (GsdDevice *device,
-                                              guint     *n_gdk_devices);
+GList    *        gsd_device_get_gdk_devices (GsdDeviceManager *manager,
+                                              GsdDevice        *device);
 GsdDevice *       gsd_device_manager_lookup_gdk_device (GsdDeviceManager *manager,
                                                         GdkDevice        *gdk_device);
-#endif
 
 G_END_DECLS
 


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