void XkbProcessOtherEvent(xEvent *xE,DeviceIntPtr dev,int count) { Bool xkbCares,isBtn; xkbCares= True; isBtn= False; switch ( xE->u.u.type ) { case KeyPress: xE->u.u.type= DeviceKeyPress; break; case KeyRelease: xE->u.u.type= DeviceKeyRelease; break; case ButtonPress: xE->u.u.type= DeviceButtonPress; isBtn= True; break; case ButtonRelease: xE->u.u.type= DeviceButtonRelease; isBtn= True; break; default: xkbCares= False; break; } if (xkbCares) { if ((!isBtn)||((dev->button)&&(dev->button->xkb_acts))) { DeviceIntPtr kbd; if (dev->key) kbd= dev; else kbd= (DeviceIntPtr)LookupKeyboardDevice(); XkbHandleActions(dev,kbd,xE,count); return; } } ProcessOtherEvent(xE,dev,count); return; }
static int KdKeybdProc(DeviceIntPtr pDevice, int onoff) { Bool ret; DevicePtr pDev = (DevicePtr)pDevice; #ifdef XKB XkbComponentNamesRec names; #endif if (!pDev) return BadImplementation; switch (onoff) { case DEVICE_INIT: if (pDev != LookupKeyboardDevice()) { return !Success; } #ifndef XKB ret = InitKeyboardDeviceStruct(pDev, &kdKeySyms, kdModMap, KdBell, KdKbdCtrl); #else memset(&names, 0, sizeof(XkbComponentNamesRec)); if (XkbInitialMap) names.keymap = XkbInitialMap; XkbSetRulesDflts ("base", "pc101", "us", NULL, NULL); ret = XkbInitKeyboardDeviceStruct ((DeviceIntPtr) pDev, &names, &kdKeySyms, kdModMap, KdBell, KdKbdCtrl); #endif if (!ret) return BadImplementation; break; case DEVICE_ON: pDev->on = TRUE; pKdKeyboard = pDevice; if (kdKeyboardFuncs) (*kdKeyboardFuncs->Init) (); break; case DEVICE_OFF: case DEVICE_CLOSE: pKdKeyboard = 0; if (pDev->on) { pDev->on = FALSE; if (kdKeyboardFuncs) (*kdKeyboardFuncs->Fini) (); } break; } return Success; }
void ProcessPointerEvent( register xEvent * xE, register DeviceIntPtr mouse, int count) { DeviceIntPtr dev = (DeviceIntPtr)LookupKeyboardDevice(); XkbSrvInfoPtr xkbi = dev->key->xkbInfo; unsigned changed = 0; xkbi->shiftKeyCount = 0; xkbi->lastPtrEventTime= xE->u.keyButtonPointer.time; if (xE->u.u.type==ButtonPress) { changed |= XkbPointerButtonMask; } else if (xE->u.u.type==ButtonRelease) { xkbi->lockedPtrButtons&= ~(1<<(xE->u.u.detail&0x7)); changed |= XkbPointerButtonMask; } CoreProcessPointerEvent(xE,mouse,count); xkbi->state.ptr_buttons = mouse->button->state; /* clear any latched modifiers */ if ( xkbi->state.latched_mods && (xE->u.u.type==ButtonRelease) ) { unsigned changed_leds; XkbStateRec oldState; XkbSrvLedInfoPtr sli; sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId,0); oldState= xkbi->state; XkbLatchModifiers(dev,0xFF,0x00); XkbComputeDerivedState(xkbi); changed |= XkbStateChangedFlags(&oldState,&xkbi->state); if (changed&sli->usedComponents) { changed_leds= XkbIndicatorsToUpdate(dev,changed,False); if (changed_leds) { XkbEventCauseRec cause; XkbSetCauseKey(&cause,(xE->u.u.detail&0x7),xE->u.u.type); XkbUpdateIndicators(dev,changed_leds,True,NULL,&cause); } } dev->key->state= XkbStateFieldFromRec(&xkbi->state); } if (((xkbi->flags&_XkbStateNotifyInProgress)==0)&&(changed!=0)) { xkbStateNotify sn; sn.keycode= xE->u.u.detail; sn.eventType= xE->u.u.type; sn.requestMajor = sn.requestMinor = 0; sn.changed= changed; XkbSendStateNotify(dev,&sn); } } /* ProcessPointerEvent */
/* * DESCRIPTION: * * This routine processes the simulation of some input event. * */ int XETrapSimulateXEvent(register xXTrapInputReq *request, register ClientPtr client) { ScreenPtr pScr = NULL; int status = Success; xEvent xev; register int x = request->input.x; register int y = request->input.y; DevicePtr keydev = LookupKeyboardDevice(); DevicePtr ptrdev = LookupPointerDevice(); if (request->input.screen < screenInfo.numScreens) { pScr = screenInfo.screens[request->input.screen]; } else { /* Trying to play bogus events to this WS! */ #ifdef VERBOSE ErrorF("%s: Trying to send events to screen %d!\n", XTrapExtName, request->input.screen); #endif status = XETrapErrorBase + BadScreen; } /* Fill in the event structure with the information * Note: root, event, child, eventX, eventY, state, and sameScreen * are all updated by FixUpEventFromWindow() when the events * are delivered via DeliverDeviceEvents() or whatever. XTrap * needs to only concern itself with type, detail, time, rootX, * and rootY. */ if (status == Success) { xev.u.u.type = request->input.type; xev.u.u.detail = request->input.detail; xev.u.keyButtonPointer.time = GetTimeInMillis(); xev.u.keyButtonPointer.rootX = x; xev.u.keyButtonPointer.rootY = y; if (request->input.type == MotionNotify) { /* Set new cursor position on screen */ XETrap_avail.data.cur_x = x; XETrap_avail.data.cur_y = y; NewCurrentScreen (pScr, x, y); /* fix from [email protected] */ if (!(*pScr->SetCursorPosition)(pScr, x, y, xFalse)) { status = BadImplementation; } } } if (status == Success) { switch(request->input.type) { /* Now process the event appropriately */ case KeyPress: case KeyRelease: (*XETrapKbdDev->realInputProc)(&xev,(DeviceIntPtr)keydev, 1L); break; case MotionNotify: case ButtonPress: case ButtonRelease: (*XETrapPtrDev->realInputProc)(&xev,(DeviceIntPtr)ptrdev, 1L); break; default: status = BadValue; break; } } return(status); }
int ProcXUngrabDeviceKey(ClientPtr client) { DeviceIntPtr dev; DeviceIntPtr mdev; WindowPtr pWin; GrabRec temporaryGrab; REQUEST(xUngrabDeviceKeyReq); REQUEST_SIZE_MATCH(xUngrabDeviceKeyReq); dev = LookupDeviceIntRec(stuff->grabbed_device); if (dev == NULL) { SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0, BadDevice); return Success; } if (dev->key == NULL) { SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0, BadMatch); return Success; } if (stuff->modifier_device != UseXKeyboard) { mdev = LookupDeviceIntRec(stuff->modifier_device); if (mdev == NULL) { SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0, BadDevice); return Success; } if (mdev->key == NULL) { SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0, BadMatch); return Success; } } else mdev = (DeviceIntPtr) LookupKeyboardDevice(); pWin = LookupWindow(stuff->grabWindow, client); if (!pWin) { SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0, BadWindow); return Success; } if (((stuff->key > dev->key->curKeySyms.maxKeyCode) || (stuff->key < dev->key->curKeySyms.minKeyCode)) && (stuff->key != AnyKey)) { SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0, BadValue); return Success; } if ((stuff->modifiers != AnyModifier) && (stuff->modifiers & ~AllModifiersMask)) { SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0, BadValue); return Success; } temporaryGrab.resource = client->clientAsMask; temporaryGrab.device = dev; temporaryGrab.window = pWin; temporaryGrab.type = DeviceKeyPress; temporaryGrab.modifierDevice = mdev; temporaryGrab.modifiersDetail.exact = stuff->modifiers; temporaryGrab.modifiersDetail.pMask = NULL; temporaryGrab.detail.exact = stuff->key; temporaryGrab.detail.pMask = NULL; DeletePassiveGrabFromList(&temporaryGrab); return Success; }
int ProcXUngrabDeviceButton(ClientPtr client) { DeviceIntPtr dev; DeviceIntPtr mdev; WindowPtr pWin; GrabRec temporaryGrab; int rc; REQUEST(xUngrabDeviceButtonReq); REQUEST_SIZE_MATCH(xUngrabDeviceButtonReq); dev = LookupDeviceIntRec(stuff->grabbed_device); if (dev == NULL) { SendErrorToClient(client, IReqCode, X_UngrabDeviceButton, 0, BadDevice); return Success; } if (dev->button == NULL) { SendErrorToClient(client, IReqCode, X_UngrabDeviceButton, 0, BadMatch); return Success; } if (stuff->modifier_device != UseXKeyboard) { mdev = LookupDeviceIntRec(stuff->modifier_device); if (mdev == NULL) { SendErrorToClient(client, IReqCode, X_UngrabDeviceButton, 0, BadDevice); return Success; } if (mdev->key == NULL) { SendErrorToClient(client, IReqCode, X_UngrabDeviceButton, 0, BadMatch); return Success; } } else mdev = (DeviceIntPtr) LookupKeyboardDevice(); rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixUnknownAccess); if (rc != Success) { SendErrorToClient(client, IReqCode, X_UngrabDeviceButton, 0, rc); return Success; } if ((stuff->modifiers != AnyModifier) && (stuff->modifiers & ~AllModifiersMask)) { SendErrorToClient(client, IReqCode, X_UngrabDeviceButton, 0, BadValue); return Success; } temporaryGrab.resource = client->clientAsMask; temporaryGrab.device = dev; temporaryGrab.window = pWin; temporaryGrab.type = DeviceButtonPress; temporaryGrab.modifierDevice = mdev; temporaryGrab.modifiersDetail.exact = stuff->modifiers; temporaryGrab.modifiersDetail.pMask = NULL; temporaryGrab.detail.exact = stuff->button; temporaryGrab.detail.pMask = NULL; DeletePassiveGrabFromList(&temporaryGrab); return Success; }