summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Xi/exevents.c19
-rw-r--r--dix/devices.c1
-rw-r--r--dix/getevents.c45
-rw-r--r--dix/inpututils.c12
-rw-r--r--include/input.h6
5 files changed, 46 insertions, 37 deletions
diff --git a/Xi/exevents.c b/Xi/exevents.c
index ecfc9c900..c09f19be5 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -977,27 +977,28 @@ ProcessRawEvent(RawDeviceEvent *ev, DeviceIntPtr device)
static void
ProcessTouchEvent(DeviceEvent *ev, DeviceIntPtr device)
{
+ TouchClassPtr t = device->touch;
WindowPtr win;
SpritePtr sprite;
xEvent *xi2;
int err, touch, i;
if (ev->type == ET_TouchBegin) {
- touch = CreateTouchPoint(device, ev->valuators.data[2]);
+ touch = CreateTouchPoint(device, ev->valuators.data[t->id_axis]);
if (touch < 0)
{
DebugF("[Xi] %s: Could not assign touchpoint for %d\n", device->name,
- ev->valuators.data[2]);
+ ev->valuators.data[t->id_axis]);
return;
}
}
else {
- touch = FindTouchPoint(device, ev->valuators.data[2]);
+ touch = FindTouchPoint(device, ev->valuators.data[t->id_axis]);
if (touch < 0)
{
DebugF("[Xi] %s: Received TouchMotion or TouchEnd event for "
"inactive touchpoint %d\n", device->name,
- ev->valuators.data[2]);
+ ev->valuators.data[t->id_axis]);
return;
}
}
@@ -1019,7 +1020,8 @@ ProcessTouchEvent(DeviceEvent *ev, DeviceIntPtr device)
if (device->touch->mode == XIDirectTouch)
{
sprite = device->touch->spriteInfo[touch]->sprite;
- win = XYToWindow(sprite, ev->valuators.data[0], ev->valuators.data[1]);
+ win = XYToWindow(sprite, ev->valuators.data[t->x_axis],
+ ev->valuators.data[t->y_axis]);
}
else
{
@@ -1292,8 +1294,13 @@ InitTouchValuatorAxisStruct(DeviceIntPtr dev, int axnum, Atom label, int minval,
else if (ax->label == XIGetKnownProperty(AXIS_LABEL_PROP_ABS_MT_POSITION_Y))
dev->touch->y_axis = axnum;
else if (ax->label ==
- XIGetKnownProperty(AXIS_LABEL_PROP_ABS_MT_TRACKING_ID))
+ XIGetKnownProperty(AXIS_LABEL_PROP_ABS_MT_TRACKING_ID)) {
+ int i;
+
dev->touch->id_axis = axnum;
+ for (i = 0; i < dev->touch->numTouches; i++)
+ dev->touch->axisVal[i][axnum] = -1;
+ }
}
static void
diff --git a/dix/devices.c b/dix/devices.c
index 9bffdf265..e69a224b4 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -1602,7 +1602,6 @@ InitTouchClassDeviceStruct(DeviceIntPtr device, unsigned int max_touches,
for (i = 0; i < max_touches; i++)
{
touch->axisVal[i] = axisVal;
- touch->axisVal[i][2] = -1;
axisVal += numAxes;
}
diff --git a/dix/getevents.c b/dix/getevents.c
index 73e3cf3c6..498c3ba1b 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -1299,16 +1299,19 @@ GetTouchEvents(EventList *events, DeviceIntPtr pDev,
if (!pDev->enabled)
return 0;
+ /* Sanity check. */
+ if (!t)
+ return 0;
+
/* Touch ID must exist */
- if (!valuator_mask_isset(mask_in, 2))
+ if (!valuator_mask_isset(mask_in, t->id_axis))
return 0;
- touch = FindTouchPoint(pDev, valuator_mask_get(mask_in, 2));
+ touch = FindTouchPoint(pDev, valuator_mask_get(mask_in, t->id_axis));
- /* Sanity checks. */
- if (!t || (touch < 0 && (end ||
- ((!valuator_mask_isset(mask_in, 0) ||
- !valuator_mask_isset(mask_in, 1))))))
+ /* Touch must exist or must be starting and have both X and Y */
+ if (touch < 0 && (end || !valuator_mask_isset(mask_in, t->x_axis) ||
+ !valuator_mask_isset(mask_in, t->y_axis)))
return 0;
valuator_mask_copy(&mask, mask_in);
@@ -1319,29 +1322,29 @@ GetTouchEvents(EventList *events, DeviceIntPtr pDev,
if (t->mode == XIDirectTouch) {
int scaled;
- if (valuator_mask_isset(&mask, 0))
+ if (valuator_mask_isset(&mask, t->x_axis))
{
- scaled = rescaleValuatorAxis(valuator_mask_get(&mask, 0),
- 0.0, &x_frac, NULL,
- (AxisInfoPtr)t->axes + 0,
- scr->width);
- valuator_mask_set(&mask, 0, scaled);
+ scaled = rescaleValuatorAxis(valuator_mask_get(&mask, t->x_axis),
+ 0.0, &x_frac,
+ (AxisInfoPtr)(t->axes + t->x_axis),
+ NULL, scr->width);
+ valuator_mask_set(&mask, t->x_axis, scaled);
x = scaled;
}
else
- x = t->axisVal[touch][0];
+ x = t->axisVal[touch][t->x_axis];
- if (valuator_mask_isset(&mask, 1))
+ if (valuator_mask_isset(&mask, t->y_axis))
{
- scaled = rescaleValuatorAxis(valuator_mask_get(&mask, 1),
- 0.0, &y_frac, NULL,
- (AxisInfoPtr)t->axes + 1,
- scr->height);
- valuator_mask_set(&mask, 1, scaled);
+ scaled = rescaleValuatorAxis(valuator_mask_get(&mask, t->y_axis),
+ 0.0, &y_frac,
+ (AxisInfoPtr)(t->axes + t->y_axis),
+ NULL, scr->height);
+ valuator_mask_set(&mask, t->y_axis, scaled);
y = scaled;
}
else
- y = t->axisVal[touch][1];
+ y = t->axisVal[touch][t->y_axis];
}
else {
x = pDev->spriteInfo->sprite->hotPhys.x;
@@ -1359,7 +1362,7 @@ GetTouchEvents(EventList *events, DeviceIntPtr pDev,
set_valuators(pDev, event, &mask);
if (touch < 0) {
- touch = CreateTouchPoint(pDev, valuator_mask_get(&mask, 2));
+ touch = CreateTouchPoint(pDev, valuator_mask_get(&mask, t->id_axis));
if (touch < 0)
return 0;
diff --git a/dix/inpututils.c b/dix/inpututils.c
index bab5f82b5..2798c5708 100644
--- a/dix/inpututils.c
+++ b/dix/inpututils.c
@@ -548,7 +548,7 @@ CountBits(const uint8_t *mask, int len)
}
int
-FindTouchPoint(DeviceIntPtr dev, uint32_t touchid)
+FindTouchPoint(DeviceIntPtr dev, unsigned int touchid)
{
int i;
@@ -556,14 +556,14 @@ FindTouchPoint(DeviceIntPtr dev, uint32_t touchid)
return -1;
for (i = 0; i < dev->touch->numTouches; i++)
- if (dev->touch->axisVal[i][2] == touchid)
+ if (dev->touch->axisVal[i][dev->touch->id_axis] == (int)touchid)
return i;
return -1;
}
int
-CreateTouchPoint(DeviceIntPtr dev, uint32_t touchid)
+CreateTouchPoint(DeviceIntPtr dev, unsigned int touchid)
{
int touch;
@@ -577,17 +577,17 @@ CreateTouchPoint(DeviceIntPtr dev, uint32_t touchid)
if (touch < 0)
return -1;
- dev->touch->axisVal[touch][2] = touchid;
+ dev->touch->axisVal[touch][dev->touch->id_axis] = touchid;
return touch;
}
void
-FinishTouchPoint(DeviceIntPtr dev, uint32_t touchid)
+FinishTouchPoint(DeviceIntPtr dev, unsigned int touchid)
{
int touch = FindTouchPoint(dev, touchid);
if (!touch)
return;
- dev->touch->axisVal[touch][2] = -1;
+ dev->touch->axisVal[touch][dev->touch->id_axis] = -1;
}
diff --git a/include/input.h b/include/input.h
index c6a65a988..580b91d88 100644
--- a/include/input.h
+++ b/include/input.h
@@ -538,9 +538,9 @@ extern DeviceIntPtr GetXTestDevice(DeviceIntPtr master);
extern void SendDevicePresenceEvent(int deviceid, int type);
extern _X_EXPORT InputAttributes *DuplicateInputAttributes(InputAttributes *attrs);
extern _X_EXPORT void FreeInputAttributes(InputAttributes *attrs);
-extern int CreateTouchPoint(DeviceIntPtr dev, uint32_t touchid);
-extern int FindTouchPoint(DeviceIntPtr dev, uint32_t touchid);
-extern void FinishTouchPoint(DeviceIntPtr dev, uint32_t touchid);
+extern int CreateTouchPoint(DeviceIntPtr dev, unsigned int touchid);
+extern int FindTouchPoint(DeviceIntPtr dev, unsigned int touchid);
+extern void FinishTouchPoint(DeviceIntPtr dev, unsigned int touchid);
/* misc event helpers */
extern Mask GetEventMask(DeviceIntPtr dev, xEvent* ev, InputClientsPtr clients);