summaryrefslogtreecommitdiff
path: root/Xi/xiproperty.c
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@redhat.com>2008-09-18 18:21:03 +0930
committerPeter Hutterer <peter.hutterer@redhat.com>2008-09-26 13:32:08 +0930
commita2d83b9dc8387ec7e70689db1371cf6500b2f68e (patch)
tree023558fc93239790152337b995c18e95122da413 /Xi/xiproperty.c
parent22e90472681ebc7bdd28f82bbf2753a5b259e931 (diff)
Xi: add "deletable" flag to properties, add DeleteProperty handler.
A property can only be deleted if any of the following is true: - if a property is deletable and all handlers return Success. - if a property is non-deleteable and the all handlers return Success AND the delete request does not come from a client (i.e. driver or the server). A client can never delete a non-deletable property.
Diffstat (limited to 'Xi/xiproperty.c')
-rw-r--r--Xi/xiproperty.c36
1 files changed, 35 insertions, 1 deletions
diff --git a/Xi/xiproperty.c b/Xi/xiproperty.c
index bd130d1f9..72efb67b1 100644
--- a/Xi/xiproperty.c
+++ b/Xi/xiproperty.c
@@ -98,7 +98,9 @@ XIRegisterPropertyHandler(DeviceIntPtr dev,
Atom property,
XIPropertyValuePtr prop),
int (*GetProperty) (DeviceIntPtr dev,
- Atom property))
+ Atom property),
+ int (*DeleteProperty) (DeviceIntPtr dev,
+ Atom property))
{
XIPropertyHandlerPtr new_handler;
@@ -109,6 +111,7 @@ XIRegisterPropertyHandler(DeviceIntPtr dev,
new_handler->id = XIPropHandlerID++;
new_handler->SetProperty = SetProperty;
new_handler->GetProperty = GetProperty;
+ new_handler->DeleteProperty = DeleteProperty;
new_handler->next = dev->properties.handlers;
dev->properties.handlers = new_handler;
@@ -153,6 +156,7 @@ XICreateDeviceProperty (Atom property)
prop->value.format = 0;
prop->value.size = 0;
prop->value.data = NULL;
+ prop->deletable = TRUE;
return prop;
}
@@ -218,11 +222,29 @@ XIDeleteDeviceProperty (DeviceIntPtr device, Atom property, Bool fromClient)
{
XIPropertyPtr prop, *prev;
devicePropertyNotify event;
+ int rc = Success;
for (prev = &device->properties.properties; (prop = *prev); prev = &(prop->next))
if (prop->propertyName == property)
break;
+ if (fromClient && !prop->deletable)
+ return BadAccess;
+
+ /* Ask handlers if we may delete the property */
+ if (device->properties.handlers)
+ {
+ XIPropertyHandlerPtr handler = device->properties.handlers;
+ while(handler)
+ {
+ if (handler->DeleteProperty)
+ rc = handler->DeleteProperty(device, prop->propertyName);
+ if (rc != Success)
+ return (rc);
+ handler = handler->next;
+ }
+ }
+
if (prop)
{
*prev = prop->next;
@@ -403,6 +425,18 @@ XIGetDeviceProperty (DeviceIntPtr dev, Atom property, XIPropertyValuePtr *value)
}
int
+XISetDevicePropertyDeletable(DeviceIntPtr dev, Atom property, Bool deletable)
+{
+ XIPropertyPtr prop = XIFetchDeviceProperty(dev, property);
+
+ if (!prop)
+ return BadAtom;
+
+ prop->deletable = deletable;
+ return Success;
+}
+
+int
ProcXListDeviceProperties (ClientPtr client)
{
Atom *pAtoms = NULL, *temppAtoms;