2009-09-06 13:44:18 -06:00
|
|
|
/*
|
|
|
|
* Copyright © 2006 Keith Packard
|
|
|
|
* Copyright © 2008 Peter Hutterer
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
* Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WAXIANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WAXIANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
* DEALINGS IN THE SOFTWARE.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* This code is a modified version of randr/rrproperty.c */
|
|
|
|
|
|
|
|
#ifdef HAVE_DIX_CONFIG_H
|
|
|
|
#include <dix-config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "dix.h"
|
|
|
|
#include "inputstr.h"
|
|
|
|
#include <X11/extensions/XI.h>
|
|
|
|
#include <X11/Xatom.h>
|
|
|
|
#include <X11/extensions/XIproto.h>
|
2010-07-27 13:02:24 -06:00
|
|
|
#include <X11/extensions/XI2proto.h>
|
2009-09-06 13:44:18 -06:00
|
|
|
#include "exglobals.h"
|
|
|
|
#include "exevents.h"
|
|
|
|
#include "swaprep.h"
|
|
|
|
|
|
|
|
#include "xiproperty.h"
|
|
|
|
#include "xserver-properties.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Properties used or alloced from inside the server.
|
|
|
|
*/
|
2012-06-10 07:21:05 -06:00
|
|
|
static struct dev_properties {
|
2009-09-06 13:44:18 -06:00
|
|
|
Atom type;
|
2012-06-10 07:21:05 -06:00
|
|
|
const char *name;
|
2009-09-06 13:44:18 -06:00
|
|
|
} dev_properties[] = {
|
2013-06-07 11:28:45 -06:00
|
|
|
{0, XI_PROP_ENABLED},
|
|
|
|
{0, XI_PROP_XTEST_DEVICE},
|
|
|
|
{0, XATOM_FLOAT},
|
|
|
|
{0, ACCEL_PROP_PROFILE_NUMBER},
|
|
|
|
{0, ACCEL_PROP_CONSTANT_DECELERATION},
|
|
|
|
{0, ACCEL_PROP_ADAPTIVE_DECELERATION},
|
|
|
|
{0, ACCEL_PROP_VELOCITY_SCALING},
|
|
|
|
{0, AXIS_LABEL_PROP},
|
|
|
|
{0, AXIS_LABEL_PROP_REL_X},
|
|
|
|
{0, AXIS_LABEL_PROP_REL_Y},
|
|
|
|
{0, AXIS_LABEL_PROP_REL_Z},
|
|
|
|
{0, AXIS_LABEL_PROP_REL_RX},
|
|
|
|
{0, AXIS_LABEL_PROP_REL_RY},
|
|
|
|
{0, AXIS_LABEL_PROP_REL_RZ},
|
|
|
|
{0, AXIS_LABEL_PROP_REL_HWHEEL},
|
|
|
|
{0, AXIS_LABEL_PROP_REL_DIAL},
|
|
|
|
{0, AXIS_LABEL_PROP_REL_WHEEL},
|
|
|
|
{0, AXIS_LABEL_PROP_REL_MISC},
|
|
|
|
{0, AXIS_LABEL_PROP_REL_VSCROLL},
|
|
|
|
{0, AXIS_LABEL_PROP_REL_HSCROLL},
|
|
|
|
{0, AXIS_LABEL_PROP_ABS_X},
|
|
|
|
{0, AXIS_LABEL_PROP_ABS_Y},
|
|
|
|
{0, AXIS_LABEL_PROP_ABS_Z},
|
|
|
|
{0, AXIS_LABEL_PROP_ABS_RX},
|
|
|
|
{0, AXIS_LABEL_PROP_ABS_RY},
|
|
|
|
{0, AXIS_LABEL_PROP_ABS_RZ},
|
|
|
|
{0, AXIS_LABEL_PROP_ABS_THROTTLE},
|
|
|
|
{0, AXIS_LABEL_PROP_ABS_RUDDER},
|
|
|
|
{0, AXIS_LABEL_PROP_ABS_WHEEL},
|
|
|
|
{0, AXIS_LABEL_PROP_ABS_GAS},
|
|
|
|
{0, AXIS_LABEL_PROP_ABS_BRAKE},
|
|
|
|
{0, AXIS_LABEL_PROP_ABS_HAT0X},
|
|
|
|
{0, AXIS_LABEL_PROP_ABS_HAT0Y},
|
|
|
|
{0, AXIS_LABEL_PROP_ABS_HAT1X},
|
|
|
|
{0, AXIS_LABEL_PROP_ABS_HAT1Y},
|
|
|
|
{0, AXIS_LABEL_PROP_ABS_HAT2X},
|
|
|
|
{0, AXIS_LABEL_PROP_ABS_HAT2Y},
|
|
|
|
{0, AXIS_LABEL_PROP_ABS_HAT3X},
|
|
|
|
{0, AXIS_LABEL_PROP_ABS_HAT3Y},
|
|
|
|
{0, AXIS_LABEL_PROP_ABS_PRESSURE},
|
|
|
|
{0, AXIS_LABEL_PROP_ABS_DISTANCE},
|
|
|
|
{0, AXIS_LABEL_PROP_ABS_TILT_X},
|
|
|
|
{0, AXIS_LABEL_PROP_ABS_TILT_Y},
|
|
|
|
{0, AXIS_LABEL_PROP_ABS_TOOL_WIDTH},
|
|
|
|
{0, AXIS_LABEL_PROP_ABS_VOLUME},
|
|
|
|
{0, AXIS_LABEL_PROP_ABS_MT_TOUCH_MAJOR},
|
|
|
|
{0, AXIS_LABEL_PROP_ABS_MT_TOUCH_MINOR},
|
|
|
|
{0, AXIS_LABEL_PROP_ABS_MT_WIDTH_MAJOR},
|
|
|
|
{0, AXIS_LABEL_PROP_ABS_MT_WIDTH_MINOR},
|
|
|
|
{0, AXIS_LABEL_PROP_ABS_MT_ORIENTATION},
|
|
|
|
{0, AXIS_LABEL_PROP_ABS_MT_POSITION_X},
|
|
|
|
{0, AXIS_LABEL_PROP_ABS_MT_POSITION_Y},
|
|
|
|
{0, AXIS_LABEL_PROP_ABS_MT_TOOL_TYPE},
|
|
|
|
{0, AXIS_LABEL_PROP_ABS_MT_BLOB_ID},
|
|
|
|
{0, AXIS_LABEL_PROP_ABS_MT_TRACKING_ID},
|
|
|
|
{0, AXIS_LABEL_PROP_ABS_MT_PRESSURE},
|
|
|
|
{0, AXIS_LABEL_PROP_ABS_MT_DISTANCE},
|
|
|
|
{0, AXIS_LABEL_PROP_ABS_MT_TOOL_X},
|
|
|
|
{0, AXIS_LABEL_PROP_ABS_MT_TOOL_Y},
|
|
|
|
{0, AXIS_LABEL_PROP_ABS_MISC},
|
|
|
|
{0, BTN_LABEL_PROP},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_UNKNOWN},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_WHEEL_UP},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_WHEEL_DOWN},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_HWHEEL_LEFT},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_HWHEEL_RIGHT},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_0},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_1},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_2},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_3},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_4},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_5},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_6},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_7},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_8},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_9},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_LEFT},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_RIGHT},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_MIDDLE},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_SIDE},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_EXTRA},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_FORWARD},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_BACK},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_TASK},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_TRIGGER},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_THUMB},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_THUMB2},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_TOP},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_TOP2},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_PINKIE},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_BASE},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_BASE2},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_BASE3},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_BASE4},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_BASE5},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_BASE6},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_DEAD},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_A},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_B},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_C},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_X},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_Y},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_Z},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_TL},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_TR},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_TL2},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_TR2},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_SELECT},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_START},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_MODE},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_THUMBL},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_THUMBR},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_TOOL_PEN},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_TOOL_RUBBER},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_TOOL_BRUSH},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_TOOL_PENCIL},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_TOOL_AIRBRUSH},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_TOOL_FINGER},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_TOOL_MOUSE},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_TOOL_LENS},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_TOUCH},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_STYLUS},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_STYLUS2},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_TOOL_DOUBLETAP},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_TOOL_TRIPLETAP},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_GEAR_DOWN},
|
|
|
|
{0, BTN_LABEL_PROP_BTN_GEAR_UP},
|
|
|
|
{0, XI_PROP_TRANSFORM}
|
2009-09-06 13:44:18 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
static long XIPropHandlerID = 1;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
|
|
|
send_property_event(DeviceIntPtr dev, Atom property, int what)
|
2010-07-27 13:02:24 -06:00
|
|
|
{
|
2013-06-07 11:28:45 -06:00
|
|
|
int state = (what == XIPropertyDeleted) ? PropertyDelete : PropertyNewValue;
|
|
|
|
devicePropertyNotify event = {
|
|
|
|
.type = DevicePropertyNotify,
|
|
|
|
.deviceid = dev->id,
|
|
|
|
.state = state,
|
|
|
|
.atom = property,
|
|
|
|
.time = currentTime.milliseconds
|
|
|
|
};
|
|
|
|
xXIPropertyEvent xi2 = {
|
|
|
|
.type = GenericEvent,
|
|
|
|
.extension = IReqCode,
|
|
|
|
.length = 0,
|
|
|
|
.evtype = XI_PropertyEvent,
|
|
|
|
.deviceid = dev->id,
|
|
|
|
.time = currentTime.milliseconds,
|
|
|
|
.property = property,
|
|
|
|
.what = what
|
|
|
|
};
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
SendEventToAllWindows(dev, DevicePropertyNotifyMask, (xEvent *) &event, 1);
|
|
|
|
|
|
|
|
SendEventToAllWindows(dev, GetEventFilter(dev, (xEvent *) &xi2),
|
|
|
|
(xEvent *) &xi2, 1);
|
2010-07-27 13:02:24 -06:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static int
|
|
|
|
list_atoms(DeviceIntPtr dev, int *natoms, Atom **atoms_return)
|
2010-07-27 13:02:24 -06:00
|
|
|
{
|
|
|
|
XIPropertyPtr prop;
|
2012-06-10 07:21:05 -06:00
|
|
|
Atom *atoms = NULL;
|
|
|
|
int nprops = 0;
|
2010-07-27 13:02:24 -06:00
|
|
|
|
|
|
|
for (prop = dev->properties.properties; prop; prop = prop->next)
|
|
|
|
nprops++;
|
2012-06-10 07:21:05 -06:00
|
|
|
if (nprops) {
|
2010-07-27 13:02:24 -06:00
|
|
|
Atom *a;
|
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
atoms = xallocarray(nprops, sizeof(Atom));
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!atoms)
|
2010-07-27 13:02:24 -06:00
|
|
|
return BadAlloc;
|
|
|
|
a = atoms;
|
|
|
|
for (prop = dev->properties.properties; prop; prop = prop->next, a++)
|
|
|
|
*a = prop->propertyName;
|
|
|
|
}
|
|
|
|
|
|
|
|
*natoms = nprops;
|
|
|
|
*atoms_return = atoms;
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
get_property(ClientPtr client, DeviceIntPtr dev, Atom property, Atom type,
|
|
|
|
BOOL delete, int offset, int length,
|
|
|
|
int *bytes_after, Atom *type_return, int *format, int *nitems,
|
|
|
|
int *length_return, char **data)
|
|
|
|
{
|
|
|
|
unsigned long n, len, ind;
|
|
|
|
int rc;
|
|
|
|
XIPropertyPtr prop;
|
|
|
|
XIPropertyValuePtr prop_value;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!ValidAtom(property)) {
|
2010-07-27 13:02:24 -06:00
|
|
|
client->errorValue = property;
|
2010-12-05 08:36:02 -07:00
|
|
|
return BadAtom;
|
2010-07-27 13:02:24 -06:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((delete != xTrue) && (delete != xFalse)) {
|
2010-07-27 13:02:24 -06:00
|
|
|
client->errorValue = delete;
|
2010-12-05 08:36:02 -07:00
|
|
|
return BadValue;
|
2010-07-27 13:02:24 -06:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((type != AnyPropertyType) && !ValidAtom(type)) {
|
2010-07-27 13:02:24 -06:00
|
|
|
client->errorValue = type;
|
2010-12-05 08:36:02 -07:00
|
|
|
return BadAtom;
|
2010-07-27 13:02:24 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
for (prop = dev->properties.properties; prop; prop = prop->next)
|
|
|
|
if (prop->propertyName == property)
|
|
|
|
break;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!prop) {
|
2010-07-27 13:02:24 -06:00
|
|
|
*bytes_after = 0;
|
|
|
|
*type_return = None;
|
|
|
|
*format = 0;
|
|
|
|
*nitems = 0;
|
|
|
|
*length_return = 0;
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
rc = XIGetDeviceProperty(dev, property, &prop_value);
|
2012-06-10 07:21:05 -06:00
|
|
|
if (rc != Success) {
|
2010-07-27 13:02:24 -06:00
|
|
|
client->errorValue = property;
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If the request type and actual type don't match. Return the
|
2012-06-10 07:21:05 -06:00
|
|
|
property information, but not the data. */
|
2010-07-27 13:02:24 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (((type != prop_value->type) && (type != AnyPropertyType))) {
|
2010-07-27 13:02:24 -06:00
|
|
|
*bytes_after = prop_value->size;
|
|
|
|
*format = prop_value->format;
|
|
|
|
*length_return = 0;
|
|
|
|
*nitems = 0;
|
|
|
|
*type_return = prop_value->type;
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Return type, format, value to client */
|
2012-06-10 07:21:05 -06:00
|
|
|
n = (prop_value->format / 8) * prop_value->size; /* size (bytes) of prop */
|
2010-07-27 13:02:24 -06:00
|
|
|
ind = offset << 2;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/* If offset is invalid such that it causes "len" to
|
|
|
|
be negative, it's a value error. */
|
2010-07-27 13:02:24 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (n < ind) {
|
2010-07-27 13:02:24 -06:00
|
|
|
client->errorValue = offset;
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
len = min(n - ind, 4 * length);
|
|
|
|
|
|
|
|
*bytes_after = n - (ind + len);
|
|
|
|
*format = prop_value->format;
|
|
|
|
*length_return = len;
|
|
|
|
if (prop_value->format)
|
|
|
|
*nitems = len / (prop_value->format / 8);
|
|
|
|
else
|
|
|
|
*nitems = 0;
|
|
|
|
*type_return = prop_value->type;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
*data = (char *) prop_value->data + ind;
|
2010-07-27 13:02:24 -06:00
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
check_change_property(ClientPtr client, Atom property, Atom type, int format,
|
|
|
|
int mode, int nitems)
|
|
|
|
{
|
|
|
|
if ((mode != PropModeReplace) && (mode != PropModeAppend) &&
|
2012-06-10 07:21:05 -06:00
|
|
|
(mode != PropModePrepend)) {
|
2010-07-27 13:02:24 -06:00
|
|
|
client->errorValue = mode;
|
|
|
|
return BadValue;
|
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((format != 8) && (format != 16) && (format != 32)) {
|
2010-07-27 13:02:24 -06:00
|
|
|
client->errorValue = format;
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!ValidAtom(property)) {
|
2010-07-27 13:02:24 -06:00
|
|
|
client->errorValue = property;
|
2010-12-05 08:36:02 -07:00
|
|
|
return BadAtom;
|
2010-07-27 13:02:24 -06:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!ValidAtom(type)) {
|
2010-07-27 13:02:24 -06:00
|
|
|
client->errorValue = type;
|
2010-12-05 08:36:02 -07:00
|
|
|
return BadAtom;
|
2010-07-27 13:02:24 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
change_property(ClientPtr client, DeviceIntPtr dev, Atom property, Atom type,
|
|
|
|
int format, int mode, int len, void *data)
|
|
|
|
{
|
|
|
|
int rc = Success;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
rc = XIChangeDeviceProperty(dev, property, type, format, mode, len, data,
|
|
|
|
TRUE);
|
2010-07-27 13:02:24 -06:00
|
|
|
if (rc != Success)
|
|
|
|
client->errorValue = property;
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
/**
|
2010-07-27 13:02:24 -06:00
|
|
|
* Return the atom assigned to the specified string or 0 if the atom isn't known
|
2009-09-06 13:44:18 -06:00
|
|
|
* to the DIX.
|
|
|
|
*
|
|
|
|
* If name is NULL, None is returned.
|
|
|
|
*/
|
2010-07-27 13:02:24 -06:00
|
|
|
Atom
|
2012-06-10 07:21:05 -06:00
|
|
|
XIGetKnownProperty(const char *name)
|
2009-09-06 13:44:18 -06:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (!name)
|
|
|
|
return None;
|
|
|
|
|
2019-07-27 01:57:06 -06:00
|
|
|
for (i = 0; i < ARRAY_SIZE(dev_properties); i++) {
|
2012-06-10 07:21:05 -06:00
|
|
|
if (strcmp(name, dev_properties[i].name) == 0) {
|
|
|
|
if (dev_properties[i].type == None) {
|
|
|
|
dev_properties[i].type =
|
|
|
|
MakeAtom(dev_properties[i].name,
|
|
|
|
strlen(dev_properties[i].name), TRUE);
|
2010-07-27 13:02:24 -06:00
|
|
|
}
|
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
return dev_properties[i].type;
|
2010-07-27 13:02:24 -06:00
|
|
|
}
|
2009-09-06 13:44:18 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
void
|
|
|
|
XIResetProperties(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2019-07-27 01:57:06 -06:00
|
|
|
for (i = 0; i < ARRAY_SIZE(dev_properties); i++)
|
2010-07-27 13:02:24 -06:00
|
|
|
dev_properties[i].type = None;
|
|
|
|
}
|
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
/**
|
|
|
|
* Convert the given property's value(s) into @nelem_return integer values and
|
|
|
|
* store them in @buf_return. If @nelem_return is larger than the number of
|
|
|
|
* values in the property, @nelem_return is set to the number of values in the
|
|
|
|
* property.
|
|
|
|
*
|
|
|
|
* If *@buf_return is NULL and @nelem_return is 0, memory is allocated
|
|
|
|
* automatically and must be freed by the caller.
|
|
|
|
*
|
|
|
|
* Possible return codes.
|
|
|
|
* Success ... No error.
|
|
|
|
* BadMatch ... Wrong atom type, atom is not XA_INTEGER
|
|
|
|
* BadAlloc ... NULL passed as buffer and allocation failed.
|
|
|
|
* BadLength ... @buff is NULL but @nelem_return is non-zero.
|
|
|
|
*
|
|
|
|
* @param val The property value
|
|
|
|
* @param nelem_return The maximum number of elements to return.
|
|
|
|
* @param buf_return Pointer to an array of at least @nelem_return values.
|
|
|
|
* @return Success or the error code if an error occured.
|
|
|
|
*/
|
|
|
|
_X_EXPORT int
|
|
|
|
XIPropToInt(XIPropertyValuePtr val, int *nelem_return, int **buf_return)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int *buf;
|
|
|
|
|
|
|
|
if (val->type != XA_INTEGER)
|
|
|
|
return BadMatch;
|
|
|
|
if (!*buf_return && *nelem_return)
|
|
|
|
return BadLength;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
switch (val->format) {
|
|
|
|
case 8:
|
|
|
|
case 16:
|
|
|
|
case 32:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return BadValue;
|
2009-09-06 13:44:18 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
buf = *buf_return;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!buf && !(*nelem_return)) {
|
2010-12-05 08:36:02 -07:00
|
|
|
buf = calloc(val->size, sizeof(int));
|
2009-09-06 13:44:18 -06:00
|
|
|
if (!buf)
|
|
|
|
return BadAlloc;
|
|
|
|
*buf_return = buf;
|
|
|
|
*nelem_return = val->size;
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
|
|
|
else if (val->size < *nelem_return)
|
2009-09-06 13:44:18 -06:00
|
|
|
*nelem_return = val->size;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
for (i = 0; i < val->size && i < *nelem_return; i++) {
|
|
|
|
switch (val->format) {
|
|
|
|
case 8:
|
|
|
|
buf[i] = ((CARD8 *) val->data)[i];
|
|
|
|
break;
|
|
|
|
case 16:
|
|
|
|
buf[i] = ((CARD16 *) val->data)[i];
|
|
|
|
break;
|
|
|
|
case 32:
|
|
|
|
buf[i] = ((CARD32 *) val->data)[i];
|
|
|
|
break;
|
2009-09-06 13:44:18 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convert the given property's value(s) into @nelem_return float values and
|
|
|
|
* store them in @buf_return. If @nelem_return is larger than the number of
|
|
|
|
* values in the property, @nelem_return is set to the number of values in the
|
|
|
|
* property.
|
|
|
|
*
|
|
|
|
* If *@buf_return is NULL and @nelem_return is 0, memory is allocated
|
|
|
|
* automatically and must be freed by the caller.
|
|
|
|
*
|
|
|
|
* Possible errors returned:
|
|
|
|
* Success
|
|
|
|
* BadMatch ... Wrong atom type, atom is not XA_FLOAT
|
|
|
|
* BadValue ... Wrong format, format is not 32
|
|
|
|
* BadAlloc ... NULL passed as buffer and allocation failed.
|
|
|
|
* BadLength ... @buff is NULL but @nelem_return is non-zero.
|
|
|
|
*
|
|
|
|
* @param val The property value
|
|
|
|
* @param nelem_return The maximum number of elements to return.
|
|
|
|
* @param buf_return Pointer to an array of at least @nelem_return values.
|
|
|
|
* @return Success or the error code if an error occured.
|
|
|
|
*/
|
|
|
|
_X_EXPORT int
|
|
|
|
XIPropToFloat(XIPropertyValuePtr val, int *nelem_return, float **buf_return)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
float *buf;
|
|
|
|
|
|
|
|
if (!val->type || val->type != XIGetKnownProperty(XATOM_FLOAT))
|
|
|
|
return BadMatch;
|
|
|
|
|
|
|
|
if (val->format != 32)
|
|
|
|
return BadValue;
|
|
|
|
if (!*buf_return && *nelem_return)
|
|
|
|
return BadLength;
|
|
|
|
|
|
|
|
buf = *buf_return;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!buf && !(*nelem_return)) {
|
2010-12-05 08:36:02 -07:00
|
|
|
buf = calloc(val->size, sizeof(float));
|
2009-09-06 13:44:18 -06:00
|
|
|
if (!buf)
|
|
|
|
return BadAlloc;
|
|
|
|
*buf_return = buf;
|
|
|
|
*nelem_return = val->size;
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
|
|
|
else if (val->size < *nelem_return)
|
2009-09-06 13:44:18 -06:00
|
|
|
*nelem_return = val->size;
|
|
|
|
|
|
|
|
for (i = 0; i < val->size && i < *nelem_return; i++)
|
2012-06-10 07:21:05 -06:00
|
|
|
buf[i] = ((float *) val->data)[i];
|
2009-09-06 13:44:18 -06:00
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Registers a new property handler on the given device and returns a unique
|
|
|
|
* identifier for this handler. This identifier is required to unregister the
|
|
|
|
* property handler again.
|
|
|
|
* @return The handler's identifier or 0 if an error occured.
|
|
|
|
*/
|
|
|
|
long
|
2012-06-10 07:21:05 -06:00
|
|
|
XIRegisterPropertyHandler(DeviceIntPtr dev,
|
2009-09-06 13:44:18 -06:00
|
|
|
int (*SetProperty) (DeviceIntPtr dev,
|
|
|
|
Atom property,
|
|
|
|
XIPropertyValuePtr prop,
|
|
|
|
BOOL checkonly),
|
|
|
|
int (*GetProperty) (DeviceIntPtr dev,
|
|
|
|
Atom property),
|
|
|
|
int (*DeleteProperty) (DeviceIntPtr dev,
|
|
|
|
Atom property))
|
|
|
|
{
|
|
|
|
XIPropertyHandlerPtr new_handler;
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
new_handler = calloc(1, sizeof(XIPropertyHandler));
|
2009-09-06 13:44:18 -06:00
|
|
|
if (!new_handler)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
return new_handler->id;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
XIUnregisterPropertyHandler(DeviceIntPtr dev, long id)
|
|
|
|
{
|
|
|
|
XIPropertyHandlerPtr curr, prev = NULL;
|
|
|
|
|
|
|
|
curr = dev->properties.handlers;
|
2012-06-10 07:21:05 -06:00
|
|
|
while (curr && curr->id != id) {
|
2009-09-06 13:44:18 -06:00
|
|
|
prev = curr;
|
|
|
|
curr = curr->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!curr)
|
|
|
|
return;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!prev) /* first one */
|
2009-09-06 13:44:18 -06:00
|
|
|
dev->properties.handlers = curr->next;
|
|
|
|
else
|
|
|
|
prev->next = curr->next;
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
free(curr);
|
2009-09-06 13:44:18 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static XIPropertyPtr
|
2012-06-10 07:21:05 -06:00
|
|
|
XICreateDeviceProperty(Atom property)
|
2009-09-06 13:44:18 -06:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
XIPropertyPtr prop;
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
prop = (XIPropertyPtr) malloc(sizeof(XIPropertyRec));
|
2009-09-06 13:44:18 -06:00
|
|
|
if (!prop)
|
|
|
|
return NULL;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
prop->next = NULL;
|
|
|
|
prop->propertyName = property;
|
|
|
|
prop->value.type = None;
|
2009-09-06 13:44:18 -06:00
|
|
|
prop->value.format = 0;
|
2012-06-10 07:21:05 -06:00
|
|
|
prop->value.size = 0;
|
|
|
|
prop->value.data = NULL;
|
|
|
|
prop->deletable = TRUE;
|
2009-09-06 13:44:18 -06:00
|
|
|
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
|
|
|
static XIPropertyPtr
|
|
|
|
XIFetchDeviceProperty(DeviceIntPtr dev, Atom property)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
XIPropertyPtr prop;
|
2009-09-06 13:44:18 -06:00
|
|
|
|
|
|
|
for (prop = dev->properties.properties; prop; prop = prop->next)
|
|
|
|
if (prop->propertyName == property)
|
|
|
|
return prop;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
XIDestroyDeviceProperty(XIPropertyPtr prop)
|
2009-09-06 13:44:18 -06:00
|
|
|
{
|
2010-12-05 08:36:02 -07:00
|
|
|
free(prop->value.data);
|
|
|
|
free(prop);
|
2009-09-06 13:44:18 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/* This function destroys all of the device's property-related stuff,
|
|
|
|
* including removing all device handlers.
|
|
|
|
* DO NOT CALL FROM THE DRIVER.
|
|
|
|
*/
|
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
XIDeleteAllDeviceProperties(DeviceIntPtr device)
|
2009-09-06 13:44:18 -06:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
XIPropertyPtr prop, next;
|
|
|
|
XIPropertyHandlerPtr curr_handler, next_handler;
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2017-12-08 08:01:59 -07:00
|
|
|
UpdateCurrentTimeIf();
|
2012-06-10 07:21:05 -06:00
|
|
|
for (prop = device->properties.properties; prop; prop = next) {
|
2009-09-06 13:44:18 -06:00
|
|
|
next = prop->next;
|
2010-07-27 13:02:24 -06:00
|
|
|
send_property_event(device, prop->propertyName, XIPropertyDeleted);
|
2009-09-06 13:44:18 -06:00
|
|
|
XIDestroyDeviceProperty(prop);
|
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
device->properties.properties = NULL;
|
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
/* Now free all handlers */
|
|
|
|
curr_handler = device->properties.handlers;
|
2012-06-10 07:21:05 -06:00
|
|
|
while (curr_handler) {
|
2009-09-06 13:44:18 -06:00
|
|
|
next_handler = curr_handler->next;
|
2010-12-05 08:36:02 -07:00
|
|
|
free(curr_handler);
|
2009-09-06 13:44:18 -06:00
|
|
|
curr_handler = next_handler;
|
|
|
|
}
|
2010-07-27 13:02:24 -06:00
|
|
|
|
|
|
|
device->properties.handlers = NULL;
|
2009-09-06 13:44:18 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2012-06-10 07:21:05 -06:00
|
|
|
XIDeleteDeviceProperty(DeviceIntPtr device, Atom property, Bool fromClient)
|
2009-09-06 13:44:18 -06:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
XIPropertyPtr prop, *prev;
|
|
|
|
int rc = Success;
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
for (prev = &device->properties.properties; (prop = *prev);
|
|
|
|
prev = &(prop->next))
|
2009-09-06 13:44:18 -06:00
|
|
|
if (prop->propertyName == property)
|
|
|
|
break;
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
if (!prop)
|
|
|
|
return Success;
|
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
if (fromClient && !prop->deletable)
|
|
|
|
return BadAccess;
|
|
|
|
|
|
|
|
/* Ask handlers if we may delete the property */
|
2012-06-10 07:21:05 -06:00
|
|
|
if (device->properties.handlers) {
|
2009-09-06 13:44:18 -06:00
|
|
|
XIPropertyHandlerPtr handler = device->properties.handlers;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
while (handler) {
|
2009-09-06 13:44:18 -06:00
|
|
|
if (handler->DeleteProperty)
|
|
|
|
rc = handler->DeleteProperty(device, prop->propertyName);
|
|
|
|
if (rc != Success)
|
2010-12-05 08:36:02 -07:00
|
|
|
return rc;
|
2009-09-06 13:44:18 -06:00
|
|
|
handler = handler->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (prop) {
|
2017-12-08 08:01:59 -07:00
|
|
|
UpdateCurrentTimeIf();
|
2009-09-06 13:44:18 -06:00
|
|
|
*prev = prop->next;
|
2010-07-27 13:02:24 -06:00
|
|
|
send_property_event(device, prop->propertyName, XIPropertyDeleted);
|
2012-06-10 07:21:05 -06:00
|
|
|
XIDestroyDeviceProperty(prop);
|
2009-09-06 13:44:18 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2012-06-10 07:21:05 -06:00
|
|
|
XIChangeDeviceProperty(DeviceIntPtr dev, Atom property, Atom type,
|
|
|
|
int format, int mode, unsigned long len,
|
|
|
|
const void *value, Bool sendevent)
|
2009-09-06 13:44:18 -06:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
XIPropertyPtr prop;
|
|
|
|
int size_in_bytes;
|
|
|
|
unsigned long total_len;
|
|
|
|
XIPropertyValuePtr prop_value;
|
|
|
|
XIPropertyValueRec new_value;
|
|
|
|
Bool add = FALSE;
|
|
|
|
int rc;
|
2009-09-06 13:44:18 -06:00
|
|
|
|
|
|
|
size_in_bytes = format >> 3;
|
|
|
|
|
|
|
|
/* first see if property already exists */
|
2012-06-10 07:21:05 -06:00
|
|
|
prop = XIFetchDeviceProperty(dev, property);
|
|
|
|
if (!prop) { /* just add to list */
|
|
|
|
prop = XICreateDeviceProperty(property);
|
2009-09-06 13:44:18 -06:00
|
|
|
if (!prop)
|
2010-12-05 08:36:02 -07:00
|
|
|
return BadAlloc;
|
2009-09-06 13:44:18 -06:00
|
|
|
add = TRUE;
|
|
|
|
mode = PropModeReplace;
|
|
|
|
}
|
|
|
|
prop_value = &prop->value;
|
|
|
|
|
|
|
|
/* To append or prepend to a property the request format and type
|
2012-06-10 07:21:05 -06:00
|
|
|
must match those of the already defined property. The
|
|
|
|
existing format and type are irrelevant when using the mode
|
|
|
|
"PropModeReplace" since they will be written over. */
|
2009-09-06 13:44:18 -06:00
|
|
|
|
|
|
|
if ((format != prop_value->format) && (mode != PropModeReplace))
|
2010-12-05 08:36:02 -07:00
|
|
|
return BadMatch;
|
2009-09-06 13:44:18 -06:00
|
|
|
if ((prop_value->type != type) && (mode != PropModeReplace))
|
2010-12-05 08:36:02 -07:00
|
|
|
return BadMatch;
|
2009-09-06 13:44:18 -06:00
|
|
|
new_value = *prop_value;
|
|
|
|
if (mode == PropModeReplace)
|
|
|
|
total_len = len;
|
|
|
|
else
|
|
|
|
total_len = prop_value->size + len;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (mode == PropModeReplace || len > 0) {
|
2014-09-27 11:52:59 -06:00
|
|
|
void *new_data = NULL, *old_data = NULL;
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2016-05-29 06:02:34 -06:00
|
|
|
new_value.data = xallocarray(total_len, size_in_bytes);
|
|
|
|
if (!new_value.data && total_len && size_in_bytes) {
|
2009-09-06 13:44:18 -06:00
|
|
|
if (add)
|
2012-06-10 07:21:05 -06:00
|
|
|
XIDestroyDeviceProperty(prop);
|
2009-09-06 13:44:18 -06:00
|
|
|
return BadAlloc;
|
|
|
|
}
|
|
|
|
new_value.size = len;
|
|
|
|
new_value.type = type;
|
|
|
|
new_value.format = format;
|
|
|
|
|
|
|
|
switch (mode) {
|
|
|
|
case PropModeReplace:
|
|
|
|
new_data = new_value.data;
|
|
|
|
old_data = NULL;
|
|
|
|
break;
|
|
|
|
case PropModeAppend:
|
2014-09-27 11:52:59 -06:00
|
|
|
new_data = (void *) (((char *) new_value.data) +
|
2009-09-06 13:44:18 -06:00
|
|
|
(prop_value->size * size_in_bytes));
|
|
|
|
old_data = new_value.data;
|
|
|
|
break;
|
|
|
|
case PropModePrepend:
|
|
|
|
new_data = new_value.data;
|
2014-09-27 11:52:59 -06:00
|
|
|
old_data = (void *) (((char *) new_value.data) +
|
2009-09-06 13:44:18 -06:00
|
|
|
(prop_value->size * size_in_bytes));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (new_data)
|
2013-06-07 11:28:45 -06:00
|
|
|
memcpy((char *) new_data, value, len * size_in_bytes);
|
2009-09-06 13:44:18 -06:00
|
|
|
if (old_data)
|
2012-06-10 07:21:05 -06:00
|
|
|
memcpy((char *) old_data, (char *) prop_value->data,
|
|
|
|
prop_value->size * size_in_bytes);
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (dev->properties.handlers) {
|
2009-09-06 13:44:18 -06:00
|
|
|
XIPropertyHandlerPtr handler;
|
|
|
|
BOOL checkonly = TRUE;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
/* run through all handlers with checkonly TRUE, then again with
|
|
|
|
* checkonly FALSE. Handlers MUST return error codes on the
|
|
|
|
* checkonly run, errors on the second run are ignored */
|
2012-06-10 07:21:05 -06:00
|
|
|
do {
|
2009-09-06 13:44:18 -06:00
|
|
|
handler = dev->properties.handlers;
|
2012-06-10 07:21:05 -06:00
|
|
|
while (handler) {
|
|
|
|
if (handler->SetProperty) {
|
2017-12-08 08:01:59 -07:00
|
|
|
input_lock();
|
2009-09-06 13:44:18 -06:00
|
|
|
rc = handler->SetProperty(dev, prop->propertyName,
|
2012-06-10 07:21:05 -06:00
|
|
|
&new_value, checkonly);
|
2017-12-08 08:01:59 -07:00
|
|
|
input_unlock();
|
2012-06-10 07:21:05 -06:00
|
|
|
if (checkonly && rc != Success) {
|
2010-12-05 08:36:02 -07:00
|
|
|
free(new_value.data);
|
2013-06-07 11:28:45 -06:00
|
|
|
if (add)
|
|
|
|
XIDestroyDeviceProperty(prop);
|
2010-12-05 08:36:02 -07:00
|
|
|
return rc;
|
2009-09-06 13:44:18 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
handler = handler->next;
|
|
|
|
}
|
|
|
|
checkonly = !checkonly;
|
|
|
|
} while (!checkonly);
|
|
|
|
}
|
2010-12-05 08:36:02 -07:00
|
|
|
free(prop_value->data);
|
2009-09-06 13:44:18 -06:00
|
|
|
*prop_value = new_value;
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
|
|
|
else if (len == 0) {
|
2009-09-06 13:44:18 -06:00
|
|
|
/* do nothing */
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (add) {
|
2009-09-06 13:44:18 -06:00
|
|
|
prop->next = dev->properties.properties;
|
|
|
|
dev->properties.properties = prop;
|
|
|
|
}
|
|
|
|
|
2017-12-08 08:01:59 -07:00
|
|
|
if (sendevent) {
|
|
|
|
UpdateCurrentTimeIf();
|
2010-07-27 13:02:24 -06:00
|
|
|
send_property_event(dev, prop->propertyName,
|
2012-06-10 07:21:05 -06:00
|
|
|
(add) ? XIPropertyCreated : XIPropertyModified);
|
2017-12-08 08:01:59 -07:00
|
|
|
}
|
2010-07-27 13:02:24 -06:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2009-09-06 13:44:18 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2012-06-10 07:21:05 -06:00
|
|
|
XIGetDeviceProperty(DeviceIntPtr dev, Atom property, XIPropertyValuePtr *value)
|
2009-09-06 13:44:18 -06:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
XIPropertyPtr prop = XIFetchDeviceProperty(dev, property);
|
2009-09-06 13:44:18 -06:00
|
|
|
int rc;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!prop) {
|
2009-09-06 13:44:18 -06:00
|
|
|
*value = NULL;
|
|
|
|
return BadAtom;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If we can, try to update the property value first */
|
2012-06-10 07:21:05 -06:00
|
|
|
if (dev->properties.handlers) {
|
2009-09-06 13:44:18 -06:00
|
|
|
XIPropertyHandlerPtr handler = dev->properties.handlers;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
while (handler) {
|
|
|
|
if (handler->GetProperty) {
|
2009-09-06 13:44:18 -06:00
|
|
|
rc = handler->GetProperty(dev, prop->propertyName);
|
2012-06-10 07:21:05 -06:00
|
|
|
if (rc != Success) {
|
2009-09-06 13:44:18 -06:00
|
|
|
*value = NULL;
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
handler = handler->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*value = &prop->value;
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
XISetDevicePropertyDeletable(DeviceIntPtr dev, Atom property, Bool deletable)
|
|
|
|
{
|
|
|
|
XIPropertyPtr prop = XIFetchDeviceProperty(dev, property);
|
|
|
|
|
|
|
|
if (!prop)
|
|
|
|
return BadAtom;
|
|
|
|
|
|
|
|
prop->deletable = deletable;
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcXListDeviceProperties(ClientPtr client)
|
2009-09-06 13:44:18 -06:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
Atom *atoms;
|
|
|
|
xListDevicePropertiesReply rep;
|
|
|
|
int natoms;
|
|
|
|
DeviceIntPtr dev;
|
|
|
|
int rc = Success;
|
2009-09-06 13:44:18 -06:00
|
|
|
|
|
|
|
REQUEST(xListDevicePropertiesReq);
|
|
|
|
REQUEST_SIZE_MATCH(xListDevicePropertiesReq);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixListPropAccess);
|
2009-09-06 13:44:18 -06:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
rc = list_atoms(dev, &natoms, &atoms);
|
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
rep = (xListDevicePropertiesReply) {
|
|
|
|
.repType = X_Reply,
|
|
|
|
.RepType = X_ListDeviceProperties,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = natoms,
|
|
|
|
.nAtoms = natoms
|
|
|
|
};
|
2009-09-06 13:44:18 -06:00
|
|
|
|
|
|
|
WriteReplyToClient(client, sizeof(xListDevicePropertiesReply), &rep);
|
2012-06-10 07:21:05 -06:00
|
|
|
if (natoms) {
|
|
|
|
client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
|
2010-07-27 13:02:24 -06:00
|
|
|
WriteSwappedDataToClient(client, natoms * sizeof(Atom), atoms);
|
2010-12-05 08:36:02 -07:00
|
|
|
free(atoms);
|
2009-09-06 13:44:18 -06:00
|
|
|
}
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcXChangeDeviceProperty(ClientPtr client)
|
2009-09-06 13:44:18 -06:00
|
|
|
{
|
|
|
|
REQUEST(xChangeDevicePropertyReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
DeviceIntPtr dev;
|
|
|
|
unsigned long len;
|
|
|
|
int totalSize;
|
|
|
|
int rc;
|
2009-09-06 13:44:18 -06:00
|
|
|
|
|
|
|
REQUEST_AT_LEAST_SIZE(xChangeDevicePropertyReq);
|
|
|
|
UpdateCurrentTime();
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixSetPropAccess);
|
2009-09-06 13:44:18 -06:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
rc = check_change_property(client, stuff->property, stuff->type,
|
|
|
|
stuff->format, stuff->mode, stuff->nUnits);
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
len = stuff->nUnits;
|
|
|
|
if (len > (bytes_to_int32(0xffffffff - sizeof(xChangeDevicePropertyReq))))
|
|
|
|
return BadLength;
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
totalSize = len * (stuff->format / 8);
|
2010-07-27 13:02:24 -06:00
|
|
|
REQUEST_FIXED_SIZE(xChangeDevicePropertyReq, totalSize);
|
|
|
|
|
|
|
|
rc = change_property(client, dev, stuff->property, stuff->type,
|
2012-06-10 07:21:05 -06:00
|
|
|
stuff->format, stuff->mode, len, (void *) &stuff[1]);
|
2009-09-06 13:44:18 -06:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcXDeleteDeviceProperty(ClientPtr client)
|
2009-09-06 13:44:18 -06:00
|
|
|
{
|
|
|
|
REQUEST(xDeleteDevicePropertyReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
DeviceIntPtr dev;
|
|
|
|
int rc;
|
2009-09-06 13:44:18 -06:00
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xDeleteDevicePropertyReq);
|
|
|
|
UpdateCurrentTime();
|
2012-06-10 07:21:05 -06:00
|
|
|
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixSetPropAccess);
|
2009-09-06 13:44:18 -06:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!ValidAtom(stuff->property)) {
|
2009-09-06 13:44:18 -06:00
|
|
|
client->errorValue = stuff->property;
|
2010-12-05 08:36:02 -07:00
|
|
|
return BadAtom;
|
2009-09-06 13:44:18 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
rc = XIDeleteDeviceProperty(dev, stuff->property, TRUE);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcXGetDeviceProperty(ClientPtr client)
|
2009-09-06 13:44:18 -06:00
|
|
|
{
|
|
|
|
REQUEST(xGetDevicePropertyReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
DeviceIntPtr dev;
|
|
|
|
int length;
|
|
|
|
int rc, format, nitems, bytes_after;
|
|
|
|
char *data;
|
|
|
|
Atom type;
|
|
|
|
xGetDevicePropertyReply reply;
|
2009-09-06 13:44:18 -06:00
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xGetDevicePropertyReq);
|
|
|
|
if (stuff->delete)
|
|
|
|
UpdateCurrentTime();
|
2012-06-10 07:21:05 -06:00
|
|
|
rc = dixLookupDevice(&dev, stuff->deviceid, client,
|
|
|
|
stuff->delete ? DixSetPropAccess : DixGetPropAccess);
|
2009-09-06 13:44:18 -06:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
rc = get_property(client, dev, stuff->property, stuff->type,
|
2012-06-10 07:21:05 -06:00
|
|
|
stuff->delete, stuff->longOffset, stuff->longLength,
|
|
|
|
&bytes_after, &type, &format, &nitems, &length, &data);
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
reply = (xGetDevicePropertyReply) {
|
|
|
|
.repType = X_Reply,
|
|
|
|
.RepType = X_GetDeviceProperty,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = bytes_to_int32(length),
|
|
|
|
.propertyType = type,
|
|
|
|
.bytesAfter = bytes_after,
|
|
|
|
.nItems = nitems,
|
|
|
|
.format = format,
|
|
|
|
.deviceid = dev->id
|
|
|
|
};
|
2009-09-06 13:44:18 -06:00
|
|
|
|
|
|
|
if (stuff->delete && (reply.bytesAfter == 0))
|
2010-07-27 13:02:24 -06:00
|
|
|
send_property_event(dev, stuff->property, XIPropertyDeleted);
|
2009-09-06 13:44:18 -06:00
|
|
|
|
|
|
|
WriteReplyToClient(client, sizeof(xGenericReply), &reply);
|
2010-07-27 13:02:24 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (length) {
|
2009-09-06 13:44:18 -06:00
|
|
|
switch (reply.format) {
|
2012-06-10 07:21:05 -06:00
|
|
|
case 32:
|
|
|
|
client->pSwapReplyFunc = (ReplySwapPtr) CopySwap32Write;
|
|
|
|
break;
|
|
|
|
case 16:
|
|
|
|
client->pSwapReplyFunc = (ReplySwapPtr) CopySwap16Write;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
client->pSwapReplyFunc = (ReplySwapPtr) WriteToClient;
|
|
|
|
break;
|
2009-09-06 13:44:18 -06:00
|
|
|
}
|
2010-07-27 13:02:24 -06:00
|
|
|
WriteSwappedDataToClient(client, length, data);
|
2009-09-06 13:44:18 -06:00
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
/* delete the Property */
|
2012-06-10 07:21:05 -06:00
|
|
|
if (stuff->delete && (reply.bytesAfter == 0)) {
|
2010-07-27 13:02:24 -06:00
|
|
|
XIPropertyPtr prop, *prev;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
for (prev = &dev->properties.properties; (prop = *prev);
|
|
|
|
prev = &prop->next) {
|
|
|
|
if (prop->propertyName == stuff->property) {
|
2010-07-27 13:02:24 -06:00
|
|
|
*prev = prop->next;
|
|
|
|
XIDestroyDeviceProperty(prop);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-09-06 13:44:18 -06:00
|
|
|
}
|
2010-07-27 13:02:24 -06:00
|
|
|
return Success;
|
2009-09-06 13:44:18 -06:00
|
|
|
}
|
|
|
|
|
2019-07-27 01:57:06 -06:00
|
|
|
int _X_COLD
|
2012-06-10 07:21:05 -06:00
|
|
|
SProcXListDeviceProperties(ClientPtr client)
|
2009-09-06 13:44:18 -06:00
|
|
|
{
|
|
|
|
REQUEST(xListDevicePropertiesReq);
|
2014-12-09 10:58:52 -07:00
|
|
|
REQUEST_SIZE_MATCH(xListDevicePropertiesReq);
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->length);
|
2009-09-06 13:44:18 -06:00
|
|
|
return (ProcXListDeviceProperties(client));
|
|
|
|
}
|
|
|
|
|
2019-07-27 01:57:06 -06:00
|
|
|
int _X_COLD
|
2012-06-10 07:21:05 -06:00
|
|
|
SProcXChangeDeviceProperty(ClientPtr client)
|
2009-09-06 13:44:18 -06:00
|
|
|
{
|
|
|
|
REQUEST(xChangeDevicePropertyReq);
|
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
REQUEST_AT_LEAST_SIZE(xChangeDevicePropertyReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->length);
|
|
|
|
swapl(&stuff->property);
|
|
|
|
swapl(&stuff->type);
|
|
|
|
swapl(&stuff->nUnits);
|
2009-09-06 13:44:18 -06:00
|
|
|
return (ProcXChangeDeviceProperty(client));
|
|
|
|
}
|
|
|
|
|
2019-07-27 01:57:06 -06:00
|
|
|
int _X_COLD
|
2012-06-10 07:21:05 -06:00
|
|
|
SProcXDeleteDeviceProperty(ClientPtr client)
|
2009-09-06 13:44:18 -06:00
|
|
|
{
|
|
|
|
REQUEST(xDeleteDevicePropertyReq);
|
2014-12-09 10:58:52 -07:00
|
|
|
REQUEST_SIZE_MATCH(xDeleteDevicePropertyReq);
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->length);
|
|
|
|
swapl(&stuff->property);
|
2009-09-06 13:44:18 -06:00
|
|
|
return (ProcXDeleteDeviceProperty(client));
|
|
|
|
}
|
|
|
|
|
2019-07-27 01:57:06 -06:00
|
|
|
int _X_COLD
|
2012-06-10 07:21:05 -06:00
|
|
|
SProcXGetDeviceProperty(ClientPtr client)
|
2009-09-06 13:44:18 -06:00
|
|
|
{
|
|
|
|
REQUEST(xGetDevicePropertyReq);
|
2014-12-09 10:58:52 -07:00
|
|
|
REQUEST_SIZE_MATCH(xGetDevicePropertyReq);
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->length);
|
|
|
|
swapl(&stuff->property);
|
|
|
|
swapl(&stuff->type);
|
|
|
|
swapl(&stuff->longOffset);
|
|
|
|
swapl(&stuff->longLength);
|
2009-09-06 13:44:18 -06:00
|
|
|
return (ProcXGetDeviceProperty(client));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Reply swapping */
|
|
|
|
|
2019-07-27 01:57:06 -06:00
|
|
|
void _X_COLD
|
2009-09-06 13:44:18 -06:00
|
|
|
SRepXListDeviceProperties(ClientPtr client, int size,
|
2012-06-10 07:21:05 -06:00
|
|
|
xListDevicePropertiesReply * rep)
|
2009-09-06 13:44:18 -06:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&rep->sequenceNumber);
|
|
|
|
swapl(&rep->length);
|
|
|
|
swaps(&rep->nAtoms);
|
2009-09-06 13:44:18 -06:00
|
|
|
/* properties will be swapped later, see ProcXListDeviceProperties */
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(client, size, rep);
|
2009-09-06 13:44:18 -06:00
|
|
|
}
|
|
|
|
|
2019-07-27 01:57:06 -06:00
|
|
|
void _X_COLD
|
2009-09-06 13:44:18 -06:00
|
|
|
SRepXGetDeviceProperty(ClientPtr client, int size,
|
2012-06-10 07:21:05 -06:00
|
|
|
xGetDevicePropertyReply * rep)
|
2009-09-06 13:44:18 -06:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&rep->sequenceNumber);
|
|
|
|
swapl(&rep->length);
|
|
|
|
swapl(&rep->propertyType);
|
|
|
|
swapl(&rep->bytesAfter);
|
|
|
|
swapl(&rep->nItems);
|
2009-09-06 13:44:18 -06:00
|
|
|
/* data will be swapped, see ProcXGetDeviceProperty */
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(client, size, rep);
|
2009-09-06 13:44:18 -06:00
|
|
|
}
|
2010-07-27 13:02:24 -06:00
|
|
|
|
|
|
|
/* XI2 Request/reply handling */
|
|
|
|
int
|
|
|
|
ProcXIListProperties(ClientPtr client)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
Atom *atoms;
|
|
|
|
xXIListPropertiesReply rep;
|
|
|
|
int natoms;
|
|
|
|
DeviceIntPtr dev;
|
|
|
|
int rc = Success;
|
2010-07-27 13:02:24 -06:00
|
|
|
|
|
|
|
REQUEST(xXIListPropertiesReq);
|
|
|
|
REQUEST_SIZE_MATCH(xXIListPropertiesReq);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixListPropAccess);
|
2010-07-27 13:02:24 -06:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
rc = list_atoms(dev, &natoms, &atoms);
|
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
rep = (xXIListPropertiesReply) {
|
|
|
|
.repType = X_Reply,
|
|
|
|
.RepType = X_XIListProperties,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = natoms,
|
|
|
|
.num_properties = natoms
|
|
|
|
};
|
2010-07-27 13:02:24 -06:00
|
|
|
|
|
|
|
WriteReplyToClient(client, sizeof(xXIListPropertiesReply), &rep);
|
2012-06-10 07:21:05 -06:00
|
|
|
if (natoms) {
|
|
|
|
client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
|
2010-07-27 13:02:24 -06:00
|
|
|
WriteSwappedDataToClient(client, natoms * sizeof(Atom), atoms);
|
2010-12-05 08:36:02 -07:00
|
|
|
free(atoms);
|
2010-07-27 13:02:24 -06:00
|
|
|
}
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
ProcXIChangeProperty(ClientPtr client)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
int rc;
|
|
|
|
DeviceIntPtr dev;
|
|
|
|
int totalSize;
|
|
|
|
unsigned long len;
|
2010-07-27 13:02:24 -06:00
|
|
|
|
|
|
|
REQUEST(xXIChangePropertyReq);
|
|
|
|
REQUEST_AT_LEAST_SIZE(xXIChangePropertyReq);
|
|
|
|
UpdateCurrentTime();
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixSetPropAccess);
|
2010-07-27 13:02:24 -06:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
rc = check_change_property(client, stuff->property, stuff->type,
|
|
|
|
stuff->format, stuff->mode, stuff->num_items);
|
|
|
|
len = stuff->num_items;
|
|
|
|
if (len > bytes_to_int32(0xffffffff - sizeof(xXIChangePropertyReq)))
|
|
|
|
return BadLength;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
totalSize = len * (stuff->format / 8);
|
2010-07-27 13:02:24 -06:00
|
|
|
REQUEST_FIXED_SIZE(xXIChangePropertyReq, totalSize);
|
|
|
|
|
|
|
|
rc = change_property(client, dev, stuff->property, stuff->type,
|
2012-06-10 07:21:05 -06:00
|
|
|
stuff->format, stuff->mode, len, (void *) &stuff[1]);
|
2010-07-27 13:02:24 -06:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
ProcXIDeleteProperty(ClientPtr client)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
DeviceIntPtr dev;
|
|
|
|
int rc;
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
REQUEST(xXIDeletePropertyReq);
|
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xXIDeletePropertyReq);
|
|
|
|
UpdateCurrentTime();
|
2012-06-10 07:21:05 -06:00
|
|
|
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixSetPropAccess);
|
2010-07-27 13:02:24 -06:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!ValidAtom(stuff->property)) {
|
2010-07-27 13:02:24 -06:00
|
|
|
client->errorValue = stuff->property;
|
2010-12-05 08:36:02 -07:00
|
|
|
return BadAtom;
|
2010-07-27 13:02:24 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
rc = XIDeleteDeviceProperty(dev, stuff->property, TRUE);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
ProcXIGetProperty(ClientPtr client)
|
|
|
|
{
|
|
|
|
REQUEST(xXIGetPropertyReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
DeviceIntPtr dev;
|
|
|
|
xXIGetPropertyReply reply;
|
|
|
|
int length;
|
|
|
|
int rc, format, nitems, bytes_after;
|
|
|
|
char *data;
|
|
|
|
Atom type;
|
2010-07-27 13:02:24 -06:00
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xXIGetPropertyReq);
|
|
|
|
if (stuff->delete)
|
|
|
|
UpdateCurrentTime();
|
2012-06-10 07:21:05 -06:00
|
|
|
rc = dixLookupDevice(&dev, stuff->deviceid, client,
|
|
|
|
stuff->delete ? DixSetPropAccess : DixGetPropAccess);
|
2010-07-27 13:02:24 -06:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
rc = get_property(client, dev, stuff->property, stuff->type,
|
2012-06-10 07:21:05 -06:00
|
|
|
stuff->delete, stuff->offset, stuff->len,
|
|
|
|
&bytes_after, &type, &format, &nitems, &length, &data);
|
2010-07-27 13:02:24 -06:00
|
|
|
|
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
reply = (xXIGetPropertyReply) {
|
|
|
|
.repType = X_Reply,
|
|
|
|
.RepType = X_XIGetProperty,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = bytes_to_int32(length),
|
|
|
|
.type = type,
|
|
|
|
.bytes_after = bytes_after,
|
|
|
|
.num_items = nitems,
|
|
|
|
.format = format
|
|
|
|
};
|
2010-07-27 13:02:24 -06:00
|
|
|
|
|
|
|
if (length && stuff->delete && (reply.bytes_after == 0))
|
|
|
|
send_property_event(dev, stuff->property, XIPropertyDeleted);
|
|
|
|
|
|
|
|
WriteReplyToClient(client, sizeof(xXIGetPropertyReply), &reply);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (length) {
|
2010-07-27 13:02:24 -06:00
|
|
|
switch (reply.format) {
|
2012-06-10 07:21:05 -06:00
|
|
|
case 32:
|
|
|
|
client->pSwapReplyFunc = (ReplySwapPtr) CopySwap32Write;
|
|
|
|
break;
|
|
|
|
case 16:
|
|
|
|
client->pSwapReplyFunc = (ReplySwapPtr) CopySwap16Write;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
client->pSwapReplyFunc = (ReplySwapPtr) WriteToClient;
|
|
|
|
break;
|
2010-07-27 13:02:24 -06:00
|
|
|
}
|
|
|
|
WriteSwappedDataToClient(client, length, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* delete the Property */
|
2012-06-10 07:21:05 -06:00
|
|
|
if (stuff->delete && (reply.bytes_after == 0)) {
|
2010-07-27 13:02:24 -06:00
|
|
|
XIPropertyPtr prop, *prev;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
for (prev = &dev->properties.properties; (prop = *prev);
|
|
|
|
prev = &prop->next) {
|
|
|
|
if (prop->propertyName == stuff->property) {
|
2010-07-27 13:02:24 -06:00
|
|
|
*prev = prop->next;
|
|
|
|
XIDestroyDeviceProperty(prop);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
2019-07-27 01:57:06 -06:00
|
|
|
int _X_COLD
|
2010-07-27 13:02:24 -06:00
|
|
|
SProcXIListProperties(ClientPtr client)
|
|
|
|
{
|
|
|
|
REQUEST(xXIListPropertiesReq);
|
2014-12-09 10:58:52 -07:00
|
|
|
REQUEST_SIZE_MATCH(xXIListPropertiesReq);
|
2010-07-27 13:02:24 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->length);
|
|
|
|
swaps(&stuff->deviceid);
|
2010-07-27 13:02:24 -06:00
|
|
|
return (ProcXIListProperties(client));
|
|
|
|
}
|
|
|
|
|
2019-07-27 01:57:06 -06:00
|
|
|
int _X_COLD
|
2010-07-27 13:02:24 -06:00
|
|
|
SProcXIChangeProperty(ClientPtr client)
|
|
|
|
{
|
|
|
|
REQUEST(xXIChangePropertyReq);
|
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
REQUEST_AT_LEAST_SIZE(xXIChangePropertyReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->length);
|
|
|
|
swaps(&stuff->deviceid);
|
|
|
|
swapl(&stuff->property);
|
|
|
|
swapl(&stuff->type);
|
|
|
|
swapl(&stuff->num_items);
|
2010-07-27 13:02:24 -06:00
|
|
|
return (ProcXIChangeProperty(client));
|
|
|
|
}
|
|
|
|
|
2019-07-27 01:57:06 -06:00
|
|
|
int _X_COLD
|
2010-07-27 13:02:24 -06:00
|
|
|
SProcXIDeleteProperty(ClientPtr client)
|
|
|
|
{
|
|
|
|
REQUEST(xXIDeletePropertyReq);
|
2014-12-09 10:58:52 -07:00
|
|
|
REQUEST_SIZE_MATCH(xXIDeletePropertyReq);
|
2010-07-27 13:02:24 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->length);
|
|
|
|
swaps(&stuff->deviceid);
|
|
|
|
swapl(&stuff->property);
|
2010-07-27 13:02:24 -06:00
|
|
|
return (ProcXIDeleteProperty(client));
|
|
|
|
}
|
|
|
|
|
2019-07-27 01:57:06 -06:00
|
|
|
int _X_COLD
|
2010-07-27 13:02:24 -06:00
|
|
|
SProcXIGetProperty(ClientPtr client)
|
|
|
|
{
|
|
|
|
REQUEST(xXIGetPropertyReq);
|
2014-12-09 10:58:52 -07:00
|
|
|
REQUEST_SIZE_MATCH(xXIGetPropertyReq);
|
2010-07-27 13:02:24 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->length);
|
|
|
|
swaps(&stuff->deviceid);
|
|
|
|
swapl(&stuff->property);
|
|
|
|
swapl(&stuff->type);
|
|
|
|
swapl(&stuff->offset);
|
|
|
|
swapl(&stuff->len);
|
2010-07-27 13:02:24 -06:00
|
|
|
return (ProcXIGetProperty(client));
|
|
|
|
}
|
|
|
|
|
2019-07-27 01:57:06 -06:00
|
|
|
void _X_COLD
|
2012-06-10 07:21:05 -06:00
|
|
|
SRepXIListProperties(ClientPtr client, int size, xXIListPropertiesReply * rep)
|
2010-07-27 13:02:24 -06:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&rep->sequenceNumber);
|
|
|
|
swapl(&rep->length);
|
|
|
|
swaps(&rep->num_properties);
|
2010-07-27 13:02:24 -06:00
|
|
|
/* properties will be swapped later, see ProcXIListProperties */
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(client, size, rep);
|
2010-07-27 13:02:24 -06:00
|
|
|
}
|
|
|
|
|
2019-07-27 01:57:06 -06:00
|
|
|
void _X_COLD
|
2012-06-10 07:21:05 -06:00
|
|
|
SRepXIGetProperty(ClientPtr client, int size, xXIGetPropertyReply * rep)
|
2010-07-27 13:02:24 -06:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&rep->sequenceNumber);
|
|
|
|
swapl(&rep->length);
|
|
|
|
swapl(&rep->type);
|
|
|
|
swapl(&rep->bytes_after);
|
|
|
|
swapl(&rep->num_items);
|
2010-07-27 13:02:24 -06:00
|
|
|
/* data will be swapped, see ProcXIGetProperty */
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(client, size, rep);
|
2010-07-27 13:02:24 -06:00
|
|
|
}
|