Xi: allow Set/GetProperties to return a status, and honour this status code.
If a property handler now bails out, return the error code to the caller. This allows to be slightly more specific with the errors.
This commit is contained in:
parent
1e24e7b9df
commit
22e9047268
|
@ -94,11 +94,11 @@ XIInitKnownProperties(void)
|
||||||
*/
|
*/
|
||||||
long
|
long
|
||||||
XIRegisterPropertyHandler(DeviceIntPtr dev,
|
XIRegisterPropertyHandler(DeviceIntPtr dev,
|
||||||
Bool (*SetProperty) (DeviceIntPtr dev,
|
int (*SetProperty) (DeviceIntPtr dev,
|
||||||
Atom property,
|
Atom property,
|
||||||
XIPropertyValuePtr prop),
|
XIPropertyValuePtr prop),
|
||||||
Bool (*GetProperty) (DeviceIntPtr dev,
|
int (*GetProperty) (DeviceIntPtr dev,
|
||||||
Atom property))
|
Atom property))
|
||||||
{
|
{
|
||||||
XIPropertyHandlerPtr new_handler;
|
XIPropertyHandlerPtr new_handler;
|
||||||
|
|
||||||
|
@ -252,6 +252,7 @@ XIChangeDeviceProperty (DeviceIntPtr dev, Atom property, Atom type,
|
||||||
XIPropertyValuePtr prop_value;
|
XIPropertyValuePtr prop_value;
|
||||||
XIPropertyValueRec new_value;
|
XIPropertyValueRec new_value;
|
||||||
Bool add = FALSE;
|
Bool add = FALSE;
|
||||||
|
int rc;
|
||||||
|
|
||||||
size_in_bytes = format >> 3;
|
size_in_bytes = format >> 3;
|
||||||
|
|
||||||
|
@ -325,12 +326,16 @@ XIChangeDeviceProperty (DeviceIntPtr dev, Atom property, Atom type,
|
||||||
XIPropertyHandlerPtr handler = dev->properties.handlers;
|
XIPropertyHandlerPtr handler = dev->properties.handlers;
|
||||||
while(handler)
|
while(handler)
|
||||||
{
|
{
|
||||||
if (handler->SetProperty &&
|
if (handler->SetProperty)
|
||||||
!handler->SetProperty(dev, prop->propertyName, &new_value))
|
|
||||||
{
|
{
|
||||||
if (new_value.data)
|
rc = handler->SetProperty(dev, prop->propertyName,
|
||||||
xfree (new_value.data);
|
&new_value);
|
||||||
return (BadValue);
|
if (rc != Success)
|
||||||
|
{
|
||||||
|
if (new_value.data)
|
||||||
|
xfree (new_value.data);
|
||||||
|
return (rc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
handler = handler->next;
|
handler = handler->next;
|
||||||
}
|
}
|
||||||
|
@ -349,7 +354,6 @@ XIChangeDeviceProperty (DeviceIntPtr dev, Atom property, Atom type,
|
||||||
dev->properties.properties = prop;
|
dev->properties.properties = prop;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (sendevent)
|
if (sendevent)
|
||||||
{
|
{
|
||||||
event.type = DevicePropertyNotify;
|
event.type = DevicePropertyNotify;
|
||||||
|
@ -363,16 +367,17 @@ XIChangeDeviceProperty (DeviceIntPtr dev, Atom property, Atom type,
|
||||||
return(Success);
|
return(Success);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
int
|
||||||
*
|
XIGetDeviceProperty (DeviceIntPtr dev, Atom property, XIPropertyValuePtr *value)
|
||||||
*/
|
|
||||||
_X_EXPORT XIPropertyValuePtr
|
|
||||||
XIGetDeviceProperty (DeviceIntPtr dev, Atom property)
|
|
||||||
{
|
{
|
||||||
XIPropertyPtr prop = XIFetchDeviceProperty (dev, property);
|
XIPropertyPtr prop = XIFetchDeviceProperty (dev, property);
|
||||||
|
int rc;
|
||||||
|
|
||||||
if (!prop)
|
if (!prop)
|
||||||
return NULL;
|
{
|
||||||
|
*value = NULL;
|
||||||
|
return BadAtom;
|
||||||
|
}
|
||||||
|
|
||||||
/* If we can, try to update the property value first */
|
/* If we can, try to update the property value first */
|
||||||
if (dev->properties.handlers)
|
if (dev->properties.handlers)
|
||||||
|
@ -381,11 +386,20 @@ XIGetDeviceProperty (DeviceIntPtr dev, Atom property)
|
||||||
while(handler)
|
while(handler)
|
||||||
{
|
{
|
||||||
if (handler->GetProperty)
|
if (handler->GetProperty)
|
||||||
handler->GetProperty(dev, prop->propertyName);
|
{
|
||||||
|
rc = handler->GetProperty(dev, prop->propertyName);
|
||||||
|
if (rc != Success)
|
||||||
|
{
|
||||||
|
*value = NULL;
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
}
|
||||||
handler = handler->next;
|
handler = handler->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return &prop->value;
|
|
||||||
|
*value = &prop->value;
|
||||||
|
return Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -489,6 +503,8 @@ ProcXChangeDeviceProperty (ClientPtr client)
|
||||||
stuff->type, (int)format,
|
stuff->type, (int)format,
|
||||||
(int)mode, len, (pointer)&stuff[1], TRUE);
|
(int)mode, len, (pointer)&stuff[1], TRUE);
|
||||||
|
|
||||||
|
if (rc != Success)
|
||||||
|
client->errorValue = stuff->property;
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -570,9 +586,12 @@ ProcXGetDeviceProperty (ClientPtr client)
|
||||||
return(client->noClientException);
|
return(client->noClientException);
|
||||||
}
|
}
|
||||||
|
|
||||||
prop_value = XIGetDeviceProperty(dev, stuff->property);
|
rc = XIGetDeviceProperty(dev, stuff->property, &prop_value);
|
||||||
if (!prop_value)
|
if (rc != Success)
|
||||||
return BadAtom;
|
{
|
||||||
|
client->errorValue = stuff->property;
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
/* If the request type and actual type don't match. Return the
|
/* If the request type and actual type don't match. Return the
|
||||||
property information, but not the data. */
|
property information, but not the data. */
|
||||||
|
|
|
@ -101,22 +101,21 @@ DevPrivateKey UnusedClassesPrivateKey = &UnusedClassesPrivateKeyIndex;
|
||||||
/**
|
/**
|
||||||
* DIX property handler.
|
* DIX property handler.
|
||||||
*/
|
*/
|
||||||
static Bool
|
static int
|
||||||
DeviceSetProperty(DeviceIntPtr dev, Atom property, XIPropertyValuePtr prop)
|
DeviceSetProperty(DeviceIntPtr dev, Atom property, XIPropertyValuePtr prop)
|
||||||
{
|
{
|
||||||
if (property == XIGetKnownProperty(XI_PROP_ENABLED))
|
if (property == XIGetKnownProperty(XI_PROP_ENABLED))
|
||||||
{
|
{
|
||||||
if (prop->format != 8 || prop->type != XA_INTEGER || prop->size != 1)
|
if (prop->format != 8 || prop->type != XA_INTEGER || prop->size != 1)
|
||||||
return FALSE;
|
return BadValue;
|
||||||
|
|
||||||
if ((*((CARD8*)prop->data)) && !dev->enabled)
|
if ((*((CARD8*)prop->data)) && !dev->enabled)
|
||||||
EnableDevice(dev);
|
EnableDevice(dev);
|
||||||
else if (!(*((CARD8*)prop->data)) && dev->enabled)
|
else if (!(*((CARD8*)prop->data)) && dev->enabled)
|
||||||
DisableDevice(dev);
|
DisableDevice(dev);
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -216,19 +216,19 @@ extern int XIChangeDeviceProperty(
|
||||||
Bool /* sendevent*/
|
Bool /* sendevent*/
|
||||||
);
|
);
|
||||||
|
|
||||||
extern XIPropertyValuePtr XIGetDeviceProperty(
|
extern int XIGetDeviceProperty(
|
||||||
DeviceIntPtr /* dev */,
|
DeviceIntPtr /* dev */,
|
||||||
Atom /* property */
|
Atom /* property */,
|
||||||
|
XIPropertyValuePtr* /* value */
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
extern long XIRegisterPropertyHandler(
|
extern long XIRegisterPropertyHandler(
|
||||||
DeviceIntPtr dev,
|
DeviceIntPtr dev,
|
||||||
Bool (*SetProperty) (DeviceIntPtr dev,
|
int (*SetProperty) (DeviceIntPtr dev,
|
||||||
Atom property,
|
Atom property,
|
||||||
XIPropertyValuePtr prop),
|
XIPropertyValuePtr prop),
|
||||||
Bool (*GetProperty) (DeviceIntPtr dev,
|
int (*GetProperty) (DeviceIntPtr dev,
|
||||||
Atom property)
|
Atom property)
|
||||||
);
|
);
|
||||||
|
|
||||||
extern void XIUnRegisterPropertyHandler(
|
extern void XIUnRegisterPropertyHandler(
|
||||||
|
|
|
@ -364,11 +364,11 @@ typedef struct _XIPropertyHandler
|
||||||
{
|
{
|
||||||
struct _XIPropertyHandler* next;
|
struct _XIPropertyHandler* next;
|
||||||
long id;
|
long id;
|
||||||
Bool (*SetProperty) (DeviceIntPtr dev,
|
int (*SetProperty) (DeviceIntPtr dev,
|
||||||
Atom property,
|
Atom property,
|
||||||
XIPropertyValuePtr prop);
|
XIPropertyValuePtr prop);
|
||||||
Bool (*GetProperty) (DeviceIntPtr dev,
|
int (*GetProperty) (DeviceIntPtr dev,
|
||||||
Atom property);
|
Atom property);
|
||||||
} XIPropertyHandler, *XIPropertyHandlerPtr;
|
} XIPropertyHandler, *XIPropertyHandlerPtr;
|
||||||
|
|
||||||
/* states for devices */
|
/* states for devices */
|
||||||
|
|
Loading…
Reference in New Issue