xace: add new hooks + access controls: XInput extension.

Introduces new dix API to lookup a device, dixLookupDevice(), which
replaces LookupDeviceIntRec and LookupDevice.
This commit is contained in:
Eamon Walsh 2007-09-28 08:02:00 -04:00 committed by Eamon Walsh
parent 27612748e0
commit 5c03d13181
45 changed files with 187 additions and 197 deletions

View File

@ -49,7 +49,6 @@ from The Open Group.
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#define EXTENSION_EVENT_BASE 64
#include "extinit.h" /* LookupDeviceIntRec */
#endif /* XINPUT */
#include "modinit.h"
@ -286,11 +285,12 @@ ProcXTestFakeInput(client)
#ifdef XINPUT
if (extension)
{
dev = LookupDeviceIntRec(stuff->deviceid & 0177);
if (!dev)
rc = dixLookupDevice(&dev, stuff->deviceid & 0177, client,
DixWriteAccess);
if (rc != Success)
{
client->errorValue = stuff->deviceid & 0177;
return BadValue;
return rc;
}
if (nev > 1)
{

View File

@ -60,7 +60,6 @@ SOFTWARE.
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h"
#include "allowev.h"
@ -95,13 +94,14 @@ ProcXAllowDeviceEvents(ClientPtr client)
{
TimeStamp time;
DeviceIntPtr thisdev;
int rc;
REQUEST(xAllowDeviceEventsReq);
REQUEST_SIZE_MATCH(xAllowDeviceEventsReq);
thisdev = LookupDeviceIntRec(stuff->deviceid);
if (thisdev == NULL)
return BadDevice;
rc = dixLookupDevice(&thisdev, stuff->deviceid, client, DixGetAttrAccess);
if (rc != Success)
return rc;
time = ClientTimeToServerTime(stuff->time);
switch (stuff->mode) {

View File

@ -61,7 +61,6 @@ SOFTWARE.
#include <X11/extensions/XIproto.h> /* control constants */
#include "XIstubs.h"
#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h"
#include "exevents.h"
@ -112,11 +111,9 @@ ProcXChangeDeviceControl(ClientPtr client)
REQUEST_AT_LEAST_SIZE(xChangeDeviceControlReq);
len = stuff->length - (sizeof(xChangeDeviceControlReq) >> 2);
dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL) {
ret = BadDevice;
ret = dixLookupDevice(&dev, stuff->deviceid, client, DixSetAttrAccess);
if (ret != Success)
goto out;
}
rep.repType = X_Reply;
rep.RepType = X_ChangeDeviceControl;

View File

@ -60,7 +60,6 @@ SOFTWARE.
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h> /* control constants */
#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h"
#include "chgfctl.h"
@ -444,14 +443,15 @@ ProcXChangeFeedbackControl(ClientPtr client)
StringFeedbackPtr s;
BellFeedbackPtr b;
LedFeedbackPtr l;
int rc;
REQUEST(xChangeFeedbackControlReq);
REQUEST_AT_LEAST_SIZE(xChangeFeedbackControlReq);
len = stuff->length - (sizeof(xChangeFeedbackControlReq) >> 2);
dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL)
return BadDevice;
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixSetAttrAccess);
if (rc != Success)
return rc;
switch (stuff->feedbackid) {
case KbdFeedbackClass:

View File

@ -59,7 +59,6 @@ SOFTWARE.
#include "inputstr.h" /* DeviceIntPtr */
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "extinit.h" /* LookupDeviceIntRec */
#include "exevents.h"
#include "exglobals.h"
@ -107,9 +106,9 @@ ProcXChangeDeviceKeyMapping(ClientPtr client)
REQUEST(xChangeDeviceKeyMappingReq);
REQUEST_AT_LEAST_SIZE(xChangeDeviceKeyMappingReq);
dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL)
return BadDevice;
ret = dixLookupDevice(&dev, stuff->deviceid, client, DixSetAttrAccess);
if (ret != Success)
return ret;
len = stuff->length - (sizeof(xChangeDeviceKeyMappingReq) >> 2);
ret = ChangeKeyMapping(client, dev, len, DeviceMappingNotify,

View File

@ -60,7 +60,6 @@ SOFTWARE.
#include "windowstr.h"
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "extinit.h" /* LookupDeviceIntRec */
#include "exevents.h"
#include "exglobals.h"
@ -115,7 +114,7 @@ ProcXChangeDeviceDontPropagateList(ClientPtr client)
stuff->count)
return BadLength;
rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess);
rc = dixLookupWindow(&pWin, stuff->window, client, DixSetAttrAccess);
if (rc != Success)
return rc;

View File

@ -63,8 +63,6 @@ SOFTWARE.
#include "windowstr.h" /* window structure */
#include "scrnintstr.h" /* screen structure */
#include "extinit.h" /* LookupDeviceIntRec */
#include "dixevents.h"
#include "exevents.h"
#include "exglobals.h"

View File

@ -62,7 +62,6 @@ SOFTWARE.
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "XIstubs.h"
#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h"
#include "closedev.h"
@ -140,16 +139,16 @@ DeleteEventsFromChildren(DeviceIntPtr dev, WindowPtr p1, ClientPtr client)
int
ProcXCloseDevice(ClientPtr client)
{
int i;
int rc, i;
WindowPtr pWin, p1;
DeviceIntPtr d;
REQUEST(xCloseDeviceReq);
REQUEST_SIZE_MATCH(xCloseDeviceReq);
d = LookupDeviceIntRec(stuff->deviceid);
if (d == NULL)
return BadDevice;
rc = dixLookupDevice(&d, stuff->deviceid, client, DixGetAttrAccess);
if (rc != Success)
return rc;
if (d->grab && SameClient(d->grab, client))
(*d->DeactivateGrab) (d); /* release active grab */

View File

@ -59,7 +59,6 @@ SOFTWARE.
#include "inputstr.h" /* DeviceIntPtr */
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h"
#include "devbell.h"
@ -93,7 +92,7 @@ ProcXDeviceBell(ClientPtr client)
DeviceIntPtr dev;
KbdFeedbackPtr k;
BellFeedbackPtr b;
int base;
int rc, base;
int newpercent;
CARD8 class;
pointer ctrl;
@ -102,10 +101,10 @@ ProcXDeviceBell(ClientPtr client)
REQUEST(xDeviceBellReq);
REQUEST_SIZE_MATCH(xDeviceBellReq);
dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL) {
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixBellAccess);
if (rc != Success) {
client->errorValue = stuff->deviceid;
return BadDevice;
return rc;
}
if (stuff->percent < -100 || stuff->percent > 100) {

View File

@ -67,11 +67,11 @@ SOFTWARE.
#include "region.h"
#include "exevents.h"
#include "extnsionst.h"
#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h"
#include "dixevents.h" /* DeliverFocusedEvent */
#include "dixgrabs.h" /* CreateGrab() */
#include "scrnintstr.h"
#include "xace.h"
#ifdef XKB
#include "xkbsrv.h"
@ -511,6 +511,7 @@ GrabButton(ClientPtr client, DeviceIntPtr dev, BYTE this_device_mode,
WindowPtr pWin, confineTo;
CursorPtr cursor;
GrabPtr grab;
Mask access_mode = DixGrabAccess;
int rc;
if ((this_device_mode != GrabModeSync) &&
@ -531,25 +532,33 @@ GrabButton(ClientPtr client, DeviceIntPtr dev, BYTE this_device_mode,
client->errorValue = ownerEvents;
return BadValue;
}
rc = dixLookupWindow(&pWin, grabWindow, client, DixUnknownAccess);
rc = dixLookupWindow(&pWin, grabWindow, client, DixSetAttrAccess);
if (rc != Success)
return rc;
if (rconfineTo == None)
confineTo = NullWindow;
else {
rc = dixLookupWindow(&confineTo, rconfineTo, client, DixUnknownAccess);
rc = dixLookupWindow(&confineTo, rconfineTo, client, DixSetAttrAccess);
if (rc != Success)
return rc;
}
if (rcursor == None)
cursor = NullCursor;
else {
cursor = (CursorPtr) LookupIDByType(rcursor, RT_CURSOR);
if (!cursor) {
rc = dixLookupResource((pointer *)&cursor, rcursor, RT_CURSOR,
client, DixUseAccess);
if (rc != Success)
{
client->errorValue = rcursor;
return BadCursor;
return (rc == BadValue) ? BadCursor : rc;
}
access_mode |= DixForceAccess;
}
if (this_device_mode == GrabModeSync || other_devices_mode == GrabModeSync)
access_mode |= DixFreezeAccess;
rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, access_mode);
if (rc != Success)
return rc;
grab = CreateGrab(client->index, dev, pWin, eventMask,
(Bool) ownerEvents, (Bool) this_device_mode,
@ -569,6 +578,7 @@ GrabKey(ClientPtr client, DeviceIntPtr dev, BYTE this_device_mode,
WindowPtr pWin;
GrabPtr grab;
KeyClassPtr k = dev->key;
Mask access_mode = DixGrabAccess;
int rc;
if (k == NULL)
@ -596,7 +606,12 @@ GrabKey(ClientPtr client, DeviceIntPtr dev, BYTE this_device_mode,
client->errorValue = ownerEvents;
return BadValue;
}
rc = dixLookupWindow(&pWin, grabWindow, client, DixUnknownAccess);
rc = dixLookupWindow(&pWin, grabWindow, client, DixSetAttrAccess);
if (rc != Success)
return rc;
if (this_device_mode == GrabModeSync || other_devices_mode == GrabModeSync)
access_mode |= DixFreezeAccess;
rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, access_mode);
if (rc != Success)
return rc;
@ -837,7 +852,7 @@ SendEvent(ClientPtr client, DeviceIntPtr d, Window dest, Bool propagate,
if (!mask)
break;
}
} else
} else if (!XaceHook(XACE_SEND_ACCESS, client, NULL, pWin, ev, count))
(void)(DeliverEventsToWindow(pWin, ev, count, mask, NullGrab, d->id));
return Success;
}
@ -1101,7 +1116,8 @@ MaybeSendDeviceMotionNotifyHint(deviceKeyButtonPointer * pEvents, Mask mask)
{
DeviceIntPtr dev;
dev = LookupDeviceIntRec(pEvents->deviceid & DEVICE_BITS);
dixLookupDevice(&dev, pEvents->deviceid & DEVICE_BITS, serverClient,
DixReadAccess);
if (!dev)
return 0;
@ -1125,7 +1141,8 @@ CheckDeviceGrabAndHintWindow(WindowPtr pWin, int type,
{
DeviceIntPtr dev;
dev = LookupDeviceIntRec(xE->deviceid & DEVICE_BITS);
dixLookupDevice(&dev, xE->deviceid & DEVICE_BITS, serverClient,
DixReadAccess);
if (!dev)
return;

View File

@ -856,29 +856,6 @@ MakeDeviceTypeAtoms(void)
MakeAtom(dev_type[i].name, strlen(dev_type[i].name), 1);
}
/**************************************************************************
* Return a DeviceIntPtr corresponding to a specified device id.
*
*/
DeviceIntPtr
LookupDeviceIntRec(CARD8 id)
{
DeviceIntPtr dev;
for (dev = inputInfo.devices; dev; dev = dev->next) {
if (dev->id == id)
return dev;
}
for (dev = inputInfo.off_devices; dev; dev = dev->next) {
if (dev->id == id)
return dev;
}
return NULL;
}
/*****************************************************************************
*
* SEventIDispatch

View File

@ -59,7 +59,6 @@ SOFTWARE.
#include "inputstr.h" /* DeviceIntPtr */
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h"
#include "getbmap.h"
@ -92,6 +91,7 @@ ProcXGetDeviceButtonMapping(ClientPtr client)
DeviceIntPtr dev;
xGetDeviceButtonMappingReply rep;
ButtonClassPtr b;
int rc;
REQUEST(xGetDeviceButtonMappingReq);
REQUEST_SIZE_MATCH(xGetDeviceButtonMappingReq);
@ -102,9 +102,9 @@ ProcXGetDeviceButtonMapping(ClientPtr client)
rep.length = 0;
rep.sequenceNumber = client->sequence;
dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL)
return BadDevice;
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixGetAttrAccess);
if (rc != Success)
return rc;
b = dev->button;
if (b == NULL)

View File

@ -59,7 +59,6 @@ SOFTWARE.
#include "inputstr.h" /* DeviceIntPtr */
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h"
#include "getdctl.h"
@ -238,7 +237,7 @@ SRepXGetDeviceControl(ClientPtr client, int size, xGetDeviceControlReply * rep)
int
ProcXGetDeviceControl(ClientPtr client)
{
int total_length = 0;
int rc, total_length = 0;
char *buf, *savbuf;
DeviceIntPtr dev;
xGetDeviceControlReply rep;
@ -246,9 +245,9 @@ ProcXGetDeviceControl(ClientPtr client)
REQUEST(xGetDeviceControlReq);
REQUEST_SIZE_MATCH(xGetDeviceControlReq);
dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL)
return BadDevice;
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixGetAttrAccess);
if (rc != Success)
return rc;
rep.repType = X_Reply;
rep.RepType = X_GetDeviceControl;

View File

@ -59,7 +59,6 @@ SOFTWARE.
#include "inputstr.h" /* DeviceIntPtr */
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h"
#include "getfctl.h"
@ -290,7 +289,7 @@ SRepXGetFeedbackControl(ClientPtr client, int size,
int
ProcXGetFeedbackControl(ClientPtr client)
{
int total_length = 0;
int rc, total_length = 0;
char *buf, *savbuf;
DeviceIntPtr dev;
KbdFeedbackPtr k;
@ -304,9 +303,9 @@ ProcXGetFeedbackControl(ClientPtr client)
REQUEST(xGetFeedbackControlReq);
REQUEST_SIZE_MATCH(xGetFeedbackControlReq);
dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL)
return BadDevice;
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixGetAttrAccess);
if (rc != Success)
return rc;
rep.repType = X_Reply;
rep.RepType = X_GetFeedbackControl;

View File

@ -60,7 +60,6 @@ SOFTWARE.
#include "inputstr.h" /* DeviceIntPtr */
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h"
#include "getfocus.h"
@ -93,12 +92,15 @@ ProcXGetDeviceFocus(ClientPtr client)
DeviceIntPtr dev;
FocusClassPtr focus;
xGetDeviceFocusReply rep;
int rc;
REQUEST(xGetDeviceFocusReq);
REQUEST_SIZE_MATCH(xGetDeviceFocusReq);
dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL || !dev->focus)
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixGetFocusAccess);
if (rc != Success)
return rc;
if (!dev->focus)
return BadDevice;
rep.repType = X_Reply;

View File

@ -59,7 +59,6 @@ SOFTWARE.
#include "inputstr.h" /* DeviceIntPtr */
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h"
#include "swaprep.h"
@ -94,13 +93,14 @@ ProcXGetDeviceKeyMapping(ClientPtr client)
xGetDeviceKeyMappingReply rep;
DeviceIntPtr dev;
KeySymsPtr k;
int rc;
REQUEST(xGetDeviceKeyMappingReq);
REQUEST_SIZE_MATCH(xGetDeviceKeyMappingReq);
dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL)
return BadDevice;
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixGetAttrAccess);
if (rc != Success)
return rc;
if (dev->key == NULL)
return BadMatch;
k = &dev->key->curKeySyms;

View File

@ -59,7 +59,6 @@ SOFTWARE.
#include "inputstr.h" /* DeviceIntPtr */
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h> /* Request macro */
#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h"
#include "getmmap.h"
@ -94,13 +93,14 @@ ProcXGetDeviceModifierMapping(ClientPtr client)
DeviceIntPtr dev;
xGetDeviceModifierMappingReply rep;
KeyClassPtr kp;
int rc;
REQUEST(xGetDeviceModifierMappingReq);
REQUEST_SIZE_MATCH(xGetDeviceModifierMappingReq);
dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL)
return BadDevice;
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixGetAttrAccess);
if (rc != Success)
return rc;
kp = dev->key;
if (kp == NULL)

View File

@ -60,7 +60,6 @@ SOFTWARE.
#include "windowstr.h" /* window structs */
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h"
#include "swaprep.h"
@ -112,7 +111,7 @@ ProcXGetDeviceDontPropagateList(ClientPtr client)
rep.length = 0;
rep.count = 0;
rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess);
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
return rc;

View File

@ -60,7 +60,6 @@ SOFTWARE.
#include <X11/extensions/XIproto.h>
#include "inputstr.h" /* DeviceIntPtr */
#include "windowstr.h" /* window struct */
#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h"
#include "swaprep.h"
@ -114,7 +113,7 @@ ProcXGetSelectedExtensionEvents(ClientPtr client)
rep.this_client_count = 0;
rep.all_clients_count = 0;
rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess);
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
return rc;

View File

@ -59,7 +59,6 @@ SOFTWARE.
#include "inputstr.h" /* DeviceIntPtr */
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h"
#include "getvers.h"

View File

@ -60,7 +60,6 @@ SOFTWARE.
#include "windowstr.h" /* window structure */
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h"
#include "dixevents.h" /* GrabDevice */
@ -122,9 +121,9 @@ ProcXGrabDevice(ClientPtr client)
rep.sequenceNumber = client->sequence;
rep.length = 0;
dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL)
return BadDevice;
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixGrabAccess);
if (rc != Success)
return rc;
if ((rc = CreateMaskFromList(client, (XEventClass *) & stuff[1],
stuff->event_count, tmp, dev,
@ -153,7 +152,7 @@ int
CreateMaskFromList(ClientPtr client, XEventClass * list, int count,
struct tmask *mask, DeviceIntPtr dev, int req)
{
int i, j;
int rc, i, j;
int device;
DeviceIntPtr tdev;
@ -167,8 +166,10 @@ CreateMaskFromList(ClientPtr client, XEventClass * list, int count,
if (device > 255)
return BadClass;
tdev = LookupDeviceIntRec(device);
if (tdev == NULL || (dev != NULL && tdev != dev))
rc = dixLookupDevice(&tdev, device, client, DixReadAccess);
if (rc != BadDevice && rc != Success)
return rc;
if (rc == BadDevice || (dev != NULL && tdev != dev))
return BadClass;
for (j = 0; j < ExtEventIndex; j++)

View File

@ -61,7 +61,6 @@ SOFTWARE.
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "exevents.h"
#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h"
#include "grabdev.h"
@ -117,14 +116,15 @@ ProcXGrabDeviceButton(ClientPtr client)
(sizeof(xGrabDeviceButtonReq) >> 2) + stuff->event_count)
return BadLength;
dev = LookupDeviceIntRec(stuff->grabbed_device);
if (dev == NULL)
return BadDevice;
ret = dixLookupDevice(&dev, stuff->grabbed_device, client, DixGrabAccess);
if (ret != Success)
return ret;
if (stuff->modifier_device != UseXKeyboard) {
mdev = LookupDeviceIntRec(stuff->modifier_device);
if (mdev == NULL)
return BadDevice;
ret = dixLookupDevice(&mdev, stuff->modifier_device, client,
DixReadAccess);
if (ret != Success)
return ret;
if (mdev->key == NULL)
return BadMatch;
} else

View File

@ -61,7 +61,6 @@ SOFTWARE.
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "exevents.h"
#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h"
#include "grabdev.h"
@ -115,14 +114,15 @@ ProcXGrabDeviceKey(ClientPtr client)
if (stuff->length != (sizeof(xGrabDeviceKeyReq) >> 2) + stuff->event_count)
return BadLength;
dev = LookupDeviceIntRec(stuff->grabbed_device);
if (dev == NULL)
return BadDevice;
ret = dixLookupDevice(&dev, stuff->grabbed_device, client, DixGrabAccess);
if (ret != Success)
return ret;
if (stuff->modifier_device != UseXKeyboard) {
mdev = LookupDeviceIntRec(stuff->modifier_device);
if (mdev == NULL)
return BadDevice;
ret = dixLookupDevice(&mdev, stuff->modifier_device, client,
DixReadAccess);
if (ret != Success)
return ret;
if (mdev->key == NULL)
return BadMatch;
} else

View File

@ -59,7 +59,6 @@ SOFTWARE.
#include "inputstr.h" /* DeviceIntPtr */
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "extinit.h" /* LookupDeviceIntRec */
#include "exevents.h"
#include "exglobals.h"
@ -96,7 +95,7 @@ ProcXGetDeviceMotionEvents(ClientPtr client)
INT32 *coords = NULL, *bufptr;
xGetDeviceMotionEventsReply rep;
unsigned long i;
int num_events, axes, size = 0, tsize;
int rc, num_events, axes, size = 0, tsize;
unsigned long nEvents;
DeviceIntPtr dev;
TimeStamp start, stop;
@ -106,9 +105,9 @@ ProcXGetDeviceMotionEvents(ClientPtr client)
REQUEST(xGetDeviceMotionEventsReq);
REQUEST_SIZE_MATCH(xGetDeviceMotionEventsReq);
dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL)
return BadDevice;
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixReadAccess);
if (rc != Success)
return rc;
v = dev->valuator;
if (v == NULL || v->numAxes == 0)
return BadMatch;

View File

@ -63,8 +63,8 @@ SOFTWARE.
#include <X11/extensions/XIproto.h>
#include "XIstubs.h"
#include "extnsionst.h"
#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h" /* FIXME */
#include "xace.h"
#include "listdev.h"
@ -310,7 +310,7 @@ ProcXListInputDevices(ClientPtr client)
xListInputDevicesReply rep;
int numdevs = 0;
int namesize = 1; /* need 1 extra byte for strcpy */
int size = 0;
int rc, size = 0;
int total_length;
char *devbuf;
char *classbuf;
@ -329,10 +329,16 @@ ProcXListInputDevices(ClientPtr client)
AddOtherInputDevices();
for (d = inputInfo.devices; d; d = d->next) {
rc = XaceHook(XACE_DEVICE_ACCESS, client, d, DixGetAttrAccess);
if (rc != Success)
return rc;
SizeDeviceInfo(d, &namesize, &size);
numdevs++;
}
for (d = inputInfo.off_devices; d; d = d->next) {
rc = XaceHook(XACE_DEVICE_ACCESS, client, d, DixGetAttrAccess);
if (rc != Success)
return rc;
SizeDeviceInfo(d, &namesize, &size);
numdevs++;
}

View File

@ -61,7 +61,6 @@ SOFTWARE.
#include <X11/extensions/XIproto.h>
#include "XIstubs.h"
#include "windowstr.h" /* window structure */
#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h"
#include "opendev.h"
@ -107,13 +106,15 @@ ProcXOpenDevice(ClientPtr client)
stuff->deviceid == inputInfo.keyboard->id)
return BadDevice;
if ((dev = LookupDeviceIntRec(stuff->deviceid)) == NULL) { /* not open */
status = dixLookupDevice(&dev, stuff->deviceid, client, DixReadAccess);
if (status == BadDevice) { /* not open */
for (dev = inputInfo.off_devices; dev; dev = dev->next)
if (dev->id == stuff->deviceid)
break;
if (dev == NULL)
return BadDevice;
}
} else if (status != Success)
return status;
OpenInputDevice(dev, client, &status);
if (status != Success)

View File

@ -42,7 +42,6 @@ from The Open Group.
#include "windowstr.h" /* window structure */
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "extinit.h" /* LookupDeviceIntRec */
#include "exevents.h"
#include "exglobals.h"
@ -74,7 +73,7 @@ int
ProcXQueryDeviceState(ClientPtr client)
{
char n;
int i;
int rc, i;
int num_classes = 0;
int total_length = 0;
char *buf, *savbuf;
@ -96,9 +95,9 @@ ProcXQueryDeviceState(ClientPtr client)
rep.length = 0;
rep.sequenceNumber = client->sequence;
dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL)
return BadDevice;
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixReadAccess);
if (rc != Success)
return rc;
v = dev->valuator;
if (v != NULL && v->motionHintWindow != NULL)

View File

@ -61,7 +61,6 @@ SOFTWARE.
#include "windowstr.h" /* window structure */
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "extinit.h" /* LookupDeviceIntRec */
#include "exevents.h"
#include "exglobals.h"
@ -164,7 +163,7 @@ ProcXSelectExtensionEvent(ClientPtr client)
if (stuff->length != (sizeof(xSelectExtensionEventReq) >> 2) + stuff->count)
return BadLength;
ret = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess);
ret = dixLookupWindow(&pWin, stuff->window, client, DixReceiveAccess);
if (ret != Success)
return ret;

View File

@ -59,9 +59,9 @@ SOFTWARE.
#include "inputstr.h" /* DeviceIntPtr */
#include "windowstr.h" /* Window */
#include "extnsionst.h" /* EventSwapPtr */
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "extinit.h" /* LookupDeviceIntRec */
#include "exevents.h"
#include "exglobals.h"
@ -131,9 +131,9 @@ ProcXSendExtensionEvent(ClientPtr client)
(stuff->num_events * (sizeof(xEvent) >> 2)))
return BadLength;
dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL)
return BadDevice;
ret = dixLookupDevice(&dev, stuff->deviceid, client, DixWriteAccess);
if (ret != Success)
return ret;
/* The client's event type must be one defined by an extension. */

View File

@ -63,7 +63,6 @@ SOFTWARE.
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "exevents.h"
#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h"
#include "setbmap.h"
@ -110,9 +109,9 @@ ProcXSetDeviceButtonMapping(ClientPtr client)
rep.sequenceNumber = client->sequence;
rep.status = MappingSuccess;
dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL)
return BadDevice;
ret = dixLookupDevice(&dev, stuff->deviceid, client, DixSetAttrAccess);
if (ret != Success)
return ret;
ret = SetButtonMapping(client, dev, stuff->map_length, (BYTE *) & stuff[1]);

View File

@ -60,7 +60,6 @@ SOFTWARE.
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "XIstubs.h"
#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h"
#include "setdval.h"
@ -92,6 +91,7 @@ ProcXSetDeviceValuators(ClientPtr client)
{
DeviceIntPtr dev;
xSetDeviceValuatorsReply rep;
int rc;
REQUEST(xSetDeviceValuatorsReq);
REQUEST_AT_LEAST_SIZE(xSetDeviceValuatorsReq);
@ -106,9 +106,9 @@ ProcXSetDeviceValuators(ClientPtr client)
stuff->num_valuators)
return BadLength;
dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL)
return BadDevice;
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixSetAttrAccess);
if (rc != Success)
return rc;
if (dev->valuator == NULL)
return BadMatch;

View File

@ -63,7 +63,6 @@ SOFTWARE.
#include "dixevents.h"
#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h"
#include "setfocus.h"
@ -102,8 +101,10 @@ ProcXSetDeviceFocus(ClientPtr client)
REQUEST(xSetDeviceFocusReq);
REQUEST_SIZE_MATCH(xSetDeviceFocusReq);
dev = LookupDeviceIntRec(stuff->device);
if (dev == NULL || !dev->focus)
ret = dixLookupDevice(&dev, stuff->device, client, DixSetFocusAccess);
if (ret != Success)
return ret;
if (!dev->focus)
return BadDevice;
ret = SetInputFocus(client, dev, stuff->focus, stuff->revertTo,

View File

@ -60,7 +60,6 @@ SOFTWARE.
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "exevents.h"
#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h"
#include "setmmap.h"
@ -99,9 +98,9 @@ ProcXSetDeviceModifierMapping(ClientPtr client)
REQUEST(xSetDeviceModifierMappingReq);
REQUEST_AT_LEAST_SIZE(xSetDeviceModifierMappingReq);
dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL)
return BadDevice;
ret = dixLookupDevice(&dev, stuff->deviceid, client, DixSetAttrAccess);
if (ret != Success)
return ret;
rep.repType = X_Reply;
rep.RepType = X_SetDeviceModifierMapping;

View File

@ -60,7 +60,6 @@ SOFTWARE.
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "XIstubs.h"
#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h"
#include "setmode.h"
@ -92,6 +91,7 @@ ProcXSetDeviceMode(ClientPtr client)
{
DeviceIntPtr dev;
xSetDeviceModeReply rep;
int rc;
REQUEST(xSetDeviceModeReq);
REQUEST_SIZE_MATCH(xSetDeviceModeReq);
@ -101,9 +101,9 @@ ProcXSetDeviceMode(ClientPtr client)
rep.length = 0;
rep.sequenceNumber = client->sequence;
dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL)
return BadDevice;
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixSetAttrAccess);
if (rc != Success)
return rc;
if (dev->valuator == NULL)
return BadMatch;
if ((dev->grab) && !SameClient(dev->grab, client))

View File

@ -65,6 +65,7 @@ SOFTWARE.
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "XIstubs.h"
#include "xace.h"
/***********************************************************************
*
@ -153,6 +154,7 @@ AddOtherInputDevices(void)
void
OpenInputDevice(DeviceIntPtr dev, ClientPtr client, int *status)
{
*status = XaceHook(XACE_DEVICE_ACCESS, client, dev, DixReadAccess);
}
/****************************************************************************

View File

@ -59,7 +59,6 @@ SOFTWARE.
#include "inputstr.h" /* DeviceIntPtr */
#include "windowstr.h" /* window structure */
#include <X11/extensions/XIproto.h>
#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h"
#include "ungrdev.h"
@ -94,13 +93,14 @@ ProcXUngrabDevice(ClientPtr client)
DeviceIntPtr dev;
GrabPtr grab;
TimeStamp time;
int rc;
REQUEST(xUngrabDeviceReq);
REQUEST_SIZE_MATCH(xUngrabDeviceReq);
dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL)
return BadDevice;
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixGetAttrAccess);
if (rc != Success)
return rc;
grab = dev->grab;
time = ClientTimeToServerTime(stuff->time);

View File

@ -60,7 +60,6 @@ SOFTWARE.
#include "windowstr.h" /* window structure */
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h"
#include "dixgrabs.h"
@ -107,22 +106,23 @@ ProcXUngrabDeviceButton(ClientPtr client)
REQUEST(xUngrabDeviceButtonReq);
REQUEST_SIZE_MATCH(xUngrabDeviceButtonReq);
dev = LookupDeviceIntRec(stuff->grabbed_device);
if (dev == NULL)
return BadDevice;
rc = dixLookupDevice(&dev, stuff->grabbed_device, client, DixGrabAccess);
if (rc != Success)
return rc;
if (dev->button == NULL)
return BadMatch;
if (stuff->modifier_device != UseXKeyboard) {
mdev = LookupDeviceIntRec(stuff->modifier_device);
if (mdev == NULL)
rc = dixLookupDevice(&mdev, stuff->modifier_device, client,
DixReadAccess);
if (rc != Success)
return BadDevice;
if (mdev->key == NULL)
return BadMatch;
} else
mdev = (DeviceIntPtr) LookupKeyboardDevice();
rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixUnknownAccess);
rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixSetAttrAccess);
if (rc != Success)
return rc;

View File

@ -60,7 +60,6 @@ SOFTWARE.
#include "windowstr.h" /* window structure */
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h"
#include "dixgrabs.h"
@ -107,22 +106,23 @@ ProcXUngrabDeviceKey(ClientPtr client)
REQUEST(xUngrabDeviceKeyReq);
REQUEST_SIZE_MATCH(xUngrabDeviceKeyReq);
dev = LookupDeviceIntRec(stuff->grabbed_device);
if (dev == NULL)
return BadDevice;
rc = dixLookupDevice(&dev, stuff->grabbed_device, client, DixGrabAccess);
if (rc != Success)
return rc;
if (dev->key == NULL)
return BadMatch;
if (stuff->modifier_device != UseXKeyboard) {
mdev = LookupDeviceIntRec(stuff->modifier_device);
if (mdev == NULL)
rc = dixLookupDevice(&mdev, stuff->modifier_device, client,
DixReadAccess);
if (rc != Success)
return BadDevice;
if (mdev->key == NULL)
return BadMatch;
} else
mdev = (DeviceIntPtr) LookupKeyboardDevice();
rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixUnknownAccess);
rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixSetAttrAccess);
if (rc != Success)
return rc;

View File

@ -213,7 +213,7 @@ remove_device(DBusMessage *message, DBusMessage *reply, DBusError *error)
MALFORMED_MESSAGE_ERROR();
}
dev = LookupDeviceIntRec(deviceid);
dixLookupDevice(&dev, deviceid, serverClient, DixUnknownAccess);
if (!dev) {
DebugF("[config/dbus] bogus device id %d given\n", deviceid);
ret = BadMatch;

View File

@ -717,20 +717,28 @@ LookupPointerDevice(void)
return inputInfo.pointer ? &inputInfo.pointer->public : NULL;
}
DevicePtr
LookupDevice(int id)
int
dixLookupDevice(DeviceIntPtr *pDev, int id, ClientPtr client, Mask access_mode)
{
DeviceIntPtr dev;
int rc;
*pDev = NULL;
for (dev=inputInfo.devices; dev; dev=dev->next) {
if (dev->id == (CARD8)id)
return (DevicePtr)dev;
goto found;
}
for (dev=inputInfo.off_devices; dev; dev=dev->next) {
if (dev->id == (CARD8)id)
return (DevicePtr)dev;
goto found;
}
return NULL;
return BadDevice;
found:
rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, access_mode);
if (rc == Success)
*pDev = dev;
return rc;
}
void

View File

@ -82,7 +82,6 @@
#ifdef XINPUT
#include <X11/extensions/XIproto.h>
#define EXTENSION_PROC_ARGS void *
#include "extinit.h" /* For LookupDeviceIntRec */
#endif
#if DMX_EQ_DEBUG
@ -217,8 +216,9 @@ static void dmxeqProcessXInputEvent(xEvent *xe, EventRec *e)
{
deviceKeyButtonPointer *ev = (deviceKeyButtonPointer *)xe;
int id = ev->deviceid & DEVICE_BITS;
DeviceIntPtr pDevice = LookupDeviceIntRec(id);
DeviceIntPtr pDevice;
dixLookupDevice(&pDevice, id, serverClient, DixUnknownAccess);
if (!pDevice) {
dmxLog(dmxError, "dmxeqProcessInputEvents: id %d not found\n", id);
return;

View File

@ -77,7 +77,6 @@
#define EXTENSION_PROC_ARGS void *
#include "extnsionst.h"
#include "extinit.h" /* LookupDeviceIntRec */
#include "windowstr.h" /* screenIsSaved */

View File

@ -44,9 +44,4 @@ AssignTypeAndName (
char * /* name */
);
DeviceIntPtr
LookupDeviceIntRec (
CARD8 /* id */
);
#endif /* EXTINIT_H */

View File

@ -201,8 +201,11 @@ extern DevicePtr LookupKeyboardDevice(void);
extern DevicePtr LookupPointerDevice(void);
extern DevicePtr LookupDevice(
int /* id */);
extern int dixLookupDevice(
DeviceIntPtr * /* dev */,
int /* id */,
ClientPtr /* client */,
Mask /* access_mode */);
extern void QueryMinMaxKeyCodes(
KeyCode* /*minCode*/,
@ -436,9 +439,6 @@ extern int GetMotionHistory(
extern void SwitchCoreKeyboard(DeviceIntPtr pDev);
extern void SwitchCorePointer(DeviceIntPtr pDev);
extern DeviceIntPtr LookupDeviceIntRec(
CARD8 deviceid);
/* Implemented by the DDX. */
extern int NewInputDeviceRequest(
InputOption *options,

View File

@ -65,7 +65,7 @@ DeviceIntPtr dev = NULL;
if (id&(~0xff))
dev = NULL;
dev= (DeviceIntPtr)LookupDevice(id);
dixLookupDevice(&dev, id, serverClient, DixUnknownAccess);
if (dev!=NULL)
return dev;
if ((!dev)&&(why_rtrn))