[gnome-settings-daemon] common: Add helper to list disabled devices
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon] common: Add helper to list disabled devices
- Date: Tue, 6 Sep 2011 19:17:19 +0000 (UTC)
commit 3dc1f72b297bfedf39cdb1c0e11f0b8df8269737
Author: Bastien Nocera <hadess hadess net>
Date: Tue Sep 6 20:09:25 2011 +0100
common: Add helper to list disabled devices
plugins/common/gsd-input-helper.c | 36 +++++++++++++++++++++++++++++++++++-
plugins/common/gsd-input-helper.h | 2 ++
plugins/common/test-input-helper.c | 24 ++++++++++++++++++++++++
3 files changed, 61 insertions(+), 1 deletions(-)
---
diff --git a/plugins/common/gsd-input-helper.c b/plugins/common/gsd-input-helper.c
index 2d82722..a2a0451 100644
--- a/plugins/common/gsd-input-helper.c
+++ b/plugins/common/gsd-input-helper.c
@@ -238,7 +238,7 @@ set_device_enabled (int device_id,
gdk_error_trap_push ();
- value = enabled;
+ value = enabled ? 1 : 0;
XIChangeProperty (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
device_id, prop, XA_INTEGER, 8, PropModeReplace, &value, 1);
@@ -320,3 +320,37 @@ run_custom_command (GdkDevice *device,
return (exit_status == 0);
}
+
+GList *
+get_disabled_devices (GdkDeviceManager *manager)
+{
+ XDeviceInfo *device_info;
+ gint n_devices;
+ guint i;
+ GList *ret;
+
+ ret = NULL;
+
+ device_info = XListInputDevices (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), &n_devices);
+ if (device_info == NULL)
+ return ret;
+
+ for (i = 0; i < n_devices; i++) {
+ GdkDevice *device;
+
+ /* Ignore core devices */
+ if (device_info[i].use == IsXKeyboard ||
+ device_info[i].use == IsXPointer)
+ continue;
+
+ /* Check whether the device is actually available */
+ device = gdk_x11_device_manager_lookup (manager, device_info[i].id);
+ g_message ("checking whether we have a device for %d: %s", device_info[i].id, device ? "yes" : "no");
+ if (device != NULL)
+ continue;
+
+ ret = g_list_prepend (ret, GINT_TO_POINTER (device_info[i].id));
+ }
+
+ return ret;
+}
diff --git a/plugins/common/gsd-input-helper.h b/plugins/common/gsd-input-helper.h
index 736c452..48bc249 100644
--- a/plugins/common/gsd-input-helper.h
+++ b/plugins/common/gsd-input-helper.h
@@ -69,6 +69,8 @@ gboolean device_set_property (XDevice *xdevice,
gboolean run_custom_command (GdkDevice *device,
CustomCommand command);
+GList * get_disabled_devices (GdkDeviceManager *manager);
+
G_END_DECLS
#endif /* __GSD_INPUT_HELPER_H */
diff --git a/plugins/common/test-input-helper.c b/plugins/common/test-input-helper.c
index 500c624..bbdd30b 100644
--- a/plugins/common/test-input-helper.c
+++ b/plugins/common/test-input-helper.c
@@ -29,6 +29,28 @@
#include "gsd-input-helper.h"
+static void
+print_disabled_devices (void)
+{
+ GList *devices, *l;
+ GdkDeviceManager *manager;
+
+ manager = gdk_display_get_device_manager (gdk_display_get_default ());
+
+ devices = get_disabled_devices (manager);
+ g_print ("Disabled devices:\t\t\t");
+ if (devices == NULL) {
+ g_print ("no\n");
+ return;
+ }
+
+ for (l = devices; l != NULL; l = l->next) {
+ g_print ("%d ", GPOINTER_TO_INT (l->data));
+ }
+ g_list_free (devices);
+ g_print ("\n");
+}
+
int main (int argc, char **argv)
{
gboolean supports_xinput;
@@ -66,6 +88,8 @@ int main (int argc, char **argv)
return 1;
}
+ print_disabled_devices ();
+
for (i = 0; i < n_devices; i++) {
XDevice *device;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]