dix: cleaned up GetPointerEvents() to avoid code duplication.
This commit is contained in:
parent
bffb1f9b67
commit
4d07b50372
|
@ -488,7 +488,7 @@ GetPointerEvents(xEvent *events, DeviceIntPtr pDev, int type, int buttons,
|
||||||
CARD32 ms = 0;
|
CARD32 ms = 0;
|
||||||
deviceKeyButtonPointer *kbp = NULL;
|
deviceKeyButtonPointer *kbp = NULL;
|
||||||
Bool sendValuators = (type == MotionNotify || flags & POINTER_ABSOLUTE);
|
Bool sendValuators = (type == MotionNotify || flags & POINTER_ABSOLUTE);
|
||||||
DeviceIntPtr cp = inputInfo.pointer;
|
DeviceIntPtr pointer = NULL;
|
||||||
int x = 0, y = 0;
|
int x = 0, y = 0;
|
||||||
|
|
||||||
/* Sanity checks. */
|
/* Sanity checks. */
|
||||||
|
@ -525,6 +525,11 @@ GetPointerEvents(xEvent *events, DeviceIntPtr pDev, int type, int buttons,
|
||||||
kbp->time = ms;
|
kbp->time = ms;
|
||||||
kbp->deviceid = pDev->id;
|
kbp->deviceid = pDev->id;
|
||||||
|
|
||||||
|
if (pDev->coreEvents)
|
||||||
|
pointer = inputInfo.pointer;
|
||||||
|
else
|
||||||
|
pointer = pDev;
|
||||||
|
|
||||||
/* Set x and y based on whether this is absolute or relative, and
|
/* Set x and y based on whether this is absolute or relative, and
|
||||||
* accelerate if we need to. */
|
* accelerate if we need to. */
|
||||||
if (flags & POINTER_ABSOLUTE) {
|
if (flags & POINTER_ABSOLUTE) {
|
||||||
|
@ -532,20 +537,14 @@ GetPointerEvents(xEvent *events, DeviceIntPtr pDev, int type, int buttons,
|
||||||
x = valuators[0];
|
x = valuators[0];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (pDev->coreEvents)
|
x = pointer->valuator->lastx;
|
||||||
x = cp->valuator->lastx;
|
|
||||||
else
|
|
||||||
x = pDev->valuator->lastx;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (first_valuator <= 1 && num_valuators >= (2 - first_valuator)) {
|
if (first_valuator <= 1 && num_valuators >= (2 - first_valuator)) {
|
||||||
y = valuators[1 - first_valuator];
|
y = valuators[1 - first_valuator];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (pDev->coreEvents)
|
y = pointer->valuator->lasty;
|
||||||
x = cp->valuator->lasty;
|
|
||||||
else
|
|
||||||
y = pDev->valuator->lasty;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -553,28 +552,15 @@ GetPointerEvents(xEvent *events, DeviceIntPtr pDev, int type, int buttons,
|
||||||
acceleratePointer(pDev, first_valuator, num_valuators,
|
acceleratePointer(pDev, first_valuator, num_valuators,
|
||||||
valuators);
|
valuators);
|
||||||
|
|
||||||
if (pDev->coreEvents) {
|
|
||||||
if (first_valuator == 0 && num_valuators >= 1)
|
if (first_valuator == 0 && num_valuators >= 1)
|
||||||
x = cp->valuator->lastx + valuators[0];
|
x = pointer->valuator->lastx + valuators[0];
|
||||||
else
|
else
|
||||||
x = cp->valuator->lastx;
|
x = pointer->valuator->lastx;
|
||||||
|
|
||||||
if (first_valuator <= 1 && num_valuators >= (2 - first_valuator))
|
if (first_valuator <= 1 && num_valuators >= (2 - first_valuator))
|
||||||
y = cp->valuator->lasty + valuators[1 - first_valuator];
|
y = pointer->valuator->lasty + valuators[1 - first_valuator];
|
||||||
else
|
else
|
||||||
y = cp->valuator->lasty;
|
y = pointer->valuator->lasty;
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (first_valuator == 0 && num_valuators >= 1)
|
|
||||||
x = pDev->valuator->lastx + valuators[0];
|
|
||||||
else
|
|
||||||
x = pDev->valuator->lastx;
|
|
||||||
|
|
||||||
if (first_valuator <= 1 && num_valuators >= (2 - first_valuator))
|
|
||||||
y = pDev->valuator->lasty + valuators[1 - first_valuator];
|
|
||||||
else
|
|
||||||
y = pDev->valuator->lasty;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Clip both x and y to the defined limits (usually co-ord space limit). */
|
/* Clip both x and y to the defined limits (usually co-ord space limit). */
|
||||||
|
@ -596,8 +582,9 @@ GetPointerEvents(xEvent *events, DeviceIntPtr pDev, int type, int buttons,
|
||||||
updateMotionHistory(pDev, ms, first_valuator, num_valuators, valuators);
|
updateMotionHistory(pDev, ms, first_valuator, num_valuators, valuators);
|
||||||
|
|
||||||
if (pDev->coreEvents) {
|
if (pDev->coreEvents) {
|
||||||
cp->valuator->lastx = x;
|
/* set the virtual core pointer's coordinates */
|
||||||
cp->valuator->lasty = y;
|
pointer->valuator->lastx = x;
|
||||||
|
pointer->valuator->lasty = y;
|
||||||
}
|
}
|
||||||
pDev->valuator->lastx = x;
|
pDev->valuator->lastx = x;
|
||||||
pDev->valuator->lasty = y;
|
pDev->valuator->lasty = y;
|
||||||
|
|
Loading…
Reference in New Issue