[gnome-settings-daemon/wip/settings-relocation: 7/10] common: Add xdevice_is_libinput()



commit 03ffc6c86d9f06e4340b265bd0c037029d0c2dca
Author: Carlos Garnacho <carlosg gnome org>
Date:   Wed Dec 17 14:54:22 2014 +0100

    common: Add xdevice_is_libinput()
    
    This function pokes a libinput-driver-specific property, and can be used to
    find out whether a device uses the libinput driver or not.
    
    This will be used to determine whether a device is to be managed by mutter,
    or by g-s-d itself.

 plugins/common/gsd-input-helper.c |   24 ++++++++++++++++++++++++
 plugins/common/gsd-input-helper.h |    3 +++
 2 files changed, 27 insertions(+), 0 deletions(-)
---
diff --git a/plugins/common/gsd-input-helper.c b/plugins/common/gsd-input-helper.c
index 4872506..d3cf40c 100644
--- a/plugins/common/gsd-input-helper.c
+++ b/plugins/common/gsd-input-helper.c
@@ -675,3 +675,27 @@ xdevice_get_dimensions (int    deviceid,
 
         return (w != 0 && h != 0);
 }
+
+gboolean
+xdevice_is_libinput (gint deviceid)
+{
+        GdkDisplay *display = gdk_display_get_default ();
+        gulong nitems, bytes_after;
+        gint rc, format;
+        guchar *data;
+        Atom type;
+
+        gdk_error_trap_push ();
+
+        /* Lookup a libinput driver specific property */
+        rc = XIGetProperty (GDK_DISPLAY_XDISPLAY (display), deviceid,
+                            gdk_x11_get_xatom_by_name ("libinput Send Events Mode Enabled"),
+                            0, 1, False, XA_INTEGER, &type, &format, &nitems, &bytes_after, &data);
+
+        if (rc == Success)
+                XFree (data);
+
+        gdk_error_trap_pop_ignored ();
+
+        return rc == Success && nitems > 0;
+}
diff --git a/plugins/common/gsd-input-helper.h b/plugins/common/gsd-input-helper.h
index 85e8492..f7f568e 100644
--- a/plugins/common/gsd-input-helper.h
+++ b/plugins/common/gsd-input-helper.h
@@ -87,6 +87,9 @@ void      xdevice_close      (XDevice                *xdevice);
 
 const char * xdevice_get_wacom_tool_type (int               deviceid);
 
+gboolean  xdevice_is_libinput (gint deviceid);
+
+
 G_END_DECLS
 
 #endif /* __GSD_INPUT_HELPER_H */


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