aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/xkb/xkbEvents.c
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/xkb/xkbEvents.c')
-rw-r--r--xorg-server/xkb/xkbEvents.c505
1 files changed, 280 insertions, 225 deletions
diff --git a/xorg-server/xkb/xkbEvents.c b/xorg-server/xkb/xkbEvents.c
index 4d3debba7..8fb49c1d8 100644
--- a/xorg-server/xkb/xkbEvents.c
+++ b/xorg-server/xkb/xkbEvents.c
@@ -29,13 +29,14 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
#endif
#include <stdio.h>
-#define NEED_EVENTS 1
#include <X11/X.h>
#include <X11/Xproto.h>
#include <X11/keysym.h>
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "inputstr.h"
+#include "exevents.h"
+#include "exglobals.h"
#include "windowstr.h"
#include "exevents.h"
#include <xkbsrv.h>
@@ -43,58 +44,151 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
/***====================================================================***/
+/*
+ * This function sends out two kinds of notification:
+ * - Core mapping notify events sent to clients for whom kbd is the
+ * current core ('picked') keyboard _and_ have not explicitly
+ * selected for XKB mapping notify events;
+ * - Xi mapping events, sent unconditionally to all clients who have
+ * explicitly selected for them (including those who have explicitly
+ * selected for XKB mapping notify events!).
+ */
+static void
+XkbSendLegacyMapNotify(DeviceIntPtr kbd, CARD16 xkb_event, CARD16 changed,
+ int first_key, int num_keys)
+{
+ int i;
+ int keymap_changed = 0;
+ int modmap_changed = 0;
+ xEvent core_mn;
+ deviceMappingNotify xi_mn;
+ CARD32 time = GetTimeInMillis();
+
+ if (xkb_event == XkbNewKeyboardNotify) {
+ if (changed & XkbNKN_KeycodesMask) {
+ keymap_changed = 1;
+ modmap_changed = 1;
+ }
+ }
+ else if (xkb_event == XkbMapNotify) {
+ if (changed & XkbKeySymsMask)
+ keymap_changed = 1;
+ if (changed & XkbModifierMapMask)
+ modmap_changed = 1;
+ }
+ if (!keymap_changed && !modmap_changed)
+ return;
+
+ core_mn.u.u.type = MappingNotify;
+ xi_mn.type = DeviceMappingNotify;
+ xi_mn.deviceid = kbd->id;
+ xi_mn.time = time;
+
+ /* 0 is serverClient. */
+ for (i = 1; i < currentMaxClients; i++) {
+ if (!clients[i] || clients[i]->clientState != ClientStateRunning)
+ continue;
+
+ /* Ignore clients which will have already received this.
+ * Inconsistent with themselves, but consistent with previous
+ * behaviour.*/
+ if (xkb_event == XkbMapNotify && (clients[i]->mapNotifyMask & changed))
+ continue;
+ if (xkb_event == XkbNewKeyboardNotify &&
+ (clients[i]->xkbClientFlags & _XkbClientInitialized))
+ continue;
+
+ /* Don't send core events to clients who don't know about us. */
+ if (!XIShouldNotify(clients[i], kbd))
+ continue;
+
+ core_mn.u.u.sequenceNumber = clients[i]->sequence;
+ if (keymap_changed) {
+ core_mn.u.mappingNotify.request = MappingKeyboard;
+
+ /* Clip the keycode range to what the client knows about, so it
+ * doesn't freak out. */
+ if (first_key >= clients[i]->minKC)
+ core_mn.u.mappingNotify.firstKeyCode = first_key;
+ else
+ core_mn.u.mappingNotify.firstKeyCode = clients[i]->minKC;
+ if (first_key + num_keys - 1 <= clients[i]->maxKC)
+ core_mn.u.mappingNotify.count = num_keys;
+ else
+ core_mn.u.mappingNotify.count = clients[i]->maxKC -
+ clients[i]->minKC + 1;
+
+ WriteEventsToClient(clients[i], 1, &core_mn);
+ }
+ if (modmap_changed) {
+ core_mn.u.mappingNotify.request = MappingModifier;
+ core_mn.u.mappingNotify.firstKeyCode = 0;
+ core_mn.u.mappingNotify.count = 0;
+ WriteEventsToClient(clients[i], 1, &core_mn);
+ }
+ }
+
+ /* Hmm, maybe we can accidentally generate Xi events for core devices
+ * here? Clients might be upset, but that seems better than the
+ * alternative of stale keymaps. -ds */
+ if (keymap_changed) {
+ xi_mn.request = MappingKeyboard;
+ xi_mn.firstKeyCode = first_key;
+ xi_mn.count = num_keys;
+ SendEventToAllWindows(kbd, DeviceMappingNotifyMask, (xEvent *) &xi_mn,
+ 1);
+ }
+ if (modmap_changed) {
+ xi_mn.request = MappingModifier;
+ xi_mn.firstKeyCode = 0;
+ xi_mn.count = 0;
+ SendEventToAllWindows(kbd, DeviceMappingNotifyMask, (xEvent *) &xi_mn,
+ 1);
+ }
+}
+
+/***====================================================================***/
+
void
XkbSendNewKeyboardNotify(DeviceIntPtr kbd,xkbNewKeyboardNotify *pNKN)
-{
-register int i;
-Time time;
-CARD16 changed;
+{
+ int i;
+ Time time = GetTimeInMillis();
+ CARD16 changed = pNKN->changed;
pNKN->type = XkbEventCode + XkbEventBase;
pNKN->xkbType = XkbNewKeyboardNotify;
- pNKN->time = time = GetTimeInMillis();
- changed = pNKN->changed;
for (i=1; i<currentMaxClients; i++) {
- if ((!clients[i]) || clients[i]->clientGone ||
- (clients[i]->requestVector==InitialVector)) {
- continue;
- }
+ if (!clients[i] || clients[i]->clientState != ClientStateRunning)
+ continue;
+
+ if (!(clients[i]->newKeyboardNotifyMask & changed))
+ continue;
+
+ if (!XIShouldNotify(clients[i], kbd))
+ continue;
+
+ pNKN->sequenceNumber = clients[i]->sequence;
+ pNKN->time = time;
+ pNKN->changed = changed;
+ if (clients[i]->swapped) {
+ int n;
+ swaps(&pNKN->sequenceNumber,n);
+ swapl(&pNKN->time,n);
+ swaps(&pNKN->changed,n);
+ }
+ WriteToClient(clients[i], sizeof(xEvent), pNKN);
- if (clients[i]->xkbClientFlags&_XkbClientInitialized) {
- if (clients[i]->newKeyboardNotifyMask&changed) {
- pNKN->sequenceNumber = clients[i]->sequence;
- pNKN->time = time;
- pNKN->changed = changed;
- if ( clients[i]->swapped ) {
- register int n;
- swaps(&pNKN->sequenceNumber,n);
- swapl(&pNKN->time,n);
- swaps(&pNKN->changed,n);
- }
- WriteToClient(clients[i],sizeof(xEvent),(char *)pNKN);
- if (changed&XkbNKN_KeycodesMask) {
- clients[i]->minKC= pNKN->minKeyCode;
- clients[i]->maxKC= pNKN->maxKeyCode;
- }
- }
- }
- else if (changed&XkbNKN_KeycodesMask) {
- xEvent event;
- event.u.u.type= MappingNotify;
- event.u.mappingNotify.request= MappingKeyboard;
- event.u.mappingNotify.firstKeyCode= clients[i]->minKC;
- event.u.mappingNotify.count= clients[i]->maxKC-clients[i]->minKC+1;
- event.u.u.sequenceNumber= clients[i]->sequence;
- if (clients[i]->swapped) {
- int n;
- swaps(&event.u.u.sequenceNumber,n);
- }
- WriteToClient(clients[i],SIZEOF(xEvent), (char *)&event);
- event.u.mappingNotify.request= MappingModifier;
- WriteToClient(clients[i],SIZEOF(xEvent), (char *)&event);
- }
+ if (changed & XkbNKN_KeycodesMask) {
+ clients[i]->minKC = pNKN->minKeyCode;
+ clients[i]->maxKC = pNKN->maxKeyCode;
+ }
}
+
+ XkbSendLegacyMapNotify(kbd, XkbNewKeyboardNotify, changed, pNKN->minKeyCode,
+ pNKN->maxKeyCode - pNKN->minKeyCode + 1);
+
return;
}
@@ -140,7 +234,8 @@ register CARD16 changed,bState;
if ((!interest->client->clientGone) &&
(interest->client->requestVector != InitialVector) &&
(interest->client->xkbClientFlags&_XkbClientInitialized) &&
- (interest->stateNotifyMask&changed)) {
+ (interest->stateNotifyMask&changed) &&
+ XIShouldNotify(interest->client,kbd)) {
pSN->sequenceNumber = interest->client->sequence;
pSN->time = time;
pSN->changed = changed;
@@ -161,49 +256,50 @@ register CARD16 changed,bState;
/***====================================================================***/
+/*
+ * This function sends out XKB mapping notify events to clients which
+ * 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;
-XkbSrvInfoPtr xkbi;
-unsigned time = 0,initialized;
-CARD16 changed;
-
- if (!kbd->key || !kbd->key->xkbInfo)
- return;
-
- xkbi = kbd->key->xkbInfo;
- initialized= 0;
-
- changed = pMN->changed;
- pMN->minKeyCode= xkbi->desc->min_key_code;
- pMN->maxKeyCode= xkbi->desc->max_key_code;
- for (i=1; i<currentMaxClients; i++) {
- if (clients[i] && ! clients[i]->clientGone &&
- (clients[i]->requestVector != InitialVector) &&
- (clients[i]->xkbClientFlags&_XkbClientInitialized) &&
- (clients[i]->mapNotifyMask&changed))
- {
- if (!initialized) {
- pMN->type = XkbEventCode + XkbEventBase;
- pMN->xkbType = XkbMapNotify;
- pMN->deviceID = kbd->id;
- time = GetTimeInMillis();
- initialized= 1;
- }
- pMN->time= time;
- pMN->sequenceNumber = clients[i]->sequence;
- pMN->changed = changed;
- if ( clients[i]->swapped ) {
- register int n;
- swaps(&pMN->sequenceNumber,n);
- swapl(&pMN->time,n);
- swaps(&pMN->changed,n);
- }
- WriteToClient(clients[i],sizeof(xEvent),(char *)pMN);
- }
+ int i;
+ CARD32 time = GetTimeInMillis();
+ CARD16 changed = pMN->changed;
+ XkbSrvInfoPtr xkbi = kbd->key->xkbInfo;
+
+ pMN->minKeyCode = xkbi->desc->min_key_code;
+ pMN->maxKeyCode = xkbi->desc->max_key_code;
+ pMN->type = XkbEventCode + XkbEventBase;
+ pMN->xkbType = XkbMapNotify;
+ pMN->deviceID = kbd->id;
+
+ /* 0 is serverClient. */
+ for (i = 1; i < currentMaxClients; i++) {
+ if (!clients[i] || clients[i]->clientState != ClientStateRunning)
+ continue;
+
+ if (!(clients[i]->mapNotifyMask & changed))
+ continue;
+
+ if (!XIShouldNotify(clients[i], kbd))
+ continue;
+
+ pMN->time = time;
+ pMN->sequenceNumber = clients[i]->sequence;
+ pMN->changed = changed;
+
+ if (clients[i]->swapped) {
+ int n;
+ swaps(&pMN->sequenceNumber, n);
+ swapl(&pMN->time, n);
+ swaps(&pMN->changed, n);
+ }
+ WriteToClient(clients[i], sizeof(xEvent), pMN);
}
- return;
+
+ XkbSendLegacyMapNotify(kbd, XkbMapNotify, changed, pMN->firstKeySym,
+ pMN->nKeySyms);
}
int
@@ -307,7 +403,8 @@ Time time = 0;
if ((!interest->client->clientGone) &&
(interest->client->requestVector != InitialVector) &&
(interest->client->xkbClientFlags&_XkbClientInitialized) &&
- (interest->ctrlsNotifyMask&changedControls)) {
+ (interest->ctrlsNotifyMask&changedControls) &&
+ XIShouldNotify(interest->client, kbd)) {
if (!initialized) {
pCN->type = XkbEventCode + XkbEventBase;
pCN->xkbType = XkbControlsNotify;
@@ -355,6 +452,7 @@ CARD32 state,changed;
if ((!interest->client->clientGone) &&
(interest->client->requestVector != InitialVector) &&
(interest->client->xkbClientFlags&_XkbClientInitialized) &&
+ XIShouldNotify(interest->client, kbd) &&
(((xkbType==XkbIndicatorStateNotify)&&
(interest->iStateNotifyMask&changed))||
((xkbType==XkbIndicatorMapNotify)&&
@@ -438,7 +536,8 @@ XID winID = 0;
if ((!interest->client->clientGone) &&
(interest->client->requestVector != InitialVector) &&
(interest->client->xkbClientFlags&_XkbClientInitialized) &&
- (interest->bellNotifyMask)) {
+ (interest->bellNotifyMask) &&
+ XIShouldNotify(interest->client,kbd)) {
if (!initialized) {
time = GetTimeInMillis();
bn.type = XkbEventCode + XkbEventBase;
@@ -492,7 +591,8 @@ CARD16 sk_delay,db_delay;
if ((!interest->client->clientGone) &&
(interest->client->requestVector != InitialVector) &&
(interest->client->xkbClientFlags&_XkbClientInitialized) &&
- (interest->accessXNotifyMask&(1<<pEv->detail))) {
+ (interest->accessXNotifyMask&(1<<pEv->detail)) &&
+ XIShouldNotify(interest->client, kbd)) {
if (!initialized) {
pEv->type = XkbEventCode + XkbEventBase;
pEv->xkbType = XkbAccessXNotify;
@@ -539,7 +639,8 @@ CARD32 changedIndicators;
if ((!interest->client->clientGone) &&
(interest->client->requestVector != InitialVector) &&
(interest->client->xkbClientFlags&_XkbClientInitialized) &&
- (interest->namesNotifyMask&pEv->changed)) {
+ (interest->namesNotifyMask&pEv->changed) &&
+ XIShouldNotify(interest->client, kbd)) {
if (!initialized) {
pEv->type = XkbEventCode + XkbEventBase;
pEv->xkbType = XkbNamesNotify;
@@ -584,7 +685,8 @@ CARD16 firstSI = 0, nSI = 0, nTotalSI = 0;
if ((!interest->client->clientGone) &&
(interest->client->requestVector != InitialVector) &&
(interest->client->xkbClientFlags&_XkbClientInitialized) &&
- (interest->compatNotifyMask)) {
+ (interest->compatNotifyMask) &&
+ XIShouldNotify(interest->client, kbd)) {
if (!initialized) {
pEv->type = XkbEventCode + XkbEventBase;
pEv->xkbType = XkbCompatMapNotify;
@@ -636,7 +738,8 @@ Time time = 0;
if ((!interest->client->clientGone) &&
(interest->client->requestVector != InitialVector) &&
(interest->client->xkbClientFlags&_XkbClientInitialized) &&
- (interest->actionMessageMask)) {
+ (interest->actionMessageMask) &&
+ XIShouldNotify(interest->client, kbd)) {
if (!initialized) {
pEv->type = XkbEventCode + XkbEventBase;
pEv->xkbType = XkbActionMessage;
@@ -668,7 +771,7 @@ int initialized;
XkbInterestPtr interest;
Time time = 0;
CARD32 defined, state;
-CARD16 reason, supported = 0;
+CARD16 reason;
interest = dev->xkb_interest;
if (!interest)
@@ -682,14 +785,14 @@ CARD16 reason, supported = 0;
if ((!interest->client->clientGone) &&
(interest->client->requestVector != InitialVector) &&
(interest->client->xkbClientFlags&_XkbClientInitialized) &&
- (interest->extDevNotifyMask&reason)) {
+ (interest->extDevNotifyMask&reason) &&
+ XIShouldNotify(interest->client, dev)) {
if (!initialized) {
pEv->type = XkbEventCode + XkbEventBase;
pEv->xkbType = XkbExtensionDeviceNotify;
pEv->deviceID = dev->id;
pEv->sequenceNumber = interest->client->sequence;
pEv->time = time = GetTimeInMillis();
- supported= pEv->supported;
initialized= 1;
}
else {
@@ -698,14 +801,7 @@ CARD16 reason, supported = 0;
pEv->ledsDefined= defined;
pEv->ledState= state;
pEv->reason= reason;
- pEv->supported= supported;
- }
- if (client!=interest->client) {
- /* only report UnsupportedFeature to the client that */
- /* issued the failing request */
- pEv->reason&= ~XkbXI_UnsupportedFeatureMask;
- if ((interest->extDevNotifyMask&reason)==0)
- continue;
+ pEv->supported= XkbXI_AllFeaturesMask;
}
if ( interest->client->swapped ) {
register int n;
@@ -742,6 +838,7 @@ XkbSrvLedInfoPtr sli;
}
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;
@@ -763,6 +860,7 @@ XkbSrvLedInfoPtr sli;
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;
@@ -775,6 +873,7 @@ XkbSrvLedInfoPtr sli;
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);
@@ -783,12 +882,14 @@ XkbSrvLedInfoPtr sli;
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;
@@ -801,6 +902,7 @@ XkbSrvLedInfoPtr sli;
}
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;
@@ -812,151 +914,104 @@ XkbSrvLedInfoPtr sli;
/***====================================================================***/
-Bool
-XkbFilterEvents(ClientPtr pClient,int nEvents,xEvent *xE)
+void
+XkbFilterEvents(ClientPtr client,int nEvents,xEvent *xE)
{
-int i, button_mask;
-DeviceIntPtr pXDev = inputInfo.keyboard;
-XkbSrvInfoPtr xkbi;
+ DeviceIntPtr dev = NULL;
+ XkbSrvInfoPtr xkbi;
+ CARD8 type = xE[0].u.u.type;
if (xE->u.u.type & EXTENSION_EVENT_BASE)
- {
- pXDev = XIGetDevice(xE);
- if (!pXDev)
- pXDev = inputInfo.keyboard;
- }
+ dev = XIGetDevice(xE);
- xkbi= (pXDev->key) ? pXDev->key->xkbInfo : NULL;
+ if (!dev)
+ dev = PickKeyboard(client);
- if ( pClient->xkbClientFlags & _XkbClientInitialized ) {
- if ((xkbDebugFlags&0x10)&&
- ((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:\n");
- DebugF("[xkb] Event state= 0x%04x\n",xE[0].u.keyButtonPointer.state);
- DebugF("[xkb] XkbLastRepeatEvent!=xE (0x%p!=0x%p) %s\n",
- XkbLastRepeatEvent,xE,
- ((XkbLastRepeatEvent!=(pointer)xE)?"True":"False"));
- DebugF("[xkb] (xkbClientEventsFlags&XWDA)==0 (0x%x) %s\n",
- pClient->xkbClientFlags,
- (_XkbWantsDetectableAutoRepeat(pClient)?"True":"False"));
- DebugF("[xkb] !IsRelease(%d) %s\n",xE[0].u.u.type,
- (!_XkbIsReleaseEvent(xE[0].u.u.type))?"True":"False");
- }
- if ( (XkbLastRepeatEvent==(pointer)xE) &&
- (_XkbWantsDetectableAutoRepeat(pClient)) &&
- (_XkbIsReleaseEvent(xE[0].u.u.type)) ) {
- return False;
- }
-
- if (!xkbi)
- return True;
+ if (!dev->key)
+ return;
- if ((pXDev->deviceGrab.grab != NullGrab)
- && pXDev->deviceGrab.fromPassiveGrab &&
- ((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;
+ xkbi = dev->key->xkbInfo;
- flags= pClient->xkbClientFlags;
- state= xkbi->state.compat_grab_mods;
+ if (client->xkbClientFlags & _XkbClientInitialized) {
+ if ((xkbDebugFlags&0x10)&&
+ (type == KeyPress || type == KeyRelease ||
+ type == DeviceKeyPress || type == DeviceKeyRelease))
+ 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;
+ 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 = 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;
+ else if (flags & XkbPCF_LookupStateWhenGrabbed) {
+ state = xkbi->state.compat_lookup_mods;
+ }
+ xE[0].u.keyButtonPointer.state = state;
}
- button_mask = 1 << xE[0].u.u.detail;
- if (xE[0].u.u.type == ButtonPress &&
- ((xE[0].u.keyButtonPointer.state >> 7) & button_mask) == button_mask &&
- (xkbi->lockedPtrButtons & button_mask) == button_mask) {
- /* If the MouseKeys is pressed, and the "real" mouse is also pressed
- * when the mouse is released, the server does not behave properly.
- * Faking a release of the button here solves the problem.
- */
- DebugF("[xkb] Faking release of button %d\n", xE[0].u.u.detail);
- XkbDDXFakeDeviceButton(xkbi->device, 0, xE[0].u.u.detail);
- }
}
else {
- register CARD8 type;
-
- if (!xkbi)
- return True;
-
- for (i=0;i<nEvents;i++) {
- type= xE[i].u.u.type;
- if ((xkbDebugFlags&0x4)&&
- ((xE[i].u.u.type==KeyPress)||(xE[i].u.u.type==KeyRelease)||
- (xE[i].u.u.type==DeviceKeyPress)||
- (xE[i].u.u.type == DeviceKeyRelease))) {
- DebugF("[xkb] XKbFilterWriteEvents (non-XKB):\n");
- DebugF("[xkb] event= 0x%04x\n",xE[i].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;
+ if ((xkbDebugFlags & 0x4) &&
+ (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",
+ 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[i].u.keyButtonPointer.state&(~0x1f00);
- new= xE[i].u.keyButtonPointer.state&0x1F00;
+ 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[i].u.keyButtonPointer.state= new;
- }
- else if ((type==EnterNotify)||(type==LeaveNotify)) {
- 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 &&
- (xkbi->lockedPtrButtons & button_mask) == button_mask) {
- DebugF("[xkb] Faking release of button %d\n", xE[i].u.u.detail);
- XkbDDXFakeDeviceButton(xkbi->device, 0, xE[i].u.u.detail);
- } else if (type == DeviceButtonPress &&
- ((((deviceKeyButtonPointer*)&xE[i])->state >> 7) & button_mask) == button_mask &&
- (xkbi->lockedPtrButtons & button_mask) == button_mask) {
- DebugF("[xkb] Faking release of button %d\n", ((deviceKeyButtonPointer*)&xE[i])->state);
- XkbDDXFakeDeviceButton(xkbi->device, 0, ((deviceKeyButtonPointer*)&xE[i])->state);
- }
+ 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;
+ }
+ else if (type >= DeviceKeyPress && type <= DeviceMotionNotify) {
+ CARD16 old, new;
+ 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
+ new |= xkbi->state.compat_grab_mods;
+ kbp->state = new;
+ }
}
- return True;
}
/***====================================================================***/
-XkbInterestPtr
+XkbInterestPtr
XkbFindClientResource(DevicePtr inDev,ClientPtr client)
{
DeviceIntPtr dev = (DeviceIntPtr)inDev;
@@ -974,7 +1029,7 @@ XkbInterestPtr interest;
return NULL;
}
-XkbInterestPtr
+XkbInterestPtr
XkbAddClientResource(DevicePtr inDev,ClientPtr client,XID id)
{
DeviceIntPtr dev = (DeviceIntPtr)inDev;
@@ -1031,7 +1086,7 @@ ClientPtr client = NULL;
autoCtrls= interest->autoCtrls;
autoValues= interest->autoCtrlValues;
client= interest->client;
- _XkbFree(interest);
+ xfree(interest);
found= True;
}
while ((!found)&&(interest->next)) {
@@ -1041,7 +1096,7 @@ ClientPtr client = NULL;
autoCtrls= victim->autoCtrls;
autoValues= victim->autoCtrlValues;
client= victim->client;
- _XkbFree(victim);
+ xfree(victim);
found= True;
}
interest = interest->next;