aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/dix/devices.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2011-04-27 06:58:32 +0000
committermarha <marha@users.sourceforge.net>2011-04-27 06:58:32 +0000
commit96d6df5da9cddedf4931bf8e17f96e242467c661 (patch)
tree07977c913b04e80b7dbd302e7a5890422aeacb1b /xorg-server/dix/devices.c
parent71372d36e1a3f0230b88808f70d35446fda12260 (diff)
downloadvcxsrv-96d6df5da9cddedf4931bf8e17f96e242467c661.tar.gz
vcxsrv-96d6df5da9cddedf4931bf8e17f96e242467c661.tar.bz2
vcxsrv-96d6df5da9cddedf4931bf8e17f96e242467c661.zip
xserver libX11 libxtrans mesa pixman xkeyboard-config git update 27 Apr 2011
Diffstat (limited to 'xorg-server/dix/devices.c')
-rw-r--r--xorg-server/dix/devices.c49
1 files changed, 38 insertions, 11 deletions
diff --git a/xorg-server/dix/devices.c b/xorg-server/dix/devices.c
index 534931c3e..3f46ad6fb 100644
--- a/xorg-server/dix/devices.c
+++ b/xorg-server/dix/devices.c
@@ -1221,13 +1221,46 @@ InitButtonClassDeviceStruct(DeviceIntPtr dev, int numButtons, Atom* labels,
return TRUE;
}
+/**
+ * Allocate a valuator class and set up the pointers for the axis values
+ * appropriately.
+ *
+ * @param src If non-NULL, the memory is reallocated from src. If NULL, the
+ * memory is calloc'd.
+ * @parma numAxes Number of axes to allocate.
+ * @return The allocated valuator struct.
+ */
+ValuatorClassPtr
+AllocValuatorClass(ValuatorClassPtr src, int numAxes)
+{
+ ValuatorClassPtr v;
+ /* force alignment with double */
+ union align_u { ValuatorClassRec valc; double d; } *align;
+ int size;
+
+ size = sizeof(union align_u) + numAxes * (sizeof(double) + sizeof(AxisInfo));
+ align = (union align_u *) realloc(src, size);
+
+ if (!align)
+ return NULL;
+
+ if (!src)
+ memset(align, 0, size);
+
+ v = &align->valc;
+ v->numAxes = numAxes;
+ v->axisVal = (double*)(align + 1);
+ v->axes = (AxisInfoPtr)(v->axisVal + numAxes);
+
+ return v;
+}
+
Bool
InitValuatorClassDeviceStruct(DeviceIntPtr dev, int numAxes, Atom *labels,
int numMotionEvents, int mode)
{
int i;
ValuatorClassPtr valc;
- union align_u { ValuatorClassRec valc; double d; } *align;
if (!dev)
return FALSE;
@@ -1240,13 +1273,10 @@ InitValuatorClassDeviceStruct(DeviceIntPtr dev, int numAxes, Atom *labels,
numAxes = MAX_VALUATORS;
}
- align = (union align_u *) calloc(1, sizeof(union align_u) +
- numAxes * sizeof(double) +
- numAxes * sizeof(AxisInfo));
- if (!align)
- return FALSE;
+ valc = AllocValuatorClass(NULL, numAxes);
+ if (!valc)
+ return FALSE;
- valc = &align->valc;
valc->sourceid = dev->id;
valc->motion = NULL;
valc->first_motion = 0;
@@ -1254,9 +1284,6 @@ InitValuatorClassDeviceStruct(DeviceIntPtr dev, int numAxes, Atom *labels,
valc->numMotionEvents = numMotionEvents;
valc->motionHintWindow = NullWindow;
- valc->numAxes = numAxes;
- valc->axisVal = (double *)(align + 1);
- valc->axes = (AxisInfoPtr)(valc->axisVal + numAxes);
if (mode & OutOfProximity)
InitProximityClassDeviceStruct(dev);
@@ -2365,7 +2392,7 @@ ReleaseButtonsAndKeys(DeviceIntPtr dev)
{
if (BitIsOn(k->down, i))
{
- nevents = GetKeyboardEvents(eventlist, dev, KeyRelease, i);
+ nevents = GetKeyboardEvents(eventlist, dev, KeyRelease, i, NULL);
for (j = 0; j < nevents; j++)
mieqProcessDeviceEvent(dev, (InternalEvent*)(eventlist+j)->event, NULL);
}