GPE: fix absolute button events / GKVE: (non-XKB) don't repeat lock keys

Fix absolute button events in GPE, where we would previously send valuator
events without bumping numEvents accordingly, causing the core event to
go missing.
In the non-XKB path in GKVE, implement proper lock behaviour (one press to
enable, one press to disable, discard releases).
Fix debug_events prototype.
This commit is contained in:
Daniel Stone 2006-08-15 15:23:53 +03:00 committed by Daniel Stone
parent d003bada33
commit 34228d8b28

View File

@ -113,6 +113,7 @@ of the copyright holder.
#endif #endif
#include <X11/X.h> #include <X11/X.h>
#include <X11/keysym.h>
#include "misc.h" #include "misc.h"
#include "resource.h" #include "resource.h"
#define NEED_EVENTS #define NEED_EVENTS
@ -210,7 +211,7 @@ Mask DontPropagateMasks[DNPMCOUNT];
static int DontPropagateRefCnts[DNPMCOUNT]; static int DontPropagateRefCnts[DNPMCOUNT];
#ifdef DEBUG #ifdef DEBUG
static debug_events = 0; static int debug_events = 0;
#endif #endif
_X_EXPORT InputInfo inputInfo; _X_EXPORT InputInfo inputInfo;
@ -4711,6 +4712,7 @@ int GetKeyboardValuatorEvents(xEvent *events, DeviceIntPtr pDev, int type,
int key_code, int num_valuators, int key_code, int num_valuators,
int *valuators) { int *valuators) {
int numEvents = 0, numRepeatEvents = 0, ms = 0, first_valuator = 0, i = 0; int numEvents = 0, numRepeatEvents = 0, ms = 0, first_valuator = 0, i = 0;
KeySym sym = pDev->key->curKeySyms.map[key_code * pDev->key->curKeySyms.mapWidth];
deviceKeyButtonPointer *kbp = NULL; deviceKeyButtonPointer *kbp = NULL;
deviceValuator *xv = NULL; deviceValuator *xv = NULL;
xEvent *repeatEvents = NULL; xEvent *repeatEvents = NULL;
@ -4740,11 +4742,28 @@ int GetKeyboardValuatorEvents(xEvent *events, DeviceIntPtr pDev, int type,
numEvents += (num_valuators / 6) + 1; numEvents += (num_valuators / 6) + 1;
} }
#ifdef XKB
if (noXkbExtension)
#endif
{
switch (sym) {
case XK_Num_Lock:
case XK_Caps_Lock:
case XK_Scroll_Lock:
case XK_Shift_Lock:
if (type == KeyRelease)
return 0;
else if (type == KeyPress &&
(pDev->key->down[key_code >> 3] & (key_code & 7)) & 1)
type = KeyRelease;
}
}
/* Handle core repeating, via press/release/press/release. /* Handle core repeating, via press/release/press/release.
* FIXME: In theory, if you're repeating with two keyboards, * FIXME: In theory, if you're repeating with two keyboards,
* you could get unbalanced events here. */ * you could get unbalanced events here. */
if (type == KeyPress && if (type == KeyPress &&
((pDev->key->down[key_code >> 3] & (key_code & 7)) & 1)) { (((pDev->key->down[key_code >> 3] & (key_code & 7))) & 1)) {
if (!pDev->kbdfeed->ctrl.autoRepeat || if (!pDev->kbdfeed->ctrl.autoRepeat ||
pDev->key->modifierMap[key_code] || pDev->key->modifierMap[key_code] ||
!(pDev->kbdfeed->ctrl.autoRepeats[key_code >> 3] !(pDev->kbdfeed->ctrl.autoRepeats[key_code >> 3]
@ -4760,7 +4779,7 @@ int GetKeyboardValuatorEvents(xEvent *events, DeviceIntPtr pDev, int type,
num_valuators, valuators); num_valuators, valuators);
events += numEvents; events += numEvents;
} }
}
ms = GetTimeInMillis(); ms = GetTimeInMillis();
@ -4942,6 +4961,7 @@ GetPointerEvents(xEvent *events, DeviceIntPtr pDev, int type, int buttons,
deviceValuator *xv = NULL; deviceValuator *xv = NULL;
AxisInfoPtr axes = NULL; AxisInfoPtr axes = NULL;
xEvent *ev = NULL; xEvent *ev = NULL;
Bool sendValuators = (type == MotionNotify || flags & POINTER_ABSOLUTE);
DeviceIntPtr cp = inputInfo.pointer; DeviceIntPtr cp = inputInfo.pointer;
if (type != MotionNotify && type != ButtonPress && type != ButtonRelease) if (type != MotionNotify && type != ButtonPress && type != ButtonRelease)
@ -4961,14 +4981,13 @@ GetPointerEvents(xEvent *events, DeviceIntPtr pDev, int type, int buttons,
else else
numEvents = 1; numEvents = 1;
if (type == MotionNotify) { if (num_valuators > 2 && sendValuators) {
if (num_valuators > 2) { if (((num_valuators / 6) + 1) > MAX_VALUATOR_EVENTS)
if (((num_valuators / 6) + 1) > MAX_VALUATOR_EVENTS) num_valuators = MAX_VALUATOR_EVENTS;
num_valuators = MAX_VALUATOR_EVENTS; numEvents += (num_valuators / 6) + 1;
numEvents += (num_valuators / 6) + 1; }
} else if (type == MotionNotify && num_valuators < 2) {
else if (num_valuators < 2) return 0;
return 0;
} }
ms = GetTimeInMillis(); ms = GetTimeInMillis();
@ -5067,8 +5086,7 @@ GetPointerEvents(xEvent *events, DeviceIntPtr pDev, int type, int buttons,
kbp->detail = pDev->button->map[buttons]; kbp->detail = pDev->button->map[buttons];
} }
if (num_valuators > 2 && (type == MotionNotify || if (num_valuators > 2 && sendValuators) {
flags & POINTER_ABSOLUTE)) {
kbp->deviceid |= MORE_EVENTS; kbp->deviceid |= MORE_EVENTS;
while (first_valuator < num_valuators) { while (first_valuator < num_valuators) {
xv = (deviceValuator *) ++events; xv = (deviceValuator *) ++events;
@ -5106,6 +5124,9 @@ GetPointerEvents(xEvent *events, DeviceIntPtr pDev, int type, int buttons,
if (pDev->coreEvents) { if (pDev->coreEvents) {
events++; events++;
events->u.u.type = type; events->u.u.type = type;
#ifdef DEBUG
ErrorF("GPE: core type is %d\n", type);
#endif
events->u.keyButtonPointer.time = ms; events->u.keyButtonPointer.time = ms;
events->u.keyButtonPointer.rootX = kbp->root_x; events->u.keyButtonPointer.rootX = kbp->root_x;
events->u.keyButtonPointer.rootY = kbp->root_y; events->u.keyButtonPointer.rootY = kbp->root_y;