diff options
author | marha <marha@users.sourceforge.net> | 2012-03-23 10:05:55 +0100 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2012-03-23 10:05:55 +0100 |
commit | 0f834b91a4768673833ab4917e87d86c237bb1a6 (patch) | |
tree | 363489504ed4b2d360259b8de4c9e392918e5d02 /xorg-server/xkb/xkbEvents.c | |
parent | fc72edebf875378459368c5383d9023730cbca54 (diff) | |
download | vcxsrv-0f834b91a4768673833ab4917e87d86c237bb1a6.tar.gz vcxsrv-0f834b91a4768673833ab4917e87d86c237bb1a6.tar.bz2 vcxsrv-0f834b91a4768673833ab4917e87d86c237bb1a6.zip |
libX11 xserver fontconfig mesa pixman xkbcomp xkeyboard-config git update
23 Mar 2012
Diffstat (limited to 'xorg-server/xkb/xkbEvents.c')
-rw-r--r-- | xorg-server/xkb/xkbEvents.c | 1199 |
1 files changed, 603 insertions, 596 deletions
diff --git a/xorg-server/xkb/xkbEvents.c b/xorg-server/xkb/xkbEvents.c index 347f0f8a4..d49e4c1ba 100644 --- a/xorg-server/xkb/xkbEvents.c +++ b/xorg-server/xkb/xkbEvents.c @@ -118,7 +118,7 @@ XkbSendLegacyMapNotify(DeviceIntPtr kbd, CARD16 xkb_event, CARD16 changed, core_mn.u.mappingNotify.count = num_keys; else core_mn.u.mappingNotify.count = clients[i]->maxKC - - clients[i]->minKC + 1; + clients[i]->minKC + 1; WriteEventsToClient(clients[i], 1, &core_mn); } @@ -152,7 +152,7 @@ XkbSendLegacyMapNotify(DeviceIntPtr kbd, CARD16 xkb_event, CARD16 changed, /***====================================================================***/ void -XkbSendNewKeyboardNotify(DeviceIntPtr kbd,xkbNewKeyboardNotify *pNKN) +XkbSendNewKeyboardNotify(DeviceIntPtr kbd, xkbNewKeyboardNotify * pNKN) { int i; Time time = GetTimeInMillis(); @@ -161,7 +161,7 @@ XkbSendNewKeyboardNotify(DeviceIntPtr kbd,xkbNewKeyboardNotify *pNKN) pNKN->type = XkbEventCode + XkbEventBase; pNKN->xkbType = XkbNewKeyboardNotify; - for (i=1; i<currentMaxClients; i++) { + for (i = 1; i < currentMaxClients; i++) { if (!clients[i] || clients[i]->clientState != ClientStateRunning) continue; @@ -193,19 +193,19 @@ XkbSendNewKeyboardNotify(DeviceIntPtr kbd,xkbNewKeyboardNotify *pNKN) /***====================================================================***/ void -XkbSendStateNotify(DeviceIntPtr kbd,xkbStateNotify *pSN) +XkbSendStateNotify(DeviceIntPtr kbd, xkbStateNotify * pSN) { -XkbSrvInfoPtr xkbi; -XkbStatePtr state; -XkbInterestPtr interest; -Time time; -register CARD16 changed,bState; + XkbSrvInfoPtr xkbi; + XkbStatePtr state; + XkbInterestPtr interest; + Time time; + register CARD16 changed, bState; interest = kbd->xkb_interest; if (!interest || !kbd->key || !kbd->key->xkbInfo) - return; + return; xkbi = kbd->key->xkbInfo; - state= &xkbi->state; + state = &xkbi->state; pSN->type = XkbEventCode + XkbEventBase; pSN->xkbType = XkbStateNotify; @@ -226,26 +226,26 @@ register CARD16 changed,bState; pSN->compatLookupMods = state->compat_lookup_mods; pSN->ptrBtnState = state->ptr_buttons; changed = pSN->changed; - bState= pSN->ptrBtnState; + bState = pSN->ptrBtnState; while (interest) { - if ((!interest->client->clientGone) && - (interest->client->requestVector != InitialVector) && - (interest->client->xkbClientFlags&_XkbClientInitialized) && - (interest->stateNotifyMask&changed)) { - pSN->sequenceNumber = interest->client->sequence; - pSN->time = time; - pSN->changed = changed; - pSN->ptrBtnState = bState; - if ( interest->client->swapped ) { - swaps(&pSN->sequenceNumber); - swapl(&pSN->time); - swaps(&pSN->changed); - swaps(&pSN->ptrBtnState); - } - WriteToClient(interest->client, sizeof(xEvent), (char *)pSN); - } - interest= interest->next; + if ((!interest->client->clientGone) && + (interest->client->requestVector != InitialVector) && + (interest->client->xkbClientFlags & _XkbClientInitialized) && + (interest->stateNotifyMask & changed)) { + pSN->sequenceNumber = interest->client->sequence; + pSN->time = time; + pSN->changed = changed; + pSN->ptrBtnState = bState; + if (interest->client->swapped) { + swaps(&pSN->sequenceNumber); + swapl(&pSN->time); + swaps(&pSN->changed); + swaps(&pSN->ptrBtnState); + } + WriteToClient(interest->client, sizeof(xEvent), (char *) pSN); + } + interest = interest->next; } return; } @@ -257,7 +257,7 @@ register CARD16 changed,bState; * have explicitly selected for them. Core and Xi events are handled by * XkbSendLegacyMapNotify. */ void -XkbSendMapNotify(DeviceIntPtr kbd, xkbMapNotify *pMN) +XkbSendMapNotify(DeviceIntPtr kbd, xkbMapNotify * pMN) { int i; CARD32 time = GetTimeInMillis(); @@ -295,595 +295,599 @@ XkbSendMapNotify(DeviceIntPtr kbd, xkbMapNotify *pMN) } int -XkbComputeControlsNotify( DeviceIntPtr kbd, - XkbControlsPtr old, - XkbControlsPtr new, - xkbControlsNotify * pCN, - Bool forceCtrlProc) +XkbComputeControlsNotify(DeviceIntPtr kbd, + XkbControlsPtr old, + XkbControlsPtr new, + xkbControlsNotify * pCN, Bool forceCtrlProc) { -int i; -CARD32 changedControls; + int i; + CARD32 changedControls; - changedControls= 0; + changedControls = 0; if (!kbd || !kbd->kbdfeed) return 0; - - if (old->enabled_ctrls!=new->enabled_ctrls) - changedControls|= XkbControlsEnabledMask; - if ((old->repeat_delay!=new->repeat_delay)|| - (old->repeat_interval!=new->repeat_interval)) - changedControls|= XkbRepeatKeysMask; + + if (old->enabled_ctrls != new->enabled_ctrls) + changedControls |= XkbControlsEnabledMask; + if ((old->repeat_delay != new->repeat_delay) || + (old->repeat_interval != new->repeat_interval)) + changedControls |= XkbRepeatKeysMask; for (i = 0; i < XkbPerKeyBitArraySize; i++) - if (old->per_key_repeat[i] != new->per_key_repeat[i]) - changedControls|= XkbPerKeyRepeatMask; - if (old->slow_keys_delay!=new->slow_keys_delay) - changedControls|= XkbSlowKeysMask; - if (old->debounce_delay!=new->debounce_delay) - changedControls|= XkbBounceKeysMask; - if ((old->mk_delay!=new->mk_delay)|| - (old->mk_interval!=new->mk_interval)|| - (old->mk_dflt_btn!=new->mk_dflt_btn)) - changedControls|= XkbMouseKeysMask; - if ((old->mk_time_to_max!=new->mk_time_to_max)|| - (old->mk_curve!=new->mk_curve)|| - (old->mk_max_speed!=new->mk_max_speed)) - changedControls|= XkbMouseKeysAccelMask; - if (old->ax_options!=new->ax_options) - changedControls|= XkbAccessXKeysMask; - if ((old->ax_options^new->ax_options) & XkbAX_SKOptionsMask) - changedControls|= XkbStickyKeysMask; - if ((old->ax_options^new->ax_options) & XkbAX_FBOptionsMask) - changedControls|= XkbAccessXFeedbackMask; - if ((old->ax_timeout!=new->ax_timeout)|| - (old->axt_ctrls_mask!=new->axt_ctrls_mask)|| - (old->axt_ctrls_values!=new->axt_ctrls_values)|| - (old->axt_opts_mask!=new->axt_opts_mask)|| - (old->axt_opts_values!= new->axt_opts_values)) { - changedControls|= XkbAccessXTimeoutMask; + if (old->per_key_repeat[i] != new->per_key_repeat[i]) + changedControls |= XkbPerKeyRepeatMask; + if (old->slow_keys_delay != new->slow_keys_delay) + changedControls |= XkbSlowKeysMask; + if (old->debounce_delay != new->debounce_delay) + changedControls |= XkbBounceKeysMask; + if ((old->mk_delay != new->mk_delay) || + (old->mk_interval != new->mk_interval) || + (old->mk_dflt_btn != new->mk_dflt_btn)) + changedControls |= XkbMouseKeysMask; + if ((old->mk_time_to_max != new->mk_time_to_max) || + (old->mk_curve != new->mk_curve) || + (old->mk_max_speed != new->mk_max_speed)) + changedControls |= XkbMouseKeysAccelMask; + if (old->ax_options != new->ax_options) + changedControls |= XkbAccessXKeysMask; + if ((old->ax_options ^ new->ax_options) & XkbAX_SKOptionsMask) + changedControls |= XkbStickyKeysMask; + if ((old->ax_options ^ new->ax_options) & XkbAX_FBOptionsMask) + changedControls |= XkbAccessXFeedbackMask; + if ((old->ax_timeout != new->ax_timeout) || + (old->axt_ctrls_mask != new->axt_ctrls_mask) || + (old->axt_ctrls_values != new->axt_ctrls_values) || + (old->axt_opts_mask != new->axt_opts_mask) || + (old->axt_opts_values != new->axt_opts_values)) { + changedControls |= XkbAccessXTimeoutMask; } - if ((old->internal.mask!=new->internal.mask)|| - (old->internal.real_mods!=new->internal.real_mods)|| - (old->internal.vmods!=new->internal.vmods)) - changedControls|= XkbInternalModsMask; - if ((old->ignore_lock.mask!=new->ignore_lock.mask)|| - (old->ignore_lock.real_mods!=new->ignore_lock.real_mods)|| - (old->ignore_lock.vmods!=new->ignore_lock.vmods)) - changedControls|= XkbIgnoreLockModsMask; - - if (new->enabled_ctrls&XkbRepeatKeysMask) - kbd->kbdfeed->ctrl.autoRepeat=TRUE; - else kbd->kbdfeed->ctrl.autoRepeat=FALSE; + if ((old->internal.mask != new->internal.mask) || + (old->internal.real_mods != new->internal.real_mods) || + (old->internal.vmods != new->internal.vmods)) + changedControls |= XkbInternalModsMask; + if ((old->ignore_lock.mask != new->ignore_lock.mask) || + (old->ignore_lock.real_mods != new->ignore_lock.real_mods) || + (old->ignore_lock.vmods != new->ignore_lock.vmods)) + changedControls |= XkbIgnoreLockModsMask; + + if (new->enabled_ctrls & XkbRepeatKeysMask) + kbd->kbdfeed->ctrl.autoRepeat = TRUE; + else + kbd->kbdfeed->ctrl.autoRepeat = FALSE; if (kbd->kbdfeed && kbd->kbdfeed->CtrlProc && - (changedControls || forceCtrlProc)) - (*kbd->kbdfeed->CtrlProc)(kbd, &kbd->kbdfeed->ctrl); + (changedControls || forceCtrlProc)) + (*kbd->kbdfeed->CtrlProc) (kbd, &kbd->kbdfeed->ctrl); - if ((!changedControls)&&(old->num_groups==new->num_groups)) - return 0; + if ((!changedControls) && (old->num_groups == new->num_groups)) + return 0; if (!kbd->xkb_interest) - return 0; + return 0; pCN->changedControls = changedControls; pCN->enabledControls = new->enabled_ctrls; - pCN->enabledControlChanges = (new->enabled_ctrls^old->enabled_ctrls); + pCN->enabledControlChanges = (new->enabled_ctrls ^ old->enabled_ctrls); pCN->numGroups = new->num_groups; return 1; } void -XkbSendControlsNotify(DeviceIntPtr kbd,xkbControlsNotify *pCN) +XkbSendControlsNotify(DeviceIntPtr kbd, xkbControlsNotify * pCN) { -int initialized; -CARD32 changedControls, enabledControls, enabledChanges = 0; -XkbSrvInfoPtr xkbi; -XkbInterestPtr interest; -Time time = 0; + int initialized; + CARD32 changedControls, enabledControls, enabledChanges = 0; + XkbSrvInfoPtr xkbi; + XkbInterestPtr interest; + Time time = 0; interest = kbd->xkb_interest; if (!interest || !kbd->key || !kbd->key->xkbInfo) - return; + return; xkbi = kbd->key->xkbInfo; - + initialized = 0; enabledControls = xkbi->desc->ctrls->enabled_ctrls; changedControls = pCN->changedControls; - pCN->numGroups= xkbi->desc->ctrls->num_groups; + pCN->numGroups = xkbi->desc->ctrls->num_groups; while (interest) { - if ((!interest->client->clientGone) && - (interest->client->requestVector != InitialVector) && - (interest->client->xkbClientFlags&_XkbClientInitialized) && - (interest->ctrlsNotifyMask&changedControls)) { - if (!initialized) { - pCN->type = XkbEventCode + XkbEventBase; - pCN->xkbType = XkbControlsNotify; - pCN->deviceID = kbd->id; - pCN->time = time = GetTimeInMillis(); - enabledChanges = pCN->enabledControlChanges; - initialized= 1; - } - pCN->changedControls = changedControls; - pCN->enabledControls = enabledControls; - pCN->enabledControlChanges = enabledChanges; - pCN->sequenceNumber = interest->client->sequence; - pCN->time = time; - if ( interest->client->swapped ) { - swaps(&pCN->sequenceNumber); - swapl(&pCN->changedControls); - swapl(&pCN->enabledControls); - swapl(&pCN->enabledControlChanges); - swapl(&pCN->time); - } - WriteToClient(interest->client, sizeof(xEvent), (char *)pCN); - } - interest= interest->next; + if ((!interest->client->clientGone) && + (interest->client->requestVector != InitialVector) && + (interest->client->xkbClientFlags & _XkbClientInitialized) && + (interest->ctrlsNotifyMask & changedControls)) { + if (!initialized) { + pCN->type = XkbEventCode + XkbEventBase; + pCN->xkbType = XkbControlsNotify; + pCN->deviceID = kbd->id; + pCN->time = time = GetTimeInMillis(); + enabledChanges = pCN->enabledControlChanges; + initialized = 1; + } + pCN->changedControls = changedControls; + pCN->enabledControls = enabledControls; + pCN->enabledControlChanges = enabledChanges; + pCN->sequenceNumber = interest->client->sequence; + pCN->time = time; + if (interest->client->swapped) { + swaps(&pCN->sequenceNumber); + swapl(&pCN->changedControls); + swapl(&pCN->enabledControls); + swapl(&pCN->enabledControlChanges); + swapl(&pCN->time); + } + WriteToClient(interest->client, sizeof(xEvent), (char *) pCN); + } + interest = interest->next; } return; } static void -XkbSendIndicatorNotify(DeviceIntPtr kbd,int xkbType,xkbIndicatorNotify *pEv) +XkbSendIndicatorNotify(DeviceIntPtr kbd, int xkbType, xkbIndicatorNotify * pEv) { -int initialized; -XkbInterestPtr interest; -Time time = 0; -CARD32 state,changed; + int initialized; + XkbInterestPtr interest; + Time time = 0; + CARD32 state, changed; interest = kbd->xkb_interest; if (!interest) - return; - + return; + initialized = 0; state = pEv->state; changed = pEv->changed; while (interest) { - if ((!interest->client->clientGone) && - (interest->client->requestVector != InitialVector) && - (interest->client->xkbClientFlags&_XkbClientInitialized) && - (((xkbType==XkbIndicatorStateNotify)&& - (interest->iStateNotifyMask&changed))|| - ((xkbType==XkbIndicatorMapNotify)&& - (interest->iMapNotifyMask&changed)))) { - if (!initialized) { - pEv->type = XkbEventCode + XkbEventBase; - pEv->xkbType = xkbType; - pEv->deviceID = kbd->id; - pEv->time = time = GetTimeInMillis(); - initialized= 1; - } - pEv->sequenceNumber = interest->client->sequence; - pEv->time = time; - pEv->changed = changed; - pEv->state = state; - if ( interest->client->swapped ) { - swaps(&pEv->sequenceNumber); - swapl(&pEv->time); - swapl(&pEv->changed); - swapl(&pEv->state); - } - WriteToClient(interest->client, sizeof(xEvent), (char *)pEv); - } - interest= interest->next; + if ((!interest->client->clientGone) && + (interest->client->requestVector != InitialVector) && + (interest->client->xkbClientFlags & _XkbClientInitialized) && + (((xkbType == XkbIndicatorStateNotify) && + (interest->iStateNotifyMask & changed)) || + ((xkbType == XkbIndicatorMapNotify) && + (interest->iMapNotifyMask & changed)))) { + if (!initialized) { + pEv->type = XkbEventCode + XkbEventBase; + pEv->xkbType = xkbType; + pEv->deviceID = kbd->id; + pEv->time = time = GetTimeInMillis(); + initialized = 1; + } + pEv->sequenceNumber = interest->client->sequence; + pEv->time = time; + pEv->changed = changed; + pEv->state = state; + if (interest->client->swapped) { + swaps(&pEv->sequenceNumber); + swapl(&pEv->time); + swapl(&pEv->changed); + swapl(&pEv->state); + } + WriteToClient(interest->client, sizeof(xEvent), (char *) pEv); + } + interest = interest->next; } return; } - void -XkbHandleBell( BOOL force, - BOOL eventOnly, - DeviceIntPtr kbd, - CARD8 percent, - pointer pCtrl, - CARD8 class, - Atom name, - WindowPtr pWin, - ClientPtr pClient) +XkbHandleBell(BOOL force, + BOOL eventOnly, + DeviceIntPtr kbd, + CARD8 percent, + pointer pCtrl, + CARD8 class, Atom name, WindowPtr pWin, ClientPtr pClient) { -xkbBellNotify bn; -int initialized; -XkbSrvInfoPtr xkbi; -XkbInterestPtr interest; -CARD8 id; -CARD16 pitch,duration; -Time time = 0; -XID winID = 0; + xkbBellNotify bn; + int initialized; + XkbSrvInfoPtr xkbi; + XkbInterestPtr interest; + CARD8 id; + CARD16 pitch, duration; + Time time = 0; + XID winID = 0; if (!kbd->key || !kbd->key->xkbInfo) return; xkbi = kbd->key->xkbInfo; - if ((force||(xkbi->desc->ctrls->enabled_ctrls&XkbAudibleBellMask))&& - (!eventOnly)) { + if ((force || (xkbi->desc->ctrls->enabled_ctrls & XkbAudibleBellMask)) && + (!eventOnly)) { if (kbd->kbdfeed->BellProc) - (*kbd->kbdfeed->BellProc)(percent,kbd,(pointer)pCtrl,class); + (*kbd->kbdfeed->BellProc) (percent, kbd, (pointer) pCtrl, class); } interest = kbd->xkb_interest; - if ((!interest)||(force)) - return; - - if ((class==0)||(class==KbdFeedbackClass)) { - KeybdCtrl *pKeyCtrl= (KeybdCtrl *)pCtrl; - id= pKeyCtrl->id; - pitch= pKeyCtrl->bell_pitch; - duration= pKeyCtrl->bell_duration; + if ((!interest) || (force)) + return; + + if ((class == 0) || (class == KbdFeedbackClass)) { + KeybdCtrl *pKeyCtrl = (KeybdCtrl *) pCtrl; + + id = pKeyCtrl->id; + pitch = pKeyCtrl->bell_pitch; + duration = pKeyCtrl->bell_duration; } - else if (class==BellFeedbackClass) { - BellCtrl *pBellCtrl= (BellCtrl *)pCtrl; - id= pBellCtrl->id; - pitch= pBellCtrl->pitch; - duration= pBellCtrl->duration; + else if (class == BellFeedbackClass) { + BellCtrl *pBellCtrl = (BellCtrl *) pCtrl; + + id = pBellCtrl->id; + pitch = pBellCtrl->pitch; + duration = pBellCtrl->duration; } - else return; - + else + return; + initialized = 0; while (interest) { - if ((!interest->client->clientGone) && - (interest->client->requestVector != InitialVector) && - (interest->client->xkbClientFlags&_XkbClientInitialized) && - (interest->bellNotifyMask)) { - if (!initialized) { - time = GetTimeInMillis(); - bn.type = XkbEventCode + XkbEventBase; - bn.xkbType = XkbBellNotify; - bn.deviceID = kbd->id; - bn.bellClass = class; - bn.bellID = id; - bn.percent= percent; - bn.eventOnly = (eventOnly!=0); - winID= (pWin?pWin->drawable.id:None); - initialized= 1; - } - bn.sequenceNumber = interest->client->sequence; - bn.time = time; - bn.pitch = pitch; - bn.duration = duration; - bn.name = name; - bn.window= winID; - if ( interest->client->swapped ) { - swaps(&bn.sequenceNumber); - swapl(&bn.time); - swaps(&bn.pitch); - swaps(&bn.duration); - swapl(&bn.name); - swapl(&bn.window); - } - WriteToClient(interest->client, sizeof(xEvent), (char *)&bn); - } - interest= interest->next; + if ((!interest->client->clientGone) && + (interest->client->requestVector != InitialVector) && + (interest->client->xkbClientFlags & _XkbClientInitialized) && + (interest->bellNotifyMask)) { + if (!initialized) { + time = GetTimeInMillis(); + bn.type = XkbEventCode + XkbEventBase; + bn.xkbType = XkbBellNotify; + bn.deviceID = kbd->id; + bn.bellClass = class; + bn.bellID = id; + bn.percent = percent; + bn.eventOnly = (eventOnly != 0); + winID = (pWin ? pWin->drawable.id : None); + initialized = 1; + } + bn.sequenceNumber = interest->client->sequence; + bn.time = time; + bn.pitch = pitch; + bn.duration = duration; + bn.name = name; + bn.window = winID; + if (interest->client->swapped) { + swaps(&bn.sequenceNumber); + swapl(&bn.time); + swaps(&bn.pitch); + swaps(&bn.duration); + swapl(&bn.name); + swapl(&bn.window); + } + WriteToClient(interest->client, sizeof(xEvent), (char *) &bn); + } + interest = interest->next; } return; } void -XkbSendAccessXNotify(DeviceIntPtr kbd,xkbAccessXNotify *pEv) +XkbSendAccessXNotify(DeviceIntPtr kbd, xkbAccessXNotify * pEv) { -int initialized; -XkbInterestPtr interest; -Time time = 0; -CARD16 sk_delay,db_delay; + int initialized; + XkbInterestPtr interest; + Time time = 0; + CARD16 sk_delay, db_delay; interest = kbd->xkb_interest; if (!interest) - return; - + return; + initialized = 0; - sk_delay= pEv->slowKeysDelay; - db_delay= pEv->debounceDelay; + sk_delay = pEv->slowKeysDelay; + db_delay = pEv->debounceDelay; while (interest) { - if ((!interest->client->clientGone) && - (interest->client->requestVector != InitialVector) && - (interest->client->xkbClientFlags&_XkbClientInitialized) && - (interest->accessXNotifyMask&(1<<pEv->detail))) { - if (!initialized) { - pEv->type = XkbEventCode + XkbEventBase; - pEv->xkbType = XkbAccessXNotify; - pEv->deviceID = kbd->id; - pEv->time = time = GetTimeInMillis(); - initialized= 1; - } - pEv->sequenceNumber = interest->client->sequence; - pEv->time = time; - pEv->slowKeysDelay = sk_delay; - pEv->debounceDelay = db_delay; - if ( interest->client->swapped ) { - swaps(&pEv->sequenceNumber); - swapl(&pEv->time); - swaps(&pEv->slowKeysDelay); - swaps(&pEv->debounceDelay); - } - WriteToClient(interest->client, sizeof(xEvent), (char *)pEv); - } - interest= interest->next; + if ((!interest->client->clientGone) && + (interest->client->requestVector != InitialVector) && + (interest->client->xkbClientFlags & _XkbClientInitialized) && + (interest->accessXNotifyMask & (1 << pEv->detail))) { + if (!initialized) { + pEv->type = XkbEventCode + XkbEventBase; + pEv->xkbType = XkbAccessXNotify; + pEv->deviceID = kbd->id; + pEv->time = time = GetTimeInMillis(); + initialized = 1; + } + pEv->sequenceNumber = interest->client->sequence; + pEv->time = time; + pEv->slowKeysDelay = sk_delay; + pEv->debounceDelay = db_delay; + if (interest->client->swapped) { + swaps(&pEv->sequenceNumber); + swapl(&pEv->time); + swaps(&pEv->slowKeysDelay); + swaps(&pEv->debounceDelay); + } + WriteToClient(interest->client, sizeof(xEvent), (char *) pEv); + } + interest = interest->next; } return; } void -XkbSendNamesNotify(DeviceIntPtr kbd,xkbNamesNotify *pEv) +XkbSendNamesNotify(DeviceIntPtr kbd, xkbNamesNotify * pEv) { -int initialized; -XkbInterestPtr interest; -Time time = 0; -CARD16 changed,changedVirtualMods; -CARD32 changedIndicators; + int initialized; + XkbInterestPtr interest; + Time time = 0; + CARD16 changed, changedVirtualMods; + CARD32 changedIndicators; interest = kbd->xkb_interest; if (!interest) - return; - + return; + initialized = 0; - changed= pEv->changed; - changedIndicators= pEv->changedIndicators; - changedVirtualMods= pEv->changedVirtualMods; + changed = pEv->changed; + changedIndicators = pEv->changedIndicators; + changedVirtualMods = pEv->changedVirtualMods; while (interest) { - if ((!interest->client->clientGone) && - (interest->client->requestVector != InitialVector) && - (interest->client->xkbClientFlags&_XkbClientInitialized) && - (interest->namesNotifyMask&pEv->changed)) { - if (!initialized) { - pEv->type = XkbEventCode + XkbEventBase; - pEv->xkbType = XkbNamesNotify; - pEv->deviceID = kbd->id; - pEv->time = time = GetTimeInMillis(); - initialized= 1; - } - pEv->sequenceNumber = interest->client->sequence; - pEv->time = time; - pEv->changed = changed; - pEv->changedIndicators = changedIndicators; - pEv->changedVirtualMods= changedVirtualMods; - if ( interest->client->swapped ) { - swaps(&pEv->sequenceNumber); - swapl(&pEv->time); - swaps(&pEv->changed); - swapl(&pEv->changedIndicators); - swaps(&pEv->changedVirtualMods); - } - WriteToClient(interest->client, sizeof(xEvent), (char *)pEv); - } - interest= interest->next; + if ((!interest->client->clientGone) && + (interest->client->requestVector != InitialVector) && + (interest->client->xkbClientFlags & _XkbClientInitialized) && + (interest->namesNotifyMask & pEv->changed)) { + if (!initialized) { + pEv->type = XkbEventCode + XkbEventBase; + pEv->xkbType = XkbNamesNotify; + pEv->deviceID = kbd->id; + pEv->time = time = GetTimeInMillis(); + initialized = 1; + } + pEv->sequenceNumber = interest->client->sequence; + pEv->time = time; + pEv->changed = changed; + pEv->changedIndicators = changedIndicators; + pEv->changedVirtualMods = changedVirtualMods; + if (interest->client->swapped) { + swaps(&pEv->sequenceNumber); + swapl(&pEv->time); + swaps(&pEv->changed); + swapl(&pEv->changedIndicators); + swaps(&pEv->changedVirtualMods); + } + WriteToClient(interest->client, sizeof(xEvent), (char *) pEv); + } + interest = interest->next; } return; } void -XkbSendCompatMapNotify(DeviceIntPtr kbd,xkbCompatMapNotify *pEv) +XkbSendCompatMapNotify(DeviceIntPtr kbd, xkbCompatMapNotify * pEv) { -int initialized; -XkbInterestPtr interest; -Time time = 0; -CARD16 firstSI = 0, nSI = 0, nTotalSI = 0; + int initialized; + XkbInterestPtr interest; + Time time = 0; + CARD16 firstSI = 0, nSI = 0, nTotalSI = 0; interest = kbd->xkb_interest; if (!interest) - return; - + return; + initialized = 0; while (interest) { - if ((!interest->client->clientGone) && - (interest->client->requestVector != InitialVector) && - (interest->client->xkbClientFlags&_XkbClientInitialized) && - (interest->compatNotifyMask)) { - if (!initialized) { - pEv->type = XkbEventCode + XkbEventBase; - pEv->xkbType = XkbCompatMapNotify; - pEv->deviceID = kbd->id; - pEv->time = time = GetTimeInMillis(); - firstSI= pEv->firstSI; - nSI= pEv->nSI; - nTotalSI= pEv->nTotalSI; - initialized= 1; - } - pEv->sequenceNumber = interest->client->sequence; - pEv->time = time; - pEv->firstSI = firstSI; - pEv->nSI = nSI; - pEv->nTotalSI = nTotalSI; - if ( interest->client->swapped ) { - swaps(&pEv->sequenceNumber); - swapl(&pEv->time); - swaps(&pEv->firstSI); - swaps(&pEv->nSI); - swaps(&pEv->nTotalSI); - } - WriteToClient(interest->client, sizeof(xEvent), (char *)pEv); - } - interest= interest->next; + if ((!interest->client->clientGone) && + (interest->client->requestVector != InitialVector) && + (interest->client->xkbClientFlags & _XkbClientInitialized) && + (interest->compatNotifyMask)) { + if (!initialized) { + pEv->type = XkbEventCode + XkbEventBase; + pEv->xkbType = XkbCompatMapNotify; + pEv->deviceID = kbd->id; + pEv->time = time = GetTimeInMillis(); + firstSI = pEv->firstSI; + nSI = pEv->nSI; + nTotalSI = pEv->nTotalSI; + initialized = 1; + } + pEv->sequenceNumber = interest->client->sequence; + pEv->time = time; + pEv->firstSI = firstSI; + pEv->nSI = nSI; + pEv->nTotalSI = nTotalSI; + if (interest->client->swapped) { + swaps(&pEv->sequenceNumber); + swapl(&pEv->time); + swaps(&pEv->firstSI); + swaps(&pEv->nSI); + swaps(&pEv->nTotalSI); + } + WriteToClient(interest->client, sizeof(xEvent), (char *) pEv); + } + interest = interest->next; } return; } void -XkbSendActionMessage(DeviceIntPtr kbd,xkbActionMessage *pEv) +XkbSendActionMessage(DeviceIntPtr kbd, xkbActionMessage * pEv) { -int initialized; -XkbSrvInfoPtr xkbi; -XkbInterestPtr interest; -Time time = 0; + int initialized; + XkbSrvInfoPtr xkbi; + XkbInterestPtr interest; + Time time = 0; interest = kbd->xkb_interest; if (!interest || !kbd->key || !kbd->key->xkbInfo) - return; - + return; + xkbi = kbd->key->xkbInfo; initialized = 0; - pEv->mods= xkbi->state.mods; - pEv->group= xkbi->state.group; + pEv->mods = xkbi->state.mods; + pEv->group = xkbi->state.group; while (interest) { - if ((!interest->client->clientGone) && - (interest->client->requestVector != InitialVector) && - (interest->client->xkbClientFlags&_XkbClientInitialized) && - (interest->actionMessageMask)) { - if (!initialized) { - pEv->type = XkbEventCode + XkbEventBase; - pEv->xkbType = XkbActionMessage; - pEv->deviceID = kbd->id; - pEv->sequenceNumber = interest->client->sequence; - pEv->time = time = GetTimeInMillis(); - initialized= 1; - } - pEv->sequenceNumber = interest->client->sequence; - pEv->time = time; - if ( interest->client->swapped ) { - swaps(&pEv->sequenceNumber); - swapl(&pEv->time); - } - WriteToClient(interest->client, sizeof(xEvent), (char *)pEv); - } - interest= interest->next; + if ((!interest->client->clientGone) && + (interest->client->requestVector != InitialVector) && + (interest->client->xkbClientFlags & _XkbClientInitialized) && + (interest->actionMessageMask)) { + if (!initialized) { + pEv->type = XkbEventCode + XkbEventBase; + pEv->xkbType = XkbActionMessage; + pEv->deviceID = kbd->id; + pEv->sequenceNumber = interest->client->sequence; + pEv->time = time = GetTimeInMillis(); + initialized = 1; + } + pEv->sequenceNumber = interest->client->sequence; + pEv->time = time; + if (interest->client->swapped) { + swaps(&pEv->sequenceNumber); + swapl(&pEv->time); + } + WriteToClient(interest->client, sizeof(xEvent), (char *) pEv); + } + interest = interest->next; } return; } void -XkbSendExtensionDeviceNotify( DeviceIntPtr dev, - ClientPtr client, - xkbExtensionDeviceNotify * pEv) +XkbSendExtensionDeviceNotify(DeviceIntPtr dev, + ClientPtr client, xkbExtensionDeviceNotify * pEv) { -int initialized; -XkbInterestPtr interest; -Time time = 0; -CARD32 defined, state; -CARD16 reason; + int initialized; + XkbInterestPtr interest; + Time time = 0; + CARD32 defined, state; + CARD16 reason; interest = dev->xkb_interest; if (!interest) - return; - + return; + initialized = 0; - reason= pEv->reason; - defined= pEv->ledsDefined; - state= pEv->ledState; + reason = pEv->reason; + defined = pEv->ledsDefined; + state = pEv->ledState; while (interest) { - if ((!interest->client->clientGone) && - (interest->client->requestVector != InitialVector) && - (interest->client->xkbClientFlags&_XkbClientInitialized) && - (interest->extDevNotifyMask&reason)) { - if (!initialized) { - pEv->type = XkbEventCode + XkbEventBase; - pEv->xkbType = XkbExtensionDeviceNotify; - pEv->deviceID = dev->id; - pEv->sequenceNumber = interest->client->sequence; - pEv->time = time = GetTimeInMillis(); - initialized= 1; - } - else { - pEv->sequenceNumber = interest->client->sequence; - pEv->time = time; - pEv->ledsDefined= defined; - pEv->ledState= state; - pEv->reason= reason; - pEv->supported= XkbXI_AllFeaturesMask; - } - if ( interest->client->swapped ) { - swaps(&pEv->sequenceNumber); - swapl(&pEv->time); - swapl(&pEv->ledsDefined); - swapl(&pEv->ledState); - swaps(&pEv->reason); - swaps(&pEv->supported); - } - WriteToClient(interest->client, sizeof(xEvent), (char *)pEv); - } - interest= interest->next; + if ((!interest->client->clientGone) && + (interest->client->requestVector != InitialVector) && + (interest->client->xkbClientFlags & _XkbClientInitialized) && + (interest->extDevNotifyMask & reason)) { + if (!initialized) { + pEv->type = XkbEventCode + XkbEventBase; + pEv->xkbType = XkbExtensionDeviceNotify; + pEv->deviceID = dev->id; + pEv->sequenceNumber = interest->client->sequence; + pEv->time = time = GetTimeInMillis(); + initialized = 1; + } + else { + pEv->sequenceNumber = interest->client->sequence; + pEv->time = time; + pEv->ledsDefined = defined; + pEv->ledState = state; + pEv->reason = reason; + pEv->supported = XkbXI_AllFeaturesMask; + } + if (interest->client->swapped) { + swaps(&pEv->sequenceNumber); + swapl(&pEv->time); + swapl(&pEv->ledsDefined); + swapl(&pEv->ledState); + swaps(&pEv->reason); + swaps(&pEv->supported); + } + WriteToClient(interest->client, sizeof(xEvent), (char *) pEv); + } + interest = interest->next; } return; } void -XkbSendNotification( DeviceIntPtr kbd, - XkbChangesPtr pChanges, - XkbEventCausePtr cause) +XkbSendNotification(DeviceIntPtr kbd, + XkbChangesPtr pChanges, XkbEventCausePtr cause) { -XkbSrvLedInfoPtr sli; + XkbSrvLedInfoPtr sli; - sli= NULL; + sli = NULL; if (pChanges->state_changes) { - xkbStateNotify sn; - sn.changed= pChanges->state_changes; - sn.keycode= cause->kc; - sn.eventType= cause->event; - sn.requestMajor= cause->mjr; - sn.requestMinor= cause->mnr; - XkbSendStateNotify(kbd,&sn); + xkbStateNotify sn; + + sn.changed = pChanges->state_changes; + sn.keycode = cause->kc; + sn.eventType = cause->event; + sn.requestMajor = cause->mjr; + sn.requestMinor = cause->mnr; + XkbSendStateNotify(kbd, &sn); } if (pChanges->map.changed) { - xkbMapNotify mn; - memset(&mn, 0, sizeof(xkbMapNotify)); - mn.changed= pChanges->map.changed; - mn.firstType= pChanges->map.first_type; - mn.nTypes= pChanges->map.num_types; - mn.firstKeySym= pChanges->map.first_key_sym; - mn.nKeySyms= pChanges->map.num_key_syms; - mn.firstKeyAct= pChanges->map.first_key_act; - mn.nKeyActs= pChanges->map.num_key_acts; - mn.firstKeyBehavior= pChanges->map.first_key_behavior; - mn.nKeyBehaviors= pChanges->map.num_key_behaviors; - mn.virtualMods= pChanges->map.vmods; - mn.firstKeyExplicit= pChanges->map.first_key_explicit; - mn.nKeyExplicit= pChanges->map.num_key_explicit; - mn.firstModMapKey= pChanges->map.first_modmap_key; - mn.nModMapKeys= pChanges->map.num_modmap_keys; - mn.firstVModMapKey= pChanges->map.first_vmodmap_key; - mn.nVModMapKeys= pChanges->map.num_vmodmap_keys; - XkbSendMapNotify(kbd,&mn); + xkbMapNotify mn; + + memset(&mn, 0, sizeof(xkbMapNotify)); + mn.changed = pChanges->map.changed; + mn.firstType = pChanges->map.first_type; + mn.nTypes = pChanges->map.num_types; + mn.firstKeySym = pChanges->map.first_key_sym; + mn.nKeySyms = pChanges->map.num_key_syms; + mn.firstKeyAct = pChanges->map.first_key_act; + mn.nKeyActs = pChanges->map.num_key_acts; + mn.firstKeyBehavior = pChanges->map.first_key_behavior; + mn.nKeyBehaviors = pChanges->map.num_key_behaviors; + mn.virtualMods = pChanges->map.vmods; + mn.firstKeyExplicit = pChanges->map.first_key_explicit; + mn.nKeyExplicit = pChanges->map.num_key_explicit; + mn.firstModMapKey = pChanges->map.first_modmap_key; + mn.nModMapKeys = pChanges->map.num_modmap_keys; + mn.firstVModMapKey = pChanges->map.first_vmodmap_key; + mn.nVModMapKeys = pChanges->map.num_vmodmap_keys; + XkbSendMapNotify(kbd, &mn); } - if ((pChanges->ctrls.changed_ctrls)|| - (pChanges->ctrls.enabled_ctrls_changes)) { - xkbControlsNotify cn; - memset(&cn, 0, sizeof(xkbControlsNotify)); - cn.changedControls= pChanges->ctrls.changed_ctrls; - cn.enabledControlChanges= pChanges->ctrls.enabled_ctrls_changes; - cn.keycode= cause->kc; - cn.eventType= cause->event; - cn.requestMajor= cause->mjr; - cn.requestMinor= cause->mnr; - XkbSendControlsNotify(kbd,&cn); + if ((pChanges->ctrls.changed_ctrls) || + (pChanges->ctrls.enabled_ctrls_changes)) { + xkbControlsNotify cn; + + memset(&cn, 0, sizeof(xkbControlsNotify)); + cn.changedControls = pChanges->ctrls.changed_ctrls; + cn.enabledControlChanges = pChanges->ctrls.enabled_ctrls_changes; + cn.keycode = cause->kc; + cn.eventType = cause->event; + cn.requestMajor = cause->mjr; + cn.requestMinor = cause->mnr; + XkbSendControlsNotify(kbd, &cn); } if (pChanges->indicators.map_changes) { - xkbIndicatorNotify in; - if (sli==NULL) - sli= XkbFindSrvLedInfo(kbd,XkbDfltXIClass,XkbDfltXIId,0); - memset(&in, 0, sizeof(xkbIndicatorNotify)); - in.state= sli->effectiveState; - in.changed= pChanges->indicators.map_changes; - XkbSendIndicatorNotify(kbd,XkbIndicatorMapNotify,&in); + xkbIndicatorNotify in; + + if (sli == NULL) + sli = XkbFindSrvLedInfo(kbd, XkbDfltXIClass, XkbDfltXIId, 0); + memset(&in, 0, sizeof(xkbIndicatorNotify)); + in.state = sli->effectiveState; + in.changed = pChanges->indicators.map_changes; + XkbSendIndicatorNotify(kbd, XkbIndicatorMapNotify, &in); } if (pChanges->indicators.state_changes) { - xkbIndicatorNotify in; - if (sli==NULL) - sli= XkbFindSrvLedInfo(kbd,XkbDfltXIClass,XkbDfltXIId,0); - memset(&in, 0, sizeof(xkbIndicatorNotify)); - in.state= sli->effectiveState; - in.changed= pChanges->indicators.state_changes; - XkbSendIndicatorNotify(kbd,XkbIndicatorStateNotify,&in); + xkbIndicatorNotify in; + + if (sli == NULL) + sli = XkbFindSrvLedInfo(kbd, XkbDfltXIClass, XkbDfltXIId, 0); + memset(&in, 0, sizeof(xkbIndicatorNotify)); + in.state = sli->effectiveState; + in.changed = pChanges->indicators.state_changes; + XkbSendIndicatorNotify(kbd, XkbIndicatorStateNotify, &in); } if (pChanges->names.changed) { - xkbNamesNotify nn; - memset(&nn, 0, sizeof(xkbNamesNotify)); - nn.changed= pChanges->names.changed; - nn.firstType= pChanges->names.first_type; - nn.nTypes= pChanges->names.num_types; - nn.firstLevelName= pChanges->names.first_lvl; - nn.nLevelNames= pChanges->names.num_lvls; - nn.nRadioGroups= pChanges->names.num_rg; - nn.changedVirtualMods= pChanges->names.changed_vmods; - nn.changedIndicators= pChanges->names.changed_indicators; - XkbSendNamesNotify(kbd,&nn); + xkbNamesNotify nn; + + memset(&nn, 0, sizeof(xkbNamesNotify)); + nn.changed = pChanges->names.changed; + nn.firstType = pChanges->names.first_type; + nn.nTypes = pChanges->names.num_types; + nn.firstLevelName = pChanges->names.first_lvl; + nn.nLevelNames = pChanges->names.num_lvls; + nn.nRadioGroups = pChanges->names.num_rg; + nn.changedVirtualMods = pChanges->names.changed_vmods; + nn.changedIndicators = pChanges->names.changed_indicators; + XkbSendNamesNotify(kbd, &nn); } - if ((pChanges->compat.changed_groups)||(pChanges->compat.num_si>0)) { - xkbCompatMapNotify cmn; - memset(&cmn, 0, sizeof(xkbCompatMapNotify)); - cmn.changedGroups= pChanges->compat.changed_groups; - cmn.firstSI= pChanges->compat.first_si; - cmn.nSI= pChanges->compat.num_si; - cmn.nTotalSI= kbd->key->xkbInfo->desc->compat->num_si; - XkbSendCompatMapNotify(kbd,&cmn); + if ((pChanges->compat.changed_groups) || (pChanges->compat.num_si > 0)) { + xkbCompatMapNotify cmn; + + memset(&cmn, 0, sizeof(xkbCompatMapNotify)); + cmn.changedGroups = pChanges->compat.changed_groups; + cmn.firstSI = pChanges->compat.first_si; + cmn.nSI = pChanges->compat.num_si; + cmn.nTotalSI = kbd->key->xkbInfo->desc->compat->num_si; + XkbSendCompatMapNotify(kbd, &cmn); } return; } @@ -891,7 +895,7 @@ XkbSrvLedInfoPtr sli; /***====================================================================***/ void -XkbFilterEvents(ClientPtr client,int nEvents,xEvent *xE) +XkbFilterEvents(ClientPtr client, int nEvents, xEvent *xE) { DeviceIntPtr dev = NULL; XkbSrvInfoPtr xkbi; @@ -909,76 +913,78 @@ XkbFilterEvents(ClientPtr client,int nEvents,xEvent *xE) xkbi = dev->key->xkbInfo; if (client->xkbClientFlags & _XkbClientInitialized) { - if ((xkbDebugFlags&0x10)&& + if ((xkbDebugFlags & 0x10) && (type == KeyPress || type == KeyRelease || type == DeviceKeyPress || type == DeviceKeyRelease)) - DebugF("[xkb] XkbFilterWriteEvents (XKB client): state 0x%04x\n", + DebugF("[xkb] XkbFilterWriteEvents (XKB client): state 0x%04x\n", xE[0].u.keyButtonPointer.state); - if (dev->deviceGrab.grab != NullGrab && dev->deviceGrab.fromPassiveGrab && - (type == KeyPress || type == KeyRelease || - type == DeviceKeyPress || type == DeviceKeyRelease)) { - unsigned int state, flags; - - flags = client->xkbClientFlags; - state = xkbi->state.compat_grab_mods; - if (flags & XkbPCF_GrabsUseXKBStateMask) { - int group; - if (flags & XkbPCF_LookupStateWhenGrabbed) { - group = xkbi->state.group; - state = xkbi->state.lookup_mods; - } - else { - state = xkbi->state.grab_mods; - group = xkbi->state.base_group + xkbi->state.latched_group; - if (group < 0 || group >= xkbi->desc->ctrls->num_groups) - group = XkbAdjustGroup(group, xkbi->desc->ctrls); - } - state = XkbBuildCoreState(state, group); - } - else if (flags & XkbPCF_LookupStateWhenGrabbed) { - state = xkbi->state.compat_lookup_mods; + if (dev->deviceGrab.grab != NullGrab && dev->deviceGrab.fromPassiveGrab + && (type == KeyPress || type == KeyRelease || type == DeviceKeyPress + || type == DeviceKeyRelease)) { + unsigned int state, flags; + + flags = client->xkbClientFlags; + state = xkbi->state.compat_grab_mods; + if (flags & XkbPCF_GrabsUseXKBStateMask) { + int group; + + if (flags & XkbPCF_LookupStateWhenGrabbed) { + group = xkbi->state.group; + state = xkbi->state.lookup_mods; + } + else { + state = xkbi->state.grab_mods; + group = xkbi->state.base_group + xkbi->state.latched_group; + if (group < 0 || group >= xkbi->desc->ctrls->num_groups) + group = XkbAdjustGroup(group, xkbi->desc->ctrls); + } + state = XkbBuildCoreState(state, group); + } + else if (flags & XkbPCF_LookupStateWhenGrabbed) { + state = xkbi->state.compat_lookup_mods; } - xE[0].u.keyButtonPointer.state = state; - } + xE[0].u.keyButtonPointer.state = state; + } } else { if ((xkbDebugFlags & 0x4) && - (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)) { - DebugF("[xkb] XKbFilterWriteEvents (non-XKB):\n"); - DebugF("[xkb] event= 0x%04x\n",xE[0].u.keyButtonPointer.state); - DebugF("[xkb] lookup= 0x%02x, grab= 0x%02x\n", + DebugF("[xkb] XKbFilterWriteEvents (non-XKB):\n"); + DebugF("[xkb] event= 0x%04x\n", xE[0].u.keyButtonPointer.state); + DebugF("[xkb] lookup= 0x%02x, grab= 0x%02x\n", xkbi->state.lookup_mods, xkbi->state.grab_mods); - DebugF("[xkb] compat lookup= 0x%02x, grab= 0x%02x\n", - xkbi->state.compat_lookup_mods, xkbi->state.compat_grab_mods); - } - if (type >= KeyPress && type <= MotionNotify) { - CARD16 old, new; - - old = xE[0].u.keyButtonPointer.state & ~0x1f00; - new = xE[0].u.keyButtonPointer.state & 0x1F00; - - if (old == XkbStateFieldFromRec(&xkbi->state)) - new |= xkbi->state.compat_lookup_mods; - else + DebugF("[xkb] compat lookup= 0x%02x, grab= 0x%02x\n", + xkbi->state.compat_lookup_mods, + xkbi->state.compat_grab_mods); + } + if (type >= KeyPress && type <= MotionNotify) { + CARD16 old, new; + + old = xE[0].u.keyButtonPointer.state & ~0x1f00; + new = xE[0].u.keyButtonPointer.state & 0x1F00; + + if (old == XkbStateFieldFromRec(&xkbi->state)) + new |= xkbi->state.compat_lookup_mods; + else new |= xkbi->state.compat_grab_mods; - xE[0].u.keyButtonPointer.state = new; - } - else if (type == EnterNotify || type == LeaveNotify) { - xE[0].u.enterLeave.state &= 0x1F00; - xE[0].u.enterLeave.state |= xkbi->state.compat_grab_mods; - } + xE[0].u.keyButtonPointer.state = new; + } + else if (type == EnterNotify || type == LeaveNotify) { + xE[0].u.enterLeave.state &= 0x1F00; + xE[0].u.enterLeave.state |= xkbi->state.compat_grab_mods; + } else if (type >= DeviceKeyPress && type <= DeviceMotionNotify) { CARD16 old, new; - deviceKeyButtonPointer *kbp = (deviceKeyButtonPointer*) &xE[0]; + deviceKeyButtonPointer *kbp = (deviceKeyButtonPointer *) &xE[0]; old = kbp->state & ~0x1F00; new = kbp->state & 0x1F00; - if (old == XkbStateFieldFromRec(&xkbi->state)) - new |= xkbi->state.compat_lookup_mods; - else + if (old == XkbStateFieldFromRec(&xkbi->state)) + new |= xkbi->state.compat_lookup_mods; + else new |= xkbi->state.compat_grab_mods; kbp->state = new; } @@ -988,92 +994,93 @@ XkbFilterEvents(ClientPtr client,int nEvents,xEvent *xE) /***====================================================================***/ XkbInterestPtr -XkbFindClientResource(DevicePtr inDev,ClientPtr client) +XkbFindClientResource(DevicePtr inDev, ClientPtr client) { -DeviceIntPtr dev = (DeviceIntPtr)inDev; -XkbInterestPtr interest; - - if ( dev->xkb_interest ) { - interest = dev->xkb_interest; - while (interest){ - if (interest->client==client) { - return interest; - } - interest = interest->next; - } + DeviceIntPtr dev = (DeviceIntPtr) inDev; + XkbInterestPtr interest; + + if (dev->xkb_interest) { + interest = dev->xkb_interest; + while (interest) { + if (interest->client == client) { + return interest; + } + interest = interest->next; + } } return NULL; } XkbInterestPtr -XkbAddClientResource(DevicePtr inDev,ClientPtr client,XID id) +XkbAddClientResource(DevicePtr inDev, ClientPtr client, XID id) { -DeviceIntPtr dev = (DeviceIntPtr)inDev; -XkbInterestPtr interest; + DeviceIntPtr dev = (DeviceIntPtr) inDev; + XkbInterestPtr interest; interest = dev->xkb_interest; while (interest) { - if (interest->client==client) - return ((interest->resource==id)?interest:NULL); - interest = interest->next; + if (interest->client == client) + return ((interest->resource == id) ? interest : NULL); + interest = interest->next; } interest = calloc(1, sizeof(XkbInterestRec)); if (interest) { - interest->dev = dev; - interest->client = client; - interest->resource = id; - interest->next = dev->xkb_interest; - dev->xkb_interest= interest; - return interest; + interest->dev = dev; + interest->client = client; + interest->resource = id; + interest->next = dev->xkb_interest; + dev->xkb_interest = interest; + return interest; } return NULL; } int -XkbRemoveResourceClient(DevicePtr inDev,XID id) +XkbRemoveResourceClient(DevicePtr inDev, XID id) { -XkbSrvInfoPtr xkbi; -DeviceIntPtr dev = (DeviceIntPtr)inDev; -XkbInterestPtr interest; -Bool found; -unsigned long autoCtrls,autoValues; -ClientPtr client = NULL; + XkbSrvInfoPtr xkbi; + DeviceIntPtr dev = (DeviceIntPtr) inDev; + XkbInterestPtr interest; + Bool found; + unsigned long autoCtrls, autoValues; + ClientPtr client = NULL; - found= FALSE; + found = FALSE; if (!dev->key || !dev->key->xkbInfo) return found; - autoCtrls= autoValues= 0; - if ( dev->xkb_interest ) { - interest = dev->xkb_interest; - if (interest && (interest->resource==id)){ - dev->xkb_interest = interest->next; - autoCtrls= interest->autoCtrls; - autoValues= interest->autoCtrlValues; - client= interest->client; - free(interest); - found= TRUE; - } - while ((!found)&&(interest->next)) { - if (interest->next->resource==id) { - XkbInterestPtr victim = interest->next; - interest->next = victim->next; - autoCtrls= victim->autoCtrls; - autoValues= victim->autoCtrlValues; - client= victim->client; - free(victim); - found= TRUE; - } - interest = interest->next; - } + autoCtrls = autoValues = 0; + if (dev->xkb_interest) { + interest = dev->xkb_interest; + if (interest && (interest->resource == id)) { + dev->xkb_interest = interest->next; + autoCtrls = interest->autoCtrls; + autoValues = interest->autoCtrlValues; + client = interest->client; + free(interest); + found = TRUE; + } + while ((!found) && (interest->next)) { + if (interest->next->resource == id) { + XkbInterestPtr victim = interest->next; + + interest->next = victim->next; + autoCtrls = victim->autoCtrls; + autoValues = victim->autoCtrlValues; + client = victim->client; + free(victim); + found = TRUE; + } + interest = interest->next; + } } - if (found && autoCtrls && dev->key && dev->key->xkbInfo ) { - XkbEventCauseRec cause; + if (found && autoCtrls && dev->key && dev->key->xkbInfo) { + XkbEventCauseRec cause; - xkbi= dev->key->xkbInfo; - XkbSetCauseXkbReq(&cause,X_kbPerClientFlags,client); - XkbEnableDisableControls(xkbi,autoCtrls,autoValues,NULL,&cause); + xkbi = dev->key->xkbInfo; + XkbSetCauseXkbReq(&cause, X_kbPerClientFlags, client); + XkbEnableDisableControls(xkbi, autoCtrls, autoValues, NULL, &cause); } return found; } |