xserver: Branch 'mpx' - 2 commits
Peter Hutterer
whot at kemper.freedesktop.org
Tue Apr 29 19:41:00 PDT 2008
Xi/exevents.c | 13 +++++++++++--
dix/devices.c | 15 ++++++++-------
dix/getevents.c | 16 +++++++++-------
include/input.h | 2 ++
4 files changed, 30 insertions(+), 16 deletions(-)
New commits:
commit ffaccc2dc91f4ca4ea10da010206a0a7d2b5540c
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date: Wed Apr 30 11:45:19 2008 +0930
input: replace -1 as default axis limit with NO_AXIS_LIMIT define.
This allows easier refacturing of the coordinate limit handling. Grepping for
-1 is boring.
diff --git a/Xi/exevents.c b/Xi/exevents.c
index 761950e..d0c10d9 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -1153,13 +1153,22 @@ InitProximityClassDeviceStruct(DeviceIntPtr dev)
return TRUE;
}
+/**
+ * Initialise the device's valuators. The memory must already be allocated,
+ * this function merely inits the matching axis (specified through axnum) to
+ * sane values.
+ *
+ * It is a condition that (minval < maxval).
+ *
+ * @see InitValuatorClassDeviceStruct
+ */
_X_EXPORT void
InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, int minval, int maxval,
int resolution, int min_res, int max_res)
{
AxisInfoPtr ax;
-
- if (!dev || !dev->valuator)
+
+ if (!dev || !dev->valuator || minval > maxval)
return;
ax = dev->valuator->axes + axnum;
diff --git a/dix/devices.c b/dix/devices.c
index 37feb34..abd3cb6 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -1187,7 +1187,8 @@ InitValuatorClassDeviceStruct(DeviceIntPtr dev, int numAxes,
AllocateMotionHistory(dev);
for (i=0; i<numAxes; i++) {
- InitValuatorAxisStruct(dev, i, -1, -1, 0, 0, 0);
+ InitValuatorAxisStruct(dev, i, NO_AXIS_LIMITS, NO_AXIS_LIMITS,
+ 0, 0, 0);
valc->axisVal[i]=0;
}
return TRUE;
@@ -1203,10 +1204,10 @@ InitAbsoluteClassDeviceStruct(DeviceIntPtr dev)
return FALSE;
/* we don't do anything sensible with these, but should */
- abs->min_x = -1;
- abs->min_y = -1;
- abs->max_x = -1;
- abs->max_y = -1;
+ abs->min_x = NO_AXIS_LIMITS;
+ abs->min_y = NO_AXIS_LIMITS;
+ abs->max_x = NO_AXIS_LIMITS;
+ abs->max_y = NO_AXIS_LIMITS;
abs->flip_x = 0;
abs->flip_y = 0;
abs->rotation = 0;
@@ -1214,8 +1215,8 @@ InitAbsoluteClassDeviceStruct(DeviceIntPtr dev)
abs->offset_x = 0;
abs->offset_y = 0;
- abs->width = -1;
- abs->height = -1;
+ abs->width = NO_AXIS_LIMITS;
+ abs->height = NO_AXIS_LIMITS;
abs->following = 0;
abs->screen = 0;
diff --git a/dix/getevents.c b/dix/getevents.c
index e9c1db0..a358bb3 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -358,14 +358,15 @@ clipAxis(DeviceIntPtr pDev, int axisNum, int *val)
{
AxisInfoPtr axes = pDev->valuator->axes + axisNum;
- /* Don't clip if min_value and max_value are the same, or if an invalid
- range is specified. */
- if(axes->min_value < axes->max_value) {
- if (*val < axes->min_value)
- *val = axes->min_value;
- if (*val > axes->max_value)
- *val = axes->max_value;
- }
+ /* InitValuatoraAxisStruct ensures that (min < max) */
+
+ if (axes->min_value != NO_AXIS_LIMITS &&
+ *val < axis->min_value)
+ *val = axes->min_value;
+
+ if (axes->max_value != NO_AXIS_LIMITS &&
+ *val > axes->max_value)
+ *val = axes->max_value;
}
/**
diff --git a/include/input.h b/include/input.h
index 10dadfe..ec6ac90 100644
--- a/include/input.h
+++ b/include/input.h
@@ -63,6 +63,8 @@ SOFTWARE.
#define POINTER_ABSOLUTE (1 << 2)
#define POINTER_ACCELERATE (1 << 3)
+#define NO_AXIS_LIMITS -1
+
#define MAP_LENGTH 256
#define DOWN_LENGTH 32 /* 256/8 => number of bytes to hold 256 bits */
#define NullGrab ((GrabPtr)NULL)
commit 00acb40f2bc5bb4a1977b9b08db75630677ff787
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date: Wed Apr 30 11:29:03 2008 +0930
dix: fix typo in clipAxis.
Check needs to be (min_axis < max_axis), not (min_axis < min_axis)
diff --git a/dix/getevents.c b/dix/getevents.c
index 0a44a80..e9c1db0 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -358,8 +358,9 @@ clipAxis(DeviceIntPtr pDev, int axisNum, int *val)
{
AxisInfoPtr axes = pDev->valuator->axes + axisNum;
- /* No clipping if the value-range <= 0 */
- if(axes->min_value < axes->min_value) {
+ /* Don't clip if min_value and max_value are the same, or if an invalid
+ range is specified. */
+ if(axes->min_value < axes->max_value) {
if (*val < axes->min_value)
*val = axes->min_value;
if (*val > axes->max_value)
More information about the xorg-commit
mailing list