--- xc/programs/Xserver/dix/devices.c 2005-03-16 14:53:51.000000000 -0800 +++ xc/programs/Xserver/dix/devices.c.fix 2005-02-01 11:28:28.000000000 -0800 @@ -122,6 +122,8 @@ #ifdef XKB dev->xkb_interest= NULL; #endif + dev->nPrivates = 0; + dev->devPrivates = dev->unwrapProc = NULL; inputInfo.off_devices = dev; return dev; } @@ -358,13 +360,10 @@ { inputInfo.pointer = device; #ifdef XKB - if (noXkbExtension) { - device->public.processInputProc = CoreProcessPointerEvent; - device->public.realInputProc = CoreProcessPointerEvent; - } else { - device->public.processInputProc = ProcessPointerEvent; - device->public.realInputProc = ProcessPointerEvent; - } + device->public.processInputProc = CoreProcessPointerEvent; + device->public.realInputProc = CoreProcessPointerEvent; + if (!noXkbExtension) + XkbSetExtension(device,ProcessPointerEvent); #else device->public.processInputProc = ProcessPointerEvent; device->public.realInputProc = ProcessPointerEvent; @@ -385,13 +384,10 @@ { inputInfo.keyboard = device; #ifdef XKB - if (noXkbExtension) { - device->public.processInputProc = CoreProcessKeyboardEvent; - device->public.realInputProc = CoreProcessKeyboardEvent; - } else { - device->public.processInputProc = ProcessKeyboardEvent; - device->public.realInputProc = ProcessKeyboardEvent; - } + device->public.processInputProc = CoreProcessKeyboardEvent; + device->public.realInputProc = CoreProcessKeyboardEvent; + if (!noXkbExtension) + XkbSetExtension(device,ProcessKeyboardEvent); #else device->public.processInputProc = ProcessKeyboardEvent; device->public.realInputProc = ProcessKeyboardEvent; --- xc/programs/Xserver/hw/xfree86/loader/dixsym.c 2004-12-07 21:32:54.000000000 -0800 +++ xc/programs/Xserver/hw/xfree86/loader/dixsym.c.fix 2005-02-01 11:28:30.000000000 -0800 @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/hw/xfree86/loader/dixsym.c,v 1.5.2.2 2004/12/08 05:32:54 gisburn Exp $ */ +/* $XdotOrg: xc/programs/Xserver/hw/xfree86/loader/dixsym.c,v 1.7 2004/09/14 23:21:22 gisburn Exp $ */ /* $XFree86: xc/programs/Xserver/hw/xfree86/loader/dixsym.c,v 1.63 2003/12/03 * 17:11:29 tsi Exp $ */ @@ -54,6 +54,7 @@ #include "sym.h" #include "colormap.h" #include "cursor.h" +#include "cursorstr.h" #include "dix.h" #include "dixevents.h" #include "dixfont.h" @@ -168,6 +169,7 @@ SYMFUNC(PointerConfinedToScreen) SYMFUNC(TryClientEvents) SYMFUNC(WriteEventsToClient) + SYMFUNC(GetCurrentRootWindow) SYMVAR(DeviceEventCallback) SYMVAR(EventCallback) SYMVAR(inputInfo) @@ -184,6 +186,10 @@ SYMFUNC(DeclareExtensionSecurity) SYMFUNC(MinorOpcodeOfRequest) SYMFUNC(StandardMinorOpcode) +#ifdef XEVIE + SYMVAR(xeviehot) + SYMVAR(xeviewin) +#endif /* gc.c */ SYMFUNC(CopyGC) SYMFUNC(CreateGC) @@ -248,6 +254,8 @@ SYMFUNC(AllocateWindowPrivateIndex) SYMFUNC(AllocateScreenPrivateIndex) SYMFUNC(AllocateColormapPrivateIndex) + SYMFUNC(AllocateDevicePrivateIndex) + SYMFUNC(AllocateDevicePrivate) #ifdef PIXPRIV SYMFUNC(AllocatePixmapPrivateIndex) SYMFUNC(AllocatePixmapPrivate) --- xc/programs/Xserver/dix/privates.c 2005-03-16 15:20:09.000000000 -0800 +++ xc/programs/Xserver/dix/privates.c.fix 2005-02-01 11:28:28.000000000 -0800 @@ -39,6 +39,7 @@ #include "colormapst.h" #include "servermd.h" #include "site.h" +#include "inputstr.h" /* * See the Wrappers and devPrivates section in "Definition of the @@ -368,3 +369,37 @@ return index; } + +static int devicePrivateIndex = 0; + +int +AllocateDevicePrivateIndex() +{ + return devicePrivateIndex++; +} + +Bool +AllocateDevicePrivate(DeviceIntPtr device, int index) +{ + if (device->nPrivates < ++index) { + DevUnion *nprivs = (DevUnion *)xrealloc(device->devPrivates, + index * sizeof(DevUnion)); + if (!nprivs) + return FALSE; + device->devPrivates = nprivs; + bzero(&nprivs[device->nPrivates], sizeof(DevUnion) + * (index - device->nPrivates)); + device->nPrivates = index; + return TRUE; + } else { + return TRUE; + } +} + +void +ResetDevicePrivateIndex(void) +{ + devicePrivateIndex = 0; +} + + --- xc/programs/Xserver/dix/main.c 2004-12-07 22:02:34.000000000 -0800 +++ xc/programs/Xserver/dix/main.c.fix 2005-02-01 11:28:28.000000000 -0800 @@ -360,6 +360,7 @@ #endif ResetColormapPrivates(); ResetFontPrivateIndex(); + ResetDevicePrivateIndex(); InitCallbackManager(); InitVisualWrap(); InitOutput(&screenInfo, argc, argv); --- xc/programs/Xserver/dix/events.c 2005-03-16 14:20:23.000000000 -0800 +++ xc/programs/Xserver/dix/events.c.fix 2005-02-01 11:28:28.000000000 -0800 @@ -425,7 +425,13 @@ if (qe) { sprite.hot.pScreen = qe->pScreen; /* should always be Screen 0 */ +#ifdef XEVIE + xeviehot.x = +#endif sprite.hot.x = qe->event->u.keyButtonPointer.rootX; +#ifdef XEVIE + xeviehot.y = +#endif sprite.hot.y = qe->event->u.keyButtonPointer.rootY; pWin = inputInfo.pointer->grab ? inputInfo.pointer->grab->confineTo : NullWindow; @@ -462,12 +468,24 @@ lims = *REGION_EXTENTS(sprite.screen, &sprite.Reg2); if (sprite.hot.x < lims.x1) +#ifdef XEVIE + xeviehot.x = +#endif sprite.hot.x = lims.x1; else if (sprite.hot.x >= lims.x2) +#ifdef XEVIE + xeviehot.x = +#endif sprite.hot.x = lims.x2 - 1; if (sprite.hot.y < lims.y1) +#ifdef XEVIE + xeviehot.y = +#endif sprite.hot.y = lims.y1; else if (sprite.hot.y >= lims.y2) +#ifdef XEVIE + xeviehot.y = +#endif sprite.hot.y = lims.y2 - 1; if (REGION_NUM_RECTS(&sprite.Reg2) > 1) @@ -497,16 +515,33 @@ panoramiXdataPtr[0].x; XE_KBPTR.rootY += panoramiXdataPtr[sprite.screen->myNum].y - panoramiXdataPtr[0].y; - +#ifdef XEVIE + xeviehot.x = +#endif sprite.hot.x = XE_KBPTR.rootX; +#ifdef XEVIE + xeviehot.y = +#endif sprite.hot.y = XE_KBPTR.rootY; if (sprite.hot.x < sprite.physLimits.x1) +#ifdef XEVIE + xeviehot.x = +#endif sprite.hot.x = sprite.physLimits.x1; else if (sprite.hot.x >= sprite.physLimits.x2) +#ifdef XEVIE + xeviehot.x = +#endif sprite.hot.x = sprite.physLimits.x2 - 1; if (sprite.hot.y < sprite.physLimits.y1) +#ifdef XEVIE + xeviehot.y = +#endif sprite.hot.y = sprite.physLimits.y1; else if (sprite.hot.y >= sprite.physLimits.y2) +#ifdef XEVIE + xeviehot.y = +#endif sprite.hot.y = sprite.physLimits.y2 - 1; if (sprite.hotShape) @@ -523,6 +558,9 @@ XE_KBPTR.rootY = sprite.hot.y; } +#ifdef XEVIE + xeviewin = +#endif sprite.win = XYToWindow(sprite.hot.x, sprite.hot.y); if (sprite.win != prevSpriteWin) @@ -747,7 +785,13 @@ if (qe) { sprite.hot.pScreen = qe->pScreen; +#ifdef XEVIE + xeviehot.x = +#endif sprite.hot.x = qe->event->u.keyButtonPointer.rootX; +#ifdef XEVIE + xeviehot.y = +#endif sprite.hot.y = qe->event->u.keyButtonPointer.rootY; pWin = inputInfo.pointer->grab ? inputInfo.pointer->grab->confineTo : NullWindow; @@ -759,16 +803,31 @@ if (sprite.hot.pScreen != pWin->drawable.pScreen) { sprite.hot.pScreen = pWin->drawable.pScreen; +#ifdef XEVIE + xeviehot.x = xeviehot.y = 0; +#endif sprite.hot.x = sprite.hot.y = 0; } lims = *REGION_EXTENTS(pWin->drawable.pScreen, &pWin->borderSize); if (sprite.hot.x < lims.x1) +#ifdef XEVIE + xeviehot.x = +#endif sprite.hot.x = lims.x1; else if (sprite.hot.x >= lims.x2) +#ifdef XEVIE + xeviehot.x = +#endif sprite.hot.x = lims.x2 - 1; if (sprite.hot.y < lims.y1) +#ifdef XEVIE + xeviehot.y = +#endif sprite.hot.y = lims.y1; else if (sprite.hot.y >= lims.y2) +#ifdef XEVIE + xeviehot.y = +#endif sprite.hot.y = lims.y2 - 1; #ifdef SHAPE if (wBoundingShape(pWin)) @@ -1996,15 +2055,33 @@ sprite.hot.pScreen = sprite.hotPhys.pScreen; ROOT = WindowTable[sprite.hot.pScreen->myNum]; } +#ifdef XEVIE + xeviehot.x = +#endif sprite.hot.x = XE_KBPTR.rootX; +#ifdef XEVIE + xeviehot.y = +#endif sprite.hot.y = XE_KBPTR.rootY; if (sprite.hot.x < sprite.physLimits.x1) +#ifdef XEVIE + xeviehot.x = +#endif sprite.hot.x = sprite.physLimits.x1; else if (sprite.hot.x >= sprite.physLimits.x2) +#ifdef XEVIE + xeviehot.x = +#endif sprite.hot.x = sprite.physLimits.x2 - 1; if (sprite.hot.y < sprite.physLimits.y1) +#ifdef XEVIE + xeviehot.y = +#endif sprite.hot.y = sprite.physLimits.y1; else if (sprite.hot.y >= sprite.physLimits.y2) +#ifdef XEVIE + xeviehot.y = +#endif sprite.hot.y = sprite.physLimits.y2 - 1; #ifdef SHAPE if (sprite.hotShape) @@ -2022,6 +2099,9 @@ XE_KBPTR.rootY = sprite.hot.y; } +#ifdef XEVIE + xeviewin = +#endif sprite.win = XYToWindow(sprite.hot.x, sprite.hot.y); #ifdef notyet if (!(sprite.win->deliverableEvents & @@ -2102,6 +2182,9 @@ sprite.hot = sprite.hotPhys; sprite.hotLimits.x2 = pScreen->width; sprite.hotLimits.y2 = pScreen->height; +#ifdef XEVIE + xeviewin = +#endif sprite.win = win; sprite.current = wCursor (win); spriteTraceGood = 1; @@ -2705,20 +2788,13 @@ {} else { #ifdef XKB if(!noXkbExtension) - xevieKBEventSent = 0; + xevieKBEventSent = 1; #endif if(!xevieKBEventSent) { xeviekb = keybd; if(!rootWin) { - WindowPtr pWin = xeviewin->parent; - while(pWin) { - if(!pWin->parent) { - rootWin = pWin->drawable.id; - break; - } - pWin = pWin->parent; - }; + rootWin = GetCurrentRootWindow()->drawable.id; } xE->u.keyButtonPointer.event = xeviewin->drawable.id; xE->u.keyButtonPointer.root = rootWin; @@ -2750,13 +2826,30 @@ CallCallbacks(&DeviceEventCallback, (pointer)&eventinfo); } } - XE_KBPTR.state = (keyc->state | inputInfo.pointer->button->state); + /* fix for bug5094030: don't change the state bit if the event is from XEvIE client */ if(!(!xeviegrabState && xevieFlag && clients[xevieClientIndex] && + (xevieMask & xevieFilters[xE->u.u.type] +#ifdef XKB + && !noXkbExtension +#endif + ))) + XE_KBPTR.state = (keyc->state | inputInfo.pointer->button->state); XE_KBPTR.rootX = sprite.hot.x; XE_KBPTR.rootY = sprite.hot.y; key = xE->u.u.detail; kptr = &keyc->down[key >> 3]; bit = 1 << (key & 7); modifiers = keyc->modifierMap[key]; +#ifdef XKB + if(!noXkbExtension && !xeviegrabState && + xevieFlag && clients[xevieClientIndex] && + (xevieMask & xevieFilters[xE->u.u.type])) { + switch(xE->u.u.type) { + case KeyPress: *kptr &= ~bit; break; + case KeyRelease: *kptr |= bit; break; + } + } +#endif + #ifdef DEBUG if ((xkbDebugFlags&0x4)&& ((xE->u.u.type==KeyPress)||(xE->u.u.type==KeyRelease))) { @@ -4043,6 +4136,9 @@ spriteTraceGood = 0; lastEventMask = OwnerGrabButtonMask; filters[MotionNotify] = PointerMotionMask; +#ifdef XEVIE + xeviewin = +#endif sprite.win = NullWindow; sprite.current = NullCursor; sprite.hotLimits.x1 = 0; --- xc/programs/Xserver/Xext/xevie.c 2005-03-16 14:30:31.000000000 -0800 +++ xc/programs/Xserver/Xext/xevie.c.fix 2005-02-01 11:28:27.000000000 -0800 @@ -45,6 +45,10 @@ #include "Xeviestr.h" #include "Xfuncproto.h" #include "input.h" +#include "inputstr.h" +#include "windowstr.h" +#include "cursorstr.h" +#include "XKBsrv.h" #include "../os/osdep.h" @@ -66,6 +70,12 @@ Mask xevieMask = 0; int xevieEventSent = 0; int xevieKBEventSent = 0; +static unsigned int xevieServerGeneration; +static int xevieDevicePrivateIndex; +static Bool xevieModifiersOn = FALSE; + +#define XEVIEINFO(dev) ((xevieDeviceInfoPtr)dev->devPrivates[xevieDevicePrivateIndex].ptr) + Mask xevieFilters[128] = { NoSuchEvent, /* 0 */ @@ -77,18 +87,53 @@ PointerMotionMask /* MotionNotify (initial state) */ }; +typedef struct { + ProcessInputProc processInputProc; + ProcessInputProc realInputProc; + DeviceUnwrapProc unwrapProc; +} xevieDeviceInfoRec, *xevieDeviceInfoPtr; + +typedef struct { + CARD32 time; + KeyClassPtr keyc; +} xevieKeycQueueRec, *xevieKeycQueuePtr; + +#define KEYC_QUEUE_SIZE 100 +xevieKeycQueueRec keycq[KEYC_QUEUE_SIZE] = {0, NULL}; +static int keycqHead = 0, keycqTail = 0; + +static int ProcDispatch (ClientPtr), SProcDispatch (ClientPtr); +static void ResetProc (ExtensionEntry*); + +static int ErrorBase; + +static Bool XevieStart(void); static void XevieEnd(int clientIndex); static void XevieClientStateCallback(CallbackListPtr *pcbl, pointer nulldata, - pointer calldata); + pointer calldata); static void XevieServerGrabStateCallback(CallbackListPtr *pcbl, - pointer nulldata, - pointer calldata); + pointer nulldata, + pointer calldata); + +static Bool XevieAdd(DeviceIntPtr device, pointer data); +static void XevieWrap(DeviceIntPtr device, ProcessInputProc proc); +static Bool XevieRemove(DeviceIntPtr device, pointer data); +static void doSendEvent(xEvent *xE, DeviceIntPtr device); +static void XeviePointerProcessInputProc(xEvent *xE, DeviceIntPtr dev, + int count); +static void XevieKbdProcessInputProc(xEvent *xE, DeviceIntPtr dev, int count); void XevieExtensionInit () { ExtensionEntry* extEntry; + if (serverGeneration != xevieServerGeneration) { + if ((xevieDevicePrivateIndex = AllocateDevicePrivateIndex()) == -1) + return; + xevieServerGeneration = serverGeneration; + } + if (!AddCallback(&ServerGrabCallback,XevieServerGrabStateCallback,NULL)) return; @@ -147,10 +192,25 @@ xevieFlag = 1; rep.pad1 = 1; xevieClientIndex = client->index; + if(!keycq[0].time ) { + int i; + for(i=0; ixkbInfo = xalloc(sizeof(XkbSrvInfoRec)); + } + } } else return BadAlloc; } else return BadAccess; + if (!noXkbExtension) { + if (!XevieStart()) { + DeleteCallback(&ClientStateCallback,XevieClientStateCallback,NULL); + return BadAlloc; + } + } + + xevieModifiersOn = FALSE; rep.type = X_Reply; rep.sequence_number = client->sequence; @@ -164,7 +224,13 @@ { xXevieEndReply rep; - XevieEnd(xevieClientIndex); + if (xevieFlag) { + if (client->index != xevieClientIndex) + return BadAccess; + + DeleteCallback(&ClientStateCallback,XevieClientStateCallback,NULL); + XevieEnd(xevieClientIndex); + } rep.type = X_Reply; rep.sequence_number = client->sequence; @@ -182,6 +248,9 @@ OsCommPtr oc; static unsigned char lastDetail = 0, lastType = 0; + if (client->index != xevieClientIndex) + return BadAccess; + xE = (xEvent *)&stuff->event; rep.type = X_Reply; rep.sequence_number = client->sequence; @@ -191,16 +260,19 @@ case KeyPress: case KeyRelease: xevieKBEventSent = 1; -#ifdef XKB if(noXkbExtension) -#endif CoreProcessKeyboardEvent (xE, xeviekb, 1); + else + doSendEvent(xE, inputInfo.keyboard); break; case ButtonPress: case ButtonRelease: case MotionNotify: xevieEventSent = 1; - CoreProcessPointerEvent(xE, xeviemouse, 1); + if(noXkbExtension) + CoreProcessPointerEvent(xE, xeviemouse, 1); + else + doSendEvent(xE, inputInfo.pointer); break; default: break; @@ -217,6 +289,9 @@ REQUEST (xXevieSelectInputReq); xXevieSelectInputReply rep; + if (client->index != xevieClientIndex) + return BadAccess; + xevieMask = (long)stuff->event_mask; rep.type = X_Reply; rep.sequence_number = client->sequence; @@ -335,11 +410,154 @@ return BadRequest; } } +/*======================================================*/ + +#define WRAP_INPUTPROC(dev,store,inputProc) \ + store->processInputProc = dev->public.processInputProc; \ + dev->public.processInputProc = inputProc; \ + store->realInputProc = dev->public.realInputProc; \ + dev->public.realInputProc = inputProc; + +#define COND_WRAP_INPUTPROC(dev,store,inputProc) \ + if (dev->public.processInputProc == dev->public.realInputProc) \ + dev->public.processInputProc = inputProc; \ + store->processInputProc = \ + store->realInputProc = dev->public.realInputProc; \ + dev->public.realInputProc = inputProc; + +#define UNWRAP_INPUTPROC(dev,restore) \ + dev->public.processInputProc = restore->processInputProc; \ + dev->public.realInputProc = restore->realInputProc; + +#define UNWRAP_INPUTPROC(dev,restore) \ + dev->public.processInputProc = restore->processInputProc; \ + dev->public.realInputProc = restore->realInputProc; + +#define XEVIE_EVENT(xE) \ + (xevieFlag \ + && !xeviegrabState \ + && clients[xevieClientIndex] \ + && (xevieMask & xevieFilters[xE->u.u.type])) + + +static void +sendEvent(ClientPtr pClient, xEvent *xE) +{ + if(pClient->swapped) { + xEvent eventTo; + + /* Remember to strip off the leading bit of type in case + this event was sent with "SendEvent." */ + (*EventSwapVector[xE->u.u.type & 0177]) (xE, &eventTo); + (void)WriteToClient(pClient, sizeof(xEvent), (char *)&eventTo); + } else { + (void)WriteToClient(pClient, sizeof(xEvent), (char *) xE); + } +} + +static void +XevieKbdProcessInputProc(xEvent *xE, DeviceIntPtr dev, int count) +{ + int key, bit; + BYTE *kptr; + ProcessInputProc tmp; + KeyClassPtr keyc = dev->key; + xevieDeviceInfoPtr xeviep = XEVIEINFO(dev); + + if(XEVIE_EVENT(xE)) { + key = xE->u.u.detail; + kptr = &keyc->down[key >> 3]; + bit = 1 << (key & 7); + + if (dev->key->modifierMap[xE->u.u.detail]) + xevieModifiersOn = TRUE; + + xE->u.keyButtonPointer.event = xeviewin->drawable.id; + xE->u.keyButtonPointer.root = GetCurrentRootWindow()->drawable.id; + xE->u.keyButtonPointer.child = (xeviewin->firstChild) + ? xeviewin->firstChild->drawable.id:0; + xE->u.keyButtonPointer.rootX = xeviehot.x; + xE->u.keyButtonPointer.rootY = xeviehot.y; + xE->u.keyButtonPointer.state = keyc->state | inputInfo.pointer->button->state; + /* fix bug: sequence lost in Xlib */ + xE->u.u.sequenceNumber = clients[xevieClientIndex]->sequence; + /* fix for bug5092586 */ + if(!noXkbExtension) { + switch(xE->u.u.type) { + case KeyPress: *kptr |= bit; break; + case KeyRelease: *kptr &= ~bit; break; + } + } + keycq[keycqHead].time = xE->u.keyButtonPointer.time; + memcpy(keycq[keycqHead].keyc, keyc, sizeof(KeyClassRec) - sizeof(KeyClassPtr)); + memcpy(keycq[keycqHead].keyc->xkbInfo, keyc->xkbInfo, sizeof(XkbSrvInfoRec)); + if(++keycqHead >=KEYC_QUEUE_SIZE) + keycqHead = 0; + sendEvent(clients[xevieClientIndex], xE); + return; + } + + tmp = dev->public.realInputProc; + UNWRAP_INPUTPROC(dev,xeviep); + dev->public.processInputProc(xE,dev,count); + COND_WRAP_INPUTPROC(dev,xeviep,tmp); +} + +static void +XeviePointerProcessInputProc(xEvent *xE, DeviceIntPtr dev, int count) +{ + xevieDeviceInfoPtr xeviep = XEVIEINFO(dev); + ProcessInputProc tmp; + + if (XEVIE_EVENT(xE)) { + /* fix bug: sequence lost in Xlib */ + xE->u.u.sequenceNumber = clients[xevieClientIndex]->sequence; + sendEvent(clients[xevieClientIndex], xE); + return; + } + + tmp = dev->public.realInputProc; + UNWRAP_INPUTPROC(dev,xeviep); + dev->public.processInputProc(xE,dev,count); + COND_WRAP_INPUTPROC(dev,xeviep,tmp); +} + +static Bool +XevieStart(void) +{ + ProcessInputProc prp; + prp = XevieKbdProcessInputProc; + if (!XevieAdd(inputInfo.keyboard,&prp)) + return FALSE; + prp = XeviePointerProcessInputProc; + if (!XevieAdd(inputInfo.pointer,&prp)) + return FALSE; + + return TRUE; +} + static void XevieEnd(int clientIndex) { if (!clientIndex || clientIndex == xevieClientIndex) { + + if(!noXkbExtension) { + + XevieRemove(inputInfo.keyboard,NULL); + + inputInfo.keyboard->public.processInputProc = CoreProcessKeyboardEvent; + inputInfo.keyboard->public.realInputProc = CoreProcessKeyboardEvent; + XkbSetExtension(inputInfo.keyboard,ProcessKeyboardEvent); + + + XevieRemove(inputInfo.pointer,NULL); + + inputInfo.pointer->public.processInputProc = CoreProcessPointerEvent; + inputInfo.pointer->public.realInputProc = CoreProcessPointerEvent; + XkbSetExtension(inputInfo.pointer,ProcessPointerEvent); + } + xevieFlag = 0; xevieClientIndex = 0; DeleteCallback (&ClientStateCallback, XevieClientStateCallback, NULL); @@ -368,4 +586,125 @@ xeviegrabState = FALSE; } +#define UNWRAP_UNWRAPPROC(device,proc_store) \ + device->unwrapProc = proc_store; + +#define WRAP_UNWRAPPROC(device,proc_store,proc) \ + proc_store = device->unwrapProc; \ + device->unwrapProc = proc; + +static void +xevieUnwrapProc(DeviceIntPtr device, DeviceHandleProc proc, pointer data) +{ + xevieDeviceInfoPtr xeviep = XEVIEINFO(device); + ProcessInputProc tmp = device->public.processInputProc; + + UNWRAP_INPUTPROC(device,xeviep); + UNWRAP_UNWRAPPROC(device,xeviep->unwrapProc); + proc(device,data); + WRAP_INPUTPROC(device,xeviep,tmp); + WRAP_UNWRAPPROC(device,xeviep->unwrapProc,xevieUnwrapProc); +} + +static Bool +XevieUnwrapAdd(DeviceIntPtr device, void* data) +{ + if (device->unwrapProc) + device->unwrapProc(device,XevieUnwrapAdd,data); + else { + ProcessInputProc *ptr = data; + XevieWrap(device,*ptr); + } + + return TRUE; +} + +static Bool +XevieAdd(DeviceIntPtr device, void* data) +{ + xevieDeviceInfoPtr xeviep; + + if (!AllocateDevicePrivate(device, xevieDevicePrivateIndex)) + return FALSE; + + xeviep = xalloc (sizeof (xevieDeviceInfoRec)); + if (!xeviep) + return FALSE; + + device->devPrivates[xevieDevicePrivateIndex].ptr = xeviep; + XevieUnwrapAdd(device, data); + + return TRUE; +} + +static Bool +XevieRemove(DeviceIntPtr device,pointer data) +{ + xevieDeviceInfoPtr xeviep = XEVIEINFO(device); + + if (!xeviep) return TRUE; + + UNWRAP_INPUTPROC(device,xeviep); + UNWRAP_UNWRAPPROC(device,xeviep->unwrapProc); + + xfree(xeviep); + device->devPrivates[xevieDevicePrivateIndex].ptr = NULL; + return TRUE; +} + +static void +XevieWrap(DeviceIntPtr device, ProcessInputProc proc) +{ + xevieDeviceInfoPtr xeviep = XEVIEINFO(device); + + WRAP_INPUTPROC(device,xeviep,proc); + WRAP_UNWRAPPROC(device,xeviep->unwrapProc,xevieUnwrapProc); +} + +static void +doSendEvent(xEvent *xE, DeviceIntPtr dev) +{ + xevieDeviceInfoPtr xeviep = XEVIEINFO(dev); + ProcessInputProc tmp = dev->public.realInputProc; + if (((xE->u.u.type==KeyPress)||(xE->u.u.type==KeyRelease)) + && !xevieModifiersOn) { + KeyClassPtr keyc = dev->key; + CARD8 realModes = dev->key->modifierMap[xE->u.u.detail]; + int notFound = 0; + /* if some events are consumed by client, move the queue tail pointer to the current + event which just comes back from Xevie client . + */ + if(keycq[keycqTail].time != xE->u.keyButtonPointer.time) { + while(keycq[keycqTail].time != xE->u.keyButtonPointer.time) { + if(++keycqTail >= KEYC_QUEUE_SIZE) + keycqTail = 0; + if(keycqTail == keycqHead) { + notFound = 1; + break; + } + } + } + if(!notFound) { + dev->key = keycq[keycqTail].keyc; + if(++keycqTail >= KEYC_QUEUE_SIZE) + keycqTail = 0; + } + dev->key->modifierMap[xE->u.u.detail] = 0; + + UNWRAP_INPUTPROC(dev,xeviep); + dev->public.processInputProc(xE,dev,1); + COND_WRAP_INPUTPROC(dev,xeviep,tmp); + dev->key->modifierMap[xE->u.u.detail] = realModes; + dev->key = keyc; + if(notFound) { + DeleteCallback(&ClientStateCallback,XevieClientStateCallback,NULL); + XevieEnd(xevieClientIndex); + ErrorF("Error: Xevie keyc queue size is not enough, disable Xevie\n"); + } + } else { + UNWRAP_INPUTPROC(dev,xeviep); + dev->public.processInputProc(xE,dev,1); + COND_WRAP_INPUTPROC(dev,xeviep,tmp); + } +} --- xc/include/extensions/XKBsrv.h 2005-03-16 14:58:12.000000000 -0800 +++ xc/include/extensions/XKBsrv.h.fix 2005-02-01 11:28:20.000000000 -0800 @@ -231,6 +231,40 @@ */ #define _XkbStateNotifyInProgress (1<<0) +typedef struct +{ + ProcessInputProc processInputProc; + ProcessInputProc realInputProc; + DeviceUnwrapProc unwrapProc; +} xkbDeviceInfoRec, *xkbDeviceInfoPtr; + +#define WRAP_PROCESS_INPUT_PROC(device, oldprocs, proc, unwrapproc) \ + device->public.processInputProc = proc; \ + oldprocs->processInputProc = \ + oldprocs->realInputProc = device->public.realInputProc; \ + device->public.realInputProc = proc; \ + oldprocs->unwrapProc = device->unwrapProc; \ + device->unwrapProc = unwrapproc; + +#define COND_WRAP_PROCESS_INPUT_PROC(device, oldprocs, proc, unwrapproc) \ + if (device->public.processInputProc == device->public.realInputProc)\ + device->public.processInputProc = proc; \ + oldprocs->processInputProc = \ + oldprocs->realInputProc = device->public.realInputProc; \ + device->public.realInputProc = proc; \ + oldprocs->unwrapProc = device->unwrapProc; \ + device->unwrapProc = unwrapproc; + +#define UNWRAP_PROCESS_INPUT_PROC(device, oldprocs) \ + device->public.processInputProc = oldprocs->processInputProc; \ + device->public.realInputProc = oldprocs->realInputProc; \ + device->unwrapProc = oldprocs->unwrapProc; + +#define XKBDEVICEINFO(dev) ((xkbDeviceInfoPtr) (dev)->devPrivates[xkbDevicePrivateIndex].ptr) + +/***====================================================================***/ + + /***====================================================================***/ #define XkbAX_KRGMask (XkbSlowKeysMask|XkbBounceKeysMask) --- xc/programs/Xserver/xkb/xkbActions.c 2005-03-16 14:52:49.000000000 -0800 +++ xc/programs/Xserver/xkb/xkbActions.c.fix 2005-03-18 12:47:09.000000000 -0800 @@ -38,6 +38,48 @@ #include "xkb.h" #include +static unsigned int _xkbServerGeneration; +int xkbDevicePrivateIndex = -1; + +void +xkbUnwrapProc(DeviceIntPtr device, DeviceHandleProc proc, + pointer data) +{ + xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(device); + ProcessInputProc tmp = device->public.processInputProc; + if(xkbPrivPtr->unwrapProc) + xkbPrivPtr->unwrapProc = NULL; + + UNWRAP_PROCESS_INPUT_PROC(device,xkbPrivPtr); + proc(device,data); + WRAP_PROCESS_INPUT_PROC(device,xkbPrivPtr, + tmp,xkbUnwrapProc); +} + + +void +XkbSetExtension(DeviceIntPtr device, ProcessInputProc proc) +{ + xkbDeviceInfoPtr xkbPrivPtr; + + if (serverGeneration != _xkbServerGeneration) { + if ((xkbDevicePrivateIndex = AllocateDevicePrivateIndex()) == -1) + return; + _xkbServerGeneration = serverGeneration; + } + if (!AllocateDevicePrivate(device, xkbDevicePrivateIndex)) + return; + + xkbPrivPtr = (xkbDeviceInfoPtr) xalloc(sizeof(xkbDeviceInfoRec)); + if (!xkbPrivPtr) + return; + xkbPrivPtr->unwrapProc = NULL; + + device->devPrivates[xkbDevicePrivateIndex].ptr = xkbPrivPtr; + WRAP_PROCESS_INPUT_PROC(device,xkbPrivPtr, + proc,xkbUnwrapProc); +} + #ifdef XINPUT extern void ProcessOtherEvent( xEvent * /* xE */, @@ -822,6 +864,7 @@ int x,y; XkbStateRec old; unsigned mods,mask,oldCoreState = 0,oldCorePrevState = 0; +xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(xkbi->device); if ((filter->keycode!=0)&&(filter->keycode!=keycode)) return 1; @@ -870,7 +913,10 @@ realMods = xkbi->device->key->modifierMap[ev.u.u.detail]; xkbi->device->key->modifierMap[ev.u.u.detail] = 0; - CoreProcessKeyboardEvent(&ev,xkbi->device,1); + UNWRAP_PROCESS_INPUT_PROC(xkbi->device,xkbPrivPtr); + xkbi->device->public.processInputProc(&ev,xkbi->device,1); + COND_WRAP_PROCESS_INPUT_PROC(xkbi->device, xkbPrivPtr, + ProcessKeyboardEvent,xkbUnwrapProc); xkbi->device->key->modifierMap[ev.u.u.detail] = realMods; if ( mask || mods ) { @@ -908,7 +954,10 @@ realMods = xkbi->device->key->modifierMap[ev.u.u.detail]; xkbi->device->key->modifierMap[ev.u.u.detail] = 0; - CoreProcessKeyboardEvent(&ev,xkbi->device,1); + UNWRAP_PROCESS_INPUT_PROC(xkbi->device,xkbPrivPtr); + xkbi->device->public.processInputProc(&ev,xkbi->device,1); + COND_WRAP_PROCESS_INPUT_PROC(xkbi->device, xkbPrivPtr, + ProcessKeyboardEvent,xkbUnwrapProc); xkbi->device->key->modifierMap[ev.u.u.detail] = realMods; if ( mask || mods ) { @@ -1102,6 +1151,8 @@ #ifdef XINPUT Bool xiEvent; #endif + + xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(dev); keyc= kbd->key; xkbi= keyc->xkbInfo; @@ -1244,7 +1295,10 @@ if (keyEvent) { realMods = keyc->modifierMap[key]; keyc->modifierMap[key] = 0; - CoreProcessKeyboardEvent(xE,dev,count); + UNWRAP_PROCESS_INPUT_PROC(dev,xkbPrivPtr); + dev->public.processInputProc(xE,dev,count); + COND_WRAP_PROCESS_INPUT_PROC(dev, xkbPrivPtr, + ProcessKeyboardEvent,xkbUnwrapProc); keyc->modifierMap[key] = realMods; } else CoreProcessPointerEvent(xE,dev,count);