summaryrefslogtreecommitdiff
path: root/xkb
diff options
context:
space:
mode:
authorDaniel Stone <daniel@fooishbar.org>2009-08-21 16:03:36 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2009-09-04 12:59:41 +1000
commitbfb219f532f3c78ba905424365ee7c5f7b5f21a2 (patch)
tree82762cc287549124d1e04788b465525dc326aa3d /xkb
parent3d988e01e41e98fc5160f825a250522ba274d09f (diff)
input: allow for detectable autorepeat.
For core and XI1 events, store the key_repeat flag in the sequence number until TryClientEvents. The sequenceNumber is unset until TryClientEvents. [Also thrown in, some random indentation changes. Thanks] Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'xkb')
-rw-r--r--xkb/xkbAccessX.c11
-rw-r--r--xkb/xkbEvents.c190
-rw-r--r--xkb/xkbPrKeyEv.c67
3 files changed, 97 insertions, 171 deletions
diff --git a/xkb/xkbAccessX.c b/xkb/xkbAccessX.c
index 7df8e06cf..47023c048 100644
--- a/xkb/xkbAccessX.c
+++ b/xkb/xkbAccessX.c
@@ -44,7 +44,6 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
int XkbDfltRepeatDelay= 660;
int XkbDfltRepeatInterval= 40;
-pointer XkbLastRepeatEvent= NULL;
#define DFLT_TIMEOUT_CTRLS (XkbAX_KRGMask|XkbStickyKeysMask|XkbMouseKeysMask)
#define DFLT_TIMEOUT_OPTS (XkbAX_IndicatorFBMask)
@@ -131,18 +130,15 @@ AccessXKeyboardEvent(DeviceIntPtr keybd,
event.detail.key = keyCode;
event.time = GetTimeInMillis();
event.length = sizeof(DeviceEvent);
+ event.key_repeat = isRepeat;
if (xkbDebugFlags&0x8) {
DebugF("[xkb] AXKE: Key %d %s\n", keyCode,
(event.type == ET_KeyPress ? "down" : "up"));
}
- if (!_XkbIsPressEvent(type) && isRepeat)
- XkbLastRepeatEvent= (pointer)&event;
XkbProcessKeyboardEvent(&event, keybd);
- XkbLastRepeatEvent= NULL;
return;
-
} /* AccessXKeyboardEvent */
/************************************************************************/
@@ -309,14 +305,11 @@ AccessXRepeatKeyExpire(OsTimerPtr timer,CARD32 now,pointer arg)
{
DeviceIntPtr dev = (DeviceIntPtr) arg;
XkbSrvInfoPtr xkbi = dev->key->xkbInfo;
-KeyCode key;
if (xkbi->repeatKey == 0)
return 0;
- key = xkbi->repeatKey;
- AccessXKeyboardEvent(dev, ET_KeyRelease, key, True);
- AccessXKeyboardEvent(dev, ET_KeyPress, key, True);
+ AccessXKeyboardEvent(dev, ET_KeyPress, xkbi->repeatKey, True);
return xkbi->desc->ctrls->repeat_interval;
}
diff --git a/xkb/xkbEvents.c b/xkb/xkbEvents.c
index e56694dbf..8fb49c1d8 100644
--- a/xkb/xkbEvents.c
+++ b/xkb/xkbEvents.c
@@ -914,145 +914,99 @@ XkbSrvLedInfoPtr sli;
/***====================================================================***/
-Bool
-XkbFilterEvents(ClientPtr pClient,int nEvents,xEvent *xE)
+void
+XkbFilterEvents(ClientPtr client,int nEvents,xEvent *xE)
{
-int i, button_mask;
-DeviceIntPtr pXDev = NULL;
-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 = PickKeyboard(pClient);
+ 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;
}
/***====================================================================***/
diff --git a/xkb/xkbPrKeyEv.c b/xkb/xkbPrKeyEv.c
index e01282d9b..8f6705f9f 100644
--- a/xkb/xkbPrKeyEv.c
+++ b/xkb/xkbPrKeyEv.c
@@ -52,59 +52,38 @@ int key;
XkbBehavior behavior;
unsigned ndx;
- xkbi= keyc->xkbInfo;
- key= event->detail.key;
- if (xkbDebugFlags&0x8) {
+ xkbi = keyc->xkbInfo;
+ key = event->detail.key;
+ if (xkbDebugFlags & 0x8)
DebugF("[xkb] XkbPKE: Key %d %s\n",key,(event->type == ET_KeyPress?"down":"up"));
- }
- if ( (xkbi->repeatKey==key) && (event->type== ET_KeyRelease) &&
- ((xkbi->desc->ctrls->enabled_ctrls&XkbRepeatKeysMask)==0) ) {
- AccessXCancelRepeatKey(xkbi,key);
- }
+ if (xkbi->repeatKey == key && event->type== ET_KeyRelease &&
+ !(xkbi->desc->ctrls->enabled_ctrls & XkbRepeatKeysMask))
+ AccessXCancelRepeatKey(xkbi, key);
- behavior= xkbi->desc->server->behaviors[key];
+ behavior = xkbi->desc->server->behaviors[key];
/* The "permanent" flag indicates a hard-wired behavior that occurs */
/* below XKB, such as a key that physically locks. XKB does not */
/* do anything to implement the behavior, but it *does* report that */
/* key is hardwired */
- if ((behavior.type&XkbKB_Permanent)==0) {
+ if (!(behavior.type & XkbKB_Permanent)) {
switch (behavior.type) {
case XkbKB_Default:
- if (event->type == ET_KeyPress &&
- (keyc->down[key>>3] & (1<<(key&7)))) {
- XkbLastRepeatEvent= (pointer)event;
-
- event->type = ET_KeyRelease;
- XkbHandleActions(keybd, keybd, event);
-
- event->type = ET_KeyPress;
- XkbHandleActions(keybd, keybd, event);
- XkbLastRepeatEvent= NULL;
- return;
- }
+ /* Neither of these should happen in practice, but ignore them
+ anyway. */
+ if (event->type == ET_KeyPress && !event->key_repeat &&
+ key_is_down(keybd, key, KEY_PROCESSED))
+ return;
else if (event->type == ET_KeyRelease &&
- (!(keyc->down[key>>3]&(1<<(key&7))))) {
- XkbLastRepeatEvent= (pointer)event;
- event->type = ET_KeyPress;
- XkbHandleActions(keybd, keybd, event);
- event->type = ET_KeyRelease;
- XkbHandleActions(keybd, keybd, event);
- XkbLastRepeatEvent= NULL;
- return;
- }
+ !key_is_down(keybd, key, KEY_PROCESSED))
+ return;
break;
case XkbKB_Lock:
- if (event->type == ET_KeyRelease) {
+ if (event->type == ET_KeyRelease)
return;
- }
- else {
- int bit= 1<<(key&7);
- if ( keyc->down[key>>3]&bit ) {
- event->type = ET_KeyRelease;
- }
- }
+ else if (key_is_down(keybd, key, KEY_PROCESSED))
+ event->type = ET_KeyRelease;
break;
case XkbKB_RadioGroup:
ndx= (behavior.data&(~XkbKB_RGAllowNone));
@@ -173,9 +152,6 @@ ProcessKeyboardEvent(InternalEvent *ev, DeviceIntPtr keybd)
int is_press = (event->type == ET_KeyPress);
int is_release = (event->type == ET_KeyRelease);
- if (keyc)
- xkbi = keyc->xkbInfo;
-
/* We're only interested in key events. */
if (!is_press && !is_release) {
UNWRAP_PROCESS_INPUT_PROC(keybd, xkb_priv, backup_proc);
@@ -185,6 +161,8 @@ ProcessKeyboardEvent(InternalEvent *ev, DeviceIntPtr keybd)
return;
}
+ xkbi = keyc->xkbInfo;
+
/* If AccessX filters are active, then pass it through to
* AccessXFilter{Press,Release}Event; else, punt to
* XkbProcessKeyboardEvent.
@@ -196,8 +174,9 @@ ProcessKeyboardEvent(InternalEvent *ev, DeviceIntPtr keybd)
AccessXFilterPressEvent(event, keybd);
else if (is_release)
AccessXFilterReleaseEvent(event, keybd);
-
- } else {
+ return;
+ }
+ else {
XkbProcessKeyboardEvent(event, keybd);
}