xfree86/input: add proximity support, free valuators

Re-add support for proximity events, and remember to both va_end our
varargs, and free our valuators.
This commit is contained in:
Daniel Stone 2006-10-23 06:56:07 +03:00 committed by Daniel Stone
parent cccf7ae0ff
commit 0cd6a3d8ef

View File

@ -585,9 +585,9 @@ xf86PostMotionEvent(DeviceIntPtr device,
valuators = xcalloc(sizeof(int), num_valuators); valuators = xcalloc(sizeof(int), num_valuators);
va_start(var, num_valuators); va_start(var, num_valuators);
for (i = 0; i < num_valuators; i++) { for (i = 0; i < num_valuators; i++)
valuators[i] = va_arg(var, int); valuators[i] = va_arg(var, int);
} va_end(var);
if (!xf86Events) if (!xf86Events)
xf86Events = (xEvent *)xcalloc(sizeof(xEvent), GetMaximumEventsNum()); xf86Events = (xEvent *)xcalloc(sizeof(xEvent), GetMaximumEventsNum());
@ -600,6 +600,8 @@ xf86PostMotionEvent(DeviceIntPtr device,
for (i = 0; i < nevents; i++) for (i = 0; i < nevents; i++)
mieqEnqueue(device, xf86Events + i); mieqEnqueue(device, xf86Events + i);
xfree(valuators);
} }
_X_EXPORT void _X_EXPORT void
@ -610,87 +612,27 @@ xf86PostProximityEvent(DeviceIntPtr device,
...) ...)
{ {
va_list var; va_list var;
int loop; int i, nevents, *valuators = NULL;
Bool is_core = device->coreEvents;
ErrorF("xf86PostProximityEvent: no-op event called\n"); valuators = xcalloc(sizeof(int), num_valuators);
#if 0
DBG(5, ErrorF("xf86PostProximityEvent BEGIN 0x%x(%s) prox=%s is_core=%s is_absolute=%s\n",
device, device->name, is_in ? "true" : "false",
is_core ? "True" : "False",
is_absolute ? "True" : "False"));
if (is_core) {
return;
}
if (num_valuators && (!val || (first_valuator + num_valuators > val->numAxes))) {
ErrorF("Bad valuators reported for device \"%s\"\n", device->name);
return;
}
xev->type = is_in ? ProximityIn : ProximityOut;
xev->detail = 0;
xev->deviceid = device->id | MORE_EVENTS;
xv->type = DeviceValuator;
xv->deviceid = device->id;
xv->device_state = 0;
if ((device->valuator->mode & 1) == Relative) {
num_valuators = 0;
}
if (num_valuators != 0) {
int *axisvals = val->axisVal;
va_start(var, num_valuators); va_start(var, num_valuators);
for (i = 0; i < num_valuators; i++)
for(loop=0; loop<num_valuators; loop++) { valuators[i] = va_arg(var, int);
switch (loop % 6) {
case 0:
xv->valuator0 = is_absolute ? va_arg(var, int) : axisvals[loop];
break;
case 1:
xv->valuator1 = is_absolute ? va_arg(var, int) : axisvals[loop];
break;
case 2:
xv->valuator2 = is_absolute ? va_arg(var, int) : axisvals[loop];
break;
case 3:
xv->valuator3 = is_absolute ? va_arg(var, int) : axisvals[loop];
break;
case 4:
xv->valuator4 = is_absolute ? va_arg(var, int) : axisvals[loop];
break;
case 5:
xv->valuator5 = is_absolute ? va_arg(var, int) : axisvals[loop];
break;
}
if ((loop % 6 == 5) || (loop == num_valuators - 1)) {
xf86Info.lastEventTime = xev->time = GetTimeInMillis();
xv->num_valuators = (loop % 6) + 1;
xv->first_valuator = first_valuator + (loop / 6) * 6;
mieqEnqueue(xE);
}
}
va_end(var); va_end(var);
}
else {
/* no valuator */
xf86Info.lastEventTime = xev->time = GetTimeInMillis();
xv->num_valuators = 0; if (!xf86Events)
xv->first_valuator = 0; xf86Events = (xEvent *)xcalloc(sizeof(xEvent), GetMaximumEventsNum());
mieqEnqueue(xE); if (!xf86Events)
} FatalError("Couldn't allocate event store\n");
DBG(5, ErrorF("xf86PostProximityEvent END 0x%x(%s) prox=%s is_core=%s is_absolute=%s\n",
device, device->name, is_in ? "true" : "false", nevents = GetProximityEvents(xf86Events, device,
is_core ? "True" : "False", is_in ? ProximityIn : ProximityOut,
is_absolute ? "True" : "False")); first_valuator, num_valuators, valuators);
#endif for (i = 0; i < nevents; i++)
mieqEnqueue(device, xf86Events + i);
xfree(valuators);
} }
_X_EXPORT void _X_EXPORT void
@ -709,9 +651,9 @@ xf86PostButtonEvent(DeviceIntPtr device,
valuators = xcalloc(sizeof(int), num_valuators); valuators = xcalloc(sizeof(int), num_valuators);
va_start(var, num_valuators); va_start(var, num_valuators);
for (i = 0; i < num_valuators; i++) { for (i = 0; i < num_valuators; i++)
valuators[i] = va_arg(var, int); valuators[i] = va_arg(var, int);
} va_end(var);
if (!xf86Events) if (!xf86Events)
xf86Events = (xEvent *)xcalloc(sizeof(xEvent), GetMaximumEventsNum()); xf86Events = (xEvent *)xcalloc(sizeof(xEvent), GetMaximumEventsNum());
@ -726,6 +668,8 @@ xf86PostButtonEvent(DeviceIntPtr device,
for (i = 0; i < nevents; i++) for (i = 0; i < nevents; i++)
mieqEnqueue(device, xf86Events + i); mieqEnqueue(device, xf86Events + i);
xfree(valuators);
} }
_X_EXPORT void _X_EXPORT void
@ -761,6 +705,7 @@ xf86PostKeyEvent(DeviceIntPtr device,
is_down ? KeyPress : KeyRelease, is_down ? KeyPress : KeyRelease,
key_code, first_valuator, key_code, first_valuator,
num_valuators, valuators); num_valuators, valuators);
xfree(valuators);
} }
else { else {
nevents = GetKeyboardEvents(xf86Events, device, nevents = GetKeyboardEvents(xf86Events, device,