Commit b0abdf7b authored by Ulrich Sibiller's avatar Ulrich Sibiller Committed by Mihai Moldovan

Xi: reformat

parent 7aca428f
......@@ -100,15 +100,13 @@ ProcXAllowDeviceEvents(register ClientPtr client)
REQUEST_SIZE_MATCH(xAllowDeviceEventsReq);
thisdev = LookupDeviceIntRec(stuff->deviceid);
if (thisdev == NULL)
{
if (thisdev == NULL) {
SendErrorToClient(client, IReqCode, X_AllowDeviceEvents, 0, BadDevice);
return Success;
}
time = ClientTimeToServerTime(stuff->time);
switch (stuff->mode)
{
switch (stuff->mode) {
case ReplayThisDevice:
AllowSome(client, time, thisdev, NOT_GRABBED);
break;
......@@ -128,8 +126,7 @@ ProcXAllowDeviceEvents(register ClientPtr client)
AllowSome(client, time, thisdev, THAWED_BOTH);
break;
default:
SendErrorToClient(client, IReqCode, X_AllowDeviceEvents, 0,
BadValue);
SendErrorToClient(client, IReqCode, X_AllowDeviceEvents, 0, BadValue);
client->errorValue = stuff->mode;
return Success;
}
......
......@@ -107,8 +107,7 @@ ProcXChangeDeviceControl(ClientPtr client)
len = stuff->length - (sizeof(xChangeDeviceControlReq) >> 2);
dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL)
{
if (dev == NULL) {
SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0,
BadDevice);
return Success;
......@@ -119,70 +118,55 @@ ProcXChangeDeviceControl(ClientPtr client)
rep.length = 0;
rep.sequenceNumber = client->sequence;
switch (stuff->control)
{
switch (stuff->control) {
case DEVICE_RESOLUTION:
r = (xDeviceResolutionCtl *) & stuff[1];
if ((len < (sizeof(xDeviceResolutionCtl) >> 2)) ||
(len != (sizeof(xDeviceResolutionCtl)>>2) +
r->num_valuators))
{
(len != (sizeof(xDeviceResolutionCtl) >> 2) + r->num_valuators)) {
SendErrorToClient(client, IReqCode, X_ChangeDeviceControl,
0, BadLength);
return Success;
}
if (!dev->valuator)
{
if (!dev->valuator) {
SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0,
BadMatch);
return Success;
}
if ((dev->grab) && !SameClient(dev->grab, client))
{
if ((dev->grab) && !SameClient(dev->grab, client)) {
rep.status = AlreadyGrabbed;
WriteReplyToClient(client, sizeof(xChangeDeviceControlReply),
&rep);
WriteReplyToClient(client, sizeof(xChangeDeviceControlReply), &rep);
return Success;
}
resolution = (CARD32 *) (r + 1);
if (r->first_valuator + r->num_valuators > dev->valuator->numAxes)
{
if (r->first_valuator + r->num_valuators > dev->valuator->numAxes) {
SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0,
BadValue);
return Success;
}
status = ChangeDeviceControl(client, dev, (xDeviceCtl *) r);
if (status == Success)
{
if (status == Success) {
a = &dev->valuator->axes[r->first_valuator];
for (i = 0; i < r->num_valuators; i++)
if (*(resolution + i) < (a + i)->min_resolution ||
*(resolution+i) > (a+i)->max_resolution)
{
*(resolution + i) > (a + i)->max_resolution) {
SendErrorToClient(client, IReqCode,
X_ChangeDeviceControl, 0, BadValue);
return Success;
}
for (i = 0; i < r->num_valuators; i++)
(a++)->resolution = *resolution++;
}
else if (status == DeviceBusy)
{
} else if (status == DeviceBusy) {
rep.status = DeviceBusy;
WriteReplyToClient(client, sizeof(xChangeDeviceControlReply),
&rep);
WriteReplyToClient(client, sizeof(xChangeDeviceControlReply), &rep);
return Success;
}
else
{
} else {
SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0,
BadMatch);
return Success;
}
break;
default:
SendErrorToClient (client, IReqCode, X_ChangeDeviceControl, 0,
BadValue);
SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0, BadValue);
return Success;
}
WriteReplyToClient(client, sizeof(xChangeDeviceControlReply), &rep);
......
......@@ -114,8 +114,7 @@ ProcXChangeKeyboardDevice(register ClientPtr client)
rep.sequenceNumber = client->sequence;
dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL)
{
if (dev == NULL) {
rep.status = -1;
SendErrorToClient(client, IReqCode, X_ChangeKeyboardDevice, 0,
BadDevice);
......@@ -123,8 +122,7 @@ ProcXChangeKeyboardDevice(register ClientPtr client)
}
k = dev->key;
if (k == NULL)
{
if (k == NULL) {
rep.status = -1;
SendErrorToClient(client, IReqCode, X_ChangeKeyboardDevice, 0,
BadMatch);
......@@ -139,10 +137,8 @@ ProcXChangeKeyboardDevice(register ClientPtr client)
(xkbd->sync.frozen &&
xkbd->sync.other && !SameClient(xkbd->sync.other, client)))
rep.status = GrabFrozen;
else
{
if (ChangeKeyboardDevice (xkbd, dev) != Success)
{
else {
if (ChangeKeyboardDevice(xkbd, dev) != Success) {
SendErrorToClient(client, IReqCode, X_ChangeKeyboardDevice, 0,
BadDevice);
return Success;
......@@ -157,11 +153,11 @@ ProcXChangeKeyboardDevice(register ClientPtr client)
df->revert = xf->revert;
df->time = xf->time;
df->traceGood = xf->traceGood;
if (df->traceSize != xf->traceSize)
{
if (df->traceSize != xf->traceSize) {
Must_have_memory = TRUE; /* XXX */
df->trace = (WindowPtr *) realloc(df->trace,
xf->traceSize * sizeof(WindowPtr));
xf->traceSize *
sizeof(WindowPtr));
Must_have_memory = FALSE; /* XXX */
}
df->traceSize = xf->traceSize;
......@@ -177,13 +173,13 @@ ProcXChangeKeyboardDevice(register ClientPtr client)
SendEventToAllWindows(dev, ChangeDeviceNotifyMask, (xEvent *) & ev, 1);
SendMappingNotify(MappingKeyboard, k->curKeySyms.minKeyCode,
k->curKeySyms.maxKeyCode - k->curKeySyms.minKeyCode + 1,client);
k->curKeySyms.maxKeyCode - k->curKeySyms.minKeyCode +
1, client);
rep.status = 0;
}
WriteReplyToClient (client, sizeof (xChangeKeyboardDeviceReply),
&rep);
WriteReplyToClient(client, sizeof(xChangeKeyboardDeviceReply), &rep);
return Success;
}
......
......@@ -109,8 +109,7 @@ ProcXChangeDeviceKeyMapping(register ClientPtr client)
REQUEST_FIXED_SIZE(xChangeDeviceKeyMappingReq, count * sizeof(CARD32));
dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL)
{
if (dev == NULL) {
SendErrorToClient(client, IReqCode, X_ChangeDeviceKeyMapping, 0,
BadDevice);
return Success;
......@@ -118,11 +117,10 @@ ProcXChangeDeviceKeyMapping(register ClientPtr client)
len = stuff->length - (sizeof(xChangeDeviceKeyMappingReq) >> 2);
ret = ChangeKeyMapping(client, dev, len, DeviceMappingNotify,
stuff->firstKeyCode, stuff->keyCodes, stuff->keySymsPerKeyCode,
(KeySym *)&stuff[1]);
stuff->firstKeyCode, stuff->keyCodes,
stuff->keySymsPerKeyCode, (KeySym *) & stuff[1]);
if (ret != Success)
SendErrorToClient (client, IReqCode, X_ChangeDeviceKeyMapping, 0,
ret);
SendErrorToClient(client, IReqCode, X_ChangeDeviceKeyMapping, 0, ret);
return Success;
}
......@@ -108,24 +108,21 @@ ProcXChangeDeviceDontPropagateList(register ClientPtr client)
REQUEST_AT_LEAST_SIZE(xChangeDeviceDontPropagateListReq);
if (stuff->length != (sizeof(xChangeDeviceDontPropagateListReq) >> 2) +
stuff->count)
{
stuff->count) {
SendErrorToClient(client, IReqCode, X_ChangeDeviceDontPropagateList, 0,
BadLength);
return Success;
}
pWin = (WindowPtr) LookupWindow(stuff->window, client);
if (!pWin)
{
if (!pWin) {
client->errorValue = stuff->window;
SendErrorToClient(client, IReqCode, X_ChangeDeviceDontPropagateList, 0,
BadWindow);
return Success;
}
if (stuff->mode != AddToList && stuff->mode != DeleteFromList)
{
if (stuff->mode != AddToList && stuff->mode != DeleteFromList) {
client->errorValue = stuff->window;
SendErrorToClient(client, IReqCode, X_ChangeDeviceDontPropagateList, 0,
BadMode);
......@@ -133,14 +130,14 @@ ProcXChangeDeviceDontPropagateList(register ClientPtr client)
}
if (CreateMaskFromList(client, (XEventClass *) & stuff[1],
stuff->count, tmp, NULL, X_ChangeDeviceDontPropagateList) != Success)
stuff->count, tmp, NULL,
X_ChangeDeviceDontPropagateList) != Success)
return Success;
others = wOtherInputMasks(pWin);
if (!others && stuff->mode == DeleteFromList)
return Success;
for (i=0; i<EMASKSIZE; i++)
{
for (i = 0; i < EMASKSIZE; i++) {
if (tmp[i].mask == 0)
continue;
......@@ -149,10 +146,10 @@ ProcXChangeDeviceDontPropagateList(register ClientPtr client)
else if (others)
tmp[i].mask |= others->dontPropagateMask[i];
if (DeviceEventSuppressForWindow (pWin,client,tmp[i].mask,i) != Success)
{
SendErrorToClient ( client, IReqCode, X_ChangeDeviceDontPropagateList, 0,
BadClass);
if (DeviceEventSuppressForWindow(pWin, client, tmp[i].mask, i) !=
Success) {
SendErrorToClient(client, IReqCode,
X_ChangeDeviceDontPropagateList, 0, BadClass);
return Success;
}
}
......
......@@ -113,8 +113,7 @@ ProcXChangePointerDevice(register ClientPtr client)
rep.sequenceNumber = client->sequence;
dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL)
{
if (dev == NULL) {
rep.status = -1;
SendErrorToClient(client, IReqCode, X_ChangePointerDevice, 0,
BadDevice);
......@@ -123,9 +122,7 @@ ProcXChangePointerDevice(register ClientPtr client)
v = dev->valuator;
if (v == NULL || v->numAxes < 2 ||
stuff->xaxis >= v->numAxes ||
stuff->yaxis >= v->numAxes)
{
stuff->xaxis >= v->numAxes || stuff->yaxis >= v->numAxes) {
rep.status = -1;
SendErrorToClient(client, IReqCode, X_ChangePointerDevice, 0, BadMatch);
return Success;
......@@ -139,11 +136,9 @@ ProcXChangePointerDevice(register ClientPtr client)
(xptr->sync.frozen &&
xptr->sync.other && !SameClient(xptr->sync.other, client)))
rep.status = GrabFrozen;
else
{
if (ChangePointerDevice (
xptr, dev, stuff->xaxis, stuff->yaxis) != Success)
{
else {
if (ChangePointerDevice(xptr, dev, stuff->xaxis, stuff->yaxis) !=
Success) {
SendErrorToClient(client, IReqCode, X_ChangePointerDevice, 0,
BadDevice);
return Success;
......@@ -168,8 +163,7 @@ ProcXChangePointerDevice(register ClientPtr client)
rep.status = 0;
}
WriteReplyToClient (client, sizeof (xChangePointerDeviceReply),
&rep);
WriteReplyToClient(client, sizeof(xChangePointerDeviceReply), &rep);
return Success;
}
......@@ -193,8 +187,7 @@ SendEventToAllWindows(DeviceIntPtr dev, Mask mask, xEvent * ev, int count)
int i;
WindowPtr pWin, p1;
for (i=0; i<screenInfo.numScreens; i++)
{
for (i = 0; i < screenInfo.numScreens; i++) {
pWin = screenInfo.screens[i]->root;
(void)DeliverEventsToWindow(pWin, ev, count, mask, NullGrab, dev->id);
p1 = pWin->firstChild;
......@@ -215,8 +208,7 @@ FindInterestedChildren(DeviceIntPtr dev, WindowPtr p1, Mask mask,
{
WindowPtr p2;
while (p1)
{
while (p1) {
p2 = p1->firstChild;
(void)DeliverEventsToWindow(p1, ev, count, mask, NullGrab, dev->id);
FindInterestedChildren(dev, p2, mask, ev, count);
......
......@@ -101,8 +101,7 @@ ProcXCloseDevice(register ClientPtr client)
REQUEST_SIZE_MATCH(xCloseDeviceReq);
d = LookupDeviceIntRec(stuff->deviceid);
if (d == NULL)
{
if (d == NULL) {
SendErrorToClient(client, IReqCode, X_CloseDevice, 0, BadDevice);
return Success;
}
......@@ -111,11 +110,10 @@ ProcXCloseDevice(register ClientPtr client)
(*d->DeactivateGrab) (d); /* release active grab */
/* Remove event selections from all windows for events from this device
and selected by this client.
Delete passive grabs from all windows for this device. */
* and selected by this client.
* Delete passive grabs from all windows for this device. */
for (i=0; i<screenInfo.numScreens; i++)
{
for (i = 0; i < screenInfo.numScreens; i++) {
pWin = screenInfo.screens[i]->root;
DeleteDeviceEvents(d, pWin, client);
p1 = pWin->firstChild;
......@@ -138,8 +136,7 @@ DeleteEventsFromChildren(DeviceIntPtr dev, WindowPtr p1, ClientPtr client)
{
WindowPtr p2;
while (p1)
{
while (p1) {
p2 = p1->firstChild;
DeleteDeviceEvents(dev, p1, client);
DeleteEventsFromChildren(dev, p2, client);
......@@ -162,13 +159,11 @@ DeleteDeviceEvents(DeviceIntPtr dev, WindowPtr pWin, ClientPtr client)
GrabPtr grab, next;
if ((pOthers = wOtherInputMasks(pWin)) != 0)
for (others=pOthers->inputClients; others;
others = others->next)
for (others = pOthers->inputClients; others; others = others->next)
if (SameClient(others, client))
others->mask[dev->id] = NoEventMask;
for (grab = wPassiveGrabs(pWin); grab; grab=next)
{
for (grab = wPassiveGrabs(pWin); grab; grab = next) {
next = grab->next;
if ((grab->device == dev) &&
(client->clientAsMask == CLIENT_BITS(grab->resource)))
......
......@@ -103,26 +103,22 @@ ProcXDeviceBell(register ClientPtr client)
REQUEST_SIZE_MATCH(xDeviceBellReq);
dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL)
{
if (dev == NULL) {
client->errorValue = stuff->deviceid;
SendErrorToClient(client, IReqCode, X_DeviceBell, 0, BadDevice);
return Success;
}
if (stuff->percent < -100 || stuff->percent > 100)
{
if (stuff->percent < -100 || stuff->percent > 100) {
client->errorValue = stuff->percent;
SendErrorToClient(client, IReqCode, X_DeviceBell, 0, BadValue);
return Success;
}
if (stuff->feedbackclass == KbdFeedbackClass)
{
if (stuff->feedbackclass == KbdFeedbackClass) {
for (k = dev->kbdfeed; k; k = k->next)
if (k->ctrl.id == stuff->feedbackid)
break;
if (!k)
{
if (!k) {
client->errorValue = stuff->feedbackid;
SendErrorToClient(client, IReqCode, X_DeviceBell, 0, BadValue);
return Success;
......@@ -131,14 +127,11 @@ ProcXDeviceBell(register ClientPtr client)
proc = k->BellProc;
ctrl = (void *)&(k->ctrl);
class = KbdFeedbackClass;
}
else if (stuff->feedbackclass == BellFeedbackClass)
{
} else if (stuff->feedbackclass == BellFeedbackClass) {
for (b = dev->bell; b; b = b->next)
if (b->ctrl.id == stuff->feedbackid)
break;
if (!b)
{
if (!b) {
client->errorValue = stuff->feedbackid;
SendErrorToClient(client, IReqCode, X_DeviceBell, 0, BadValue);
return Success;
......@@ -147,9 +140,7 @@ ProcXDeviceBell(register ClientPtr client)
proc = b->BellProc;
ctrl = (void *)&(b->ctrl);
class = BellFeedbackClass;
}
else
{
} else {
client->errorValue = stuff->feedbackclass;
SendErrorToClient(client, IReqCode, X_DeviceBell, 0, BadValue);
return Success;
......
......@@ -120,24 +120,26 @@ struct dev_type
{
Atom type;
char *name;
}dev_type [] = {{0,XI_KEYBOARD},
{0,XI_MOUSE},
{0,XI_TABLET},
{0,XI_TOUCHSCREEN},
{0,XI_TOUCHPAD},
{0,XI_BARCODE},
{0,XI_BUTTONBOX},
{0,XI_KNOB_BOX},
{0,XI_ONE_KNOB},
{0,XI_NINE_KNOB},
{0,XI_TRACKBALL},
{0,XI_QUADRATURE},
{0,XI_ID_MODULE},
{0,XI_SPACEBALL},
{0,XI_DATAGLOVE},
{0,XI_EYETRACKER},
{0,XI_CURSORKEYS},
{0,XI_FOOTMOUSE}};
} dev_type[] = {
{
0, XI_KEYBOARD}, {
0, XI_MOUSE}, {
0, XI_TABLET}, {
0, XI_TOUCHSCREEN}, {
0, XI_TOUCHPAD}, {
0, XI_BARCODE}, {
0, XI_BUTTONBOX}, {
0, XI_KNOB_BOX}, {
0, XI_ONE_KNOB}, {
0, XI_NINE_KNOB}, {
0, XI_TRACKBALL}, {
0, XI_QUADRATURE}, {
0, XI_ID_MODULE}, {
0, XI_SPACEBALL}, {
0, XI_DATAGLOVE}, {
0, XI_EYETRACKER}, {
0, XI_CURSORKEYS}, {
0, XI_FOOTMOUSE}};
CARD8 event_base[numInputClasses];
XExtEventInfo EventInfo[32];
......@@ -223,8 +225,7 @@ XInputExtensionInit()
extEntry = AddExtension(INAME, IEVENTS, IERRORS, ProcIDispatch,
SProcIDispatch, IResetProc, StandardMinorOpcode);
if (extEntry)
{
if (extEntry) {
IReqCode = extEntry->base;
AllExtensionVersions[IReqCode - 128] = thisversion;
MakeDeviceTypeAtoms();
......@@ -246,9 +247,7 @@ XInputExtensionInit()
EventSwapVector[DeviceButtonStateNotify] = SEventIDispatch;
EventSwapVector[DeviceMappingNotify] = SEventIDispatch;
EventSwapVector[ChangeDeviceNotify] = SEventIDispatch;
}
else
{
} else {
FatalError("IExtensionInit: AddExtensions failed\n");
}
}
......@@ -334,8 +333,7 @@ ProcIDispatch(register ClientPtr client)
return (ProcXGetDeviceControl(client));
else if (stuff->data == X_ChangeDeviceControl)
return (ProcXChangeDeviceControl(client));
else
{
else {
SendErrorToClient(client, IReqCode, stuff->data, 0, BadRequest);
}
return (BadRequest);
......@@ -424,8 +422,7 @@ SProcIDispatch(register ClientPtr client)
return (SProcXGetDeviceControl(client));
else if (stuff->data == X_ChangeDeviceControl)
return (SProcXChangeDeviceControl(client));
else
{
else {
SendErrorToClient(client, IReqCode, stuff->data, 0, BadRequest);
}
return (BadRequest);
......@@ -448,7 +445,8 @@ SReplyIDispatch(ClientPtr client, int len, xGrabDeviceReply * rep)
/* All we look at is the type field */
{ /* This is common to all replies */
if (rep->RepType == X_GetExtensionVersion)
SRepXGetExtensionVersion (client, len, (xGetExtensionVersionReply *)rep);
SRepXGetExtensionVersion(client, len,
(xGetExtensionVersionReply *) rep);
else if (rep->RepType == X_ListInputDevices)
SRepXListInputDevices(client, len, (xListInputDevicesReply *) rep);
else if (rep->RepType == X_OpenDevice)
......@@ -456,15 +454,22 @@ SReplyIDispatch(ClientPtr client, int len, xGrabDeviceReply * rep)
else if (rep->RepType == X_SetDeviceMode)
SRepXSetDeviceMode(client, len, (xSetDeviceModeReply *) rep);
else if (rep->RepType == X_GetSelectedExtensionEvents)
SRepXGetSelectedExtensionEvents (client, len, (xGetSelectedExtensionEventsReply *) rep);
SRepXGetSelectedExtensionEvents(client, len,
(xGetSelectedExtensionEventsReply *)
rep);
else if (rep->RepType == X_GetDeviceDontPropagateList)
SRepXGetDeviceDontPropagateList (client, len, (xGetDeviceDontPropagateListReply *)rep);
SRepXGetDeviceDontPropagateList(client, len,
(xGetDeviceDontPropagateListReply *)
rep);
else if (rep->RepType == X_GetDeviceMotionEvents)
SRepXGetDeviceMotionEvents (client, len, (xGetDeviceMotionEventsReply *) rep);
SRepXGetDeviceMotionEvents(client, len,
(xGetDeviceMotionEventsReply *) rep);
else if (rep->RepType == X_ChangeKeyboardDevice)
SRepXChangeKeyboardDevice (client, len, (xChangeKeyboardDeviceReply *) rep);
SRepXChangeKeyboardDevice(client, len,
(xChangeKeyboardDeviceReply *) rep);
else if (rep->RepType == X_ChangePointerDevice)
SRepXChangePointerDevice (client, len, (xChangePointerDeviceReply *)rep);
SRepXChangePointerDevice(client, len,
(xChangePointerDeviceReply *) rep);
else if (rep->RepType == X_GrabDevice)
SRepXGrabDevice(client, len, (xGrabDeviceReply *) rep);
else if (rep->RepType == X_GetDeviceFocus)
......@@ -472,15 +477,20 @@ SReplyIDispatch(ClientPtr client, int len, xGrabDeviceReply * rep)
else if (rep->RepType == X_GetFeedbackControl)
SRepXGetFeedbackControl(client, len, (xGetFeedbackControlReply *) rep);
else if (rep->RepType == X_GetDeviceKeyMapping)
SRepXGetDeviceKeyMapping (client, len, (xGetDeviceKeyMappingReply *)rep);
SRepXGetDeviceKeyMapping(client, len,
(xGetDeviceKeyMappingReply *) rep);
else if (rep->RepType == X_GetDeviceModifierMapping)
SRepXGetDeviceModifierMapping (client, len, (xGetDeviceModifierMappingReply *)rep);
SRepXGetDeviceModifierMapping(client, len,
(xGetDeviceModifierMappingReply *) rep);
else if (rep->RepType == X_SetDeviceModifierMapping)
SRepXSetDeviceModifierMapping (client, len, (xSetDeviceModifierMappingReply *)rep);
SRepXSetDeviceModifierMapping(client, len,
(xSetDeviceModifierMappingReply *) rep);
else if (rep->RepType == X_GetDeviceButtonMapping)
SRepXGetDeviceButtonMapping (client, len, (xGetDeviceButtonMappingReply *)rep);
SRepXGetDeviceButtonMapping(client, len,
(xGetDeviceButtonMappingReply *) rep);
else if (rep->RepType == X_SetDeviceButtonMapping)
SRepXSetDeviceButtonMapping (client, len, (xSetDeviceButtonMappingReply *)rep);
SRepXSetDeviceButtonMapping(client, len,
(xSetDeviceButtonMappingReply *) rep);
else if (rep->RepType == X_QueryDeviceState)
SRepXQueryDeviceState(client, len, (xQueryDeviceStateReply *) rep);
else if (rep->RepType == X_SetDeviceValuators)
......@@ -488,9 +498,9 @@ SReplyIDispatch(ClientPtr client, int len, xGrabDeviceReply * rep)
else if (rep->RepType == X_GetDeviceControl)
SRepXGetDeviceControl(client, len, (xGetDeviceControlReply *) rep);
else if (rep->RepType == X_ChangeDeviceControl)
SRepXChangeDeviceControl (client, len, (xChangeDeviceControlReply *)rep);
else
{
SRepXChangeDeviceControl(client, len,
(xChangeDeviceControlReply *) rep);
else {
FatalError("XINPUT confused sending swapped reply");
}
}
......@@ -510,46 +520,32 @@ SEventIDispatch(xEvent * from, xEvent * to)
if (type == DeviceValuator)
DO_SWAP(SEventDeviceValuator, deviceValuator);
else if (type == DeviceKeyPress)
{
else if (type == DeviceKeyPress) {
SKeyButtonPtrEvent(from, to);
to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
}
else if (type == DeviceKeyRelease)
{
} else if (type == DeviceKeyRelease) {
SKeyButtonPtrEvent(from, to);
to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
}
else if (type == DeviceButtonPress)
{
} else if (type == DeviceButtonPress) {
SKeyButtonPtrEvent(from, to);
to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
}
else if (type == DeviceButtonRelease)
{
} else if (type == DeviceButtonRelease) {
SKeyButtonPtrEvent(from, to);
to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
}
else if (type == DeviceMotionNotify)
{
} else if (type == DeviceMotionNotify) {
SKeyButtonPtrEvent(from, to);
to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
}
else if (type == DeviceFocusIn)
} else if (type == DeviceFocusIn)
DO_SWAP(SEventFocus, deviceFocus);
else if (type == DeviceFocusOut)
DO_SWAP(SEventFocus, deviceFocus);
else if (type == ProximityIn)
{
else if (type == ProximityIn) {
SKeyButtonPtrEvent(from, to);
to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
}
else if (type == ProximityOut)
{
} else if (type == ProximityOut) {
SKeyButtonPtrEvent(from, to);
to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
}
else if (type == DeviceStateNotify)
} else if (type == DeviceStateNotify)
DO_SWAP(SDeviceStateNotifyEvent, deviceStateNotify);
else if (type == DeviceKeyStateNotify)
DO_SWAP(SDeviceKeyStateNotifyEvent, deviceKeyStateNotify);
......@@ -559,8 +555,7 @@ SEventIDispatch(xEvent * from, xEvent * to)
DO_SWAP(SDeviceMappingNotifyEvent, deviceMappingNotify);
else if (type == ChangeDeviceNotify)
DO_SWAP(SChangeDeviceNotifyEvent, changeDeviceNotify);
else
{
else {
FatalError("XInputExtension: Impossible event!\n");
}
}
......@@ -606,8 +601,7 @@ SDeviceStateNotifyEvent(deviceStateNotify * from, deviceStateNotify * to)
swaps(&to->sequenceNumber);
swapl(&to->time);
ip = &to->valuator0;
for (i=0; i<3; i++)
{
for (i = 0; i < 3; i++) {
swapl((ip + i)); /* macro - braces are required */
}
}
......@@ -759,8 +753,7 @@ RestoreExtensionEvents()
IReqCode = 0;
for (i=0; i<ExtEventIndex-1; i++)
{
for (i = 0; i < ExtEventIndex - 1; i++) {
if ((EventInfo[i].type >= LASTEvent) && (EventInfo[i].type < 128))
SetMaskForEvent(0, EventInfo[i].type);
EventInfo[i].mask = 0;
......@@ -865,10 +858,8 @@ LookupDeviceIntRec(CARD8 id)
{
DeviceIntPtr dev;
for (dev=inputInfo.devices; dev; dev=dev->next)
{
if (dev->id == id)
{
for (dev = inputInfo.devices; dev; dev = dev->next) {
if (dev->id == id) {
if (id == inputInfo.pointer->id || id == inputInfo.keyboard->id)
return (NULL);
return (dev);
......@@ -922,8 +913,7 @@ GetNextExtEventMask()
int i;
Mask mask = lastExtEventMask;
if (lastExtEventMask == 0)
{
if (lastExtEventMask == 0) {
FatalError("GetNextExtEventMask: no more events are available.");
}
lastExtEventMask <<= 1;
......
......@@ -103,16 +103,14 @@ ProcXGetDeviceButtonMapping(register ClientPtr client)
rep.sequenceNumber = client->sequence;
dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL)
{
if (dev == NULL) {
SendErrorToClient(client, IReqCode, X_GetDeviceButtonMapping, 0,
BadDevice);
return Success;
}
b = dev->button;
if (b == NULL)
{
if (b == NULL) {
SendErrorToClient(client, IReqCode, X_GetDeviceButtonMapping, 0,
BadMatch);
return Success;
......@@ -120,8 +118,7 @@ ProcXGetDeviceButtonMapping(register ClientPtr client)
rep.nElts = b->numButtons;
rep.length = (rep.nElts + (4 - 1)) / 4;
WriteReplyToClient(client, sizeof(xGetDeviceButtonMappingReply), &rep);
WriteToClient(client, rep.nElts,
(char *)&b->map[1]);
WriteToClient(client, rep.nElts, (char *)&b->map[1]);
return Success;
}
......
......@@ -101,10 +101,8 @@ ProcXGetDeviceControl(ClientPtr client)
REQUEST_SIZE_MATCH(xGetDeviceControlReq);
dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL)
{
SendErrorToClient (client, IReqCode, X_GetDeviceControl, 0,
BadDevice);
if (dev == NULL) {
SendErrorToClient(client, IReqCode, X_GetDeviceControl, 0, BadDevice);
return Success;
}
......@@ -113,11 +111,9 @@ ProcXGetDeviceControl(ClientPtr client)
rep.length = 0;
rep.sequenceNumber = client->sequence;
switch (stuff->control)
{
switch (stuff->control) {
case DEVICE_RESOLUTION:
if (!dev->valuator)
{
if (!dev->valuator) {
SendErrorToClient(client, IReqCode, X_GetDeviceControl, 0,
BadMatch);
return Success;
......@@ -126,25 +122,20 @@ ProcXGetDeviceControl(ClientPtr client)
(3 * sizeof(int) * dev->valuator->numAxes);
break;
default:
SendErrorToClient (client, IReqCode, X_GetDeviceControl, 0,
BadValue);
SendErrorToClient(client, IReqCode, X_GetDeviceControl, 0, BadValue);
return Success;
}
buf = (char *)malloc(total_length);
if (!buf)
{
SendErrorToClient(client, IReqCode, X_GetDeviceControl, 0,
BadAlloc);
if (!buf) {
SendErrorToClient(client, IReqCode, X_GetDeviceControl, 0, BadAlloc);
return Success;
}
savbuf = buf;
switch (stuff->control)
{
switch (stuff->control) {
case DEVICE_RESOLUTION:
CopySwapDeviceResolution(client, dev->valuator, buf,
total_length);
CopySwapDeviceResolution(client, dev->valuator, buf, total_length);
break;
default:
break;
......@@ -183,14 +174,12 @@ CopySwapDeviceResolution(ClientPtr client, ValuatorClassPtr v, char *buf,
*iptr++ = a->min_resolution;
for (i = 0, a = v->axes; i < v->numAxes; i++, a++)
*iptr++ = a->max_resolution;
if (client->swapped)
{
if (client->swapped) {
swaps(&r->control);
swaps(&r->length);
swapl(&r->num_valuators);
iptr = (int *)buf;
for (i=0; i < (3 * v->numAxes); i++,iptr++)
{
for (i = 0; i < (3 * v->numAxes); i++, iptr++) {
swapl(iptr);
}
}
......
......@@ -105,10 +105,8 @@ ProcXGetFeedbackControl(ClientPtr client)
REQUEST_SIZE_MATCH(xGetFeedbackControlReq);
dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL)
{
SendErrorToClient (client, IReqCode, X_GetFeedbackControl, 0,
BadDevice);
if (dev == NULL) {
SendErrorToClient(client, IReqCode, X_GetFeedbackControl, 0, BadDevice);
return Success;
}
......@@ -118,50 +116,40 @@ ProcXGetFeedbackControl(ClientPtr client)
rep.sequenceNumber = client->sequence;
rep.num_feedbacks = 0;
for (k=dev->kbdfeed; k; k=k->next)
{
for (k = dev->kbdfeed; k; k = k->next) {
rep.num_feedbacks++;
total_length += sizeof(xKbdFeedbackState);
}
for (p=dev->ptrfeed; p; p=p->next)
{
for (p = dev->ptrfeed; p; p = p->next) {
rep.num_feedbacks++;
total_length += sizeof(xPtrFeedbackState);
}
for (s=dev->stringfeed; s; s=s->next)
{
for (s = dev->stringfeed; s; s = s->next) {
rep.num_feedbacks++;
total_length += sizeof(xStringFeedbackState) +
(s->ctrl.num_symbols_supported * sizeof(KeySym));
}
for (i=dev->intfeed; i; i=i->next)
{
for (i = dev->intfeed; i; i = i->next) {
rep.num_feedbacks++;
total_length += sizeof(xIntegerFeedbackState);
}
for (l=dev->leds; l; l=l->next)
{
for (l = dev->leds; l; l = l->next) {
rep.num_feedbacks++;
total_length += sizeof(xLedFeedbackState);
}
for (b=dev->bell; b; b=b->next)
{
for (b = dev->bell; b; b = b->next) {
rep.num_feedbacks++;
total_length += sizeof(xBellFeedbackState);
}
if (total_length == 0)
{
SendErrorToClient(client, IReqCode, X_GetFeedbackControl, 0,
BadMatch);
if (total_length == 0) {
SendErrorToClient(client, IReqCode, X_GetFeedbackControl, 0, BadMatch);
return Success;
}
buf = (char *)malloc(total_length);
if (!buf)
{
SendErrorToClient(client, IReqCode, X_GetFeedbackControl, 0,
BadAlloc);
if (!buf) {
SendErrorToClient(client, IReqCode, X_GetFeedbackControl, 0, BadAlloc);
return Success;
}
savbuf = buf;
......@@ -210,8 +198,7 @@ CopySwapKbdFeedback(ClientPtr client, KbdFeedbackPtr k, char **buf)
k2->global_auto_repeat = k->ctrl.autoRepeat;
for (i = 0; i < 32; i++)
k2->auto_repeats[i] = k->ctrl.autoRepeats[i];
if (client->swapped)
{
if (client->swapped) {
swaps(&k2->length);
swaps(&k2->pitch);
swaps(&k2->duration);
......@@ -239,8 +226,7 @@ CopySwapPtrFeedback(ClientPtr client, PtrFeedbackPtr p, char **buf)
p2->accelNum = p->ctrl.num;
p2->accelDenom = p->ctrl.den;
p2->threshold = p->ctrl.threshold;
if (client->swapped)
{
if (client->swapped) {
swaps(&p2->length);
swaps(&p2->accelNum);
swaps(&p2->accelDenom);
......@@ -267,8 +253,7 @@ CopySwapIntegerFeedback(ClientPtr client, IntegerFeedbackPtr i, char **buf)
i2->resolution = i->ctrl.resolution;
i2->min_value = i->ctrl.min_value;
i2->max_value = i->ctrl.max_value;
if (client->swapped)
{
if (client->swapped) {
swaps(&i2->length);
swapl(&i2->resolution);
swapl(&i2->min_value);
......@@ -301,14 +286,12 @@ CopySwapStringFeedback(ClientPtr client, StringFeedbackPtr s, char **buf)
kptr = (KeySym *) (*buf);
for (i = 0; i < s->ctrl.num_symbols_supported; i++)
*kptr++ = *(s->ctrl.symbols_supported + i);
if (client->swapped)
{
if (client->swapped) {
swaps(&s2->length);
swaps(&s2->max_symbols);
swaps(&s2->num_syms_supported);
kptr = (KeySym *) (*buf);
for (i=0; i<s->ctrl.num_symbols_supported; i++,kptr++)
{
for (i = 0; i < s->ctrl.num_symbols_supported; i++, kptr++) {
swapl(kptr);
}
}
......@@ -332,8 +315,7 @@ CopySwapLedFeedback(ClientPtr client, LedFeedbackPtr l, char **buf)
l2->id = l->ctrl.id;
l2->led_values = l->ctrl.led_values;
l2->led_mask = l->ctrl.led_mask;
if (client->swapped)
{
if (client->swapped) {
swaps(&l2->length);
swapl(&l2->led_values);
swapl(&l2->led_mask);
......@@ -359,8 +341,7 @@ CopySwapBellFeedback(ClientPtr client, BellFeedbackPtr b, char **buf)
b2->percent = b->ctrl.percent;
b2->pitch = b->ctrl.pitch;
b2->duration = b->ctrl.duration;
if (client->swapped)
{
if (client->swapped) {
swaps(&b2->length);
swaps(&b2->pitch);
swaps(&b2->duration);
......
......@@ -98,8 +98,7 @@ ProcXGetDeviceFocus(ClientPtr client)
REQUEST_SIZE_MATCH(xGetDeviceFocusReq);
dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL || !dev->focus)
{
if (dev == NULL || !dev->focus) {
SendErrorToClient(client, IReqCode, X_GetDeviceFocus, 0, BadDevice);
return Success;
}
......
......@@ -99,35 +99,28 @@ ProcXGetDeviceKeyMapping(register ClientPtr client)
REQUEST_SIZE_MATCH(xGetDeviceKeyMappingReq);
dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL)
{
if (dev == NULL) {
SendErrorToClient(client, IReqCode, X_GetDeviceKeyMapping, 0,
BadDevice);
return Success;
}
if (dev->key == NULL)
{
SendErrorToClient (client, IReqCode, X_GetDeviceKeyMapping, 0,
BadMatch);
if (dev->key == NULL) {
SendErrorToClient(client, IReqCode, X_GetDeviceKeyMapping, 0, BadMatch);
return Success;
}
k = &dev->key->curKeySyms;
if ((stuff->firstKeyCode < k->minKeyCode) ||
(stuff->firstKeyCode > k->maxKeyCode))
{
(stuff->firstKeyCode > k->maxKeyCode)) {
client->errorValue = stuff->firstKeyCode;
SendErrorToClient (client, IReqCode, X_GetDeviceKeyMapping, 0,
BadValue);
SendErrorToClient(client, IReqCode, X_GetDeviceKeyMapping, 0, BadValue);
return Success;
}
if (stuff->firstKeyCode + stuff->count > k->maxKeyCode + 1)
{
if (stuff->firstKeyCode + stuff->count > k->maxKeyCode + 1) {
client->errorValue = stuff->count;
SendErrorToClient (client, IReqCode, X_GetDeviceKeyMapping, 0,
BadValue);
SendErrorToClient(client, IReqCode, X_GetDeviceKeyMapping, 0, BadValue);
return Success;
}
......@@ -139,8 +132,7 @@ ProcXGetDeviceKeyMapping(register ClientPtr client)
WriteReplyToClient(client, sizeof(xGetDeviceKeyMappingReply), &rep);
client->pSwapReplyFunc = (ReplySwapPtr) CopySwap32Write;
WriteSwappedDataToClient(
client,
WriteSwappedDataToClient(client,
k->mapWidth * stuff->count * sizeof(KeySym),
&k->map[(stuff->firstKeyCode - k->minKeyCode) *
k->mapWidth]);
......
......@@ -99,16 +99,14 @@ ProcXGetDeviceModifierMapping(ClientPtr client)
REQUEST_SIZE_MATCH(xGetDeviceModifierMappingReq);
dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL)
{
if (dev == NULL) {
SendErrorToClient(client, IReqCode, X_GetDeviceModifierMapping, 0,
BadDevice);
return Success;
}
kp = dev->key;
if (kp == NULL)
{
if (kp == NULL) {
SendErrorToClient(client, IReqCode, X_GetDeviceModifierMapping, 0,
BadMatch);
return Success;
......
......@@ -113,21 +113,18 @@ ProcXGetDeviceDontPropagateList(register ClientPtr client)
rep.count = 0;
pWin = (WindowPtr) LookupWindow(stuff->window, client);
if (!pWin)
{
if (!pWin) {
client->errorValue = stuff->window;
SendErrorToClient(client, IReqCode, X_GetDeviceDontPropagateList, 0,
BadWindow);
return Success;
}
if ((others = wOtherInputMasks(pWin)) != 0)
{
if ((others = wOtherInputMasks(pWin)) != 0) {
for (i = 0; i < EMASKSIZE; i++)
tbuf = ClassFromMask(NULL, others->dontPropagateMask[i], i,
&count, COUNT);
if (count)
{
if (count) {
rep.count = count;
buf = (XEventClass *) malloc(rep.count * sizeof(XEventClass));
rep.length = (rep.count * sizeof(XEventClass) + 3) >> 2;
......@@ -139,11 +136,9 @@ ProcXGetDeviceDontPropagateList(register ClientPtr client)
}
}
WriteReplyToClient (client, sizeof (xGetDeviceDontPropagateListReply),
&rep);
WriteReplyToClient(client, sizeof(xGetDeviceDontPropagateListReply), &rep);
if (count)
{
if (count) {
client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
WriteSwappedDataToClient(client, count * sizeof(XEventClass), buf);
free(buf);
......@@ -167,11 +162,9 @@ XEventClass
Mask tmask = 0x80000000;
for (i = 0; i < 32; i++, tmask >>= 1)
if (tmask & mask)
{
if (tmask & mask) {
for (j = 0; j < ExtEventIndex; j++)
if (EventInfo[j].mask == tmask)
{
if (EventInfo[j].mask == tmask) {
if (mode == COUNT)
(*count)++;
else
......
......@@ -115,23 +115,20 @@ ProcXGetSelectedExtensionEvents(register ClientPtr client)
rep.this_client_count = 0;
rep.all_clients_count = 0;
if (!(pWin = LookupWindow(stuff->window, client)))
{
if (!(pWin = LookupWindow(stuff->window, client))) {
SendErrorToClient(client, IReqCode, X_GetSelectedExtensionEvents, 0,
BadWindow);
return Success;
}
if ((pOthers = wOtherInputMasks(pWin)) != 0)
{
if ((pOthers = wOtherInputMasks(pWin)) != 0) {
for (others = pOthers->inputClients; others; others = others->next)
for (i = 0; i < EMASKSIZE; i++)
tclient = ClassFromMask(NULL, others->mask[i], i,
&rep.all_clients_count, COUNT);
for (others = pOthers->inputClients; others; others = others->next)
if (SameClient(others, client))
{
if (SameClient(others, client)) {
for (i = 0; i < EMASKSIZE; i++)
tclient = ClassFromMask(NULL, others->mask[i], i,
&rep.this_client_count, COUNT);
......@@ -147,17 +144,18 @@ ProcXGetSelectedExtensionEvents(register ClientPtr client)
aclient = buf + rep.this_client_count;
if (others)
for (i = 0; i < EMASKSIZE; i++)
tclient = ClassFromMask (tclient, others->mask[i], i, NULL, CREATE);
tclient =
ClassFromMask(tclient, others->mask[i], i, NULL, CREATE);
for (others = pOthers->inputClients; others; others = others->next)
for (i = 0; i < EMASKSIZE; i++)
aclient = ClassFromMask (aclient, others->mask[i], i, NULL, CREATE);
aclient =
ClassFromMask(aclient, others->mask[i], i, NULL, CREATE);
}
WriteReplyToClient(client, sizeof(xGetSelectedExtensionEventsReply), &rep);
if (total_length)
{
if (total_length) {
client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
WriteSwappedDataToClient(client, total_length, buf);
free(buf);
......
......@@ -99,8 +99,7 @@ ProcXGetExtensionVersion(register ClientPtr client)
REQUEST_AT_LEAST_SIZE(xGetExtensionVersionReq);
if (stuff->length != (sizeof(xGetExtensionVersionReq) +
stuff->nbytes + 3)>>2)
{
stuff->nbytes + 3) >> 2) {
SendErrorToClient(client, IReqCode, X_GetExtensionVersion, 0,
BadLength);
return Success;
......@@ -115,12 +114,9 @@ ProcXGetExtensionVersion(register ClientPtr client)
rep.minor_version = 0;
rep.present = TRUE;
if (rep.present)
{
rep.major_version =
AllExtensionVersions[IReqCode-128].major_version;
rep.minor_version =
AllExtensionVersions[IReqCode-128].minor_version;
if (rep.present) {
rep.major_version = AllExtensionVersions[IReqCode - 128].major_version;
rep.minor_version = AllExtensionVersions[IReqCode - 128].minor_version;
}
WriteReplyToClient(client, sizeof(xGetExtensionVersionReply), &rep);
......
......@@ -113,8 +113,7 @@ ProcXGrabDevice(ClientPtr client)
REQUEST(xGrabDeviceReq);
REQUEST_AT_LEAST_SIZE(xGrabDeviceReq);
if (stuff->length !=(sizeof(xGrabDeviceReq)>>2) + stuff->event_count)
{
if (stuff->length != (sizeof(xGrabDeviceReq) >> 2) + stuff->event_count) {
SendErrorToClient(client, IReqCode, X_GrabDevice, 0, BadLength);
return Success;
}
......@@ -125,22 +124,22 @@ ProcXGrabDevice(ClientPtr client)
rep.length = 0;
dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL)
{
if (dev == NULL) {
SendErrorToClient(client, IReqCode, X_GrabDevice, 0, BadDevice);
return Success;
}
if (CreateMaskFromList(client, (XEventClass *) & stuff[1],
stuff->event_count, tmp, dev, X_GrabDevice) != Success)
stuff->event_count, tmp, dev,
X_GrabDevice) != Success)
return Success;
error = GrabDevice(client, dev, stuff->this_device_mode,
stuff->other_devices_mode, stuff->grabWindow, stuff->ownerEvents,
stuff->time, tmp[stuff->deviceid].mask, &rep.status);
stuff->other_devices_mode, stuff->grabWindow,
stuff->ownerEvents, stuff->time,
tmp[stuff->deviceid].mask, &rep.status);
if (error != Success)
{
if (error != Success) {
SendErrorToClient(client, IReqCode, X_GrabDevice, 0, error);
return Success;
}
......@@ -163,30 +162,25 @@ CreateMaskFromList(ClientPtr client, XEventClass * list, int count,
int device;
DeviceIntPtr tdev;
for (i=0; i<EMASKSIZE; i++)
{
for (i = 0; i < EMASKSIZE; i++) {
mask[i].mask = 0;
mask[i].dev = NULL;
}
for (i=0; i<count; i++, list++)
{
for (i = 0; i < count; i++, list++) {
device = *list >> 8;
if (device > 255)
{
if (device > 255) {
SendErrorToClient(client, IReqCode, req, 0, BadClass);
return BadClass;
}
tdev = LookupDeviceIntRec(device);
if (tdev==NULL || (dev != NULL && tdev != dev))
{
if (tdev == NULL || (dev != NULL && tdev != dev)) {
SendErrorToClient(client, IReqCode, req, 0, BadClass);
return BadClass;
}
for (j = 0; j < ExtEventIndex; j++)
if (EventInfo[j].type == (*list & 0xff))
{
if (EventInfo[j].type == (*list & 0xff)) {
mask[device].mask |= EventInfo[j].mask;
mask[device].dev = (Pointer) tdev;
break;
......
......@@ -109,47 +109,42 @@ ProcXGrabDeviceButton(ClientPtr client)
REQUEST(xGrabDeviceButtonReq);
REQUEST_AT_LEAST_SIZE(xGrabDeviceButtonReq);
if (stuff->length !=(sizeof(xGrabDeviceButtonReq)>>2) + stuff->event_count)
{
if (stuff->length !=
(sizeof(xGrabDeviceButtonReq) >> 2) + stuff->event_count) {
SendErrorToClient(client, IReqCode, X_GrabDeviceButton, 0, BadLength);
return Success;
}
dev = LookupDeviceIntRec(stuff->grabbed_device);
if (dev == NULL)
{
SendErrorToClient(client, IReqCode, X_GrabDeviceButton, 0,
BadDevice);
if (dev == NULL) {
SendErrorToClient(client, IReqCode, X_GrabDeviceButton, 0, BadDevice);
return Success;
}
if (stuff->modifier_device != UseXKeyboard)
{
if (stuff->modifier_device != UseXKeyboard) {
mdev = LookupDeviceIntRec(stuff->modifier_device);
if (mdev == NULL)
{
if (mdev == NULL) {
SendErrorToClient(client, IReqCode, X_GrabDeviceButton, 0,
BadDevice);
return Success;
}
if (mdev->key == NULL)
{
if (mdev->key == NULL) {
SendErrorToClient(client, IReqCode, X_GrabDeviceButton, 0,
BadMatch);
return Success;
}
}
else
} else
mdev = (DeviceIntPtr) LookupKeyboardDevice();
class = (XEventClass *) (&stuff[1]); /* first word of values */
if ((ret = CreateMaskFromList(client, class,
stuff->event_count, tmp, dev, X_GrabDeviceButton)) != Success)
stuff->event_count, tmp, dev,
X_GrabDeviceButton)) != Success)
return Success;
ret = GrabButton(client, dev, stuff->this_device_mode,
stuff->other_devices_mode, stuff->modifiers, mdev, stuff->button,
stuff->grabWindow, stuff->ownerEvents, (Cursor)0, (Window)0,
tmp[stuff->grabbed_device].mask);
stuff->other_devices_mode, stuff->modifiers, mdev,
stuff->button, stuff->grabWindow, stuff->ownerEvents,
(Cursor) 0, (Window) 0, tmp[stuff->grabbed_device].mask);
if (ret != Success)
SendErrorToClient(client, IReqCode, X_GrabDeviceButton, 0, ret);
......
......@@ -107,51 +107,43 @@ ProcXGrabDeviceKey(ClientPtr client)
REQUEST(xGrabDeviceKeyReq);
REQUEST_AT_LEAST_SIZE(xGrabDeviceKeyReq);
if (stuff->length !=(sizeof(xGrabDeviceKeyReq)>>2) + stuff->event_count)
{
if (stuff->length != (sizeof(xGrabDeviceKeyReq) >> 2) + stuff->event_count) {
SendErrorToClient(client, IReqCode, X_GrabDeviceKey, 0, BadLength);
return Success;
}
dev = LookupDeviceIntRec(stuff->grabbed_device);
if (dev == NULL)
{
SendErrorToClient(client, IReqCode, X_GrabDeviceKey, 0,
BadDevice);
if (dev == NULL) {
SendErrorToClient(client, IReqCode, X_GrabDeviceKey, 0, BadDevice);
return Success;
}
if (stuff->modifier_device != UseXKeyboard)
{
if (stuff->modifier_device != UseXKeyboard) {
mdev = LookupDeviceIntRec(stuff->modifier_device);
if (mdev == NULL)
{
SendErrorToClient(client, IReqCode, X_GrabDeviceKey, 0,
BadDevice);
if (mdev == NULL) {
SendErrorToClient(client, IReqCode, X_GrabDeviceKey, 0, BadDevice);
return Success;
}
if (mdev->key == NULL)
{
SendErrorToClient(client, IReqCode, X_GrabDeviceKey, 0,
BadMatch);
if (mdev->key == NULL) {
SendErrorToClient(client, IReqCode, X_GrabDeviceKey, 0, BadMatch);
return Success;
}
}
else
} else
mdev = (DeviceIntPtr) LookupKeyboardDevice();
class = (XEventClass *) (&stuff[1]); /* first word of values */
if ((ret = CreateMaskFromList(client, class,
stuff->event_count, tmp, dev, X_GrabDeviceKey)) != Success)
stuff->event_count, tmp, dev,
X_GrabDeviceKey)) != Success)
return Success;
ret = GrabKey(client, dev, stuff->this_device_mode,
stuff->other_devices_mode, stuff->modifiers, mdev, stuff->key,
stuff->grabWindow, stuff->ownerEvents, tmp[stuff->grabbed_device].mask);
stuff->other_devices_mode, stuff->modifiers, mdev,
stuff->key, stuff->grabWindow, stuff->ownerEvents,
tmp[stuff->grabbed_device].mask);
if (ret != Success)
{
if (ret != Success) {
SendErrorToClient(client, IReqCode, X_GrabDeviceKey, 0, ret);
return Success;
}
......
......@@ -107,15 +107,13 @@ ProcXGetDeviceMotionEvents(ClientPtr client)
REQUEST_SIZE_MATCH(xGetDeviceMotionEventsReq);
dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL)
{
if (dev == NULL) {
SendErrorToClient(client, IReqCode, X_GetDeviceMotionEvents, 0,
BadDevice);
return Success;
}
v = dev->valuator;
if (v==NULL || v->numAxes == 0)
{
if (v == NULL || v->numAxes == 0) {
SendErrorToClient(client, IReqCode, X_GetDeviceMotionEvents, 0,
BadMatch);
return Success;
......@@ -133,16 +131,14 @@ ProcXGetDeviceMotionEvents(ClientPtr client)
start = ClientTimeToServerTime(stuff->start);
stop = ClientTimeToServerTime(stuff->stop);
if (CompareTimeStamps(start, stop) == LATER ||
CompareTimeStamps(start, currentTime) == LATER)
{
CompareTimeStamps(start, currentTime) == LATER) {
WriteReplyToClient(client, sizeof(xGetDeviceMotionEventsReply), &rep);
return Success;
}
if (CompareTimeStamps(stop, currentTime) == LATER)
stop = currentTime;
num_events = v->numMotionEvents;
if (num_events)
{
if (num_events) {
size = sizeof(Time) + (axes * sizeof(INT32));
tsize = num_events * size;
coords = (INT32 *) malloc(tsize);
......@@ -152,24 +148,20 @@ ProcXGetDeviceMotionEvents(ClientPtr client)
BadAlloc);
return Success;
}
rep.nEvents = (v->GetMotionProc) (
dev, (xTimecoord *)coords, /* XXX */
start.milliseconds, stop.milliseconds, (ScreenPtr)NULL);
rep.nEvents = (v->GetMotionProc) (dev, (xTimecoord *) coords, /* XXX */
start.milliseconds, stop.milliseconds,
(ScreenPtr) NULL);
}
if (rep.nEvents > 0)
{
if (rep.nEvents > 0) {
length = (rep.nEvents * size + 3) >> 2;
rep.length = length;
}
nEvents = rep.nEvents;
WriteReplyToClient(client, sizeof(xGetDeviceMotionEventsReply), &rep);
if (nEvents)
{
if (client->swapped)
{
if (nEvents) {
if (client->swapped) {
bufptr = coords;
for (i=0; i<nEvents * (axes+1); i++)
{
for (i = 0; i < nEvents * (axes + 1); i++) {
swapl(bufptr);
bufptr++;
}
......
......@@ -159,8 +159,7 @@ SizeDeviceInfo(DeviceIntPtr d, int *namesize, int *size)
*size += sizeof(xKeyInfo);
if (d->button != NULL)
*size += sizeof(xButtonInfo);
if (d->valuator != NULL)
{
if (d->valuator != NULL) {
chunks = ((int)d->valuator->numAxes + 19) / VPC;
*size += (chunks * sizeof(xValuatorInfo) +
d->valuator->numAxes * sizeof(xAxisInfo));
......@@ -179,19 +178,17 @@ ListDeviceInfo(ClientPtr client, DeviceIntPtr d, xDeviceInfoPtr dev,
{
CopyDeviceName(namebuf, d->name);
CopySwapDevice(client, d, 0, devbuf);
if (d->key != NULL)
{
if (d->key != NULL) {
CopySwapKeyClass(client, d->key, classbuf);
dev->num_classes++;
}
if (d->button != NULL)
{
if (d->button != NULL) {
CopySwapButtonClass(client, d->button, classbuf);
dev->num_classes++;
}
if (d->valuator != NULL)
{
dev->num_classes += CopySwapValuatorClass(client, d->valuator, classbuf);
if (d->valuator != NULL) {
dev->num_classes +=
CopySwapValuatorClass(client, d->valuator, classbuf);
}
}
......@@ -210,14 +207,11 @@ CopyDeviceName(char **namebuf, char *name)
{
char *nameptr = (char *)*namebuf;
if (name)
{
if (name) {
*nameptr++ = strlen(name);
strcpy(nameptr, name);
*namebuf += (strlen(name) + 1);
}
else
{
} else {
*nameptr++ = 0;
*namebuf += 1;
}
......@@ -246,8 +240,7 @@ CopySwapDevice(register ClientPtr client, DeviceIntPtr d, int num_classes,
dev->use = IsXPointer;
else
dev->use = IsXExtensionDevice;
if (client->swapped)
{
if (client->swapped) {
swapl(&dev->type); /* macro - braces are required */
}
*buf += sizeof(xDeviceInfo);
......@@ -270,8 +263,7 @@ CopySwapKeyClass(register ClientPtr client, KeyClassPtr k, char **buf)
k2->min_keycode = k->curKeySyms.minKeyCode;
k2->max_keycode = k->curKeySyms.maxKeyCode;
k2->num_keys = k2->max_keycode - k2->min_keycode + 1;
if (client->swapped)
{
if (client->swapped) {
swaps(&k2->num_keys);
}
*buf += sizeof(xKeyInfo);
......@@ -292,8 +284,7 @@ CopySwapButtonClass(register ClientPtr client, ButtonClassPtr b, char **buf)
b2->class = ButtonClass;
b2->length = sizeof(xButtonInfo);
b2->num_buttons = b->numButtons;
if (client->swapped)
{
if (client->swapped) {
swaps(&b2->num_buttons); /* macro - braces are required */
}
*buf += sizeof(xButtonInfo);
......@@ -319,7 +310,8 @@ CopySwapValuatorClass(register ClientPtr client, ValuatorClassPtr v, char **buf)
AxisInfo *a;
xAxisInfoPtr a2;
for (i=0,axes=v->numAxes; i < ((v->numAxes+19)/VPC); i++, axes-=VPC) {
for (i = 0, axes = v->numAxes; i < ((v->numAxes + 19) / VPC);
i++, axes -= VPC) {
t_axes = axes < VPC ? axes : VPC;
if (t_axes < 0)
t_axes = v->numAxes % VPC;
......@@ -329,8 +321,7 @@ CopySwapValuatorClass(register ClientPtr client, ValuatorClassPtr v, char **buf)
v2->num_axes = t_axes;
v2->mode = v->mode & DeviceMode;
v2->motion_buffer_size = v->numMotionEvents;
if (client->swapped)
{
if (client->swapped) {
swapl(&v2->motion_buffer_size);
}
*buf += sizeof(xValuatorInfo);
......
......@@ -105,19 +105,16 @@ ProcXOpenDevice(register ClientPtr client)
REQUEST_SIZE_MATCH(xOpenDeviceReq);
if (stuff->deviceid == inputInfo.pointer->id ||
stuff->deviceid == inputInfo.keyboard->id)
{
stuff->deviceid == inputInfo.keyboard->id) {
SendErrorToClient(client, IReqCode, X_OpenDevice, 0, BadDevice);
return Success;
}
if ((dev = LookupDeviceIntRec(stuff->deviceid)) == NULL) /* not open */
{
if ((dev = LookupDeviceIntRec(stuff->deviceid)) == NULL) { /* not open */
for (dev = inputInfo.off_devices; dev; dev = dev->next)
if (dev->id == stuff->deviceid)
break;
if (dev == NULL)
{
if (dev == NULL) {
SendErrorToClient(client, IReqCode, X_OpenDevice, 0, BadDevice);
return Success;
}
......@@ -125,8 +122,7 @@ ProcXOpenDevice(register ClientPtr client)
}
OpenInputDevice(dev, client, &status);
if (status != Success)
{
if (status != Success) {
SendErrorToClient(client, IReqCode, X_OpenDevice, 0, status);
return Success;
}
......@@ -137,34 +133,28 @@ ProcXOpenDevice(register ClientPtr client)
rep.repType = X_Reply;
rep.RepType = X_OpenDevice;
rep.sequenceNumber = client->sequence;
if (dev->key != NULL)
{
if (dev->key != NULL) {
evbase[j].class = KeyClass;
evbase[j++].event_type_base = event_base[KeyClass];
}
if (dev->button != NULL)
{
if (dev->button != NULL) {
evbase[j].class = ButtonClass;
evbase[j++].event_type_base = event_base[ButtonClass];
}
if (dev->valuator != NULL)
{
if (dev->valuator != NULL) {
evbase[j].class = ValuatorClass;
evbase[j++].event_type_base = event_base[ValuatorClass];
}
if (dev->kbdfeed != NULL || dev->ptrfeed != NULL || dev->leds != NULL ||
dev->intfeed != NULL || dev->bell != NULL || dev->stringfeed != NULL)
{
dev->intfeed != NULL || dev->bell != NULL || dev->stringfeed != NULL) {
evbase[j].class = FeedbackClass;
evbase[j++].event_type_base = event_base[FeedbackClass];
}
if (dev->focus != NULL)
{
if (dev->focus != NULL) {
evbase[j].class = FocusClass;
evbase[j++].event_type_base = event_base[FocusClass];
}
if (dev->proximity != NULL)
{
if (dev->proximity != NULL) {
evbase[j].class = ProximityClass;
evbase[j++].event_type_base = event_base[ProximityClass];
}
......
......@@ -95,10 +95,8 @@ ProcXQueryDeviceState(register ClientPtr client)
rep.sequenceNumber = client->sequence;
dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL)
{
SendErrorToClient(client, IReqCode, X_QueryDeviceState, 0,
BadDevice);
if (dev == NULL) {
SendErrorToClient(client, IReqCode, X_QueryDeviceState, 0, BadDevice);
return Success;
}
......@@ -107,36 +105,29 @@ ProcXQueryDeviceState(register ClientPtr client)
MaybeStopDeviceHint(dev, client);
k = dev->key;
if (k != NULL)
{
if (k != NULL) {
total_length += sizeof(xKeyState);
num_classes++;
}
b = dev->button;
if (b != NULL)
{
if (b != NULL) {
total_length += sizeof(xButtonState);
num_classes++;
}
if (v != NULL)
{
total_length += (sizeof(xValuatorState) +
(v->numAxes * sizeof(int)));
if (v != NULL) {
total_length += (sizeof(xValuatorState) + (v->numAxes * sizeof(int)));
num_classes++;
}
buf = (char *)malloc(total_length);
if (!buf)
{
SendErrorToClient(client, IReqCode, X_QueryDeviceState, 0,
BadAlloc);
if (!buf) {
SendErrorToClient(client, IReqCode, X_QueryDeviceState, 0, BadAlloc);
return Success;
}
savbuf = buf;
if (k != NULL)
{
if (k != NULL) {
tk = (xKeyState *) buf;
tk->class = KeyClass;
tk->length = sizeof(xKeyState);
......@@ -146,8 +137,7 @@ ProcXQueryDeviceState(register ClientPtr client)
buf += sizeof(xKeyState);
}
if (b != NULL)
{
if (b != NULL) {
tb = (xButtonState *) buf;
tb->class = ButtonClass;
tb->length = sizeof(xButtonState);
......@@ -157,19 +147,16 @@ ProcXQueryDeviceState(register ClientPtr client)
buf += sizeof(xButtonState);
}
if (v != NULL)
{
if (v != NULL) {
tv = (xValuatorState *) buf;
tv->class = ValuatorClass;
tv->length = sizeof(xValuatorState);
tv->num_valuators = v->numAxes;
tv->mode = v->mode;
buf += sizeof(xValuatorState);
for (i=0, values=v->axisVal; i<v->numAxes; i++)
{
for (i = 0, values = v->axisVal; i < v->numAxes; i++) {
*((int *)buf) = *values++;
if (client->swapped)
{
if (client->swapped) {
swapl((int *)buf); /* macro - braces needed */
}
buf += sizeof(int);
......
......@@ -110,16 +110,14 @@ ProcXSelectExtensionEvent(register ClientPtr client)
REQUEST(xSelectExtensionEventReq);
REQUEST_AT_LEAST_SIZE(xSelectExtensionEventReq);
if (stuff->length !=(sizeof(xSelectExtensionEventReq)>>2) + stuff->count)
{
if (stuff->length != (sizeof(xSelectExtensionEventReq) >> 2) + stuff->count) {
SendErrorToClient(client, IReqCode, X_SelectExtensionEvent, 0,
BadLength);
return Success;
}
pWin = (WindowPtr) LookupWindow(stuff->window, client);
if (!pWin)
{
if (!pWin) {
client->errorValue = stuff->window;
SendErrorToClient(client, IReqCode, X_SelectExtensionEvent, 0,
BadWindow);
......@@ -127,15 +125,16 @@ ProcXSelectExtensionEvent(register ClientPtr client)
}
if ((ret = CreateMaskFromList(client, (XEventClass *) & stuff[1],
stuff->count, tmp, NULL, X_SelectExtensionEvent)) != Success)
stuff->count, tmp, NULL,
X_SelectExtensionEvent)) != Success)
return Success;
for (i = 0; i < EMASKSIZE; i++)
if (tmp[i].dev != NULL)
{
if ((ret = SelectForWindow((DeviceIntPtr)tmp[i].dev, pWin, client, tmp[i].mask,
ExtExclusiveMasks[i], ExtValidMasks[i])) != Success)
{
if (tmp[i].dev != NULL) {
if ((ret =
SelectForWindow((DeviceIntPtr) tmp[i].dev, pWin, client,
tmp[i].mask, ExtExclusiveMasks[i],
ExtValidMasks[i])) != Success) {
SendErrorToClient(client, IReqCode, X_SelectExtensionEvent, 0,
ret);
return Success;
......
......@@ -98,8 +98,7 @@ SProcXSendExtensionEvent(register ClientPtr client)
return BadLength;
eventP = (xEvent *) & stuff[1];
for (i=0; i<stuff->num_events; i++,eventP++)
{
for (i = 0; i < stuff->num_events; i++, eventP++) {
proc = EventSwapVector[eventP->u.u.type & 0177];
if (proc == NotImplemented) /* no swapping proc; invalid event type? */
return (BadValue);
......@@ -132,18 +131,14 @@ ProcXSendExtensionEvent(register ClientPtr client)
REQUEST_AT_LEAST_SIZE(xSendExtensionEventReq);
if (stuff->length != (sizeof(xSendExtensionEventReq) >> 2) + stuff->count +
(stuff->num_events * (sizeof (xEvent) >> 2)))
{
SendErrorToClient (client, IReqCode, X_SendExtensionEvent, 0,
BadLength);
(stuff->num_events * (sizeof(xEvent) >> 2))) {
SendErrorToClient(client, IReqCode, X_SendExtensionEvent, 0, BadLength);
return Success;
}
dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL)
{
SendErrorToClient(client, IReqCode, X_SendExtensionEvent, 0,
BadDevice);
if (dev == NULL) {
SendErrorToClient(client, IReqCode, X_SendExtensionEvent, 0, BadDevice);
return Success;
}
......@@ -160,11 +155,9 @@ ProcXSendExtensionEvent(register ClientPtr client)
first = ((xEvent *) & stuff[1]);
if (!((EXTENSION_EVENT_BASE <= first->u.u.type) &&
(first->u.u.type < lastEvent)) )
{
(first->u.u.type < lastEvent))) {
client->errorValue = first->u.u.type;
SendErrorToClient(client, IReqCode, X_SendExtensionEvent, 0,
BadValue);
SendErrorToClient(client, IReqCode, X_SendExtensionEvent, 0, BadValue);
return Success;
}
......@@ -174,8 +167,8 @@ ProcXSendExtensionEvent(register ClientPtr client)
return Success;
ret = (SendEvent(client, dev, stuff->destination,
stuff->propagate, (xEvent *)&stuff[1], tmp[stuff->deviceid].mask,
stuff->num_events));
stuff->propagate, (xEvent *) & stuff[1],
tmp[stuff->deviceid].mask, stuff->num_events));
if (ret != Success)
SendErrorToClient(client, IReqCode, X_SendExtensionEvent, 0, ret);
......
......@@ -101,8 +101,7 @@ ProcXSetDeviceButtonMapping(register ClientPtr client)
REQUEST_AT_LEAST_SIZE(xSetDeviceButtonMappingReq);
if (stuff->length != (sizeof(xSetDeviceButtonMappingReq) +
stuff->map_length + 3)>>2)
{
stuff->map_length + 3) >> 2) {
SendErrorToClient(client, IReqCode, X_SetDeviceButtonMapping, 0,
BadLength);
return Success;
......@@ -115,8 +114,7 @@ ProcXSetDeviceButtonMapping(register ClientPtr client)
rep.status = MappingSuccess;
dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL)
{
if (dev == NULL) {
SendErrorToClient(client, IReqCode, X_SetDeviceButtonMapping, 0,
BadDevice);
return Success;
......@@ -124,14 +122,10 @@ ProcXSetDeviceButtonMapping(register ClientPtr client)
ret = SetButtonMapping(client, dev, stuff->map_length, (BYTE *) & stuff[1]);
if (ret == BadValue || ret == BadMatch)
{
SendErrorToClient(client, IReqCode, X_SetDeviceButtonMapping, 0,
ret);
if (ret == BadValue || ret == BadMatch) {
SendErrorToClient(client, IReqCode, X_SetDeviceButtonMapping, 0, ret);
return Success;
}
else
{
} else {
rep.status = ret;
WriteReplyToClient(client, sizeof(xSetDeviceButtonMappingReply), &rep);
}
......
......@@ -103,30 +103,22 @@ ProcXSetDeviceValuators(register ClientPtr client)
rep.sequenceNumber = client->sequence;
if (stuff->length != (sizeof(xSetDeviceValuatorsReq) >> 2) +
stuff->num_valuators)
{
SendErrorToClient (client, IReqCode, X_SetDeviceValuators, 0,
BadLength);
stuff->num_valuators) {
SendErrorToClient(client, IReqCode, X_SetDeviceValuators, 0, BadLength);
return Success;
}
dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL)
{
SendErrorToClient (client, IReqCode, X_SetDeviceValuators, 0,
BadDevice);
if (dev == NULL) {
SendErrorToClient(client, IReqCode, X_SetDeviceValuators, 0, BadDevice);
return Success;
}
if (dev->valuator == NULL)
{
SendErrorToClient(client, IReqCode, X_SetDeviceValuators, 0,
BadMatch);
if (dev->valuator == NULL) {
SendErrorToClient(client, IReqCode, X_SetDeviceValuators, 0, BadMatch);
return Success;
}
if (stuff->first_valuator + stuff->num_valuators > dev->valuator->numAxes)
{
SendErrorToClient(client, IReqCode, X_SetDeviceValuators, 0,
BadValue);
if (stuff->first_valuator + stuff->num_valuators > dev->valuator->numAxes) {
SendErrorToClient(client, IReqCode, X_SetDeviceValuators, 0, BadValue);
return Success;
}
......@@ -134,7 +126,8 @@ ProcXSetDeviceValuators(register ClientPtr client)
rep.status = AlreadyGrabbed;
else
rep.status = SetDeviceValuators(client, dev, (int *)&stuff[1],
stuff->first_valuator, stuff->num_valuators);
stuff->first_valuator,
stuff->num_valuators);
if (rep.status != Success && rep.status != AlreadyGrabbed)
SendErrorToClient(client, IReqCode, X_SetDeviceValuators, 0,
......
......@@ -103,8 +103,7 @@ ProcXSetDeviceFocus(register ClientPtr client)
REQUEST_SIZE_MATCH(xSetDeviceFocusReq);
dev = LookupDeviceIntRec(stuff->device);
if (dev==NULL || !dev->focus)
{
if (dev == NULL || !dev->focus) {
SendErrorToClient(client, IReqCode, X_SetDeviceFocus, 0, BadDevice);
return Success;
}
......
......@@ -100,8 +100,7 @@ ProcXSetDeviceModifierMapping(ClientPtr client)
REQUEST_AT_LEAST_SIZE(xSetDeviceModifierMappingReq);
dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL)
{
if (dev == NULL) {
SendErrorToClient(client, IReqCode, X_SetDeviceModifierMapping, 0,
BadDevice);
return Success;
......@@ -113,18 +112,17 @@ ProcXSetDeviceModifierMapping(ClientPtr client)
rep.sequenceNumber = client->sequence;
ret = SetModifierMapping(client, dev, stuff->length,
(sizeof (xSetDeviceModifierMappingReq)>>2), stuff->numKeyPerModifier,
(BYTE *)&stuff[1], &kp);
(sizeof(xSetDeviceModifierMappingReq) >> 2),
stuff->numKeyPerModifier, (BYTE *) & stuff[1],
&kp);
if (ret==MappingSuccess || ret==MappingBusy || ret==MappingFailed)
{
if (ret == MappingSuccess || ret == MappingBusy || ret == MappingFailed) {
rep.success = ret;
if (ret == MappingSuccess)
SendDeviceMappingNotify(MappingModifier, 0, 0, dev);
WriteReplyToClient(client, sizeof(xSetDeviceModifierMappingReply),&rep);
}
else
{
WriteReplyToClient(client, sizeof(xSetDeviceModifierMappingReply),
&rep);
} else {
if (ret == -1)
ret = BadValue;
SendErrorToClient(client, IReqCode, X_SetDeviceModifierMapping, 0, ret);
......
......@@ -102,13 +102,11 @@ ProcXSetDeviceMode(register ClientPtr client)
rep.sequenceNumber = client->sequence;
dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL)
{
if (dev == NULL) {
SendErrorToClient(client, IReqCode, X_SetDeviceMode, 0, BadDevice);
return Success;
}
if (dev->valuator == NULL)
{
if (dev->valuator == NULL) {
SendErrorToClient(client, IReqCode, X_SetDeviceMode, 0, BadMatch);
return Success;
}
......@@ -119,8 +117,7 @@ ProcXSetDeviceMode(register ClientPtr client)
if (rep.status == Success)
dev->valuator->mode = stuff->mode;
else if (rep.status != AlreadyGrabbed)
{
else if (rep.status != AlreadyGrabbed) {
SendErrorToClient(client, IReqCode, X_SetDeviceMode, 0, rep.status);
return Success;
}
......
......@@ -99,8 +99,7 @@ ProcXUngrabDevice(register ClientPtr client)
REQUEST_SIZE_MATCH(xUngrabDeviceReq);
dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL)
{
if (dev == NULL) {
SendErrorToClient(client, IReqCode, X_UngrabDevice, 0, BadDevice);
return Success;
}
......
......@@ -107,51 +107,39 @@ ProcXUngrabDeviceButton(ClientPtr client)
REQUEST_SIZE_MATCH(xUngrabDeviceButtonReq);
dev = LookupDeviceIntRec(stuff->grabbed_device);
if (dev == NULL)
{
SendErrorToClient(client, IReqCode, X_UngrabDeviceButton, 0,
BadDevice);
if (dev == NULL) {
SendErrorToClient(client, IReqCode, X_UngrabDeviceButton, 0, BadDevice);
return Success;
}
if (dev->button == NULL)
{
SendErrorToClient(client, IReqCode, X_UngrabDeviceButton, 0,
BadMatch);
if (dev->button == NULL) {
SendErrorToClient(client, IReqCode, X_UngrabDeviceButton, 0, BadMatch);
return Success;
}
if (stuff->modifier_device != UseXKeyboard)
{
if (stuff->modifier_device != UseXKeyboard) {
mdev = LookupDeviceIntRec(stuff->modifier_device);
if (mdev == NULL)
{
if (mdev == NULL) {
SendErrorToClient(client, IReqCode, X_UngrabDeviceButton, 0,
BadDevice);
return Success;
}
if (mdev->key == NULL)
{
if (mdev->key == NULL) {
SendErrorToClient(client, IReqCode, X_UngrabDeviceButton, 0,
BadMatch);
return Success;
}
}
else
} else
mdev = (DeviceIntPtr) LookupKeyboardDevice();
pWin = LookupWindow(stuff->grabWindow, client);
if (!pWin)
{
SendErrorToClient(client, IReqCode, X_UngrabDeviceButton, 0,
BadWindow);
if (!pWin) {
SendErrorToClient(client, IReqCode, X_UngrabDeviceButton, 0, BadWindow);
return Success;
}
if ((stuff->modifiers != AnyModifier) &&
(stuff->modifiers & ~AllModifiersMask))
{
SendErrorToClient(client, IReqCode, X_UngrabDeviceButton, 0,
BadValue);
(stuff->modifiers & ~AllModifiersMask)) {
SendErrorToClient(client, IReqCode, X_UngrabDeviceButton, 0, BadValue);
return Success;
}
......
......@@ -107,57 +107,43 @@ ProcXUngrabDeviceKey(ClientPtr client)
REQUEST_SIZE_MATCH(xUngrabDeviceKeyReq);
dev = LookupDeviceIntRec(stuff->grabbed_device);
if (dev == NULL)
{
SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0,
BadDevice);
if (dev == NULL) {
SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0, BadDevice);
return Success;
}
if (dev->key == NULL)
{
if (dev->key == NULL) {
SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0, BadMatch);
return Success;
}
if (stuff->modifier_device != UseXKeyboard)
{
if (stuff->modifier_device != UseXKeyboard) {
mdev = LookupDeviceIntRec(stuff->modifier_device);
if (mdev == NULL)
{
if (mdev == NULL) {
SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0,
BadDevice);
return Success;
}
if (mdev->key == NULL)
{
SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0,
BadMatch);
if (mdev->key == NULL) {
SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0, BadMatch);
return Success;
}
}
else
} else
mdev = (DeviceIntPtr) LookupKeyboardDevice();
pWin = LookupWindow(stuff->grabWindow, client);
if (!pWin)
{
SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0,
BadWindow);
if (!pWin) {
SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0, BadWindow);
return Success;
}
if (((stuff->key > dev->key->curKeySyms.maxKeyCode) ||
(stuff->key < dev->key->curKeySyms.minKeyCode))
&& (stuff->key != AnyKey))
{
SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0,
BadValue);
&& (stuff->key != AnyKey)) {
SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0, BadValue);
return Success;
}
if ((stuff->modifiers != AnyModifier) &&
(stuff->modifiers & ~AllModifiersMask))
{
SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0,
BadValue);
(stuff->modifiers & ~AllModifiersMask)) {
SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0, BadValue);
return Success;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment