[gnome-settings-daemon] common: Add trackball detection



commit d1d3eaf792b500b8579eef6a2e34a4a1682e11a8
Author: Ondrej Holy <oholy redhat com>
Date:   Thu Oct 11 11:52:29 2012 +0200

    common: Add trackball detection
    
    https://bugzilla.gnome.org/show_bug.cgi?id=685941

 plugins/common/gsd-input-helper.c |   27 +++++++++++++++++++++++++++
 plugins/common/gsd-input-helper.h |    2 ++
 2 files changed, 29 insertions(+), 0 deletions(-)
---
diff --git a/plugins/common/gsd-input-helper.c b/plugins/common/gsd-input-helper.c
index 3cefa70..cbf757d 100644
--- a/plugins/common/gsd-input-helper.c
+++ b/plugins/common/gsd-input-helper.c
@@ -20,6 +20,8 @@
 
 #include "config.h"
 
+#include <string.h>
+
 #include <gdk/gdk.h>
 #include <gdk/gdkx.h>
 
@@ -194,6 +196,24 @@ device_info_is_mouse (XDeviceInfo *device_info)
         return (device_info->type == XInternAtom (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), XI_MOUSE, False));
 }
 
+gboolean
+device_info_is_trackball (XDeviceInfo *device_info)
+{
+        gboolean retval;
+
+        retval = (device_info->type == XInternAtom (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), XI_TRACKBALL, False));
+        if (retval == FALSE &&
+            device_info->name != NULL) {
+                char *lowercase;
+
+                lowercase = g_ascii_strdown (device_info->name, -1);
+                retval = strstr (lowercase, "trackball") != NULL;
+                g_free (lowercase);
+        }
+
+        return retval;
+}
+
 static gboolean
 device_type_is_present (InfoIdentifyFunc info_func,
                         DeviceIdentifyFunc device_func)
@@ -263,6 +283,13 @@ mouse_is_present (void)
                                        NULL);
 }
 
+gboolean
+trackball_is_present (void)
+{
+        return device_type_is_present (device_info_is_trackball,
+                                       NULL);
+}
+
 char *
 xdevice_get_device_node (int deviceid)
 {
diff --git a/plugins/common/gsd-input-helper.h b/plugins/common/gsd-input-helper.h
index fb898b0..f86d2a4 100644
--- a/plugins/common/gsd-input-helper.h
+++ b/plugins/common/gsd-input-helper.h
@@ -62,10 +62,12 @@ gboolean  device_is_touchpad       (XDevice                *xdevice);
 gboolean  device_info_is_touchpad    (XDeviceInfo         *device_info);
 gboolean  device_info_is_touchscreen (XDeviceInfo         *device_info);
 gboolean  device_info_is_mouse       (XDeviceInfo         *device_info);
+gboolean  device_info_is_trackball   (XDeviceInfo         *device_info);
 
 gboolean  touchpad_is_present     (void);
 gboolean  touchscreen_is_present  (void);
 gboolean  mouse_is_present        (void);
+gboolean  trackball_is_present    (void);
 
 gboolean  device_set_property     (XDevice                *xdevice,
                                    const char             *device_name,



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