[gnome-settings-daemon] common: Add code to allow disabling input devices



commit 0e9b63ed1e029a086de35844ab06c7ba0f9cdff1
Author: Bastien Nocera <hadess hadess net>
Date:   Thu Jun 2 15:35:13 2011 +0100

    common: Add code to allow disabling input devices

 plugins/common/gsd-input-helper.c |   35 +++++++++++++++++++++++++++++------
 plugins/common/gsd-input-helper.h |    2 ++
 2 files changed, 31 insertions(+), 6 deletions(-)
---
diff --git a/plugins/common/gsd-input-helper.c b/plugins/common/gsd-input-helper.c
index bbe711f..e01c522 100644
--- a/plugins/common/gsd-input-helper.c
+++ b/plugins/common/gsd-input-helper.c
@@ -228,12 +228,12 @@ touchpad_is_present (void)
 static char *
 get_device_node (int deviceid)
 {
-        Atom prop;
-        Atom                act_type;
-        int                 act_format;
-        unsigned long       nitems, bytes_after;
-        unsigned char       *data;
-        char *ret;
+        Atom           prop;
+        Atom           act_type;
+        int            act_format;
+        unsigned long  nitems, bytes_after;
+        unsigned char *data;
+        char          *ret;
 
         gdk_display_sync (gdk_display_get_default ());
 
@@ -340,6 +340,29 @@ accelerometer_is_present (char **device_node,
         return retval;
 }
 
+gboolean
+set_device_enabled (int device_id,
+                    gboolean enabled)
+{
+        Atom prop;
+        guchar value;
+
+        prop = XInternAtom (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), "Device Enabled", False);
+        if (!prop)
+                return FALSE;
+
+        gdk_error_trap_push ();
+
+        value = enabled;
+        XIChangeProperty (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
+                          device_id, prop, XA_INTEGER, 8, PropModeReplace, &value, 1);
+
+        if (gdk_error_trap_pop ())
+                return FALSE;
+
+        return TRUE;
+}
+
 static const char *
 custom_command_to_string (CustomCommand command)
 {
diff --git a/plugins/common/gsd-input-helper.h b/plugins/common/gsd-input-helper.h
index 51eaed1..d5a9329 100644
--- a/plugins/common/gsd-input-helper.h
+++ b/plugins/common/gsd-input-helper.h
@@ -53,6 +53,8 @@ gboolean  supports_xinput2_devices (void);
 
 gboolean accelerometer_is_present (char **device_node,
                                    int   *device_id);
+gboolean set_device_enabled       (int device_id,
+                                   gboolean enabled);
 
 gboolean  device_is_touchpad       (XDevice                *xdevice);
 



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