Xi: declare variables where needed in ProcXGetDeviceMotionEvents()
Improve code readability by moving variable declarations to where they're actually needed. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
e6df411cf5
commit
52456a6e27
|
@ -86,24 +86,20 @@ SProcXGetDeviceMotionEvents(ClientPtr client)
|
||||||
int
|
int
|
||||||
ProcXGetDeviceMotionEvents(ClientPtr client)
|
ProcXGetDeviceMotionEvents(ClientPtr client)
|
||||||
{
|
{
|
||||||
INT32 *coords = NULL;
|
|
||||||
int rc, axes, size = 0;
|
|
||||||
DeviceIntPtr dev;
|
|
||||||
TimeStamp start, stop;
|
|
||||||
ValuatorClassPtr v;
|
|
||||||
|
|
||||||
REQUEST(xGetDeviceMotionEventsReq);
|
REQUEST(xGetDeviceMotionEventsReq);
|
||||||
REQUEST_SIZE_MATCH(xGetDeviceMotionEventsReq);
|
REQUEST_SIZE_MATCH(xGetDeviceMotionEventsReq);
|
||||||
|
|
||||||
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixReadAccess);
|
DeviceIntPtr dev;
|
||||||
|
int rc = dixLookupDevice(&dev, stuff->deviceid, client, DixReadAccess);
|
||||||
if (rc != Success)
|
if (rc != Success)
|
||||||
return rc;
|
return rc;
|
||||||
v = dev->valuator;
|
|
||||||
|
const ValuatorClassPtr v = dev->valuator;
|
||||||
if (v == NULL || v->numAxes == 0)
|
if (v == NULL || v->numAxes == 0)
|
||||||
return BadMatch;
|
return BadMatch;
|
||||||
|
|
||||||
if (dev->valuator->motionHintWindow)
|
if (dev->valuator->motionHintWindow)
|
||||||
MaybeStopDeviceHint(dev, client);
|
MaybeStopDeviceHint(dev, client);
|
||||||
axes = v->numAxes;
|
|
||||||
|
|
||||||
xGetDeviceMotionEventsReply rep = {
|
xGetDeviceMotionEventsReply rep = {
|
||||||
.repType = X_Reply,
|
.repType = X_Reply,
|
||||||
|
@ -111,12 +107,12 @@ ProcXGetDeviceMotionEvents(ClientPtr client)
|
||||||
.sequenceNumber = client->sequence,
|
.sequenceNumber = client->sequence,
|
||||||
.length = 0,
|
.length = 0,
|
||||||
.nEvents = 0,
|
.nEvents = 0,
|
||||||
.axes = axes,
|
.axes = v->numAxes,
|
||||||
.mode = Absolute /* XXX we don't do relative at the moment */
|
.mode = Absolute /* XXX we don't do relative at the moment */
|
||||||
};
|
};
|
||||||
|
|
||||||
start = ClientTimeToServerTime(stuff->start);
|
TimeStamp start = ClientTimeToServerTime(stuff->start);
|
||||||
stop = ClientTimeToServerTime(stuff->stop);
|
TimeStamp stop = ClientTimeToServerTime(stuff->stop);
|
||||||
if (CompareTimeStamps(start, stop) == LATER ||
|
if (CompareTimeStamps(start, stop) == LATER ||
|
||||||
CompareTimeStamps(start, currentTime) == LATER) {
|
CompareTimeStamps(start, currentTime) == LATER) {
|
||||||
WriteReplyToClient(client, sizeof(xGetDeviceMotionEventsReply), &rep);
|
WriteReplyToClient(client, sizeof(xGetDeviceMotionEventsReply), &rep);
|
||||||
|
@ -124,14 +120,16 @@ ProcXGetDeviceMotionEvents(ClientPtr client)
|
||||||
}
|
}
|
||||||
if (CompareTimeStamps(stop, currentTime) == LATER)
|
if (CompareTimeStamps(stop, currentTime) == LATER)
|
||||||
stop = currentTime;
|
stop = currentTime;
|
||||||
|
|
||||||
|
int length = 0;
|
||||||
|
INT32 *coords = NULL;
|
||||||
if (v->numMotionEvents) {
|
if (v->numMotionEvents) {
|
||||||
size = sizeof(Time) + (axes * sizeof(INT32));
|
|
||||||
rep.nEvents = GetMotionHistory(dev, (xTimecoord **) &coords, /* XXX */
|
rep.nEvents = GetMotionHistory(dev, (xTimecoord **) &coords, /* XXX */
|
||||||
start.milliseconds, stop.milliseconds,
|
start.milliseconds, stop.milliseconds,
|
||||||
(ScreenPtr) NULL, FALSE);
|
(ScreenPtr) NULL, FALSE);
|
||||||
|
length = rep.nEvents * (sizeof(Time) + (v->numAxes * sizeof(INT32)));
|
||||||
}
|
}
|
||||||
|
|
||||||
const int length = rep.nEvents * size;
|
|
||||||
rep.length = bytes_to_int32(length);
|
rep.length = bytes_to_int32(length);
|
||||||
|
|
||||||
if (client->swapped) {
|
if (client->swapped) {
|
||||||
|
|
Loading…
Reference in New Issue