summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNaoki Hamada <nao@tom-yam.or.jp>2007-10-25 18:45:50 +0300
committerDaniel Stone <daniel@fooishbar.org>2007-11-17 22:06:51 +0100
commit35bf7c738a8286a382aeef38c0f035773b3ab96a (patch)
tree165addaf1f6e06758f0223a811bb87603d25ba6d
parentb3de1b9d375c98b72c88991ac2011e492254c61f (diff)
Input: Fix key down test (bug #12858)
Fix the botched previous key_is_down test, which would give false positives. Also move key_autorepeats to a separate inline function. (cherry picked from commit 242f56f722243938e908d1957781ee53c2999783)
-rw-r--r--dix/getevents.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/dix/getevents.c b/dix/getevents.c
index f92a0211a..f921a2205 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -95,7 +95,14 @@ set_key_up(DeviceIntPtr pDev, int key_code)
static Bool
key_is_down(DeviceIntPtr pDev, int key_code)
{
- return pDev->key->postdown[key_code >> 3] >> (key_code & 7);
+ return !!(pDev->key->postdown[key_code >> 3] & (1 << (key_code & 7)));
+}
+
+static Bool
+key_autorepeats(DeviceIntPtr pDev, int key_code)
+{
+ return !!(pDev->kbdfeed->ctrl.autoRepeats[key_code >> 3] &
+ (1 << (key_code & 7)));
}
/**
@@ -440,10 +447,11 @@ GetKeyboardValuatorEvents(xEvent *events, DeviceIntPtr pDev, int type,
* FIXME: In theory, if you're repeating with two keyboards in non-XKB,
* you could get unbalanced events here. */
if (type == KeyPress && key_is_down(pDev, key_code)) {
+ /* If autorepeating is disabled either globally or just for that key,
+ * or we have a modifier, don't generate a repeat event. */
if (!pDev->kbdfeed->ctrl.autoRepeat ||
- pDev->key->modifierMap[key_code] ||
- !(pDev->kbdfeed->ctrl.autoRepeats[key_code >> 3]
- & (1 << (key_code & 7))))
+ !key_autorepeats(pDev, key_code) ||
+ pDev->key->modifierMap[key_code])
return 0;
#ifdef XKB