summaryrefslogtreecommitdiff
path: root/Xi
diff options
context:
space:
mode:
Diffstat (limited to 'Xi')
-rw-r--r--Xi/allowev.c8
-rw-r--r--Xi/chaccess.c23
-rw-r--r--Xi/chdevcur.c19
-rw-r--r--Xi/chdevhier.c59
-rw-r--r--Xi/chgdctl.c7
-rw-r--r--Xi/chgfctl.c8
-rw-r--r--Xi/chgkmap.c7
-rw-r--r--Xi/chgprop.c3
-rw-r--r--Xi/chgptr.c2
-rw-r--r--Xi/closedev.c9
-rw-r--r--Xi/devbell.c9
-rw-r--r--Xi/exevents.c50
-rw-r--r--Xi/extgrbdev.c11
-rw-r--r--Xi/extinit.c25
-rw-r--r--Xi/fakedevdata.c10
-rw-r--r--Xi/getbmap.c8
-rw-r--r--Xi/getdctl.c17
-rw-r--r--Xi/getfctl.c9
-rw-r--r--Xi/getfocus.c8
-rw-r--r--Xi/getkmap.c8
-rw-r--r--Xi/getmmap.c8
-rw-r--r--Xi/getpairp.c13
-rw-r--r--Xi/getprop.c3
-rw-r--r--Xi/getselev.c3
-rw-r--r--Xi/getvers.c1
-rw-r--r--Xi/grabdev.c15
-rw-r--r--Xi/grabdevb.c21
-rw-r--r--Xi/grabdevk.c21
-rw-r--r--Xi/gtmotion.c9
-rw-r--r--Xi/listdev.c10
-rw-r--r--Xi/opendev.c7
-rw-r--r--Xi/querydp.c14
-rw-r--r--Xi/queryst.c9
-rw-r--r--Xi/selectev.c3
-rw-r--r--Xi/sendexev.c8
-rw-r--r--Xi/setbmap.c7
-rw-r--r--Xi/setcptr.c13
-rw-r--r--Xi/setdval.c8
-rw-r--r--Xi/setfocus.c7
-rw-r--r--Xi/setmmap.c7
-rw-r--r--Xi/setmode.c8
-rw-r--r--Xi/stubs.c2
-rw-r--r--Xi/ungrdev.c8
-rw-r--r--Xi/ungrdevb.c14
-rw-r--r--Xi/ungrdevk.c14
-rw-r--r--Xi/warpdevp.c12
-rw-r--r--Xi/xiselev.c2
47 files changed, 285 insertions, 262 deletions
diff --git a/Xi/allowev.c b/Xi/allowev.c
index 12aeab3a9..36b6caad5 100644
--- a/Xi/allowev.c
+++ b/Xi/allowev.c
@@ -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) {
diff --git a/Xi/chaccess.c b/Xi/chaccess.c
index 9baa871d4..872612e47 100644
--- a/Xi/chaccess.c
+++ b/Xi/chaccess.c
@@ -40,7 +40,6 @@ from the author.
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "extnsionst.h"
-#include "extinit.h" /* LookupDeviceIntRec */
#include "exevents.h"
#include "exglobals.h"
@@ -119,13 +118,12 @@ ProcXChangeWindowAccess(ClientPtr client)
/* if one of the devices cannot be accessed, we don't do anything.*/
for (i = 0; i < stuff->npermit; i++)
{
- perm_devices[i] = LookupDeviceIntRec(deviceids[i]);
- if (!perm_devices[i])
+ err = dixLookupDevice(&perm_devices[i], deviceids[i], client,
+ DixWriteAccess);
+ if (err != Success)
{
xfree(perm_devices);
- SendErrorToClient(client, IReqCode, X_ChangeWindowAccess,
- deviceids[i], BadDevice);
- return Success;
+ return err;
}
}
}
@@ -146,16 +144,15 @@ ProcXChangeWindowAccess(ClientPtr client)
for (i = 0; i < stuff->ndeny; i++)
{
- deny_devices[i] =
- LookupDeviceIntRec(deviceids[i+stuff->npermit]);
-
- if (!deny_devices[i])
+ err = dixLookupDevice(&deny_devices[i],
+ deviceids[i+stuff->npermit],
+ client,
+ DixWriteAccess);
+ if (err != Success)
{
xfree(perm_devices);
xfree(deny_devices);
- SendErrorToClient(client, IReqCode, X_ChangeWindowAccess,
- deviceids[i + stuff->npermit], BadDevice);
- return Success;
+ return err;
}
}
}
diff --git a/Xi/chdevcur.c b/Xi/chdevcur.c
index dfa45ee57..0baee58ba 100644
--- a/Xi/chdevcur.c
+++ b/Xi/chdevcur.c
@@ -46,9 +46,9 @@ from the author.
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "extnsionst.h"
-#include "extinit.h" /* LookupDeviceIntRec */
#include "exevents.h"
#include "exglobals.h"
+#include "input.h"
#include "chdevcur.h"
@@ -79,22 +79,15 @@ int ProcXChangeDeviceCursor(ClientPtr client)
REQUEST(xChangeDeviceCursorReq);
REQUEST_SIZE_MATCH(xChangeDeviceCursorReq);
- pDev = LookupDeviceIntRec(stuff->deviceid);
- if (pDev == NULL) {
- SendErrorToClient(client, IReqCode, X_ChangeDeviceCursor, 0,
- BadDevice);
- return Success;
- }
+ err = dixLookupDevice(&pDev, stuff->deviceid, client, DixSetAttrAccess);
+ if (err != Success)
+ return err;
if (stuff->win != None)
{
- err = dixLookupWindow(&pWin, stuff->win, client, DixReadWriteAccess);
+ err = dixLookupWindow(&pWin, stuff->win, client, DixSetAttrAccess);
if (err != Success)
- {
- SendErrorToClient(client, IReqCode, X_ChangeDeviceCursor,
- stuff->win, err);
- return Success;
- }
+ return err;
}
if (stuff->cursor == None)
diff --git a/Xi/chdevhier.c b/Xi/chdevhier.c
index ac912f75c..0b2e3f1ab 100644
--- a/Xi/chdevhier.c
+++ b/Xi/chdevhier.c
@@ -49,7 +49,6 @@ from the author.
#include <X11/extensions/XIproto.h>
#include <X11/extensions/geproto.h>
#include "extnsionst.h"
-#include "extinit.h" /* LookupDeviceIntRec */
#include "exevents.h"
#include "exglobals.h"
#include "geext.h"
@@ -83,6 +82,7 @@ ProcXChangeDeviceHierarchy(ClientPtr client)
xAnyHierarchyChangeInfo *any;
int required_len = sizeof(xChangeDeviceHierarchyReq);
char n;
+ int rc;
deviceHierarchyChangedEvent ev;
REQUEST(xChangeDeviceHierarchyReq);
@@ -142,9 +142,16 @@ ProcXChangeDeviceHierarchy(ClientPtr client)
r->returnMode != Floating)
return BadValue;
- ptr = LookupDeviceIntRec(r->deviceid);
- if (!ptr || !ptr->isMaster)
+ rc = dixLookupDevice(&ptr, r->deviceid, client,
+ DixWriteAccess);
+ if (rc != Success)
+ return rc;
+
+ if (!ptr->isMaster)
+ {
+ client->errorValue = r->deviceid;
return BadDevice;
+ }
/* XXX: For now, don't allow removal of VCP, VCK */
if (ptr == inputInfo.pointer ||
@@ -168,11 +175,27 @@ ProcXChangeDeviceHierarchy(ClientPtr client)
newptr,
newkeybd;
- newptr = LookupDeviceIntRec(r->returnPointer);
- newkeybd = LookupDeviceIntRec(r->returnKeyboard);
- if (!newptr || !newptr->isMaster ||
- !newkeybd || !newkeybd->isMaster)
+ rc = dixLookupDevice(&newptr, r->returnPointer,
+ client, DixWriteAccess);
+ if (rc != Success)
+ return rc;
+
+ if (!newptr->isMaster)
+ {
+ client->errorValue = r->returnPointer;
+ return BadDevice;
+ }
+
+ rc = dixLookupDevice(&newkeybd, r->returnKeyboard,
+ client, DixWriteAccess);
+ if (rc != Success)
+ return rc;
+
+ if (!newkeybd->isMaster)
+ {
+ client->errorValue = r->returnKeyboard;
return BadDevice;
+ }
for (attached = inputInfo.devices;
attached;
@@ -201,17 +224,31 @@ ProcXChangeDeviceHierarchy(ClientPtr client)
{
xChangeAttachmentInfo* c = (xChangeAttachmentInfo*)any;
- ptr = LookupDeviceIntRec(c->deviceid);
- if (!ptr || ptr->isMaster)
+ rc = dixLookupDevice(&ptr, c->deviceid, client,
+ DixWriteAccess);
+ if (rc != Success)
+ return rc;
+
+ if (ptr->isMaster)
+ {
+ client->errorValue = c->deviceid;
return BadDevice;
+ }
if (c->changeMode == Floating)
AttachDevice(client, ptr, NULL);
else
{
- DeviceIntPtr newmaster = LookupDeviceIntRec(c->newMaster);
- if (!newmaster || !newmaster->isMaster)
+ DeviceIntPtr newmaster;
+ rc = dixLookupDevice(&newmaster, c->newMaster,
+ client, DixWriteAccess);
+ if (rc != Success)
+ return rc;
+ if (!newmaster->isMaster)
+ {
+ client->errorValue = c->newMaster;
return BadDevice;
+ }
if ((IsPointerDevice(newmaster) &&
!IsPointerDevice(ptr)) ||
diff --git a/Xi/chgdctl.c b/Xi/chgdctl.c
index 8aef00db2..937bb38e4 100644
--- a/Xi/chgdctl.c
+++ b/Xi/chgdctl.c
@@ -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;
diff --git a/Xi/chgfctl.c b/Xi/chgfctl.c
index 46bb8e78f..8fc24d5ff 100644
--- a/Xi/chgfctl.c
+++ b/Xi/chgfctl.c
@@ -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:
diff --git a/Xi/chgkmap.c b/Xi/chgkmap.c
index bfdc1cedc..3361e9801 100644
--- a/Xi/chgkmap.c
+++ b/Xi/chgkmap.c
@@ -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,
diff --git a/Xi/chgprop.c b/Xi/chgprop.c
index 13463dd1c..58db88620 100644
--- a/Xi/chgprop.c
+++ b/Xi/chgprop.c
@@ -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;
diff --git a/Xi/chgptr.c b/Xi/chgptr.c
index 2ce81d1d6..28950918f 100644
--- a/Xi/chgptr.c
+++ b/Xi/chgptr.c
@@ -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"
diff --git a/Xi/closedev.c b/Xi/closedev.c
index f9a0f4f48..4c593ec2f 100644
--- a/Xi/closedev.c
+++ b/Xi/closedev.c
@@ -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->deviceGrab.grab && SameClient(d->deviceGrab.grab, client))
(*d->deviceGrab.DeactivateGrab) (d); /* release active grab */
diff --git a/Xi/devbell.c b/Xi/devbell.c
index 83e844d93..264f64800 100644
--- a/Xi/devbell.c
+++ b/Xi/devbell.c
@@ -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) {
diff --git a/Xi/exevents.c b/Xi/exevents.c
index f0d288ff4..e577e3b25 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -68,12 +68,12 @@ 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 "listdev.h" /* for CopySwapXXXClass */
+#include "xace.h"
#ifdef XKB
#include <X11/extensions/XKBproto.h>
@@ -144,7 +144,8 @@ CopyKeyClass(DeviceIntPtr device, DeviceIntPtr master)
dk = device->key;
mk = master->key;
- if (master->devPrivates[CoreDevicePrivatesIndex].ptr != device) {
+ if (device != dixLookupPrivate(&master->devPrivates,
+ CoreDevicePrivateKey)) {
memcpy(mk->modifierMap, dk->modifierMap, MAP_LENGTH);
if (dk->maxKeysPerModifier)
@@ -189,7 +190,7 @@ CopyKeyClass(DeviceIntPtr device, DeviceIntPtr master)
}
#endif
- master->devPrivates[CoreDevicePrivatesIndex].ptr = device;
+ dixSetPrivate(&master->devPrivates, CoreDevicePrivateKey, device);
sendNotify = TRUE;
} else if (lastMapNotifyDevice != master)
sendNotify = TRUE;
@@ -695,7 +696,7 @@ ProcessOtherEvent(xEventPtr xE, DeviceIntPtr device, int count)
(key == device->deviceGrab.activatingKey))
deactivateDeviceGrab = TRUE;
} else if (xE->u.u.type == DeviceButtonPress) {
- xE->u.u.detail = b->map[key];
+ xE->u.u.detail = key;
if (xE->u.u.detail == 0)
return;
if (!grab)
@@ -712,7 +713,7 @@ ProcessOtherEvent(xEventPtr xE, DeviceIntPtr device, int count)
}
} else if (xE->u.u.type == DeviceButtonRelease) {
- xE->u.u.detail = b->map[key];
+ xE->u.u.detail = key;
if (xE->u.u.detail == 0)
return;
if (!b->state && device->deviceGrab.fromPassiveGrab)
@@ -970,6 +971,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) &&
@@ -990,25 +992,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,
@@ -1016,7 +1026,7 @@ GrabButton(ClientPtr client, DeviceIntPtr dev, BYTE this_device_mode,
DeviceButtonPress, button, confineTo, cursor);
if (!grab)
return BadAlloc;
- return AddPassiveGrabToList(grab);
+ return AddPassiveGrabToList(client, grab);
}
int
@@ -1028,6 +1038,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)
@@ -1055,7 +1066,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;
@@ -1065,7 +1081,7 @@ GrabKey(ClientPtr client, DeviceIntPtr dev, BYTE this_device_mode,
NullWindow, NullCursor);
if (!grab)
return BadAlloc;
- return AddPassiveGrabToList(grab);
+ return AddPassiveGrabToList(client, grab);
}
int
@@ -1296,7 +1312,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(d, pWin, ev, count, mask, NullGrab, d->id));
return Success;
}
@@ -1560,7 +1576,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;
@@ -1584,7 +1601,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;
diff --git a/Xi/extgrbdev.c b/Xi/extgrbdev.c
index 7cafdbaab..7738f1555 100644
--- a/Xi/extgrbdev.c
+++ b/Xi/extgrbdev.c
@@ -47,7 +47,6 @@ from the author.
#include <X11/extensions/XIproto.h>
#include <X11/extensions/Xge.h>
#include "extnsionst.h"
-#include "extinit.h" /* LookupDeviceIntRec */
#include "exevents.h"
#include "exglobals.h"
@@ -127,10 +126,8 @@ ProcXExtendedGrabDevice(ClientPtr client)
goto cleanup;
}
- dev = LookupDeviceIntRec(stuff->deviceid);
- if (dev == NULL) {
- errval = stuff->deviceid;
- err = BadDevice;
+ err = dixLookupDevice(&dev, stuff->deviceid, client, DixGrabAccess);
+ if (err != Success) {
goto cleanup;
}
@@ -224,9 +221,7 @@ cleanup:
}
else
{
- SendErrorToClient(client, IReqCode,
- X_ExtendedGrabDevice,
- errval, err);
+ return err;
}
return Success;
}
diff --git a/Xi/extinit.c b/Xi/extinit.c
index cc75d23f4..6aa1ece29 100644
--- a/Xi/extinit.c
+++ b/Xi/extinit.c
@@ -71,6 +71,7 @@ SOFTWARE.
#include "extinit.h"
#include "exglobals.h"
#include "swaprep.h"
+#include "registry.h"
/* modules local to Xi */
#include "allowev.h"
@@ -1099,29 +1100,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
@@ -1239,6 +1217,7 @@ XInputExtensionInit(void)
AllExtensionVersions[IReqCode - 128] = thisversion;
MakeDeviceTypeAtoms();
RT_INPUTCLIENT = CreateNewResourceType((DeleteType) InputClientGone);
+ RegisterResourceName(RT_INPUTCLIENT, "INPUTCLIENT");
FixExtensionEvents(extEntry);
ReplySwapVector[IReqCode] = (ReplySwapPtr) SReplyIDispatch;
EventSwapVector[DeviceValuator] = SEventIDispatch;
diff --git a/Xi/fakedevdata.c b/Xi/fakedevdata.c
index 2ebb7c38c..7f2d3ec4e 100644
--- a/Xi/fakedevdata.c
+++ b/Xi/fakedevdata.c
@@ -46,7 +46,6 @@ from the author.
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "extnsionst.h"
-#include "extinit.h" /* LookupDeviceIntRec */
#include "exevents.h"
#include "exglobals.h"
#include "mi.h"
@@ -80,6 +79,7 @@ ProcXFakeDeviceData(ClientPtr client)
DeviceIntPtr dev;
int nevents, i;
int* valuators = NULL;
+ int rc;
REQUEST(xFakeDeviceDataReq);
REQUEST_AT_LEAST_SIZE(xFakeDeviceDataReq);
@@ -90,11 +90,9 @@ ProcXFakeDeviceData(ClientPtr client)
return Success;
}
- dev = LookupDeviceIntRec(stuff->deviceid);
- if (dev == NULL) {
- SendErrorToClient(client, IReqCode, X_FakeDeviceData, 0, BadDevice);
- return Success;
- }
+ rc = dixLookupDevice(&dev, stuff->deviceid, client, DixWriteAccess);
+ if (rc != Success)
+ return rc;
if (!fake_events && !(fake_events = InitEventList(GetMaximumEventsNum())))
{
diff --git a/Xi/getbmap.c b/Xi/getbmap.c
index ebb0613af..9f93b06ef 100644
--- a/Xi/getbmap.c
+++ b/Xi/getbmap.c
@@ -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)
diff --git a/Xi/getdctl.c b/Xi/getdctl.c
index 7175dc253..c979959e2 100644
--- a/Xi/getdctl.c
+++ b/Xi/getdctl.c
@@ -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;
@@ -266,19 +265,19 @@ ProcXGetDeviceControl(ClientPtr client)
if (!dev->absolute)
return BadMatch;
- total_length = sizeof(xDeviceAbsCalibCtl);
+ total_length = sizeof(xDeviceAbsCalibState);
break;
case DEVICE_ABS_AREA:
if (!dev->absolute)
return BadMatch;
- total_length = sizeof(xDeviceAbsAreaCtl);
+ total_length = sizeof(xDeviceAbsAreaState);
break;
case DEVICE_CORE:
- total_length = sizeof(xDeviceCoreCtl);
+ total_length = sizeof(xDeviceCoreState);
break;
case DEVICE_ENABLE:
- total_length = sizeof(xDeviceEnableCtl);
+ total_length = sizeof(xDeviceEnableState);
break;
default:
return BadValue;
diff --git a/Xi/getfctl.c b/Xi/getfctl.c
index 7dff32f4f..1b1e594a2 100644
--- a/Xi/getfctl.c
+++ b/Xi/getfctl.c
@@ -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;
diff --git a/Xi/getfocus.c b/Xi/getfocus.c
index 073913bf2..dfef22fb7 100644
--- a/Xi/getfocus.c
+++ b/Xi/getfocus.c
@@ -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;
diff --git a/Xi/getkmap.c b/Xi/getkmap.c
index eaa0cffcc..0eec1d8df 100644
--- a/Xi/getkmap.c
+++ b/Xi/getkmap.c
@@ -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;
diff --git a/Xi/getmmap.c b/Xi/getmmap.c
index 8a99d63ed..c6c9c3362 100644
--- a/Xi/getmmap.c
+++ b/Xi/getmmap.c
@@ -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)
diff --git a/Xi/getpairp.c b/Xi/getpairp.c
index 1833a00e1..59ed18909 100644
--- a/Xi/getpairp.c
+++ b/Xi/getpairp.c
@@ -37,7 +37,6 @@ from the author.
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "extnsionst.h"
-#include "extinit.h" /* LookupDeviceIntRec */
#include "exevents.h"
#include "exglobals.h"
@@ -68,15 +67,17 @@ ProcXGetPairedPointer(ClientPtr client)
{
xGetPairedPointerReply rep;
DeviceIntPtr kbd, ptr;
+ int rc;
REQUEST(xGetPairedPointerReq);
REQUEST_SIZE_MATCH(xGetPairedPointerReq);
- kbd = LookupDeviceIntRec(stuff->deviceid);
- if (!kbd || !kbd->key || !kbd->isMaster) {
- SendErrorToClient(client, IReqCode, X_GetPairedPointer,
- stuff->deviceid, BadDevice);
- return Success;
+ rc = dixLookupDevice(&kbd, stuff->deviceid, client, DixReadAccess);
+ if (rc != Success)
+ return rc;
+ else if (!kbd->key || !kbd->isMaster) {
+ client->errorValue = stuff->deviceid;
+ return BadDevice;
}
ptr = GetPairedDevice(kbd);
diff --git a/Xi/getprop.c b/Xi/getprop.c
index 531e65f27..188f549e5 100644
--- a/Xi/getprop.c
+++ b/Xi/getprop.c
@@ -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;
diff --git a/Xi/getselev.c b/Xi/getselev.c
index 819b2dbd0..caa376fcb 100644
--- a/Xi/getselev.c
+++ b/Xi/getselev.c
@@ -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;
diff --git a/Xi/getvers.c b/Xi/getvers.c
index a223a5d1e..a4afe808f 100644
--- a/Xi/getvers.c
+++ b/Xi/getvers.c
@@ -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"
diff --git a/Xi/grabdev.c b/Xi/grabdev.c
index a963aa4a1..fe58d565f 100644
--- a/Xi/grabdev.c
+++ b/Xi/grabdev.c
@@ -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,
@@ -171,7 +170,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;
@@ -185,8 +184,10 @@ CreateMaskFromList(ClientPtr client, XEventClass * list, int count,
if (device > 255) /* FIXME: we only use 7 bit for devices? */
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++)
diff --git a/Xi/grabdevb.c b/Xi/grabdevb.c
index 7ef8ad774..a28a4ed6b 100644
--- a/Xi/grabdevb.c
+++ b/Xi/grabdevb.c
@@ -61,8 +61,8 @@ SOFTWARE.
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "exevents.h"
-#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h"
+#include "xace.h"
#include "grabdev.h"
#include "grabdevb.h"
@@ -117,18 +117,23 @@ 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
+ } else {
mdev = PickKeyboard(client);
+ ret = XaceHook(XACE_DEVICE_ACCESS, client, mdev, DixReadAccess);
+ if (ret != Success)
+ return ret;
+ }
class = (XEventClass *) (&stuff[1]); /* first word of values */
diff --git a/Xi/grabdevk.c b/Xi/grabdevk.c
index d38c053f0..238718bbb 100644
--- a/Xi/grabdevk.c
+++ b/Xi/grabdevk.c
@@ -61,8 +61,8 @@ SOFTWARE.
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "exevents.h"
-#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h"
+#include "xace.h"
#include "grabdev.h"
#include "grabdevk.h"
@@ -115,18 +115,23 @@ 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
+ } else {
mdev = PickKeyboard(client);
+ ret = XaceHook(XACE_DEVICE_ACCESS, client, mdev, DixReadAccess);
+ if (ret != Success)
+ return ret;
+ }
class = (XEventClass *) (&stuff[1]); /* first word of values */
diff --git a/Xi/gtmotion.c b/Xi/gtmotion.c
index ad2bec391..4f4d7cb77 100644
--- a/Xi/gtmotion.c
+++ b/Xi/gtmotion.c
@@ -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;
diff --git a/Xi/listdev.c b/Xi/listdev.c
index a0be219f7..4aa2688dc 100644
--- a/Xi/listdev.c
+++ b/Xi/listdev.c
@@ -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"
@@ -319,7 +319,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;
@@ -338,10 +338,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++;
}
diff --git a/Xi/opendev.c b/Xi/opendev.c
index f869df285..f4c0066ec 100644
--- a/Xi/opendev.c
+++ b/Xi/opendev.c
@@ -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"
@@ -103,13 +102,15 @@ ProcXOpenDevice(ClientPtr client)
REQUEST(xOpenDeviceReq);
REQUEST_SIZE_MATCH(xOpenDeviceReq);
- 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)
diff --git a/Xi/querydp.c b/Xi/querydp.c
index 85b480279..629d8ef88 100644
--- a/Xi/querydp.c
+++ b/Xi/querydp.c
@@ -45,7 +45,6 @@ from the author.
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "extnsionst.h"
-#include "extinit.h" /* LookupDeviceIntRec */
#include "exevents.h"
#include "exglobals.h"
@@ -83,11 +82,14 @@ ProcXQueryDevicePointer(ClientPtr client)
REQUEST(xQueryDevicePointerReq);
REQUEST_SIZE_MATCH(xQueryDevicePointerReq);
- pDev = LookupDeviceIntRec(stuff->deviceid);
- if (pDev == NULL || pDev->valuator == NULL) {
- SendErrorToClient(client, IReqCode, X_QueryDevicePointer,
- stuff->deviceid, BadDevice);
- return Success;
+ rc = dixLookupDevice(&pDev, stuff->deviceid, client, DixReadAccess);
+ if (rc != Success)
+ return rc;
+
+ if (pDev->valuator == NULL)
+ {
+ client->errorValue = stuff->deviceid;
+ return BadDevice;
}
rc = dixLookupWindow(&pWin, stuff->win, client, DixReadAccess);
diff --git a/Xi/queryst.c b/Xi/queryst.c
index 2b66b7eb2..71ab79be8 100644
--- a/Xi/queryst.c
+++ b/Xi/queryst.c
@@ -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)
diff --git a/Xi/selectev.c b/Xi/selectev.c
index a5cf56754..b93618ace 100644
--- a/Xi/selectev.c
+++ b/Xi/selectev.c
@@ -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;
diff --git a/Xi/sendexev.c b/Xi/sendexev.c
index 12fe7d2cf..5acdb4761 100644
--- a/Xi/sendexev.c
+++ b/Xi/sendexev.c
@@ -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. */
diff --git a/Xi/setbmap.c b/Xi/setbmap.c
index 40f0f9a99..3035c649e 100644
--- a/Xi/setbmap.c
+++ b/Xi/setbmap.c
@@ -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]);
diff --git a/Xi/setcptr.c b/Xi/setcptr.c
index a3bd9c2ec..8dd71817f 100644
--- a/Xi/setcptr.c
+++ b/Xi/setcptr.c
@@ -48,7 +48,6 @@ from the author.
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "extnsionst.h"
-#include "extinit.h" /* LookupDeviceIntRec */
#include "exevents.h"
#include "exglobals.h"
@@ -77,8 +76,11 @@ ProcXSetClientPointer(ClientPtr client)
REQUEST_SIZE_MATCH(xSetClientPointerReq);
- pDev = LookupDeviceIntRec(stuff->deviceid);
- if (pDev == NULL || !IsPointerDevice(pDev) || !pDev->isMaster)
+ err = dixLookupDevice(&pDev, stuff->deviceid, client, DixWriteAccess);
+ if (err != Success)
+ return err;
+
+ if (!IsPointerDevice(pDev) || !pDev->isMaster)
{
client->errorValue = stuff->deviceid;
return BadDevice;
@@ -86,13 +88,14 @@ ProcXSetClientPointer(ClientPtr client)
if (stuff->win != None)
{
- err = dixLookupWindow(&pWin, stuff->win, client, DixReadWriteAccess);
+ err = dixLookupWindow(&pWin, stuff->win, client, DixWriteAccess);
if (err != Success)
{
/* window could not be found. maybe the window ID given was a pure
client id? */
+ /* XXX: Needs to be fixed for XACE */
err = dixLookupClient(&targetClient, stuff->win,
- client, DixReadWriteAccess);
+ client, DixWriteAccess);
if (err != Success)
{
client->errorValue = stuff->win;
diff --git a/Xi/setdval.c b/Xi/setdval.c
index bbab34e33..20584629a 100644
--- a/Xi/setdval.c
+++ b/Xi/setdval.c
@@ -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;
diff --git a/Xi/setfocus.c b/Xi/setfocus.c
index 74de17e97..c6edbc2e5 100644
--- a/Xi/setfocus.c
+++ b/Xi/setfocus.c
@@ -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,
diff --git a/Xi/setmmap.c b/Xi/setmmap.c
index 19ec71bbe..be3d3cb6c 100644
--- a/Xi/setmmap.c
+++ b/Xi/setmmap.c
@@ -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;
diff --git a/Xi/setmode.c b/Xi/setmode.c
index d8a569588..2badb5161 100644
--- a/Xi/setmode.c
+++ b/Xi/setmode.c
@@ -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->deviceGrab.grab) && !SameClient(dev->deviceGrab.grab, client))
diff --git a/Xi/stubs.c b/Xi/stubs.c
index 744447adc..d01927c73 100644
--- a/Xi/stubs.c
+++ b/Xi/stubs.c
@@ -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);
}
/****************************************************************************
diff --git a/Xi/ungrdev.c b/Xi/ungrdev.c
index 3b6b252b6..f6525a287 100644
--- a/Xi/ungrdev.c
+++ b/Xi/ungrdev.c
@@ -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->deviceGrab.grab;
time = ClientTimeToServerTime(stuff->time);
diff --git a/Xi/ungrdevb.c b/Xi/ungrdevb.c
index 46d325044..d1aef5f13 100644
--- a/Xi/ungrdevb.c
+++ b/Xi/ungrdevb.c
@@ -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 = PickKeyboard(client);
- rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixUnknownAccess);
+ rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixSetAttrAccess);
if (rc != Success)
return rc;
diff --git a/Xi/ungrdevk.c b/Xi/ungrdevk.c
index 7df4095c9..bc3ada987 100644
--- a/Xi/ungrdevk.c
+++ b/Xi/ungrdevk.c
@@ -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 = PickKeyboard(client);
- rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixUnknownAccess);
+ rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixSetAttrAccess);
if (rc != Success)
return rc;
diff --git a/Xi/warpdevp.c b/Xi/warpdevp.c
index 85fa7a902..24661d099 100644
--- a/Xi/warpdevp.c
+++ b/Xi/warpdevp.c
@@ -46,7 +46,6 @@ from the author.
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "extnsionst.h"
-#include "extinit.h" /* LookupDeviceIntRec */
#include "exevents.h"
#include "exglobals.h"
@@ -83,13 +82,10 @@ ProcXWarpDevicePointer(ClientPtr client)
/* FIXME: panoramix stuff is missing, look at ProcWarpPointer */
- pDev = LookupDeviceIntRec(stuff->deviceid);
- if (pDev == NULL) {
- SendErrorToClient(client, IReqCode, X_WarpDevicePointer,
- stuff->deviceid,
- BadDevice);
- return Success;
- }
+ err = dixLookupDevice(&pDev, stuff->deviceid, client, DixWriteAccess);
+
+ if (err != Success)
+ return err;
if (stuff->dst_win != None)
{
diff --git a/Xi/xiselev.c b/Xi/xiselev.c
index 8740487df..59f75b547 100644
--- a/Xi/xiselev.c
+++ b/Xi/xiselev.c
@@ -64,7 +64,7 @@ ProcXiSelectEvent(ClientPtr client)
REQUEST(xXiSelectEventReq);
REQUEST_SIZE_MATCH(xXiSelectEventReq);
- ret = dixLookupWindow(&pWin, stuff->window, client, DixReadWriteAccess);
+ ret = dixLookupWindow(&pWin, stuff->window, client, DixWriteAccess);
if (ret != Success)
{
SendErrorToClient(client, IReqCode, X_XiSelectEvent, 0, ret);