diff options
author | Peter Hutterer <peter@cs.unisa.edu.au> | 2008-01-03 17:04:54 +1030 |
---|---|---|
committer | Peter Hutterer <peter@cs.unisa.edu.au> | 2008-01-03 17:04:54 +1030 |
commit | 8da83836b60f7cdb75d08482f4311fa0e2ab4e1d (patch) | |
tree | 092efcfc39e3e293baaf04c4c84027ee453d3e13 /xkb | |
parent | eace88989c3b65d5c20e9f37ea9b23c7c8e19335 (diff) | |
parent | ae869fc7669764729e13fdd70149ed636753f2a3 (diff) |
Merge branch 'master' into mpx
Conflicts:
XTrap/xtrapddmi.c
Xext/security.c
Xext/xprint.c
Xext/xtest.c
Xext/xvdisp.c
Xi/exevents.c
Xi/grabdevb.c
Xi/grabdevk.c
Xi/opendev.c
Xi/ungrdev.c
Xi/ungrdevb.c
Xi/ungrdevk.c
dix/cursor.c
dix/devices.c
dix/dixutils.c
dix/events.c
dix/getevents.c
dix/main.c
dix/window.c
hw/xfree86/ramdac/xf86Cursor.c
include/dix.h
include/input.h
include/inputstr.h
mi/midispcur.c
mi/miinitext.c
mi/misprite.c
render/animcur.c
xfixes/cursor.c
xkb/xkbAccessX.c
Diffstat (limited to 'xkb')
-rw-r--r-- | xkb/ddxDevBtn.c | 2 | ||||
-rw-r--r-- | xkb/ddxFakeBtn.c | 2 | ||||
-rw-r--r-- | xkb/ddxFakeMtn.c | 2 | ||||
-rw-r--r-- | xkb/ddxKillSrv.c | 4 | ||||
-rw-r--r-- | xkb/xkb.c | 101 | ||||
-rw-r--r-- | xkb/xkbAccessX.c | 15 | ||||
-rw-r--r-- | xkb/xkbActions.c | 42 | ||||
-rw-r--r-- | xkb/xkbEvents.c | 5 | ||||
-rw-r--r-- | xkb/xkbLEDs.c | 10 | ||||
-rw-r--r-- | xkb/xkbPrOtherEv.c | 2 | ||||
-rw-r--r-- | xkb/xkbUtils.c | 147 |
11 files changed, 190 insertions, 142 deletions
diff --git a/xkb/ddxDevBtn.c b/xkb/ddxDevBtn.c index 89c17d28a..e812e0be6 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 3dbb5330e..f9dcbf79d 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(inputInfo.pointer, &x,&y); ev.u.u.type = event; diff --git a/xkb/ddxFakeMtn.c b/xkb/ddxFakeMtn.c index 446764c86..3f010f9ce 100644 --- a/xkb/ddxFakeMtn.c +++ b/xkb/ddxFakeMtn.c @@ -107,7 +107,7 @@ ScreenPtr pScreen, oldScreen; oldY= y; else oldY+= y; -#define GetScreenPrivate(s) ((miPointerScreenPtr) ((s)->devPrivates[miPointerScreenIndex].ptr)) +#define GetScreenPrivate(s) ((miPointerScreenPtr)dixLookupPrivate(&(s)->devPrivates, miPointerScreenKey)) (*(GetScreenPrivate(oldScreen))->screenFuncs->CursorOffScreen) (&pScreen, &oldX, &oldY); } diff --git a/xkb/ddxKillSrv.c b/xkb/ddxKillSrv.c index a573ecbd8..3b5fd5353 100644 --- a/xkb/ddxKillSrv.c +++ b/xkb/ddxKillSrv.c @@ -41,6 +41,8 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. int XkbDDXTerminateServer(DeviceIntPtr dev,KeyCode key,XkbAction *act) { - GiveUp(1); + if (dev != inputInfo.keyboard) + GiveUp(1); + return 0; } @@ -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 b26c91880..a035d8d32 100644 --- a/xkb/xkbAccessX.c +++ b/xkb/xkbAccessX.c @@ -308,14 +308,19 @@ xkbControlsNotify cn; static CARD32 AccessXRepeatKeyExpire(OsTimerPtr timer,CARD32 now,pointer arg) { -XkbSrvInfoPtr xkbi= ((DeviceIntPtr)arg)->key->xkbInfo; +DeviceIntPtr dev = (DeviceIntPtr) arg; +XkbSrvInfoPtr xkbi = dev->key->xkbInfo; KeyCode key; +BOOL is_core; - if (xkbi->repeatKey==0) + if (xkbi->repeatKey == 0) return 0; - key= xkbi->repeatKey; - AccessXKeyboardEvent((DeviceIntPtr)arg,KeyRelease,key,True); - AccessXKeyboardEvent((DeviceIntPtr)arg,KeyPress,key,True); + + is_core = (dev == inputInfo.keyboard); + key = xkbi->repeatKey; + AccessXKeyboardEvent(dev, is_core ? KeyRelease : DeviceKeyRelease, key, + True); + AccessXKeyboardEvent(dev, is_core ? KeyPress : DeviceKeyPress, key, True); return xkbi->desc->ctrls->repeat_interval; } diff --git a/xkb/xkbActions.c b/xkb/xkbActions.c index ebc5bfda7..00165be33 100644 --- a/xkb/xkbActions.c +++ b/xkb/xkbActions.c @@ -42,8 +42,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include <ctype.h> #define EXTENSION_EVENT_BASE 64 -static unsigned int _xkbServerGeneration; -int xkbDevicePrivateIndex = -1; +DevPrivateKey xkbDevicePrivateKey = &xkbDevicePrivateKey; void xkbUnwrapProc(DeviceIntPtr device, DeviceHandleProc proc, @@ -67,20 +66,12 @@ XkbSetExtension(DeviceIntPtr device, ProcessInputProc proc) { xkbDeviceInfoPtr xkbPrivPtr; - if (serverGeneration != _xkbServerGeneration) { - if ((xkbDevicePrivateIndex = AllocateDevicePrivateIndex()) == -1) - return; - _xkbServerGeneration = serverGeneration; - } - if (!AllocateDevicePrivate(device, xkbDevicePrivateIndex)) - return; - xkbPrivPtr = (xkbDeviceInfoPtr) xcalloc(1, sizeof(xkbDeviceInfoRec)); if (!xkbPrivPtr) return; xkbPrivPtr->unwrapProc = NULL; - device->devPrivates[xkbDevicePrivateIndex].ptr = xkbPrivPtr; + dixSetPrivate(&device->devPrivates, xkbDevicePrivateKey, xkbPrivPtr); WRAP_PROCESS_INPUT_PROC(device, xkbPrivPtr, proc, xkbUnwrapProc); } @@ -561,6 +552,9 @@ _XkbFilterPointerMove( XkbSrvInfoPtr xkbi, int x,y; Bool accel; + if (xkbi->device == inputInfo.keyboard) + return 0; + if (filter->keycode==0) { /* initial press */ filter->keycode = keycode; filter->active = 1; @@ -601,6 +595,9 @@ _XkbFilterPointerBtn( XkbSrvInfoPtr xkbi, unsigned keycode, XkbAction * pAction) { + if (xkbi->device == inputInfo.keyboard) + return 0; + if (filter->keycode==0) { /* initial press */ int button= pAction->btn.button; @@ -972,8 +969,11 @@ _XkbFilterSwitchScreen( XkbSrvInfoPtr xkbi, unsigned keycode, XkbAction * pAction) { + DeviceIntPtr dev = xkbi->device; + if (dev == inputInfo.keyboard) + return 0; + if (filter->keycode==0) { /* initial press */ - DeviceIntPtr dev = xkbi->device; filter->keycode = keycode; filter->active = 1; filter->filterOthers = 0; @@ -995,8 +995,11 @@ _XkbFilterXF86Private( XkbSrvInfoPtr xkbi, unsigned keycode, XkbAction * pAction) { + DeviceIntPtr dev = xkbi->device; + if (dev == inputInfo.keyboard) + return 0; + if (filter->keycode==0) { /* initial press */ - DeviceIntPtr dev = xkbi->device; filter->keycode = keycode; filter->active = 1; filter->filterOthers = 0; @@ -1021,9 +1024,13 @@ _XkbFilterDeviceBtn( XkbSrvInfoPtr xkbi, DeviceIntPtr dev; int button; + if (dev == inputInfo.keyboard) + return 0; + 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; @@ -1062,8 +1069,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 37d850dfa..351a3280e 100644 --- a/xkb/xkbEvents.c +++ b/xkb/xkbEvents.c @@ -405,7 +405,8 @@ XID winID = 0; if ((force||(xkbi->desc->ctrls->enabled_ctrls&XkbAudibleBellMask))&& (!eventOnly)) { - (*kbd->kbdfeed->BellProc)(percent,kbd,(pointer)pCtrl,class); + if (kbd->kbdfeed->BellProc) + (*kbd->kbdfeed->BellProc)(percent,kbd,(pointer)pCtrl,class); } interest = kbd->xkb_interest; if ((!interest)||(force)) @@ -807,7 +808,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 d49a3c63d..e6dcb476f 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; - - dev= (DeviceIntPtr)LookupDevice(id); - 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 |