diff options
author | Eamon Walsh <ewalsh@tycho.nsa.gov> | 2007-11-05 19:08:36 -0500 |
---|---|---|
committer | Eamon Walsh <ewalsh@moss-charon.epoch.ncsc.mil> | 2007-11-05 19:08:36 -0500 |
commit | a52c9b2a59f27266557ff9d5d2c08492e04135a6 (patch) | |
tree | 705f11c54e8a31a07dde9ab6835032e2849e132b /xkb | |
parent | c7e18beb3c87eb1ada9b21c4ffacd11c1939c087 (diff) | |
parent | 58332894c061ae96d6a457f65266660f5f65e88b (diff) |
Merge branch 'master' into XACE-SELINUX
Conflicts:
dix/dispatch.c
dix/property.c
hw/xfree86/common/xf86VidMode.c
include/xkbsrv.h
render/glyph.c
xkb/xkbActions.c
Diffstat (limited to 'xkb')
-rw-r--r-- | xkb/xkb.c | 24 | ||||
-rw-r--r-- | xkb/xkbAccessX.c | 23 | ||||
-rw-r--r-- | xkb/xkbActions.c | 160 | ||||
-rw-r--r-- | xkb/xkbEvents.c | 39 | ||||
-rw-r--r-- | xkb/xkbInit.c | 4 | ||||
-rw-r--r-- | xkb/xkbPrKeyEv.c | 110 |
6 files changed, 219 insertions, 141 deletions
@@ -1318,7 +1318,7 @@ unsigned i,len; char *desc,*start; len= (rep->length*4)-(SIZEOF(xkbGetMapReply)-SIZEOF(xGenericReply)); - start= desc= (char *)ALLOCATE_LOCAL(len); + start= desc= (char *)xalloc(len); if (!start) return BadAlloc; if ( rep->nTypes>0 ) @@ -1358,7 +1358,7 @@ char *desc,*start; } WriteToClient(client, (i=SIZEOF(xkbGetMapReply)), (char *)rep); WriteToClient(client, len, start); - DEALLOCATE_LOCAL((char *)start); + xfree((char *)start); return client->noClientException; } @@ -2505,7 +2505,7 @@ int size; size= rep->length*4; if (size>0) { - data = (char *)ALLOCATE_LOCAL(size); + data = (char *)xalloc(size); if (data) { register unsigned i,bit; xkbModsWireDesc * grp; @@ -2556,7 +2556,7 @@ int size; WriteToClient(client, SIZEOF(xkbGetCompatMapReply), (char *)rep); if (data) { WriteToClient(client, size, data); - DEALLOCATE_LOCAL((char *)data); + xfree((char *)data); } return client->noClientException; } @@ -2807,7 +2807,7 @@ register unsigned bit; length = rep->length*4; if (length>0) { CARD8 *to; - to= map= (CARD8 *)ALLOCATE_LOCAL(length); + to= map= (CARD8 *)xalloc(length); if (map) { xkbIndicatorMapWireDesc *wire = (xkbIndicatorMapWireDesc *)to; for (i=0,bit=1;i<XkbNumIndicators;i++,bit<<=1) { @@ -2846,7 +2846,7 @@ register unsigned bit; WriteToClient(client, SIZEOF(xkbGetIndicatorMapReply), (char *)rep); if (map) { WriteToClient(client, length, (char *)map); - DEALLOCATE_LOCAL((char *)map); + xfree((char *)map); } return client->noClientException; } @@ -3295,7 +3295,7 @@ register int n; swapl(&rep->indicators,n); } - start = desc = (char *)ALLOCATE_LOCAL(length); + start = desc = (char *)xalloc(length); if ( !start ) return BadAlloc; if (xkb->names) { @@ -3419,7 +3419,7 @@ register int n; } WriteToClient(client, SIZEOF(xkbGetNamesReply), (char *)rep); WriteToClient(client, length, start); - DEALLOCATE_LOCAL((char *)start); + xfree((char *)start); return client->noClientException; } @@ -4317,7 +4317,7 @@ XkbSendGeometry( ClientPtr client, if (geom!=NULL) { len= rep->length*4; - start= desc= (char *)ALLOCATE_LOCAL(len); + start= desc= (char *)xalloc(len); if (!start) return BadAlloc; desc= XkbWriteCountedString(desc,geom->label_font,client->swapped); @@ -4361,7 +4361,7 @@ XkbSendGeometry( ClientPtr client, if (len>0) WriteToClient(client, len, start); if (start!=NULL) - DEALLOCATE_LOCAL((char *)start); + xfree((char *)start); if (freeGeom) XkbFreeGeometry(geom,XkbGeomAllMask,True); return client->noClientException; @@ -5763,12 +5763,12 @@ char * str; } WriteToClient(client,SIZEOF(xkbGetDeviceInfoReply), (char *)&rep); - str= (char*) ALLOCATE_LOCAL(nameLen); + str= (char*) xalloc(nameLen); if (!str) return BadAlloc; XkbWriteCountedString(str,dev->name,client->swapped); WriteToClient(client,nameLen,str); - DEALLOCATE_LOCAL(str); + xfree(str); length-= nameLen; if (rep.nBtnsRtrn>0) { diff --git a/xkb/xkbAccessX.c b/xkb/xkbAccessX.c index fbd281536..50a611eb4 100644 --- a/xkb/xkbAccessX.c +++ b/xkb/xkbAccessX.c @@ -692,6 +692,8 @@ ProcessPointerEvent( register xEvent * xE, DeviceIntPtr dev = inputInfo.keyboard; XkbSrvInfoPtr xkbi = dev->key->xkbInfo; unsigned changed = 0; +ProcessInputProc backupproc; +xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(mouse); xkbi->shiftKeyCount = 0; xkbi->lastPtrEventTime= xE->u.keyButtonPointer.time; @@ -703,7 +705,26 @@ unsigned changed = 0; xkbi->lockedPtrButtons&= ~(1<<(xE->u.u.detail&0x7)); changed |= XkbPointerButtonMask; } - CoreProcessPointerEvent(xE,mouse,count); + + /* Guesswork. mostly. + * xkb actuall goes through some effort to transparently wrap the + * processInputProcs (see XkbSetExtension). But we all love fun, so the + * previous XKB implementation just hardcoded the CPPE call here instead + * of unwrapping like anybody with any sense of decency would do. + * I got no clue what the correct thing to do is, but my guess is that + * it's not hardcoding. I may be wrong. whatever it is, don't come whining + * to me. I just work here. + * + * Anyway. here's the old call, if you don't like the wrapping, revert it. + * + * CoreProcessPointerEvent(xE,mouse,count); + * + * see. it's still steaming. told you. (whot) + */ + UNWRAP_PROCESS_INPUT_PROC(mouse, xkbPrivPtr, backupproc); + mouse->public.processInputProc(xE, mouse, count); + COND_WRAP_PROCESS_INPUT_PROC(mouse, xkbPrivPtr, + backupproc, xkbUnwrapProc); xkbi->state.ptr_buttons = mouse->button->state; diff --git a/xkb/xkbActions.c b/xkb/xkbActions.c index 822afffcb..380a232d1 100644 --- a/xkb/xkbActions.c +++ b/xkb/xkbActions.c @@ -36,22 +36,25 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include <X11/keysym.h> #include "misc.h" #include "inputstr.h" +#include "exevents.h" #include <xkbsrv.h> #include "xkb.h" #include <ctype.h> +#define EXTENSION_EVENT_BASE 64 -static DevPrivateKey xkbDevicePrivateKey = &xkbDevicePrivateKey; +DevPrivateKey xkbDevicePrivateKey = &xkbDevicePrivateKey; -static void +void xkbUnwrapProc(DeviceIntPtr device, DeviceHandleProc proc, pointer data) { xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(device); ProcessInputProc tmp = device->public.processInputProc; + ProcessInputProc dummy; /* unused, but neede for macro */ if(xkbPrivPtr->unwrapProc) xkbPrivPtr->unwrapProc = NULL; - UNWRAP_PROCESS_INPUT_PROC(device,xkbPrivPtr); + UNWRAP_PROCESS_INPUT_PROC(device,xkbPrivPtr, dummy); proc(device,data); WRAP_PROCESS_INPUT_PROC(device,xkbPrivPtr, tmp,xkbUnwrapProc); @@ -63,23 +66,20 @@ XkbSetExtension(DeviceIntPtr device, ProcessInputProc proc) { xkbDeviceInfoPtr xkbPrivPtr; - xkbPrivPtr = (xkbDeviceInfoPtr) xalloc(sizeof(xkbDeviceInfoRec)); + xkbPrivPtr = (xkbDeviceInfoPtr) xcalloc(1, sizeof(xkbDeviceInfoRec)); if (!xkbPrivPtr) return; xkbPrivPtr->unwrapProc = NULL; dixSetPrivate(&device->devPrivates, xkbDevicePrivateKey, xkbPrivPtr); - WRAP_PROCESS_INPUT_PROC(device,xkbPrivPtr, - proc,xkbUnwrapProc); + WRAP_PROCESS_INPUT_PROC(device, xkbPrivPtr, proc, xkbUnwrapProc); } -#ifdef XINPUT extern void ProcessOtherEvent( xEvent * /* xE */, DeviceIntPtr /* dev */, int /* count */ ); -#endif /***====================================================================***/ @@ -227,22 +227,6 @@ XkbAction fake; #define SYNTHETIC_KEYCODE 1 #define BTN_ACT_FLAG 0x100 -typedef struct _XkbFilter { - CARD16 keycode; - CARD8 what; - CARD8 active; - CARD8 filterOthers; - CARD32 priv; - XkbAction upAction; - int (*filter)( - XkbSrvInfoPtr /* xkbi */, - struct _XkbFilter * /* filter */, - unsigned /* keycode */, - XkbAction * /* action */ - ); - struct _XkbFilter *next; -} XkbFilterRec,*XkbFilterPtr; - static int _XkbFilterSetState( XkbSrvInfoPtr xkbi, XkbFilterPtr filter, @@ -407,7 +391,6 @@ _XkbFilterLockState( XkbSrvInfoPtr xkbi, unsigned keycode, XkbAction * pAction) { - if (pAction&&(pAction->type==XkbSA_LockGroup)) { if (pAction->group.flags&XkbSA_GroupAbsolute) xkbi->state.locked_group= XkbSAGroup(&pAction->group); @@ -679,6 +662,7 @@ _XkbFilterPointerBtn( XkbSrvInfoPtr xkbi, &old,xkbi->desc->ctrls, &cn,False)) { cn.keycode = keycode; + /* XXX: what about DeviceKeyPress? */ cn.eventType = KeyPress; cn.requestMajor = 0; cn.requestMinor = 0; @@ -743,6 +727,7 @@ XkbEventCauseRec cause; ctrls->enabled_ctrls|= change; if (XkbComputeControlsNotify(kbd,&old,ctrls,&cn,False)) { cn.keycode = keycode; + /* XXX: what about DeviceKeyPress? */ cn.eventType = KeyPress; cn.requestMajor = 0; cn.requestMinor = 0; @@ -858,6 +843,7 @@ int x,y; XkbStateRec old; unsigned mods,mask,oldCoreState = 0,oldCorePrevState = 0; xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(xkbi->device); +ProcessInputProc backupproc; /* never actually used uninitialised, but gcc isn't smart enough * to work that out. */ @@ -883,6 +869,7 @@ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(xkbi->device); filter->filter = _XkbFilterRedirectKey; filter->upAction = *pAction; + /* XXX: what about DeviceKeyPress */ ev.u.u.type = KeyPress; ev.u.u.detail = pAction->redirect.new_key; @@ -910,10 +897,14 @@ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(xkbi->device); realMods = xkbi->device->key->modifierMap[ev.u.u.detail]; xkbi->device->key->modifierMap[ev.u.u.detail] = 0; - UNWRAP_PROCESS_INPUT_PROC(xkbi->device,xkbPrivPtr); + /* XXX: Bad! Since the switch to XI devices xkbi->device will be the + * XI device. Sending a core event through ProcessOtherEvent will + * cause trouble. Somebody should fix this. + */ + UNWRAP_PROCESS_INPUT_PROC(xkbi->device,xkbPrivPtr, backupproc); xkbi->device->public.processInputProc(&ev,xkbi->device,1); COND_WRAP_PROCESS_INPUT_PROC(xkbi->device, xkbPrivPtr, - ProcessKeyboardEvent,xkbUnwrapProc); + backupproc,xkbUnwrapProc); xkbi->device->key->modifierMap[ev.u.u.detail] = realMods; if ( mask || mods ) { @@ -924,6 +915,7 @@ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(xkbi->device); } else if (filter->keycode==keycode) { + /* XXX: what about DeviceKeyRelease */ ev.u.u.type = KeyRelease; ev.u.u.detail = filter->upAction.redirect.new_key; @@ -951,10 +943,14 @@ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(xkbi->device); realMods = xkbi->device->key->modifierMap[ev.u.u.detail]; xkbi->device->key->modifierMap[ev.u.u.detail] = 0; - UNWRAP_PROCESS_INPUT_PROC(xkbi->device,xkbPrivPtr); + /* XXX: Bad! Since the switch to XI devices xkbi->device will be the + * XI device. Sending a core event through ProcessOtherEvent will + * cause trouble. Somebody should fix this. + */ + UNWRAP_PROCESS_INPUT_PROC(xkbi->device,xkbPrivPtr, backupproc); xkbi->device->public.processInputProc(&ev,xkbi->device,1); COND_WRAP_PROCESS_INPUT_PROC(xkbi->device, xkbPrivPtr, - ProcessKeyboardEvent,xkbUnwrapProc); + backupproc,xkbUnwrapProc); xkbi->device->key->modifierMap[ev.u.u.detail] = realMods; if ( mask || mods ) { @@ -1014,7 +1010,6 @@ _XkbFilterXF86Private( XkbSrvInfoPtr xkbi, return 1; } -#ifdef XINPUT static int _XkbFilterDeviceBtn( XkbSrvInfoPtr xkbi, @@ -1088,34 +1083,33 @@ int button; } return 0; } -#endif - -static int szFilters = 0; -static XkbFilterPtr filters = NULL; static XkbFilterPtr _XkbNextFreeFilter( - void + XkbSrvInfoPtr xkbi ) { register int i; - if (szFilters==0) { - szFilters = 4; - filters = _XkbTypedCalloc(szFilters,XkbFilterRec); + if (xkbi->szFilters==0) { + xkbi->szFilters = 4; + xkbi->filters = _XkbTypedCalloc(xkbi->szFilters,XkbFilterRec); /* 6/21/93 (ef) -- XXX! deal with allocation failure */ } - for (i=0;i<szFilters;i++) { - if (!filters[i].active) { - filters[i].keycode = 0; - return &filters[i]; + for (i=0;i<xkbi->szFilters;i++) { + if (!xkbi->filters[i].active) { + xkbi->filters[i].keycode = 0; + return &xkbi->filters[i]; } } - szFilters*=2; - filters= _XkbTypedRealloc(filters,szFilters,XkbFilterRec); + xkbi->szFilters*=2; + xkbi->filters= _XkbTypedRealloc(xkbi->filters, + xkbi->szFilters, + XkbFilterRec); /* 6/21/93 (ef) -- XXX! deal with allocation failure */ - bzero(&filters[szFilters/2],(szFilters/2)*sizeof(XkbFilterRec)); - return &filters[szFilters/2]; + bzero(&xkbi->filters[xkbi->szFilters/2], + (xkbi->szFilters/2)*sizeof(XkbFilterRec)); + return &xkbi->filters[xkbi->szFilters/2]; } static int @@ -1124,9 +1118,10 @@ _XkbApplyFilters(XkbSrvInfoPtr xkbi,unsigned kc,XkbAction *pAction) register int i,send; send= 1; - for (i=0;i<szFilters;i++) { - if ((filters[i].active)&&(filters[i].filter)) - send= ((*filters[i].filter)(xkbi,&filters[i],kc,pAction)&&send); + for (i=0;i<xkbi->szFilters;i++) { + if ((xkbi->filters[i].active)&&(xkbi->filters[i].filter)) + send= ((*xkbi->filters[i].filter)(xkbi,&xkbi->filters[i],kc,pAction) + && send); } return send; } @@ -1145,15 +1140,15 @@ XkbAction act; XkbFilterPtr filter; Bool keyEvent; Bool pressEvent; -#ifdef XINPUT -Bool xiEvent; -#endif +ProcessInputProc backupproc; xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(dev); keyc= kbd->key; xkbi= keyc->xkbInfo; key= xE->u.u.detail; + /* The state may change, so if we're not in the middle of sending a state + * notify, prepare for it */ if ((xkbi->flags&_XkbStateNotifyInProgress)==0) { oldState= xkbi->state; xkbi->flags|= _XkbStateNotifyInProgress; @@ -1165,18 +1160,10 @@ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(dev); xkbi->groupChange = 0; sendEvent = 1; -#ifdef XINPUT keyEvent= ((xE->u.u.type==KeyPress)||(xE->u.u.type==DeviceKeyPress)|| (xE->u.u.type==KeyRelease)||(xE->u.u.type==DeviceKeyRelease)); pressEvent= (xE->u.u.type==KeyPress)||(xE->u.u.type==DeviceKeyPress)|| (xE->u.u.type==ButtonPress)||(xE->u.u.type==DeviceButtonPress); - xiEvent= (xE->u.u.type==DeviceKeyPress)||(xE->u.u.type==DeviceKeyRelease)|| - (xE->u.u.type==DeviceButtonPress)|| - (xE->u.u.type==DeviceButtonRelease); -#else - keyEvent= (xE->u.u.type==KeyPress)||(xE->u.u.type==KeyRelease); - pressEvent= (xE->u.u.type==KeyPress)||(xE->u.u.type==ButtonPress); -#endif if (pressEvent) { if (keyEvent) @@ -1190,62 +1177,60 @@ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(dev); switch (act.type) { case XkbSA_SetMods: case XkbSA_SetGroup: - filter = _XkbNextFreeFilter(); + filter = _XkbNextFreeFilter(xkbi); sendEvent = _XkbFilterSetState(xkbi,filter,key,&act); break; case XkbSA_LatchMods: case XkbSA_LatchGroup: - filter = _XkbNextFreeFilter(); + filter = _XkbNextFreeFilter(xkbi); sendEvent=_XkbFilterLatchState(xkbi,filter,key,&act); break; case XkbSA_LockMods: case XkbSA_LockGroup: - filter = _XkbNextFreeFilter(); + filter = _XkbNextFreeFilter(xkbi); sendEvent=_XkbFilterLockState(xkbi,filter,key,&act); break; case XkbSA_ISOLock: - filter = _XkbNextFreeFilter(); + filter = _XkbNextFreeFilter(xkbi); sendEvent=_XkbFilterISOLock(xkbi,filter,key,&act); break; case XkbSA_MovePtr: - filter = _XkbNextFreeFilter(); + filter = _XkbNextFreeFilter(xkbi); sendEvent= _XkbFilterPointerMove(xkbi,filter,key,&act); break; case XkbSA_PtrBtn: case XkbSA_LockPtrBtn: case XkbSA_SetPtrDflt: - filter = _XkbNextFreeFilter(); + filter = _XkbNextFreeFilter(xkbi); sendEvent= _XkbFilterPointerBtn(xkbi,filter,key,&act); break; case XkbSA_Terminate: sendEvent= XkbDDXTerminateServer(dev,key,&act); break; case XkbSA_SwitchScreen: - filter = _XkbNextFreeFilter(); + filter = _XkbNextFreeFilter(xkbi); sendEvent=_XkbFilterSwitchScreen(xkbi,filter,key,&act); break; case XkbSA_SetControls: case XkbSA_LockControls: - filter = _XkbNextFreeFilter(); + filter = _XkbNextFreeFilter(xkbi); sendEvent=_XkbFilterControls(xkbi,filter,key,&act); break; case XkbSA_ActionMessage: - filter = _XkbNextFreeFilter(); + filter = _XkbNextFreeFilter(xkbi); sendEvent=_XkbFilterActionMessage(xkbi,filter,key,&act); break; case XkbSA_RedirectKey: - filter = _XkbNextFreeFilter(); + filter = _XkbNextFreeFilter(xkbi); sendEvent= _XkbFilterRedirectKey(xkbi,filter,key,&act); break; -#ifdef XINPUT case XkbSA_DeviceBtn: case XkbSA_LockDeviceBtn: - filter = _XkbNextFreeFilter(); + filter = _XkbNextFreeFilter(xkbi); sendEvent= _XkbFilterDeviceBtn(xkbi,filter,key,&act); break; -#endif case XkbSA_XFree86Private: - filter = _XkbNextFreeFilter(); + filter = _XkbNextFreeFilter(xkbi); sendEvent= _XkbFilterXF86Private(xkbi,filter,key,&act); break; } @@ -1282,24 +1267,21 @@ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(dev); } if (sendEvent) { -#ifdef XINPUT - if (xiEvent) - ProcessOtherEvent(xE,dev,count); - else -#endif if (keyEvent) { realMods = keyc->modifierMap[key]; keyc->modifierMap[key] = 0; - UNWRAP_PROCESS_INPUT_PROC(dev,xkbPrivPtr); - dev->public.processInputProc(xE,dev,count); - COND_WRAP_PROCESS_INPUT_PROC(dev, xkbPrivPtr, - ProcessKeyboardEvent,xkbUnwrapProc); + } + + UNWRAP_PROCESS_INPUT_PROC(dev,xkbPrivPtr, backupproc); + dev->public.processInputProc(xE,dev,count); + COND_WRAP_PROCESS_INPUT_PROC(dev, xkbPrivPtr, + backupproc,xkbUnwrapProc); + if (keyEvent) keyc->modifierMap[key] = realMods; - } - else CoreProcessPointerEvent(xE,dev,count); } - else if (keyEvent) + else if (keyEvent) { FixKeyState(xE,dev); + } xkbi->prev_state= oldState; XkbComputeDerivedState(xkbi); @@ -1321,7 +1303,7 @@ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(dev); if (changed) { XkbEventCauseRec cause; XkbSetCauseKey(&cause,key,xE->u.u.type); - XkbUpdateIndicators(dev,changed,True,NULL,&cause); + XkbUpdateIndicators(dev,changed,False,NULL,&cause); } return; } @@ -1345,7 +1327,7 @@ unsigned clear; act.type = XkbSA_LatchMods; act.mods.flags = 0; act.mods.mask = mask&latches; - filter = _XkbNextFreeFilter(); + filter = _XkbNextFreeFilter(xkbi); _XkbFilterLatchState(xkbi,filter,SYNTHETIC_KEYCODE,&act); _XkbFilterLatchState(xkbi,filter,SYNTHETIC_KEYCODE,(XkbAction *)NULL); return Success; @@ -1365,7 +1347,7 @@ XkbAction act; act.type = XkbSA_LatchGroup; act.group.flags = 0; XkbSASetGroup(&act.group,group); - filter = _XkbNextFreeFilter(); + filter = _XkbNextFreeFilter(xkbi); _XkbFilterLatchState(xkbi,filter,SYNTHETIC_KEYCODE,&act); _XkbFilterLatchState(xkbi,filter,SYNTHETIC_KEYCODE,(XkbAction *)NULL); return Success; diff --git a/xkb/xkbEvents.c b/xkb/xkbEvents.c index 15b4949e5..604cc48dd 100644 --- a/xkb/xkbEvents.c +++ b/xkb/xkbEvents.c @@ -34,6 +34,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include <X11/Xproto.h> #include <X11/keysym.h> #include <X11/extensions/XI.h> +#include <X11/extensions/XIproto.h> #include "inputstr.h" #include "windowstr.h" #include <xkbsrv.h> @@ -813,7 +814,9 @@ XkbSrvInfoPtr xkbi; if ( pClient->xkbClientFlags & _XkbClientInitialized ) { #ifdef DEBUG if ((xkbDebugFlags&0x10)&& - ((xE[0].u.u.type==KeyPress)||(xE[0].u.u.type==KeyRelease))) { + ((xE[0].u.u.type==KeyPress)||(xE[0].u.u.type==KeyRelease)|| + (xE[0].u.u.type==DeviceKeyPress)|| + (xE[0].u.u.type == DeviceKeyRelease))) { ErrorF("XKbFilterWriteEvents:\n"); ErrorF(" Event state= 0x%04x\n",xE[0].u.keyButtonPointer.state); ErrorF(" XkbLastRepeatEvent!=xE (0x%p!=0x%p) %s\n", @@ -832,7 +835,9 @@ XkbSrvInfoPtr xkbi; return False; } if ((pXDev->grab != NullGrab) && pXDev->fromPassiveGrab && - ((xE[0].u.u.type==KeyPress)||(xE[0].u.u.type==KeyRelease))) { + ((xE[0].u.u.type==KeyPress)||(xE[0].u.u.type==KeyRelease)|| + (xE[0].u.u.type==DeviceKeyPress)|| + (xE[0].u.u.type == DeviceKeyRelease))) { register unsigned state,flags; flags= pClient->xkbClientFlags; @@ -877,10 +882,12 @@ XkbSrvInfoPtr xkbi; type= xE[i].u.u.type; #ifdef DEBUG if ((xkbDebugFlags&0x4)&& - ((xE[0].u.u.type==KeyPress)||(xE[0].u.u.type==KeyRelease))) { + ((xE[i].u.u.type==KeyPress)||(xE[i].u.u.type==KeyRelease)|| + (xE[i].u.u.type==DeviceKeyPress)|| + (xE[i].u.u.type == DeviceKeyRelease))) { XkbStatePtr s= &xkbi->state; ErrorF("XKbFilterWriteEvents (non-XKB):\n"); - ErrorF("event= 0x%04x\n",xE[0].u.keyButtonPointer.state); + ErrorF("event= 0x%04x\n",xE[i].u.keyButtonPointer.state); ErrorF("lookup= 0x%02x, grab= 0x%02x\n",s->lookup_mods, s->grab_mods); ErrorF("compat lookup= 0x%02x, grab= 0x%02x\n", @@ -900,9 +907,18 @@ XkbSrvInfoPtr xkbi; xE[i].u.keyButtonPointer.state= new; } else if ((type==EnterNotify)||(type==LeaveNotify)) { - xE->u.enterLeave.state&= 0x1F00; - xE->u.enterLeave.state|= xkbi->state.compat_grab_mods; - } + xE[i].u.enterLeave.state&= 0x1F00; + xE[i].u.enterLeave.state|= xkbi->state.compat_grab_mods; + } else if ((type>=DeviceKeyPress)&&(type<=DeviceMotionNotify)) { + CARD16 old, new; + deviceKeyButtonPointer *kbp = (deviceKeyButtonPointer*)&xE[i]; + old= kbp->state&(~0x1F00); + new= kbp->state&0x1F00; + if (old==XkbStateFieldFromRec(&xkbi->state)) + new|= xkbi->state.compat_lookup_mods; + else new|= xkbi->state.compat_grab_mods; + kbp->state= new; + } button_mask = 1 << xE[i].u.u.detail; if (type == ButtonPress && ((xE[i].u.keyButtonPointer.state >> 7) & button_mask) == button_mask && @@ -911,7 +927,14 @@ XkbSrvInfoPtr xkbi; ErrorF("Faking release of button %d\n", xE[i].u.u.detail); #endif XkbDDXFakePointerButton(ButtonRelease, xE[i].u.u.detail); - } + } else if (type == DeviceButtonPress && + ((((deviceKeyButtonPointer*)&xE[i])->state >> 7) & button_mask) == button_mask && + (xkbi->lockedPtrButtons & button_mask) == button_mask) { +#ifdef DEBUG + ErrorF("Faking release of button %d\n", ((deviceKeyButtonPointer*)&xE[i])->state); +#endif + XkbDDXFakePointerButton(DeviceButtonRelease, ((deviceKeyButtonPointer*)&xE[i])->state); + } } } return True; diff --git a/xkb/xkbInit.c b/xkb/xkbInit.c index c0867adf0..6301a32e7 100644 --- a/xkb/xkbInit.c +++ b/xkb/xkbInit.c @@ -182,7 +182,7 @@ char * pval; ErrorF("Atom error: %s not created\n",_XKB_RF_NAMES_PROP_ATOM); return True; } - pval= (char*) ALLOCATE_LOCAL(len); + pval= (char*) xalloc(len); if (!pval) { ErrorF("Allocation error: %s proprerty not created\n", _XKB_RF_NAMES_PROP_ATOM); @@ -223,7 +223,7 @@ char * pval; } ChangeWindowProperty(WindowTable[0],name,XA_STRING,8,PropModeReplace, len,pval,True); - DEALLOCATE_LOCAL(pval); + xfree(pval); return True; } diff --git a/xkb/xkbPrKeyEv.c b/xkb/xkbPrKeyEv.c index 81124bcfb..3fec4f5ca 100644 --- a/xkb/xkbPrKeyEv.c +++ b/xkb/xkbPrKeyEv.c @@ -36,9 +36,10 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include <X11/keysym.h> #include "misc.h" #include "inputstr.h" +#include "exevents.h" #include <xkbsrv.h> #include <ctype.h> - +#define EXTENSION_EVENT_BASE 64 /***====================================================================***/ @@ -50,9 +51,11 @@ XkbSrvInfoPtr xkbi; int key; XkbBehavior behavior; unsigned ndx; +int xiEvent; xkbi= keyc->xkbInfo; key= xE->u.u.detail; + xiEvent= (xE->u.u.type & EXTENSION_EVENT_BASE); #ifdef DEBUG if (xkbDebugFlags&0x8) { ErrorF("XkbPKE: Key %d %s\n",key,(xE->u.u.type==KeyPress?"down":"up")); @@ -69,45 +72,69 @@ unsigned ndx; /* below XKB, such as a key that physically locks. XKB does not */ /* do anything to implement the behavior, but it *does* report that */ /* key is hardwired */ + if ((behavior.type&XkbKB_Permanent)==0) { switch (behavior.type) { case XkbKB_Default: - if (( xE->u.u.type == KeyPress ) && + if (( xE->u.u.type == KeyPress || + xE->u.u.type == DeviceKeyPress) && (keyc->down[key>>3] & (1<<(key&7)))) { XkbLastRepeatEvent= (pointer)xE; - xE->u.u.type = KeyRelease; + + if (xiEvent) + xE->u.u.type = DeviceKeyRelease; + else + xE->u.u.type = KeyRelease; XkbHandleActions(keybd,keybd,xE,count); - xE->u.u.type = KeyPress; + + if (xiEvent) + xE->u.u.type = DeviceKeyPress; + else + xE->u.u.type = KeyPress; XkbHandleActions(keybd,keybd,xE,count); XkbLastRepeatEvent= NULL; return; } - else if ((xE->u.u.type==KeyRelease) && + else if ((xE->u.u.type==KeyRelease || + xE->u.u.type == DeviceKeyRelease) && (!(keyc->down[key>>3]&(1<<(key&7))))) { XkbLastRepeatEvent= (pointer)&xE; - xE->u.u.type = KeyPress; + if (xiEvent) + xE->u.u.type = DeviceKeyPress; + else + xE->u.u.type = KeyPress; XkbHandleActions(keybd,keybd,xE,count); - xE->u.u.type = KeyRelease; + if (xiEvent) + xE->u.u.type = DeviceKeyRelease; + else + xE->u.u.type = KeyRelease; XkbHandleActions(keybd,keybd,xE,count); XkbLastRepeatEvent= NULL; return; } break; case XkbKB_Lock: - if ( xE->u.u.type == KeyRelease ) + if ( xE->u.u.type == KeyRelease || + xE->u.u.type == DeviceKeyRelease) { return; + } else { int bit= 1<<(key&7); - if ( keyc->down[key>>3]&bit ) - xE->u.u.type= KeyRelease; - } + if ( keyc->down[key>>3]&bit ) { + if (xiEvent) + xE->u.u.type = DeviceKeyRelease; + else + xE->u.u.type= KeyRelease; + } + } break; case XkbKB_RadioGroup: ndx= (behavior.data&(~XkbKB_RGAllowNone)); if ( ndx<xkbi->nRadioGroups ) { XkbRadioGroupPtr rg; - if ( xE->u.u.type == KeyRelease ) + if ( xE->u.u.type == KeyRelease || + xE->u.u.type == DeviceKeyRelease) return; rg = &xkbi->radioGroups[ndx]; @@ -121,10 +148,16 @@ unsigned ndx; } if ( rg->currentDown!=0 ) { int key = xE->u.u.detail; - xE->u.u.type= KeyRelease; + if (xiEvent) + xE->u.u.type = DeviceKeyRelease; + else + xE->u.u.type= KeyRelease; xE->u.u.detail= rg->currentDown; XkbHandleActions(keybd,keybd,xE,count); - xE->u.u.type= KeyPress; + if (xiEvent) + xE->u.u.type = DeviceKeyPress; + else + xE->u.u.type= KeyPress; xE->u.u.detail= key; } rg->currentDown= key; @@ -160,23 +193,42 @@ unsigned ndx; void ProcessKeyboardEvent(xEvent *xE,DeviceIntPtr keybd,int count) { -KeyClassPtr keyc = keybd->key; -XkbSrvInfoPtr xkbi; - xkbi= keyc->xkbInfo; + KeyClassPtr keyc = keybd->key; + XkbSrvInfoPtr xkbi = NULL; + ProcessInputProc backup_proc; + xkbDeviceInfoPtr xkb_priv = XKBDEVICEINFO(keybd); + int is_press = (xE->u.u.type == KeyPress || xE->u.u.type == DeviceKeyPress); + int is_release = (xE->u.u.type == KeyRelease || + xE->u.u.type == DeviceKeyRelease); + + if (keyc) + xkbi = keyc->xkbInfo; + + /* We're only interested in key events. */ + if (!is_press && !is_release) { + UNWRAP_PROCESS_INPUT_PROC(keybd, xkb_priv, backup_proc); + keybd->public.processInputProc(xE, keybd, count); + COND_WRAP_PROCESS_INPUT_PROC(keybd, xkb_priv, backup_proc, + xkbUnwrapProc); + return; + } -#ifdef DEBUG - if (xkbDebugFlags&0x8) { - int key= xE->u.u.detail; - ErrorF("PKE: Key %d %s\n",key,(xE->u.u.type==KeyPress?"down":"up")); + /* If AccessX filters are active, then pass it through to + * AccessXFilter{Press,Release}Event; else, punt to + * XkbProcessKeyboardEvent. + * + * If AXF[PK]E don't intercept anything (which they probably won't), + * they'll punt through XPKE anyway. */ + if ((xkbi->desc->ctrls->enabled_ctrls & XkbAllFilteredEventsMask)) { + if (is_press) + AccessXFilterPressEvent(xE, keybd, count); + else if (is_release) + AccessXFilterReleaseEvent(xE, keybd, count); } -#endif - if ((xkbi->desc->ctrls->enabled_ctrls&XkbAllFilteredEventsMask)==0) - XkbProcessKeyboardEvent(xE,keybd,count); - else if (xE->u.u.type==KeyPress) - AccessXFilterPressEvent(xE,keybd,count); - else if (xE->u.u.type==KeyRelease) - AccessXFilterReleaseEvent(xE,keybd,count); + else { + XkbProcessKeyboardEvent(xE, keybd, count); + } + return; } - |