[PATCH 6/9] input: move proximity state into ProximityClassRec.

Peter Hutterer peter.hutterer at who-t.net
Thu Oct 21 23:29:33 PDT 2010


Previously the OutOfProximity bit in the valuator mode.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 Xi/exevents.c      |    8 ++++++--
 Xi/queryst.c       |    2 +-
 dix/devices.c      |    5 ++++-
 include/inputstr.h |    2 +-
 4 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/Xi/exevents.c b/Xi/exevents.c
index 1f59001..9bff2b3 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -891,9 +891,9 @@ UpdateDeviceState(DeviceIntPtr device, DeviceEvent* event)
         mask = PointerMotionMask | b->state | b->motionMask;
         SetMaskForEvent(device->id, mask, MotionNotify);
     } else if (event->type == ET_ProximityIn)
-	device->valuator->mode &= ~OutOfProximity;
+	device->proximity->in_proximity = TRUE;
     else if (event->type == ET_ProximityOut)
-	device->valuator->mode |= OutOfProximity;
+	device->proximity->in_proximity = FALSE;
 
     return DEFAULT;
 }
@@ -1112,6 +1112,7 @@ InitProximityClassDeviceStruct(DeviceIntPtr dev)
     if (!proxc)
 	return FALSE;
     proxc->sourceid = dev->id;
+    proxc->in_proximity = TRUE;
     dev->proximity = proxc;
     return TRUE;
 }
@@ -1145,6 +1146,9 @@ InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, Atom label, int minval, int
     ax->max_resolution = max_res;
     ax->label = label;
     ax->mode = mode;
+
+    if (mode & OutOfProximity)
+        dev->proximity->in_proximity = FALSE;
 }
 
 static void
diff --git a/Xi/queryst.c b/Xi/queryst.c
index 65a43d1..9c9e4e0 100644
--- a/Xi/queryst.c
+++ b/Xi/queryst.c
@@ -151,7 +151,7 @@ ProcXQueryDeviceState(ClientPtr client)
 	tv->class = ValuatorClass;
 	tv->length = sizeof(xValuatorState) + v->numAxes * 4;
 	tv->num_valuators = v->numAxes;
-	tv->mode = v->mode;
+	tv->mode |= (dev->proximity && !dev->proximity->in_proximity) ? OutOfProximity : 0;
 	buf += sizeof(xValuatorState);
 	for (i = 0, values = v->axisVal; i < v->numAxes; i++) {
 	    if (rc != BadAccess)
diff --git a/dix/devices.c b/dix/devices.c
index 45edd37..a4c8e76 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -1251,9 +1251,12 @@ InitValuatorClassDeviceStruct(DeviceIntPtr dev, int numAxes, Atom *labels,
     valc->numMotionEvents = numMotionEvents;
     valc->motionHintWindow = NullWindow;
     valc->numAxes = numAxes;
-    valc->mode = mode;
     valc->axes = (AxisInfoPtr)(valc + 1);
     valc->axisVal = (double *)(valc->axes + numAxes);
+
+    if (mode & OutOfProximity)
+        InitProximityClassDeviceStruct(dev);
+
     dev->valuator = valc;
 
     AllocateMotionHistory(dev);
diff --git a/include/inputstr.h b/include/inputstr.h
index dfab791..cd66876 100644
--- a/include/inputstr.h
+++ b/include/inputstr.h
@@ -273,7 +273,7 @@ typedef struct _FocusClassRec {
 
 typedef struct _ProximityClassRec {
     int		sourceid;
-    char	pad;
+    char	in_proximity;
 } ProximityClassRec, *ProximityClassPtr;
 
 typedef struct _AbsoluteClassRec {
-- 
1.7.2.3



More information about the xorg-devel mailing list