summaryrefslogtreecommitdiff
path: root/xkb
diff options
context:
space:
mode:
authorEamon Walsh <ewalsh@tycho.nsa.gov>2007-09-28 13:34:18 -0400
committerEamon Walsh <ewalsh@moss-charon.epoch.ncsc.mil>2007-09-28 13:34:18 -0400
commit8b548657204000e18c7a38706a0071ae2f93159f (patch)
treed27bfac8684053439bad7d911c8fe4ad0c758995 /xkb
parent5c03d131815cfe2f78792277ab8352e69e830196 (diff)
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.
Diffstat (limited to 'xkb')
-rw-r--r--xkb/ddxDevBtn.c2
-rw-r--r--xkb/ddxFakeBtn.c2
-rw-r--r--xkb/xkb.c101
-rw-r--r--xkb/xkbAccessX.c2
-rw-r--r--xkb/xkbActions.c10
-rw-r--r--xkb/xkbEvents.c2
-rw-r--r--xkb/xkbLEDs.c10
-rw-r--r--xkb/xkbPrOtherEv.c2
-rw-r--r--xkb/xkbUtils.c147
9 files changed, 156 insertions, 122 deletions
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 <xkbsrv.h>
#include "extnsionst.h"
+#include "xace.h"
#include "xkb.h"
#include <X11/extensions/XI.h>
@@ -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;i<stuff->nBtns;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