From 5c03d131815cfe2f78792277ab8352e69e830196 Mon Sep 17 00:00:00 2001 From: Eamon Walsh Date: Fri, 28 Sep 2007 08:02:00 -0400 Subject: xace: add new hooks + access controls: XInput extension. Introduces new dix API to lookup a device, dixLookupDevice(), which replaces LookupDeviceIntRec and LookupDevice. --- Xi/allowev.c | 8 ++++---- Xi/chgdctl.c | 7 ++----- Xi/chgfctl.c | 8 ++++---- Xi/chgkmap.c | 7 +++---- Xi/chgprop.c | 3 +-- Xi/chgptr.c | 2 -- Xi/closedev.c | 9 ++++----- Xi/devbell.c | 9 ++++----- Xi/exevents.c | 37 +++++++++++++++++++++++++++---------- Xi/extinit.c | 23 ----------------------- Xi/getbmap.c | 8 ++++---- Xi/getdctl.c | 9 ++++----- Xi/getfctl.c | 9 ++++----- Xi/getfocus.c | 8 +++++--- Xi/getkmap.c | 8 ++++---- Xi/getmmap.c | 8 ++++---- Xi/getprop.c | 3 +-- Xi/getselev.c | 3 +-- Xi/getvers.c | 1 - Xi/grabdev.c | 15 ++++++++------- Xi/grabdevb.c | 14 +++++++------- Xi/grabdevk.c | 14 +++++++------- Xi/gtmotion.c | 9 ++++----- Xi/listdev.c | 10 ++++++++-- Xi/opendev.c | 7 ++++--- Xi/queryst.c | 9 ++++----- Xi/selectev.c | 3 +-- Xi/sendexev.c | 8 ++++---- Xi/setbmap.c | 7 +++---- Xi/setdval.c | 8 ++++---- Xi/setfocus.c | 7 ++++--- Xi/setmmap.c | 7 +++---- Xi/setmode.c | 8 ++++---- Xi/stubs.c | 2 ++ Xi/ungrdev.c | 8 ++++---- Xi/ungrdevb.c | 14 +++++++------- Xi/ungrdevk.c | 14 +++++++------- 37 files changed, 161 insertions(+), 173 deletions(-) (limited to 'Xi') diff --git a/Xi/allowev.c b/Xi/allowev.c index cf075e112..0043cb138 100644 --- a/Xi/allowev.c +++ b/Xi/allowev.c @@ -60,7 +60,6 @@ SOFTWARE. #include #include -#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/chgdctl.c b/Xi/chgdctl.c index 055f459d0..e7d04a781 100644 --- a/Xi/chgdctl.c +++ b/Xi/chgdctl.c @@ -61,7 +61,6 @@ SOFTWARE. #include /* 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 #include /* 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 #include -#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 #include -#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 1ec3fa163..b2b5f69a6 100644 --- a/Xi/closedev.c +++ b/Xi/closedev.c @@ -62,7 +62,6 @@ SOFTWARE. #include #include #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 */ 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 #include -#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 377311ec9..9a179500b 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -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; diff --git a/Xi/extinit.c b/Xi/extinit.c index 73bae5e85..1a435edad 100644 --- a/Xi/extinit.c +++ b/Xi/extinit.c @@ -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 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 #include -#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 8a84e91bc..3f2bb29ae 100644 --- a/Xi/getdctl.c +++ b/Xi/getdctl.c @@ -59,7 +59,6 @@ SOFTWARE. #include "inputstr.h" /* DeviceIntPtr */ #include #include -#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; 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 #include -#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 #include -#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 #include -#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 #include /* 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/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 #include -#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 #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 #include -#include "extinit.h" /* LookupDeviceIntRec */ #include "exglobals.h" #include "getvers.h" diff --git a/Xi/grabdev.c b/Xi/grabdev.c index b303695fd..110fc6b5f 100644 --- a/Xi/grabdev.c +++ b/Xi/grabdev.c @@ -60,7 +60,6 @@ SOFTWARE. #include "windowstr.h" /* window structure */ #include #include -#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++) diff --git a/Xi/grabdevb.c b/Xi/grabdevb.c index 21e46fceb..7eb542232 100644 --- a/Xi/grabdevb.c +++ b/Xi/grabdevb.c @@ -61,7 +61,6 @@ SOFTWARE. #include #include #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 diff --git a/Xi/grabdevk.c b/Xi/grabdevk.c index 8da36ba8f..e187a4f7b 100644 --- a/Xi/grabdevk.c +++ b/Xi/grabdevk.c @@ -61,7 +61,6 @@ SOFTWARE. #include #include #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 diff --git a/Xi/gtmotion.c b/Xi/gtmotion.c index 51d4248cd..de22d0484 100644 --- a/Xi/gtmotion.c +++ b/Xi/gtmotion.c @@ -59,7 +59,6 @@ SOFTWARE. #include "inputstr.h" /* DeviceIntPtr */ #include #include -#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 160ad02fb..041de7635 100644 --- a/Xi/listdev.c +++ b/Xi/listdev.c @@ -63,8 +63,8 @@ SOFTWARE. #include #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++; } diff --git a/Xi/opendev.c b/Xi/opendev.c index dfefe055c..128b1bd9c 100644 --- a/Xi/opendev.c +++ b/Xi/opendev.c @@ -61,7 +61,6 @@ SOFTWARE. #include #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) 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 #include -#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 #include -#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 20b415a1f..e4e38d790 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 #include -#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 #include #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/setdval.c b/Xi/setdval.c index cb35b9157..b1e22fc21 100644 --- a/Xi/setdval.c +++ b/Xi/setdval.c @@ -60,7 +60,6 @@ SOFTWARE. #include #include #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 #include #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 957721c66..8b6003ad0 100644 --- a/Xi/setmode.c +++ b/Xi/setmode.c @@ -60,7 +60,6 @@ SOFTWARE. #include #include #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)) diff --git a/Xi/stubs.c b/Xi/stubs.c index 40cd02fe1..80ddd73c0 100644 --- a/Xi/stubs.c +++ b/Xi/stubs.c @@ -65,6 +65,7 @@ SOFTWARE. #include #include #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 505d6690f..7abb1d061 100644 --- a/Xi/ungrdev.c +++ b/Xi/ungrdev.c @@ -59,7 +59,6 @@ SOFTWARE. #include "inputstr.h" /* DeviceIntPtr */ #include "windowstr.h" /* window structure */ #include -#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); diff --git a/Xi/ungrdevb.c b/Xi/ungrdevb.c index 0dfe805b7..85ca5c6ce 100644 --- a/Xi/ungrdevb.c +++ b/Xi/ungrdevb.c @@ -60,7 +60,6 @@ SOFTWARE. #include "windowstr.h" /* window structure */ #include #include -#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; diff --git a/Xi/ungrdevk.c b/Xi/ungrdevk.c index e6307af01..ac4003569 100644 --- a/Xi/ungrdevk.c +++ b/Xi/ungrdevk.c @@ -60,7 +60,6 @@ SOFTWARE. #include "windowstr.h" /* window structure */ #include #include -#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; -- cgit v1.2.3 From 8b548657204000e18c7a38706a0071ae2f93159f Mon Sep 17 00:00:00 2001 From: Eamon Walsh Date: Fri, 28 Sep 2007 13:34:18 -0400 Subject: xace: add hooks + new access codes: XKB extension. Removes "LookupKeyboardDevice" and "LookupPointerDevice" in favor of inputInfo.keyboard and inputInfo.pointer, respectively; all use cases are non-XI compliant anyway. --- XTrap/xtrapddmi.c | 6 +- XTrap/xtrapdi.c | 6 +- Xext/xtest.c | 6 +- Xi/grabdevb.c | 9 ++- Xi/grabdevk.c | 9 ++- Xi/ungrdevb.c | 2 +- Xi/ungrdevk.c | 2 +- dix/devices.c | 12 ---- hw/kdrive/ephyr/ephyr.c | 2 +- hw/kdrive/vxworks/vxkbd.c | 2 +- hw/xfree86/loader/dixsym.c | 2 - hw/xgl/egl/kinput.c | 2 +- hw/xgl/glx/xglx.c | 2 +- hw/xgl/xglinput.c | 2 +- include/input.h | 4 -- include/xkbsrv.h | 46 +++++++++----- xkb/ddxDevBtn.c | 2 +- xkb/ddxFakeBtn.c | 2 +- xkb/xkb.c | 101 +++++++++++++++++-------------- xkb/xkbAccessX.c | 2 +- xkb/xkbActions.c | 10 +-- xkb/xkbEvents.c | 2 +- xkb/xkbLEDs.c | 10 +-- xkb/xkbPrOtherEv.c | 2 +- xkb/xkbUtils.c | 147 ++++++++++++++++++++++++++------------------- 25 files changed, 217 insertions(+), 175 deletions(-) (limited to 'Xi') diff --git a/XTrap/xtrapddmi.c b/XTrap/xtrapddmi.c index 73a20c1f6..3f1a72ab8 100644 --- a/XTrap/xtrapddmi.c +++ b/XTrap/xtrapddmi.c @@ -52,7 +52,7 @@ SOFTWARE. #define NEED_REPLIES #define NEED_EVENTS #include /* From library include environment */ -#include "input.h" /* From server include env. (must be before Xlib.h!) */ +#include "inputstr.h" /* From server include env. (must be before Xlib.h!) */ #ifdef PC # include "scrintst.h" /* Screen struct */ # include "extnsist.h" @@ -96,8 +96,8 @@ int XETrapSimulateXEvent(register xXTrapInputReq *request, xEvent xev; register int x = request->input.x; register int y = request->input.y; - DevicePtr keydev = LookupKeyboardDevice(); - DevicePtr ptrdev = LookupPointerDevice(); + DevicePtr keydev = (DevicePtr)inputInfo.keyboard; + DevicePtr ptrdev = (DevicePtr)inputInfo.pointer; if (request->input.screen < screenInfo.numScreens) { diff --git a/XTrap/xtrapdi.c b/XTrap/xtrapdi.c index 23d3bde7f..efad36f7a 100644 --- a/XTrap/xtrapdi.c +++ b/XTrap/xtrapdi.c @@ -58,7 +58,7 @@ CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include -#include "input.h" /* Server DevicePtr definitions */ +#include "inputstr.h" /* Server DevicePtr definitions */ #include "misc.h" /* Server swapping macros */ #include "dixstruct.h" /* Server ClientRec definitions */ #include "resource.h" /* Used with the MakeAtom call */ @@ -277,7 +277,7 @@ Bool XETrapRedirectDevices() /* Do we need to redirect the keyboard device? */ if (XETrapKbdDev == NULL) { - if ((XETrapKbdDev = LookupKeyboardDevice()) == NULL) + if ((XETrapKbdDev = (DevicePtr)inputInfo.keyboard) == NULL) { retval = False; } @@ -302,7 +302,7 @@ Bool XETrapRedirectDevices() #ifndef VECTORED_EVENTS if (XETrapPtrDev == NULL) { - if ((XETrapPtrDev = LookupPointerDevice()) == 0L) + if ((XETrapPtrDev = (DevicePtr)inputInfo.pointer) == 0L) { retval = False; } diff --git a/Xext/xtest.c b/Xext/xtest.c index 42cf8178f..add996655 100644 --- a/Xext/xtest.c +++ b/Xext/xtest.c @@ -316,7 +316,7 @@ ProcXTestFakeInput(client) #ifdef XINPUT if (!extension) #endif /* XINPUT */ - dev = (DeviceIntPtr)LookupKeyboardDevice(); + dev = inputInfo.keyboard; if (ev->u.u.detail < dev->key->curKeySyms.minKeyCode || ev->u.u.detail > dev->key->curKeySyms.maxKeyCode) { @@ -360,7 +360,7 @@ ProcXTestFakeInput(client) break; } #endif /* XINPUT */ - dev = (DeviceIntPtr)LookupPointerDevice(); + dev = inputInfo.pointer; if (ev->u.keyButtonPointer.root == None) root = GetCurrentRootWindow(); else @@ -449,7 +449,7 @@ ProcXTestFakeInput(client) #ifdef XINPUT if (!extension) #endif /* XINPUT */ - dev = (DeviceIntPtr)LookupPointerDevice(); + dev = inputInfo.pointer; if (!ev->u.u.detail || ev->u.u.detail > dev->button->numButtons) { client->errorValue = ev->u.u.detail; diff --git a/Xi/grabdevb.c b/Xi/grabdevb.c index 7eb542232..c2661e85b 100644 --- a/Xi/grabdevb.c +++ b/Xi/grabdevb.c @@ -62,6 +62,7 @@ SOFTWARE. #include #include "exevents.h" #include "exglobals.h" +#include "xace.h" #include "grabdev.h" #include "grabdevb.h" @@ -127,8 +128,12 @@ ProcXGrabDeviceButton(ClientPtr client) return ret; if (mdev->key == NULL) return BadMatch; - } else - mdev = (DeviceIntPtr) LookupKeyboardDevice(); + } else { + mdev = inputInfo.keyboard; + 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 e187a4f7b..43b19280d 100644 --- a/Xi/grabdevk.c +++ b/Xi/grabdevk.c @@ -62,6 +62,7 @@ SOFTWARE. #include #include "exevents.h" #include "exglobals.h" +#include "xace.h" #include "grabdev.h" #include "grabdevk.h" @@ -125,8 +126,12 @@ ProcXGrabDeviceKey(ClientPtr client) return ret; if (mdev->key == NULL) return BadMatch; - } else - mdev = (DeviceIntPtr) LookupKeyboardDevice(); + } else { + mdev = inputInfo.keyboard; + 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/ungrdevb.c b/Xi/ungrdevb.c index 85ca5c6ce..590699f05 100644 --- a/Xi/ungrdevb.c +++ b/Xi/ungrdevb.c @@ -120,7 +120,7 @@ ProcXUngrabDeviceButton(ClientPtr client) if (mdev->key == NULL) return BadMatch; } else - mdev = (DeviceIntPtr) LookupKeyboardDevice(); + mdev = inputInfo.keyboard; rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixSetAttrAccess); if (rc != Success) diff --git a/Xi/ungrdevk.c b/Xi/ungrdevk.c index ac4003569..521765ea3 100644 --- a/Xi/ungrdevk.c +++ b/Xi/ungrdevk.c @@ -120,7 +120,7 @@ ProcXUngrabDeviceKey(ClientPtr client) if (mdev->key == NULL) return BadMatch; } else - mdev = (DeviceIntPtr) LookupKeyboardDevice(); + mdev = inputInfo.keyboard; rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixSetAttrAccess); if (rc != Success) diff --git a/dix/devices.c b/dix/devices.c index bd1bef722..b6cb4a5c0 100644 --- a/dix/devices.c +++ b/dix/devices.c @@ -705,18 +705,6 @@ RegisterKeyboardDevice(DeviceIntPtr device) RegisterOtherDevice(device); } -_X_EXPORT DevicePtr -LookupKeyboardDevice(void) -{ - return inputInfo.keyboard ? &inputInfo.keyboard->public : NULL; -} - -_X_EXPORT DevicePtr -LookupPointerDevice(void) -{ - return inputInfo.pointer ? &inputInfo.pointer->public : NULL; -} - int dixLookupDevice(DeviceIntPtr *pDev, int id, ClientPtr client, Mask access_mode) { diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c index e8001df73..2e0c00491 100644 --- a/hw/kdrive/ephyr/ephyr.c +++ b/hw/kdrive/ephyr/ephyr.c @@ -691,7 +691,7 @@ ephyrUpdateModifierState(unsigned int state) int i; CARD8 mask; - pkeydev = (DeviceIntPtr)LookupKeyboardDevice(); + pkeydev = inputInfo.keyboard; if (!pkeydev) return; diff --git a/hw/kdrive/vxworks/vxkbd.c b/hw/kdrive/vxworks/vxkbd.c index be528c78a..ac83ef729 100644 --- a/hw/kdrive/vxworks/vxkbd.c +++ b/hw/kdrive/vxworks/vxkbd.c @@ -232,7 +232,7 @@ VxWorksKeyboardRead (int fd) void VxWorksKeyboardLeds (int leds) { - DeviceIntPtr pKeyboard = (DeviceIntPtr) LookupKeyboardDevice (); + DeviceIntPtr pKeyboard = inputInfo.keyboard; KeyboardCtrl *ctrl = &pKeyboard->kbdfeed->ctrl; led_ioctl_info led_info; int i; diff --git a/hw/xfree86/loader/dixsym.c b/hw/xfree86/loader/dixsym.c index 4b3b66a89..0eaa2d3a6 100644 --- a/hw/xfree86/loader/dixsym.c +++ b/hw/xfree86/loader/dixsym.c @@ -139,8 +139,6 @@ _X_HIDDEN void *dixLookupTab[] = { SYMFUNC(InitKeyboardDeviceStruct) SYMFUNC(SendMappingNotify) SYMFUNC(InitPointerDeviceStruct) - SYMFUNC(LookupKeyboardDevice) - SYMFUNC(LookupPointerDevice) /* dispatch.c */ SYMFUNC(SetInputCheck) SYMFUNC(SendErrorToClient) diff --git a/hw/xgl/egl/kinput.c b/hw/xgl/egl/kinput.c index 981cffcfa..774e00eb5 100644 --- a/hw/xgl/egl/kinput.c +++ b/hw/xgl/egl/kinput.c @@ -439,7 +439,7 @@ KdKeybdProc(DeviceIntPtr pDevice, int onoff) switch (onoff) { case DEVICE_INIT: - if (pDev != LookupKeyboardDevice()) + if (pDev != (DevicePtr)inputInfo.keyboard) { return !Success; } diff --git a/hw/xgl/glx/xglx.c b/hw/xgl/glx/xglx.c index 89bd72e41..33b276b74 100644 --- a/hw/xgl/glx/xglx.c +++ b/hw/xgl/glx/xglx.c @@ -1100,7 +1100,7 @@ xglxKeybdProc (DeviceIntPtr pDevice, int xkbOp, xkbEvent, xkbError, xkbMajor, xkbMinor; #endif - if (pDev != LookupKeyboardDevice ()) + if (pDev != (DevicePtr)inputInfo.keyboard) return !Success; xmodMap = XGetModifierMapping (xdisplay); diff --git a/hw/xgl/xglinput.c b/hw/xgl/xglinput.c index cda21ad49..9499fcf1f 100644 --- a/hw/xgl/xglinput.c +++ b/hw/xgl/xglinput.c @@ -224,7 +224,7 @@ xglKeybdProc (DeviceIntPtr pDevice, switch (onoff) { case DEVICE_INIT: - if (pDev != LookupKeyboardDevice ()) + if (pDev != (DevicePtr)inputInfo.keyboard) return !Success; ret = InitKeyboardDeviceStruct (pDev, diff --git a/include/input.h b/include/input.h index d8a9fe852..ca67cfac5 100644 --- a/include/input.h +++ b/include/input.h @@ -197,10 +197,6 @@ extern void RegisterPointerDevice( extern void RegisterKeyboardDevice( DeviceIntPtr /*device*/); -extern DevicePtr LookupKeyboardDevice(void); - -extern DevicePtr LookupPointerDevice(void); - extern int dixLookupDevice( DeviceIntPtr * /* dev */, int /* id */, diff --git a/include/xkbsrv.h b/include/xkbsrv.h index 71ea115e6..e4a1db3c5 100644 --- a/include/xkbsrv.h +++ b/include/xkbsrv.h @@ -262,6 +262,7 @@ typedef struct extern int XkbReqCode; extern int XkbEventBase; extern int XkbDisableLockActions; +extern int XkbKeyboardErrorCode; extern char * XkbBaseDirectory; extern char * XkbBinDirectory; extern char * XkbInitialMap; @@ -352,29 +353,44 @@ extern void XkbFreeNames( Bool /* freeMap */ ); -extern DeviceIntPtr _XkbLookupAnyDevice( - int /* id */, - int * /* why_rtrn */ +extern int _XkbLookupAnyDevice( + DeviceIntPtr *pDev, + int id, + ClientPtr client, + Mask access_mode, + int *xkb_err ); -extern DeviceIntPtr _XkbLookupKeyboard( - int /* id */, - int * /* why_rtrn */ +extern int _XkbLookupKeyboard( + DeviceIntPtr *pDev, + int id, + ClientPtr client, + Mask access_mode, + int *xkb_err ); -extern DeviceIntPtr _XkbLookupBellDevice( - int /* id */, - int * /* why_rtrn */ +extern int _XkbLookupBellDevice( + DeviceIntPtr *pDev, + int id, + ClientPtr client, + Mask access_mode, + int *xkb_err ); -extern DeviceIntPtr _XkbLookupLedDevice( - int /* id */, - int * /* why_rtrn */ +extern int _XkbLookupLedDevice( + DeviceIntPtr *pDev, + int id, + ClientPtr client, + Mask access_mode, + int *xkb_err ); -extern DeviceIntPtr _XkbLookupButtonDevice( - int /* id */, - int * /* why_rtrn */ +extern int _XkbLookupButtonDevice( + DeviceIntPtr *pDev, + int id, + ClientPtr client, + Mask access_mode, + int *xkb_err ); extern XkbDescPtr XkbAllocKeyboard( diff --git a/xkb/ddxDevBtn.c b/xkb/ddxDevBtn.c index 7e27c5189..5313a1ec5 100644 --- a/xkb/ddxDevBtn.c +++ b/xkb/ddxDevBtn.c @@ -53,7 +53,7 @@ deviceValuator * val; int x,y; int nAxes, i, count; - if ((dev==(DeviceIntPtr)LookupPointerDevice())||(!dev->public.on)) + if (dev == inputInfo.pointer || !dev->public.on) return; nAxes = (dev->valuator?dev->valuator->numAxes:0); diff --git a/xkb/ddxFakeBtn.c b/xkb/ddxFakeBtn.c index 8144fd2c5..2dad54fea 100644 --- a/xkb/ddxFakeBtn.c +++ b/xkb/ddxFakeBtn.c @@ -46,7 +46,7 @@ xEvent ev; int x,y; DevicePtr ptr; - if ((ptr = LookupPointerDevice())==NULL) + if ((ptr = (DevicePtr)inputInfo.pointer)==NULL) return; GetSpritePosition(&x,&y); ev.u.u.type = event; diff --git a/xkb/xkb.c b/xkb/xkb.c index cf4243070..9efdfb6b5 100644 --- a/xkb/xkb.c +++ b/xkb/xkb.c @@ -38,6 +38,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #define XKBSRV_NEED_FILE_FUNCS #include #include "extnsionst.h" +#include "xace.h" #include "xkb.h" #include @@ -45,7 +46,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. int XkbEventBase; static int XkbErrorBase; int XkbReqCode; -static int XkbKeyboardErrorCode; + int XkbKeyboardErrorCode; CARD32 xkbDebugFlags = 0; static CARD32 xkbDebugCtrls = 0; @@ -53,19 +54,23 @@ static RESTYPE RT_XKBCLIENT; /***====================================================================***/ -#define CHK_DEVICE(d,sp,lf) {\ +#define CHK_DEVICE(dev, id, client, access_mode, lf) {\ int why;\ - d = (DeviceIntPtr)lf((sp),&why);\ - if (!dev) {\ - client->errorValue = _XkbErrCode2(why,(sp));\ - return XkbKeyboardErrorCode;\ + int rc = lf(&(dev), id, client, access_mode, &why);\ + if (rc != Success) {\ + client->errorValue = _XkbErrCode2(why, id);\ + return rc;\ }\ } -#define CHK_KBD_DEVICE(d,sp) CHK_DEVICE(d,sp,_XkbLookupKeyboard) -#define CHK_LED_DEVICE(d,sp) CHK_DEVICE(d,sp,_XkbLookupLedDevice) -#define CHK_BELL_DEVICE(d,sp) CHK_DEVICE(d,sp,_XkbLookupBellDevice) -#define CHK_ANY_DEVICE(d,sp) CHK_DEVICE(d,sp,_XkbLookupAnyDevice) +#define CHK_KBD_DEVICE(dev, id, client, mode) \ + CHK_DEVICE(dev, id, client, mode, _XkbLookupKeyboard) +#define CHK_LED_DEVICE(dev, id, client, mode) \ + CHK_DEVICE(dev, id, client, mode, _XkbLookupLedDevice) +#define CHK_BELL_DEVICE(dev, id, client, mode) \ + CHK_DEVICE(dev, id, client, mode, _XkbLookupBellDevice) +#define CHK_ANY_DEVICE(dev, id, client, mode) \ + CHK_DEVICE(dev, id, client, mode, _XkbLookupAnyDevice) #define CHK_ATOM_ONLY2(a,ev,er) {\ if (((a)==None)||(!ValidAtom((a)))) {\ @@ -206,7 +211,7 @@ ProcXkbSelectEvents(ClientPtr client) if (!(client->xkbClientFlags&_XkbClientInitialized)) return BadAccess; - CHK_ANY_DEVICE(dev,stuff->deviceSpec); + CHK_ANY_DEVICE(dev, stuff->deviceSpec, client, DixReadAccess); if (((stuff->affectWhich&XkbMapNotifyMask)!=0)&&(stuff->affectMap)) { client->mapNotifyMask&= ~stuff->affectMap; @@ -351,7 +356,7 @@ ProcXkbBell(ClientPtr client) REQUEST(xkbBellReq); DeviceIntPtr dev; WindowPtr pWin; - int base; + int rc, base; int newPercent,oldPitch,oldDuration; pointer ctrl; @@ -360,7 +365,7 @@ ProcXkbBell(ClientPtr client) if (!(client->xkbClientFlags&_XkbClientInitialized)) return BadAccess; - CHK_BELL_DEVICE(dev,stuff->deviceSpec); + CHK_BELL_DEVICE(dev, stuff->deviceSpec, client, DixBellAccess); CHK_ATOM_OR_NONE(stuff->name); if ((stuff->forceSound)&&(stuff->eventOnly)) { @@ -448,10 +453,10 @@ ProcXkbBell(ClientPtr client) return BadValue; } if (stuff->window!=None) { - pWin= (WindowPtr)LookupIDByType(stuff->window,RT_WINDOW); - if (pWin==NULL) { + rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); + if (rc != Success) { client->errorValue= stuff->window; - return BadValue; + return rc; } } else pWin= NULL; @@ -499,7 +504,7 @@ ProcXkbGetState(ClientPtr client) if (!(client->xkbClientFlags&_XkbClientInitialized)) return BadAccess; - CHK_KBD_DEVICE(dev,stuff->deviceSpec); + CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixReadAccess); xkb= &dev->key->xkbInfo->state; bzero(&rep,sizeof(xkbGetStateReply)); @@ -544,7 +549,7 @@ ProcXkbLatchLockState(ClientPtr client) if (!(client->xkbClientFlags & _XkbClientInitialized)) return BadAccess; - CHK_KBD_DEVICE(dev, stuff->deviceSpec); + CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixSetAttrAccess); CHK_MASK_MATCH(0x01, stuff->affectModLocks, stuff->modLocks); CHK_MASK_MATCH(0x01, stuff->affectModLatches, stuff->modLatches); @@ -612,7 +617,7 @@ ProcXkbGetControls(ClientPtr client) if (!(client->xkbClientFlags&_XkbClientInitialized)) return BadAccess; - CHK_KBD_DEVICE(dev,stuff->deviceSpec); + CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixGetAttrAccess); xkb = dev->key->xkbInfo->desc->ctrls; rep.type = X_Reply; @@ -689,7 +694,7 @@ ProcXkbSetControls(ClientPtr client) if (!(client->xkbClientFlags & _XkbClientInitialized)) return BadAccess; - CHK_KBD_DEVICE(dev, stuff->deviceSpec); + CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixSetAttrAccess); CHK_MASK_LEGAL(0x01, stuff->changeCtrls, XkbAllControlsMask); for (tmpd = inputInfo.keyboard; tmpd; tmpd = tmpd->next) { @@ -1370,7 +1375,7 @@ ProcXkbGetMap(ClientPtr client) if (!(client->xkbClientFlags&_XkbClientInitialized)) return BadAccess; - CHK_KBD_DEVICE(dev,stuff->deviceSpec); + CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixGetAttrAccess); CHK_MASK_OVERLAP(0x01,stuff->full,stuff->partial); CHK_MASK_LEGAL(0x02,stuff->full,XkbAllMapComponentsMask); CHK_MASK_LEGAL(0x03,stuff->partial,XkbAllMapComponentsMask); @@ -2299,7 +2304,7 @@ ProcXkbSetMap(ClientPtr client) if (!(client->xkbClientFlags&_XkbClientInitialized)) return BadAccess; - CHK_KBD_DEVICE(dev,stuff->deviceSpec); + CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixSetAttrAccess); CHK_MASK_LEGAL(0x01,stuff->present,XkbAllMapComponentsMask); XkbSetCauseXkbReq(&cause,X_kbSetMap,client); @@ -2569,7 +2574,7 @@ ProcXkbGetCompatMap(ClientPtr client) if (!(client->xkbClientFlags&_XkbClientInitialized)) return BadAccess; - CHK_KBD_DEVICE(dev,stuff->deviceSpec); + CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixGetAttrAccess); xkb = dev->key->xkbInfo->desc; compat= xkb->compat; @@ -2613,7 +2618,7 @@ ProcXkbSetCompatMap(ClientPtr client) if (!(client->xkbClientFlags&_XkbClientInitialized)) return BadAccess; - CHK_KBD_DEVICE(dev,stuff->deviceSpec); + CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixSetAttrAccess); data = (char *)&stuff[1]; xkbi = dev->key->xkbInfo; @@ -2748,7 +2753,7 @@ ProcXkbGetIndicatorState(ClientPtr client) if (!(client->xkbClientFlags&_XkbClientInitialized)) return BadAccess; - CHK_KBD_DEVICE(dev,stuff->deviceSpec); + CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixReadAccess); sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId, XkbXI_IndicatorStateMask); @@ -2859,7 +2864,7 @@ XkbIndicatorPtr leds; if (!(client->xkbClientFlags&_XkbClientInitialized)) return BadAccess; - CHK_KBD_DEVICE(dev,stuff->deviceSpec); + CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixGetAttrAccess); xkb= dev->key->xkbInfo->desc; leds= xkb->indicators; @@ -2878,7 +2883,7 @@ int ProcXkbSetIndicatorMap(ClientPtr client) { register int i,bit; - int nIndicators,why; + int nIndicators; DeviceIntPtr dev; XkbSrvInfoPtr xkbi; xkbIndicatorMapWireDesc *from; @@ -2891,11 +2896,8 @@ ProcXkbSetIndicatorMap(ClientPtr client) if (!(client->xkbClientFlags&_XkbClientInitialized)) return BadAccess; - dev = _XkbLookupKeyboard(stuff->deviceSpec,&why); - if (!dev) { - client->errorValue = _XkbErrCode2(why,stuff->deviceSpec); - return XkbKeyboardErrorCode; - } + CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixSetAttrAccess); + xkbi= dev->key->xkbInfo; if (stuff->which==0) @@ -2971,7 +2973,7 @@ ProcXkbGetNamedIndicator(ClientPtr client) if (!(client->xkbClientFlags&_XkbClientInitialized)) return BadAccess; - CHK_LED_DEVICE(dev,stuff->deviceSpec); + CHK_LED_DEVICE(dev, stuff->deviceSpec, client, DixReadAccess); CHK_ATOM_ONLY(stuff->indicator); sli= XkbFindSrvLedInfo(dev,stuff->ledClass,stuff->ledID,0); @@ -3057,7 +3059,7 @@ ProcXkbSetNamedIndicator(ClientPtr client) if (!(client->xkbClientFlags&_XkbClientInitialized)) return BadAccess; - CHK_LED_DEVICE(dev,stuff->deviceSpec); + CHK_LED_DEVICE(dev, stuff->deviceSpec, client, DixSetAttrAccess); CHK_ATOM_ONLY(stuff->indicator); CHK_MASK_LEGAL(0x10,stuff->whichGroups,XkbIM_UseAnyGroup); CHK_MASK_LEGAL(0x11,stuff->whichMods,XkbIM_UseAnyMods); @@ -3125,7 +3127,7 @@ ProcXkbSetNamedIndicator(ClientPtr client) kbd= dev; if ((sli->flags&XkbSLI_HasOwnState)==0) - kbd= (DeviceIntPtr)LookupKeyboardDevice(); + kbd = inputInfo.keyboard; XkbFlushLedEvents(dev,kbd,sli,&ed,&changes,&cause); return client->noClientException; } @@ -3433,7 +3435,7 @@ ProcXkbGetNames(ClientPtr client) if (!(client->xkbClientFlags&_XkbClientInitialized)) return BadAccess; - CHK_KBD_DEVICE(dev,stuff->deviceSpec); + CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixGetAttrAccess); CHK_MASK_LEGAL(0x01,stuff->which,XkbAllNamesMask); xkb = dev->key->xkbInfo->desc; @@ -3543,7 +3545,7 @@ ProcXkbSetNames(ClientPtr client) if (!(client->xkbClientFlags&_XkbClientInitialized)) return BadAccess; - CHK_KBD_DEVICE(dev,stuff->deviceSpec); + CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixUnknownAccess); CHK_MASK_LEGAL(0x01,stuff->which,XkbAllNamesMask); xkb = dev->key->xkbInfo->desc; @@ -4379,7 +4381,7 @@ ProcXkbGetGeometry(ClientPtr client) if (!(client->xkbClientFlags&_XkbClientInitialized)) return BadAccess; - CHK_KBD_DEVICE(dev,stuff->deviceSpec); + CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixGetAttrAccess); CHK_ATOM_OR_NONE(stuff->name); geom= XkbLookupNamedGeometry(dev,stuff->name,&shouldFree); @@ -4842,7 +4844,7 @@ ProcXkbSetGeometry(ClientPtr client) if (!(client->xkbClientFlags&_XkbClientInitialized)) return BadAccess; - CHK_KBD_DEVICE(dev,stuff->deviceSpec); + CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixSetAttrAccess); CHK_ATOM_OR_NONE(stuff->name); xkb= dev->key->xkbInfo->desc; @@ -4897,6 +4899,7 @@ ProcXkbPerClientFlags(ClientPtr client) DeviceIntPtr dev; xkbPerClientFlagsReply rep; XkbInterestPtr interest; + Mask access_mode = DixGetAttrAccess | DixSetAttrAccess; REQUEST(xkbPerClientFlagsReq); REQUEST_SIZE_MATCH(xkbPerClientFlagsReq); @@ -4904,7 +4907,7 @@ ProcXkbPerClientFlags(ClientPtr client) if (!(client->xkbClientFlags&_XkbClientInitialized)) return BadAccess; - CHK_KBD_DEVICE(dev,stuff->deviceSpec); + CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, access_mode); CHK_MASK_LEGAL(0x01,stuff->change,XkbPCF_AllFlagsMask); CHK_MASK_MATCH(0x02,stuff->change,stuff->value); @@ -5040,7 +5043,7 @@ ProcXkbListComponents(ClientPtr client) if (!(client->xkbClientFlags&_XkbClientInitialized)) return BadAccess; - CHK_KBD_DEVICE(dev,stuff->deviceSpec); + CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixGetAttrAccess); status= Success; str= (unsigned char *)&stuff[1]; @@ -5123,6 +5126,7 @@ ProcXkbGetKbdByName(ClientPtr client) Bool geom_changed; XkbSrvLedInfoPtr old_sli; XkbSrvLedInfoPtr sli; + Mask access_mode = DixGetAttrAccess | DixSetAttrAccess; REQUEST(xkbGetKbdByNameReq); REQUEST_AT_LEAST_SIZE(xkbGetKbdByNameReq); @@ -5130,7 +5134,7 @@ ProcXkbGetKbdByName(ClientPtr client) if (!(client->xkbClientFlags&_XkbClientInitialized)) return BadAccess; - CHK_KBD_DEVICE(dev,stuff->deviceSpec); + CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, access_mode); xkb = dev->key->xkbInfo->desc; status= Success; @@ -5664,7 +5668,7 @@ char * str; wanted= stuff->wanted; - CHK_ANY_DEVICE(dev,stuff->deviceSpec); + CHK_ANY_DEVICE(dev, stuff->deviceSpec, client, DixGetAttrAccess); CHK_MASK_LEGAL(0x01,wanted,XkbXI_AllDeviceFeaturesMask); if ((!dev->button)||((stuff->nBtns<1)&&(!stuff->allBtns))) @@ -5968,7 +5972,7 @@ DeviceIntPtr kbd; kbd= dev; if ((sli->flags&XkbSLI_HasOwnState)==0) - kbd= (DeviceIntPtr)LookupKeyboardDevice(); + kbd = inputInfo.keyboard; XkbFlushLedEvents(dev,kbd,sli,&ed,&changes,&cause); ledWire= (xkbDeviceLedsWireDesc *)mapWire; @@ -5993,7 +5997,7 @@ xkbExtensionDeviceNotify ed; change= stuff->change; - CHK_ANY_DEVICE(dev,stuff->deviceSpec); + CHK_ANY_DEVICE(dev, stuff->deviceSpec, client, DixSetAttrAccess); CHK_MASK_LEGAL(0x01,change,XkbXI_AllFeaturesMask); wire= (char *)&stuff[1]; @@ -6043,7 +6047,7 @@ xkbExtensionDeviceNotify ed; ed.nBtns= stuff->nBtns; if (dev->key) kbd= dev; - else kbd= (DeviceIntPtr)LookupKeyboardDevice(); + else kbd= inputInfo.keyboard; acts= &dev->button->xkb_acts[stuff->firstBtn]; for (i=0;inBtns;i++,acts++) { if (acts->type!=XkbSA_NoAction) @@ -6069,10 +6073,15 @@ ProcXkbSetDebuggingFlags(ClientPtr client) { CARD32 newFlags,newCtrls,extraLength; xkbSetDebuggingFlagsReply rep; +int rc; REQUEST(xkbSetDebuggingFlagsReq); REQUEST_AT_LEAST_SIZE(xkbSetDebuggingFlagsReq); + rc = XaceHook(XACE_SERVER_ACCESS, client, DixDebugAccess); + if (rc != Success) + return rc; + newFlags= xkbDebugFlags&(~stuff->affectFlags); newFlags|= (stuff->flags&stuff->affectFlags); newCtrls= xkbDebugCtrls&(~stuff->affectCtrls); diff --git a/xkb/xkbAccessX.c b/xkb/xkbAccessX.c index 2954a0c0e..fbd281536 100644 --- a/xkb/xkbAccessX.c +++ b/xkb/xkbAccessX.c @@ -689,7 +689,7 @@ ProcessPointerEvent( register xEvent * xE, register DeviceIntPtr mouse, int count) { -DeviceIntPtr dev = (DeviceIntPtr)LookupKeyboardDevice(); +DeviceIntPtr dev = inputInfo.keyboard; XkbSrvInfoPtr xkbi = dev->key->xkbInfo; unsigned changed = 0; diff --git a/xkb/xkbActions.c b/xkb/xkbActions.c index 7f0f74db1..822afffcb 100644 --- a/xkb/xkbActions.c +++ b/xkb/xkbActions.c @@ -1026,8 +1026,9 @@ DeviceIntPtr dev; int button; if (filter->keycode==0) { /* initial press */ - dev= _XkbLookupButtonDevice(pAction->devbtn.device,NULL); - if ((!dev)||(!dev->public.on)||(&dev->public==LookupPointerDevice())) + _XkbLookupButtonDevice(&dev, pAction->devbtn.device, serverClient, + DixUnknownAccess, &button); + if (!dev || !dev->public.on || dev == inputInfo.pointer) return 1; button= pAction->devbtn.button; @@ -1066,8 +1067,9 @@ int button; int button; filter->active= 0; - dev= _XkbLookupButtonDevice(filter->upAction.devbtn.device,NULL); - if ((!dev)||(!dev->public.on)||(&dev->public==LookupPointerDevice())) + _XkbLookupButtonDevice(&dev, filter->upAction.devbtn.device, + serverClient, DixUnknownAccess, &button); + if (!dev || !dev->public.on || dev == inputInfo.pointer) return 1; button= filter->upAction.btn.button; diff --git a/xkb/xkbEvents.c b/xkb/xkbEvents.c index 11dc17ad3..15b4949e5 100644 --- a/xkb/xkbEvents.c +++ b/xkb/xkbEvents.c @@ -806,7 +806,7 @@ Bool XkbFilterEvents(ClientPtr pClient,int nEvents,xEvent *xE) { int i, button_mask; -DeviceIntPtr pXDev = (DeviceIntPtr)LookupKeyboardDevice(); +DeviceIntPtr pXDev = inputInfo.keyboard; XkbSrvInfoPtr xkbi; xkbi= pXDev->key->xkbInfo; diff --git a/xkb/xkbLEDs.c b/xkb/xkbLEDs.c index d607d9066..2877af0c4 100644 --- a/xkb/xkbLEDs.c +++ b/xkb/xkbLEDs.c @@ -239,7 +239,7 @@ unsigned oldState; if (dev->key && dev->key->xkbInfo) kbd= dev; - else kbd= (DeviceIntPtr)LookupKeyboardDevice(); + else kbd= inputInfo.keyboard; state= &kbd->key->xkbInfo->state; ctrls= kbd->key->xkbInfo->desc->ctrls; @@ -444,7 +444,7 @@ XkbIndicatorMapPtr map; XkbDescPtr xkb; if ((sli->flags&XkbSLI_HasOwnState)==0) - dev= (DeviceIntPtr)LookupKeyboardDevice(); + dev= inputInfo.keyboard; sli->usesBase&= ~which; sli->usesLatched&= ~which; @@ -731,7 +731,7 @@ xkbExtensionDeviceNotify my_ed; return; if (dev->key && dev->key->xkbInfo) kbd= dev; - else kbd= (DeviceIntPtr)LookupKeyboardDevice(); + else kbd= inputInfo.keyboard; if (ed==NULL) { ed= &my_ed; @@ -808,7 +808,7 @@ xkbExtensionDeviceNotify my_ed; return; if (dev->key && dev->key->xkbInfo) kbd= dev; - else kbd= (DeviceIntPtr)LookupKeyboardDevice(); + else kbd= inputInfo.keyboard; if (ed==NULL) { ed= &my_ed; @@ -869,7 +869,7 @@ Bool kb_changed; return; if (dev->key && dev->key->xkbInfo) kbd= dev; - else kbd= (DeviceIntPtr)LookupKeyboardDevice(); + else kbd= inputInfo.keyboard; xkbi= kbd->key->xkbInfo; if (changes==NULL) { diff --git a/xkb/xkbPrOtherEv.c b/xkb/xkbPrOtherEv.c index a2ea0909a..d65107cdc 100644 --- a/xkb/xkbPrOtherEv.c +++ b/xkb/xkbPrOtherEv.c @@ -71,7 +71,7 @@ Bool xkbCares,isBtn; if ((!isBtn)||((dev->button)&&(dev->button->xkb_acts))) { DeviceIntPtr kbd; if (dev->key) kbd= dev; - else kbd= (DeviceIntPtr)LookupKeyboardDevice(); + else kbd= inputInfo.keyboard; XkbHandleActions(dev,kbd,xE,count); return; } diff --git a/xkb/xkbUtils.c b/xkb/xkbUtils.c index 877d4d242..31c1a9fa9 100644 --- a/xkb/xkbUtils.c +++ b/xkb/xkbUtils.c @@ -49,92 +49,115 @@ int XkbDisableLockActions = 0; /***====================================================================***/ -DeviceIntPtr -_XkbLookupAnyDevice(int id,int *why_rtrn) +int +_XkbLookupAnyDevice(DeviceIntPtr *pDev, int id, ClientPtr client, + Mask access_mode, int *xkb_err) { -DeviceIntPtr dev = NULL; + int rc = XkbKeyboardErrorCode; - dev= (DeviceIntPtr)LookupKeyboardDevice(); - if ((id==XkbUseCoreKbd)||(dev->id==id)) - return dev; - - dev= (DeviceIntPtr)LookupPointerDevice(); - if ((id==XkbUseCorePtr)||(dev->id==id)) - return dev; - - if (id&(~0xff)) - dev = NULL; - - dixLookupDevice(&dev, id, serverClient, DixUnknownAccess); - if (dev!=NULL) - return dev; - if ((!dev)&&(why_rtrn)) - *why_rtrn= XkbErr_BadDevice; - return dev; + if (id == XkbUseCoreKbd) { + if (inputInfo.keyboard) + id = inputInfo.keyboard->id; + else + goto out; + } + if (id == XkbUseCorePtr) { + if (inputInfo.pointer) + id = inputInfo.pointer->id; + else + goto out; + } + rc = dixLookupDevice(pDev, id, client, access_mode); +out: + if (rc != Success) + *xkb_err = XkbErr_BadDevice; + return rc; } -DeviceIntPtr -_XkbLookupKeyboard(int id,int *why_rtrn) +int +_XkbLookupKeyboard(DeviceIntPtr *pDev, int id, ClientPtr client, + Mask access_mode, int *xkb_err) { -DeviceIntPtr dev = NULL; + DeviceIntPtr dev; + int rc; if (id == XkbDfltXIId) id = XkbUseCoreKbd; - if ((dev= _XkbLookupAnyDevice(id,why_rtrn))==NULL) - return NULL; - else if ((!dev->key)||(!dev->key->xkbInfo)) { - if (why_rtrn) - *why_rtrn= XkbErr_BadClass; - return NULL; + + rc = _XkbLookupAnyDevice(pDev, id, client, access_mode, xkb_err); + if (rc != Success) + return rc; + + dev = *pDev; + if (!dev->key || !dev->key->xkbInfo) { + *pDev = NULL; + *xkb_err= XkbErr_BadClass; + return XkbKeyboardErrorCode; } - return dev; + return Success; } -DeviceIntPtr -_XkbLookupBellDevice(int id,int *why_rtrn) +int +_XkbLookupBellDevice(DeviceIntPtr *pDev, int id, ClientPtr client, + Mask access_mode, int *xkb_err) { -DeviceIntPtr dev = NULL; - - if ((dev= _XkbLookupAnyDevice(id,why_rtrn))==NULL) - return NULL; - else if ((!dev->kbdfeed)&&(!dev->bell)) { - if (why_rtrn) - *why_rtrn= XkbErr_BadClass; - return NULL; + DeviceIntPtr dev; + int rc; + + rc = _XkbLookupAnyDevice(pDev, id, client, access_mode, xkb_err); + if (rc != Success) + return rc; + + dev = *pDev; + if (!dev->kbdfeed && !dev->bell) { + *pDev = NULL; + *xkb_err= XkbErr_BadClass; + return XkbKeyboardErrorCode; } - return dev; + return Success; } -DeviceIntPtr -_XkbLookupLedDevice(int id,int *why_rtrn) +int +_XkbLookupLedDevice(DeviceIntPtr *pDev, int id, ClientPtr client, + Mask access_mode, int *xkb_err) { -DeviceIntPtr dev = NULL; + DeviceIntPtr dev; + int rc; if (id == XkbDfltXIId) id = XkbUseCorePtr; - if ((dev= _XkbLookupAnyDevice(id,why_rtrn))==NULL) - return NULL; - else if ((!dev->kbdfeed)&&(!dev->leds)) { - if (why_rtrn) - *why_rtrn= XkbErr_BadClass; - return NULL; + + rc = _XkbLookupAnyDevice(pDev, id, client, access_mode, xkb_err); + if (rc != Success) + return rc; + + dev = *pDev; + if (!dev->kbdfeed && !dev->leds) { + *pDev = NULL; + *xkb_err= XkbErr_BadClass; + return XkbKeyboardErrorCode; } - return dev; + return Success; } -DeviceIntPtr -_XkbLookupButtonDevice(int id,int *why_rtrn) +int +_XkbLookupButtonDevice(DeviceIntPtr *pDev, int id, ClientPtr client, + Mask access_mode, int *xkb_err) { -DeviceIntPtr dev = NULL; - - if ((dev= _XkbLookupAnyDevice(id,why_rtrn))==NULL) - return NULL; - else if (!dev->button) { - if (why_rtrn) - *why_rtrn= XkbErr_BadClass; - return NULL; + DeviceIntPtr dev; + int rc; + + rc = _XkbLookupAnyDevice(pDev, id, client, access_mode, xkb_err); + if (rc != Success) + return rc; + + dev = *pDev; + if (!dev->button) { + *pDev = NULL; + *xkb_err= XkbErr_BadClass; + return XkbKeyboardErrorCode; } - return dev; + return Success; } void -- cgit v1.2.3 From 5277a6ff589b5ddb475b90e1aaf5dbd9172d9711 Mon Sep 17 00:00:00 2001 From: Eamon Walsh Date: Mon, 15 Oct 2007 13:38:35 -0400 Subject: registry: Register Input extension protocol names. --- Xi/extinit.c | 117 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) (limited to 'Xi') diff --git a/Xi/extinit.c b/Xi/extinit.c index 1a435edad..bf5ebd221 100644 --- a/Xi/extinit.c +++ b/Xi/extinit.c @@ -69,6 +69,7 @@ SOFTWARE. #include "extinit.h" #include "exglobals.h" #include "swaprep.h" +#include "registry.h" /* modules local to Xi */ #include "allowev.h" @@ -936,6 +937,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; @@ -957,4 +959,119 @@ XInputExtensionInit(void) } else { FatalError("IExtensionInit: AddExtensions failed\n"); } + + RegisterRequestName(IReqCode, X_GetExtensionVersion, + INAME ":GetExtensionVersion"); + RegisterRequestName(IReqCode, X_ListInputDevices, + INAME ":ListInputDevices"); + RegisterRequestName(IReqCode, X_OpenDevice, + INAME ":OpenDevice"); + RegisterRequestName(IReqCode, X_CloseDevice, + INAME ":CloseDevice"); + RegisterRequestName(IReqCode, X_SetDeviceMode, + INAME ":SetDeviceMode"); + RegisterRequestName(IReqCode, X_SelectExtensionEvent, + INAME ":SelectExtensionEvent"); + RegisterRequestName(IReqCode, X_GetSelectedExtensionEvents, + INAME ":GetSelectedExtensionEvents"); + RegisterRequestName(IReqCode, X_ChangeDeviceDontPropagateList, + INAME ":ChangeDeviceDontPropagateList"); + RegisterRequestName(IReqCode, X_GetDeviceDontPropagateList, + INAME ":GetDeviceDontPropagageList"); + RegisterRequestName(IReqCode, X_GetDeviceMotionEvents, + INAME ":GetDeviceMotionEvents"); + RegisterRequestName(IReqCode, X_ChangeKeyboardDevice, + INAME ":ChangeKeyboardDevice"); + RegisterRequestName(IReqCode, X_ChangePointerDevice, + INAME ":ChangePointerDevice"); + RegisterRequestName(IReqCode, X_GrabDevice, + INAME ":GrabDevice"); + RegisterRequestName(IReqCode, X_UngrabDevice, + INAME ":UngrabDevice"); + RegisterRequestName(IReqCode, X_GrabDeviceKey, + INAME ":GrabDeviceKey"); + RegisterRequestName(IReqCode, X_UngrabDeviceKey, + INAME ":UngrabDeviceKey"); + RegisterRequestName(IReqCode, X_GrabDeviceButton, + INAME ":GrabDeviceButton"); + RegisterRequestName(IReqCode, X_UngrabDeviceButton, + INAME ":UngrabDeviceButton"); + RegisterRequestName(IReqCode, X_AllowDeviceEvents, + INAME ":AllowDeviceEvents"); + RegisterRequestName(IReqCode, X_GetDeviceFocus, + INAME ":GetDeviceFocus"); + RegisterRequestName(IReqCode, X_SetDeviceFocus, + INAME ":SetDeviceFocus"); + RegisterRequestName(IReqCode, X_GetFeedbackControl, + INAME ":GetFeedbackControl"); + RegisterRequestName(IReqCode, X_ChangeFeedbackControl, + INAME ":ChangeFeedbackControl"); + RegisterRequestName(IReqCode, X_GetDeviceKeyMapping, + INAME ":GetDeviceKeyMapping"); + RegisterRequestName(IReqCode, X_ChangeDeviceKeyMapping, + INAME ":ChangeDeviceKeyMapping"); + RegisterRequestName(IReqCode, X_GetDeviceModifierMapping, + INAME ":GetDeviceModifierMapping"); + RegisterRequestName(IReqCode, X_SetDeviceModifierMapping, + INAME ":SetDeviceModifierMapping"); + RegisterRequestName(IReqCode, X_GetDeviceButtonMapping, + INAME ":GetDeviceButtonMapping"); + RegisterRequestName(IReqCode, X_SetDeviceButtonMapping, + INAME ":SetDeviceButtonMapping"); + RegisterRequestName(IReqCode, X_QueryDeviceState, + INAME ":QueryDeviceState"); + RegisterRequestName(IReqCode, X_SendExtensionEvent, + INAME ":SendExtensionEvent"); + RegisterRequestName(IReqCode, X_DeviceBell, + INAME ":DeviceBell"); + RegisterRequestName(IReqCode, X_SetDeviceValuators, + INAME ":SetDeviceValuators"); + RegisterRequestName(IReqCode, X_GetDeviceControl, + INAME ":GetDeviceControl"); + RegisterRequestName(IReqCode, X_ChangeDeviceControl, + INAME ":ChangeDeviceControl"); + + RegisterEventName(extEntry->eventBase + XI_DeviceValuator, + INAME ":DeviceValuator"); + RegisterEventName(extEntry->eventBase + XI_DeviceKeyPress, + INAME ":DeviceKeyPress"); + RegisterEventName(extEntry->eventBase + XI_DeviceKeyRelease, + INAME ":DeviceKeyRelease"); + RegisterEventName(extEntry->eventBase + XI_DeviceButtonPress, + INAME ":DeviceButtonPress"); + RegisterEventName(extEntry->eventBase + XI_DeviceButtonRelease, + INAME ":DeviceButtonRelease"); + RegisterEventName(extEntry->eventBase + XI_DeviceMotionNotify, + INAME ":DeviceMotionNotify"); + RegisterEventName(extEntry->eventBase + XI_DeviceFocusIn, + INAME ":DeviceFocusIn"); + RegisterEventName(extEntry->eventBase + XI_DeviceFocusOut, + INAME ":DeviceFocusOut"); + RegisterEventName(extEntry->eventBase + XI_ProximityIn, + INAME ":ProximityIn"); + RegisterEventName(extEntry->eventBase + XI_ProximityOut, + INAME ":ProximityOut"); + RegisterEventName(extEntry->eventBase + XI_DeviceStateNotify, + INAME ":DeviceStateNotify"); + RegisterEventName(extEntry->eventBase + XI_DeviceMappingNotify, + INAME ":DeviceMappingNotify"); + RegisterEventName(extEntry->eventBase + XI_ChangeDeviceNotify, + INAME ":ChangeDeviceNotify"); + RegisterEventName(extEntry->eventBase + XI_DeviceKeystateNotify, + INAME ":DeviceKeystateNotify"); + RegisterEventName(extEntry->eventBase + XI_DeviceButtonstateNotify, + INAME ":DeviceButtonstateNotify"); + RegisterEventName(extEntry->eventBase + XI_DevicePresenceNotify, + INAME ":DevicePresenceNotify"); + + RegisterErrorName(extEntry->errorBase + XI_BadDevice, + INAME ":BadDevice"); + RegisterErrorName(extEntry->errorBase + XI_BadEvent, + INAME ":BadEvent"); + RegisterErrorName(extEntry->errorBase + XI_BadMode, + INAME ":BadMode"); + RegisterErrorName(extEntry->errorBase + XI_DeviceBusy, + INAME ":DeviceBusy"); + RegisterErrorName(extEntry->errorBase + XI_BadClass, + INAME ":BadClass"); } -- cgit v1.2.3 From 6107a245035366fe762756b6aa05ac0e3a5482bb Mon Sep 17 00:00:00 2001 From: Eamon Walsh Date: Thu, 18 Oct 2007 12:24:55 -0400 Subject: dix: Add client parameter to AddPassiveGrabsToList(). --- Xi/exevents.c | 4 ++-- dix/events.c | 4 ++-- dix/grabs.c | 5 ++--- include/dixgrabs.h | 1 + 4 files changed, 7 insertions(+), 7 deletions(-) (limited to 'Xi') diff --git a/Xi/exevents.c b/Xi/exevents.c index 9a179500b..7a54c08d2 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -566,7 +566,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 @@ -621,7 +621,7 @@ GrabKey(ClientPtr client, DeviceIntPtr dev, BYTE this_device_mode, NullWindow, NullCursor); if (!grab) return BadAlloc; - return AddPassiveGrabToList(grab); + return AddPassiveGrabToList(client, grab); } int diff --git a/dix/events.c b/dix/events.c index bb5b9507b..246220f59 100644 --- a/dix/events.c +++ b/dix/events.c @@ -4727,7 +4727,7 @@ ProcGrabKey(ClientPtr client) NullWindow, NullCursor); if (!grab) return BadAlloc; - return AddPassiveGrabToList(grab); + return AddPassiveGrabToList(client, grab); } @@ -4815,7 +4815,7 @@ ProcGrabButton(ClientPtr client) stuff->button, confineTo, cursor); if (!grab) return BadAlloc; - return AddPassiveGrabToList(grab); + return AddPassiveGrabToList(client, grab); } /** diff --git a/dix/grabs.c b/dix/grabs.c index b8d0df88d..229329699 100644 --- a/dix/grabs.c +++ b/dix/grabs.c @@ -307,7 +307,7 @@ GrabsAreIdentical(GrabPtr pFirstGrab, GrabPtr pSecondGrab) * @return Success or X error code on failure. */ int -AddPassiveGrabToList(GrabPtr pGrab) +AddPassiveGrabToList(ClientPtr client, GrabPtr pGrab) { GrabPtr grab; Mask access_mode = DixGrabAccess; @@ -327,8 +327,7 @@ AddPassiveGrabToList(GrabPtr pGrab) if (grab->keyboardMode == GrabModeSync || grab->pointerMode == GrabModeSync) access_mode |= DixFreezeAccess; - rc = XaceHook(XACE_DEVICE_ACCESS, clients[CLIENT_ID(grab->resource)], - grab->device, access_mode); + rc = XaceHook(XACE_DEVICE_ACCESS, client, grab->device, access_mode); if (rc != Success) return rc; diff --git a/include/dixgrabs.h b/include/dixgrabs.h index 2d66d6ba1..f93e99957 100644 --- a/include/dixgrabs.h +++ b/include/dixgrabs.h @@ -50,6 +50,7 @@ extern Bool GrabMatchesSecond( GrabPtr /* pSecondGrab */); extern int AddPassiveGrabToList( + ClientPtr /* client */, GrabPtr /* pGrab */); extern Bool DeletePassiveGrabFromList( -- cgit v1.2.3 From 17b0c729b553e2f0f8f82497698b282a47db3326 Mon Sep 17 00:00:00 2001 From: Eamon Walsh Date: Tue, 20 Nov 2007 18:46:43 -0500 Subject: registry: Remove registry code from XInput extension. Moving all the names into dix/registry.c --- Xi/extinit.c | 115 ----------------------------------------------------------- 1 file changed, 115 deletions(-) (limited to 'Xi') diff --git a/Xi/extinit.c b/Xi/extinit.c index bf5ebd221..2ffdafbc1 100644 --- a/Xi/extinit.c +++ b/Xi/extinit.c @@ -959,119 +959,4 @@ XInputExtensionInit(void) } else { FatalError("IExtensionInit: AddExtensions failed\n"); } - - RegisterRequestName(IReqCode, X_GetExtensionVersion, - INAME ":GetExtensionVersion"); - RegisterRequestName(IReqCode, X_ListInputDevices, - INAME ":ListInputDevices"); - RegisterRequestName(IReqCode, X_OpenDevice, - INAME ":OpenDevice"); - RegisterRequestName(IReqCode, X_CloseDevice, - INAME ":CloseDevice"); - RegisterRequestName(IReqCode, X_SetDeviceMode, - INAME ":SetDeviceMode"); - RegisterRequestName(IReqCode, X_SelectExtensionEvent, - INAME ":SelectExtensionEvent"); - RegisterRequestName(IReqCode, X_GetSelectedExtensionEvents, - INAME ":GetSelectedExtensionEvents"); - RegisterRequestName(IReqCode, X_ChangeDeviceDontPropagateList, - INAME ":ChangeDeviceDontPropagateList"); - RegisterRequestName(IReqCode, X_GetDeviceDontPropagateList, - INAME ":GetDeviceDontPropagageList"); - RegisterRequestName(IReqCode, X_GetDeviceMotionEvents, - INAME ":GetDeviceMotionEvents"); - RegisterRequestName(IReqCode, X_ChangeKeyboardDevice, - INAME ":ChangeKeyboardDevice"); - RegisterRequestName(IReqCode, X_ChangePointerDevice, - INAME ":ChangePointerDevice"); - RegisterRequestName(IReqCode, X_GrabDevice, - INAME ":GrabDevice"); - RegisterRequestName(IReqCode, X_UngrabDevice, - INAME ":UngrabDevice"); - RegisterRequestName(IReqCode, X_GrabDeviceKey, - INAME ":GrabDeviceKey"); - RegisterRequestName(IReqCode, X_UngrabDeviceKey, - INAME ":UngrabDeviceKey"); - RegisterRequestName(IReqCode, X_GrabDeviceButton, - INAME ":GrabDeviceButton"); - RegisterRequestName(IReqCode, X_UngrabDeviceButton, - INAME ":UngrabDeviceButton"); - RegisterRequestName(IReqCode, X_AllowDeviceEvents, - INAME ":AllowDeviceEvents"); - RegisterRequestName(IReqCode, X_GetDeviceFocus, - INAME ":GetDeviceFocus"); - RegisterRequestName(IReqCode, X_SetDeviceFocus, - INAME ":SetDeviceFocus"); - RegisterRequestName(IReqCode, X_GetFeedbackControl, - INAME ":GetFeedbackControl"); - RegisterRequestName(IReqCode, X_ChangeFeedbackControl, - INAME ":ChangeFeedbackControl"); - RegisterRequestName(IReqCode, X_GetDeviceKeyMapping, - INAME ":GetDeviceKeyMapping"); - RegisterRequestName(IReqCode, X_ChangeDeviceKeyMapping, - INAME ":ChangeDeviceKeyMapping"); - RegisterRequestName(IReqCode, X_GetDeviceModifierMapping, - INAME ":GetDeviceModifierMapping"); - RegisterRequestName(IReqCode, X_SetDeviceModifierMapping, - INAME ":SetDeviceModifierMapping"); - RegisterRequestName(IReqCode, X_GetDeviceButtonMapping, - INAME ":GetDeviceButtonMapping"); - RegisterRequestName(IReqCode, X_SetDeviceButtonMapping, - INAME ":SetDeviceButtonMapping"); - RegisterRequestName(IReqCode, X_QueryDeviceState, - INAME ":QueryDeviceState"); - RegisterRequestName(IReqCode, X_SendExtensionEvent, - INAME ":SendExtensionEvent"); - RegisterRequestName(IReqCode, X_DeviceBell, - INAME ":DeviceBell"); - RegisterRequestName(IReqCode, X_SetDeviceValuators, - INAME ":SetDeviceValuators"); - RegisterRequestName(IReqCode, X_GetDeviceControl, - INAME ":GetDeviceControl"); - RegisterRequestName(IReqCode, X_ChangeDeviceControl, - INAME ":ChangeDeviceControl"); - - RegisterEventName(extEntry->eventBase + XI_DeviceValuator, - INAME ":DeviceValuator"); - RegisterEventName(extEntry->eventBase + XI_DeviceKeyPress, - INAME ":DeviceKeyPress"); - RegisterEventName(extEntry->eventBase + XI_DeviceKeyRelease, - INAME ":DeviceKeyRelease"); - RegisterEventName(extEntry->eventBase + XI_DeviceButtonPress, - INAME ":DeviceButtonPress"); - RegisterEventName(extEntry->eventBase + XI_DeviceButtonRelease, - INAME ":DeviceButtonRelease"); - RegisterEventName(extEntry->eventBase + XI_DeviceMotionNotify, - INAME ":DeviceMotionNotify"); - RegisterEventName(extEntry->eventBase + XI_DeviceFocusIn, - INAME ":DeviceFocusIn"); - RegisterEventName(extEntry->eventBase + XI_DeviceFocusOut, - INAME ":DeviceFocusOut"); - RegisterEventName(extEntry->eventBase + XI_ProximityIn, - INAME ":ProximityIn"); - RegisterEventName(extEntry->eventBase + XI_ProximityOut, - INAME ":ProximityOut"); - RegisterEventName(extEntry->eventBase + XI_DeviceStateNotify, - INAME ":DeviceStateNotify"); - RegisterEventName(extEntry->eventBase + XI_DeviceMappingNotify, - INAME ":DeviceMappingNotify"); - RegisterEventName(extEntry->eventBase + XI_ChangeDeviceNotify, - INAME ":ChangeDeviceNotify"); - RegisterEventName(extEntry->eventBase + XI_DeviceKeystateNotify, - INAME ":DeviceKeystateNotify"); - RegisterEventName(extEntry->eventBase + XI_DeviceButtonstateNotify, - INAME ":DeviceButtonstateNotify"); - RegisterEventName(extEntry->eventBase + XI_DevicePresenceNotify, - INAME ":DevicePresenceNotify"); - - RegisterErrorName(extEntry->errorBase + XI_BadDevice, - INAME ":BadDevice"); - RegisterErrorName(extEntry->errorBase + XI_BadEvent, - INAME ":BadEvent"); - RegisterErrorName(extEntry->errorBase + XI_BadMode, - INAME ":BadMode"); - RegisterErrorName(extEntry->errorBase + XI_DeviceBusy, - INAME ":DeviceBusy"); - RegisterErrorName(extEntry->errorBase + XI_BadClass, - INAME ":BadClass"); } -- cgit v1.2.3 From edebe76cfdb31072d18a6fcd3ee8f1d95006855f Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 27 Nov 2007 10:22:44 +1030 Subject: Xi: set DeviceXXXState's length fields to the correct size of the struct. Setting it to the size of a pointer is an interesting but equally wrong approach. Luckily Xlib never used this field anyway so nobody got hurt so far. Spotted by Simon Thum. (cherry picked from commit 0f2398d06ce591724e388b3270800c5e22b3de2d) --- Xi/getdctl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'Xi') diff --git a/Xi/getdctl.c b/Xi/getdctl.c index 8a84e91bc..7175dc253 100644 --- a/Xi/getdctl.c +++ b/Xi/getdctl.c @@ -128,7 +128,7 @@ static void CopySwapDeviceAbsCalib (ClientPtr client, AbsoluteClassPtr dts, xDeviceAbsCalibState *calib = (xDeviceAbsCalibState *) buf; calib->control = DEVICE_ABS_CALIB; - calib->length = sizeof(calib); + calib->length = sizeof(xDeviceAbsCalibState); calib->min_x = dts->min_x; calib->max_x = dts->max_x; calib->min_y = dts->min_y; @@ -159,7 +159,7 @@ static void CopySwapDeviceAbsArea (ClientPtr client, AbsoluteClassPtr dts, xDeviceAbsAreaState *area = (xDeviceAbsAreaState *) buf; area->control = DEVICE_ABS_AREA; - area->length = sizeof(area); + area->length = sizeof(xDeviceAbsAreaState); area->offset_x = dts->offset_x; area->offset_y = dts->offset_y; area->width = dts->width; @@ -185,7 +185,7 @@ static void CopySwapDeviceCore (ClientPtr client, DeviceIntPtr dev, char *buf) xDeviceCoreState *c = (xDeviceCoreState *) buf; c->control = DEVICE_CORE; - c->length = sizeof(c); + c->length = sizeof(xDeviceCoreState); c->status = dev->coreEvents; c->iscore = (dev == inputInfo.keyboard || dev == inputInfo.pointer); @@ -202,7 +202,7 @@ static void CopySwapDeviceEnable (ClientPtr client, DeviceIntPtr dev, char *buf) xDeviceEnableState *e = (xDeviceEnableState *) buf; e->control = DEVICE_ENABLE; - e->length = sizeof(e); + e->length = sizeof(xDeviceEnableState); e->enable = dev->enabled; if (client->swapped) { -- cgit v1.2.3 From 0fccb24aa978b838cf0fb008e9695837e612c529 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Fri, 30 Nov 2007 20:35:26 +0200 Subject: ProcessOtherEvent: Don't do double translation of button events We already deal with the button mapping in GetPointerEvents, so don't do the remapping again in ProcessOtherEvent. --- Xi/exevents.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Xi') diff --git a/Xi/exevents.c b/Xi/exevents.c index 377311ec9..7cf0c50a5 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -244,7 +244,7 @@ ProcessOtherEvent(xEventPtr xE, DeviceIntPtr other, int count) other->valuator->motionHintWindow = NullWindow; b->buttonsDown++; b->motionMask = DeviceButtonMotionMask; - xE->u.u.detail = b->map[key]; + xE->u.u.detail = key; if (xE->u.u.detail == 0) return; if (xE->u.u.detail <= 5) @@ -266,7 +266,7 @@ ProcessOtherEvent(xEventPtr xE, DeviceIntPtr other, int count) other->valuator->motionHintWindow = NullWindow; if (b->buttonsDown >= 1 && !--b->buttonsDown) b->motionMask = 0; - xE->u.u.detail = b->map[key]; + xE->u.u.detail = key; if (xE->u.u.detail == 0) return; if (xE->u.u.detail <= 5) -- cgit v1.2.3 From d0308b64655360517d83e07e866d103c3f2b389d Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 19 Dec 2007 18:18:10 +1030 Subject: Xi: specify correct struct when calculating size of GetDeviceControl reply. This doesn't change much, as the struct previously given has the same size as the ones now anyway. Still, we should be pendantic. Thanks to Simon Thum for reporting. --- Xi/getdctl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'Xi') diff --git a/Xi/getdctl.c b/Xi/getdctl.c index 6e1e3ef58..c979959e2 100644 --- a/Xi/getdctl.c +++ b/Xi/getdctl.c @@ -265,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; -- cgit v1.2.3