From: Peter Hutterer <[EMAIL PROTECTED]>
Add "delete" parameter to SetProperty handler, handlers can refuse to delete a
property by returning something other than Success.
---
Xi/xiproperty.c| 20 ++--
dix/devices.c |6 +-
include/exevents.h |3 ++-
include/inputstr.h |3 ++-
4 files changed, 27 insertions(+), 5 deletions(-)
diff --git a/Xi/xiproperty.c b/Xi/xiproperty.c
index bd130d1..50a4caf 100644
--- a/Xi/xiproperty.c
+++ b/Xi/xiproperty.c
@@ -96,7 +96,8 @@ long
XIRegisterPropertyHandler(DeviceIntPtr dev,
int (*SetProperty) (DeviceIntPtr dev,
Atom property,
- XIPropertyValuePtr prop),
+ XIPropertyValuePtr prop,
+ BOOL delete),
int (*GetProperty) (DeviceIntPtr dev,
Atom property))
{
@@ -218,11 +219,26 @@ XIDeleteDeviceProperty (DeviceIntPtr device, Atom
property, Bool fromClient)
{
XIPropertyPtr prop, *prev;
devicePropertyNotifyevent;
+int rc;
for (prev = &device->properties.properties; (prop = *prev); prev =
&(prop->next))
if (prop->propertyName == property)
break;
+/* Ask handlers if we may delete the property */
+if (fromClient && device->properties.handlers)
+{
+XIPropertyHandlerPtr handler = device->properties.handlers;
+while(handler)
+{
+rc = handler->SetProperty(device, prop->propertyName,
+ &prop->value, TRUE);
+if (rc != Success)
+return (rc);
+handler = handler->next;
+}
+}
+
if (prop)
{
*prev = prop->next;
@@ -329,7 +345,7 @@ XIChangeDeviceProperty (DeviceIntPtr dev, Atom property,
Atom type,
if (handler->SetProperty)
{
rc = handler->SetProperty(dev, prop->propertyName,
- &new_value);
+ &new_value, FALSE);
if (rc != Success)
{
if (new_value.data)
diff --git a/dix/devices.c b/dix/devices.c
index fb63473..c0ff019 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -102,10 +102,14 @@ DevPrivateKey UnusedClassesPrivateKey =
&UnusedClassesPrivateKeyIndex;
* DIX property handler.
*/
static int
-DeviceSetProperty(DeviceIntPtr dev, Atom property, XIPropertyValuePtr prop)
+DeviceSetProperty(DeviceIntPtr dev, Atom property, XIPropertyValuePtr prop,
+ BOOL delete)
{
if (property == XIGetKnownProperty(XI_PROP_ENABLED))
{
+if (delete) /* you're not allowed to delete any server-internal prop */
+return BadAccess;
+
if (prop->format != 8 || prop->type != XA_INTEGER || prop->size != 1)
return BadValue;
diff --git a/include/exevents.h b/include/exevents.h
index c3a2ad6..b22d433 100644
--- a/include/exevents.h
+++ b/include/exevents.h
@@ -226,7 +226,8 @@ extern long XIRegisterPropertyHandler(
DeviceIntPtr dev,
int (*SetProperty) (DeviceIntPtr dev,
Atom property,
-XIPropertyValuePtr prop),
+XIPropertyValuePtr prop,
+BOOL delete),
int (*GetProperty) (DeviceIntPtr dev,
Atom property)
);
diff --git a/include/inputstr.h b/include/inputstr.h
index 93b3293..0a8bf91 100644
--- a/include/inputstr.h
+++ b/include/inputstr.h
@@ -366,7 +366,8 @@ typedef struct _XIPropertyHandler
long id;
int (*SetProperty) (DeviceIntPtr dev,
Atom property,
-XIPropertyValuePtr prop);
+XIPropertyValuePtr prop,
+BOOL delete);
int (*GetProperty) (DeviceIntPtr dev,
Atom property);
} XIPropertyHandler, *XIPropertyHandlerPtr;
--
1.5.4.3
___
xorg mailing list
xorg@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/xorg