[PATCH] dix: introduce "Xtst Device" label property.

Peter Hutterer peter.hutterer at who-t.net
Mon Jun 22 23:06:49 PDT 2009


Xtst devices get this property assigned automatically so they can be
detected easily by a client.
The property is read-only.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 Xi/xiproperty.c              |    1 +
 dix/devices.c                |   25 +++++++++++++++++++++++++
 include/xserver-properties.h |    2 ++
 3 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/Xi/xiproperty.c b/Xi/xiproperty.c
index cd49460..7ee0e69 100644
--- a/Xi/xiproperty.c
+++ b/Xi/xiproperty.c
@@ -51,6 +51,7 @@ static struct dev_properties
     char *name;
 } dev_properties[] = {
     {0, XI_PROP_ENABLED},
+    {0, XI_PROP_XTST_DEVICE},
     {0, XATOM_FLOAT},
     {0, ACCEL_PROP_PROFILE_NUMBER},
     {0, ACCEL_PROP_CONSTANT_DECELERATION},
diff --git a/dix/devices.c b/dix/devices.c
index b7f2192..a99d046 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -2563,6 +2563,19 @@ AllocDevicePair (ClientPtr client, char* name,
 }
 
 /**
+ * Don't allow changing the Xtst property.
+ */
+static int
+DeviceSetXtstProperty(DeviceIntPtr dev, Atom property,
+                      XIPropertyValuePtr prop, BOOL checkonly)
+{
+    if (property == XIGetKnownProperty(XI_PROP_XTST_DEVICE))
+        return BadAccess;
+
+    return Success;
+}
+
+/**
  * Allocate a device pair that is initialised as a slave
  * device with properties that identify the devices as belonging
  * to XTest subsystem.
@@ -2576,6 +2589,7 @@ int AllocXtstDevice (ClientPtr client, char* name,
     int retval;
     int len = strlen(name);
     char *xtstname = xcalloc(len + 6, 1 );
+    char dummy = 1;
 
     strncpy( xtstname, name, len);
     strncat( xtstname, " Xtst", 5 );
@@ -2588,6 +2602,17 @@ int AllocXtstDevice (ClientPtr client, char* name,
 
     xfree( xtstname );
 
+    XIChangeDeviceProperty(*ptr, XIGetKnownProperty(XI_PROP_XTST_DEVICE),
+                           XA_INTEGER, 8, PropModeReplace, 1, &dummy,
+                           FALSE);
+    XISetDevicePropertyDeletable(*ptr, XIGetKnownProperty(XI_PROP_XTST_DEVICE), FALSE);
+    XIRegisterPropertyHandler(*ptr, DeviceSetXtstProperty, NULL, NULL);
+    XIChangeDeviceProperty(*keybd, XIGetKnownProperty(XI_PROP_XTST_DEVICE),
+                           XA_INTEGER, 8, PropModeReplace, 1, &dummy,
+                           FALSE);
+    XISetDevicePropertyDeletable(*keybd, XIGetKnownProperty(XI_PROP_XTST_DEVICE), FALSE);
+    XIRegisterPropertyHandler(*keybd, DeviceSetXtstProperty, NULL, NULL);
+
     return retval;
 }
 
diff --git a/include/xserver-properties.h b/include/xserver-properties.h
index 9b3b7bf..0f18dbc 100644
--- a/include/xserver-properties.h
+++ b/include/xserver-properties.h
@@ -32,6 +32,8 @@
 
 /* BOOL. 0 - device disabled, 1 - device enabled */
 #define XI_PROP_ENABLED      "Device Enabled"
+/* BOOL. If present, device is a virtual Xtst device */
+#define XI_PROP_XTST_DEVICE  "Xtst Device"
 
 /* Pointer acceleration properties */
 /* INTEGER of any format */
-- 
1.6.3.rc1.2.g0164.dirty

Cheers,
  Peter


More information about the xorg-devel mailing list