From e13605ea40cfc671314a0086c75b917564298b55 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 23 Jun 2009 14:09:22 +1000 Subject: [PATCH] dix: introduce "Xtst Device" label property. 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 --- Xi/xiproperty.c | 1 + dix/devices.c | 25 +++++++++++++++++++++++++ include/xserver-properties.h | 2 ++ 3 files changed, 28 insertions(+) diff --git a/Xi/xiproperty.c b/Xi/xiproperty.c index 396061f80..55f20c402 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 b7f21927f..a99d046a5 100644 --- a/dix/devices.c +++ b/dix/devices.c @@ -2562,6 +2562,19 @@ AllocDevicePair (ClientPtr client, char* name, return Success; } +/** + * 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 @@ -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 9b3b7bf8d..0f18dbc45 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 */