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) ...@@ -100,15 +100,13 @@ ProcXAllowDeviceEvents(register ClientPtr client)
REQUEST_SIZE_MATCH(xAllowDeviceEventsReq); REQUEST_SIZE_MATCH(xAllowDeviceEventsReq);
thisdev = LookupDeviceIntRec(stuff->deviceid); thisdev = LookupDeviceIntRec(stuff->deviceid);
if (thisdev == NULL) if (thisdev == NULL) {
{
SendErrorToClient(client, IReqCode, X_AllowDeviceEvents, 0, BadDevice); SendErrorToClient(client, IReqCode, X_AllowDeviceEvents, 0, BadDevice);
return Success; return Success;
} }
time = ClientTimeToServerTime(stuff->time); time = ClientTimeToServerTime(stuff->time);
switch (stuff->mode) switch (stuff->mode) {
{
case ReplayThisDevice: case ReplayThisDevice:
AllowSome(client, time, thisdev, NOT_GRABBED); AllowSome(client, time, thisdev, NOT_GRABBED);
break; break;
...@@ -128,8 +126,7 @@ ProcXAllowDeviceEvents(register ClientPtr client) ...@@ -128,8 +126,7 @@ ProcXAllowDeviceEvents(register ClientPtr client)
AllowSome(client, time, thisdev, THAWED_BOTH); AllowSome(client, time, thisdev, THAWED_BOTH);
break; break;
default: default:
SendErrorToClient(client, IReqCode, X_AllowDeviceEvents, 0, SendErrorToClient(client, IReqCode, X_AllowDeviceEvents, 0, BadValue);
BadValue);
client->errorValue = stuff->mode; client->errorValue = stuff->mode;
return Success; return Success;
} }
......
...@@ -107,8 +107,7 @@ ProcXChangeDeviceControl(ClientPtr client) ...@@ -107,8 +107,7 @@ ProcXChangeDeviceControl(ClientPtr client)
len = stuff->length - (sizeof(xChangeDeviceControlReq) >> 2); len = stuff->length - (sizeof(xChangeDeviceControlReq) >> 2);
dev = LookupDeviceIntRec(stuff->deviceid); dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL) if (dev == NULL) {
{
SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0, SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0,
BadDevice); BadDevice);
return Success; return Success;
...@@ -119,70 +118,55 @@ ProcXChangeDeviceControl(ClientPtr client) ...@@ -119,70 +118,55 @@ ProcXChangeDeviceControl(ClientPtr client)
rep.length = 0; rep.length = 0;
rep.sequenceNumber = client->sequence; rep.sequenceNumber = client->sequence;
switch (stuff->control) switch (stuff->control) {
{
case DEVICE_RESOLUTION: case DEVICE_RESOLUTION:
r = (xDeviceResolutionCtl *) & stuff[1]; r = (xDeviceResolutionCtl *) & stuff[1];
if ((len < (sizeof(xDeviceResolutionCtl) >> 2)) || if ((len < (sizeof(xDeviceResolutionCtl) >> 2)) ||
(len != (sizeof(xDeviceResolutionCtl)>>2) + (len != (sizeof(xDeviceResolutionCtl) >> 2) + r->num_valuators)) {
r->num_valuators))
{
SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, SendErrorToClient(client, IReqCode, X_ChangeDeviceControl,
0, BadLength); 0, BadLength);
return Success; return Success;
} }
if (!dev->valuator) if (!dev->valuator) {
{
SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0, SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0,
BadMatch); BadMatch);
return Success; return Success;
} }
if ((dev->grab) && !SameClient(dev->grab, client)) if ((dev->grab) && !SameClient(dev->grab, client)) {
{
rep.status = AlreadyGrabbed; rep.status = AlreadyGrabbed;
WriteReplyToClient(client, sizeof(xChangeDeviceControlReply), WriteReplyToClient(client, sizeof(xChangeDeviceControlReply), &rep);
&rep);
return Success; return Success;
} }
resolution = (CARD32 *) (r + 1); 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, SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0,
BadValue); BadValue);
return Success; return Success;
} }
status = ChangeDeviceControl(client, dev, (xDeviceCtl *) r); status = ChangeDeviceControl(client, dev, (xDeviceCtl *) r);
if (status == Success) if (status == Success) {
{
a = &dev->valuator->axes[r->first_valuator]; a = &dev->valuator->axes[r->first_valuator];
for (i = 0; i < r->num_valuators; i++) for (i = 0; i < r->num_valuators; i++)
if (*(resolution + i) < (a + i)->min_resolution || if (*(resolution + i) < (a + i)->min_resolution ||
*(resolution+i) > (a+i)->max_resolution) *(resolution + i) > (a + i)->max_resolution) {
{
SendErrorToClient(client, IReqCode, SendErrorToClient(client, IReqCode,
X_ChangeDeviceControl, 0, BadValue); X_ChangeDeviceControl, 0, BadValue);
return Success; return Success;
} }
for (i = 0; i < r->num_valuators; i++) for (i = 0; i < r->num_valuators; i++)
(a++)->resolution = *resolution++; (a++)->resolution = *resolution++;
} } else if (status == DeviceBusy) {
else if (status == DeviceBusy)
{
rep.status = DeviceBusy; rep.status = DeviceBusy;
WriteReplyToClient(client, sizeof(xChangeDeviceControlReply), WriteReplyToClient(client, sizeof(xChangeDeviceControlReply), &rep);
&rep);
return Success; return Success;
} } else {
else
{
SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0, SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0,
BadMatch); BadMatch);
return Success; return Success;
} }
break; break;
default: default:
SendErrorToClient (client, IReqCode, X_ChangeDeviceControl, 0, SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0, BadValue);
BadValue);
return Success; return Success;
} }
WriteReplyToClient(client, sizeof(xChangeDeviceControlReply), &rep); WriteReplyToClient(client, sizeof(xChangeDeviceControlReply), &rep);
......
...@@ -109,40 +109,36 @@ ProcXChangeFeedbackControl(ClientPtr client) ...@@ -109,40 +109,36 @@ ProcXChangeFeedbackControl(ClientPtr client)
len = stuff->length - (sizeof(xChangeFeedbackControlReq) >> 2); len = stuff->length - (sizeof(xChangeFeedbackControlReq) >> 2);
dev = LookupDeviceIntRec(stuff->deviceid); dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL) if (dev == NULL) {
{
SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0, SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0,
BadDevice); BadDevice);
return Success; return Success;
} }
switch (stuff->feedbackid) switch (stuff->feedbackid) {
{
case KbdFeedbackClass: case KbdFeedbackClass:
if (len != (sizeof(xKbdFeedbackCtl)>>2)) if (len != (sizeof(xKbdFeedbackCtl) >> 2)) {
{
SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl,
0, BadLength); 0, BadLength);
return Success; return Success;
} }
for (k = dev->kbdfeed; k; k = k->next) for (k = dev->kbdfeed; k; k = k->next)
if (k->ctrl.id == ((xKbdFeedbackCtl *) &stuff[1])->id) if (k->ctrl.id == ((xKbdFeedbackCtl *) & stuff[1])->id) {
{ ChangeKbdFeedback(client, dev, stuff->mask, k,
ChangeKbdFeedback (client, dev, stuff->mask, k, (xKbdFeedbackCtl *)&stuff[1]); (xKbdFeedbackCtl *) & stuff[1]);
return Success; return Success;
} }
break; break;
case PtrFeedbackClass: case PtrFeedbackClass:
if (len != (sizeof(xPtrFeedbackCtl)>>2)) if (len != (sizeof(xPtrFeedbackCtl) >> 2)) {
{
SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl,
0, BadLength); 0, BadLength);
return Success; return Success;
} }
for (p = dev->ptrfeed; p; p = p->next) for (p = dev->ptrfeed; p; p = p->next)
if (p->ctrl.id == ((xPtrFeedbackCtl *) &stuff[1])->id) if (p->ctrl.id == ((xPtrFeedbackCtl *) & stuff[1])->id) {
{ ChangePtrFeedback(client, dev, stuff->mask, p,
ChangePtrFeedback (client, dev, stuff->mask, p, (xPtrFeedbackCtl *)&stuff[1]); (xPtrFeedbackCtl *) & stuff[1]);
return Success; return Success;
} }
break; break;
...@@ -155,59 +151,55 @@ ProcXChangeFeedbackControl(ClientPtr client) ...@@ -155,59 +151,55 @@ ProcXChangeFeedbackControl(ClientPtr client)
return BadLength; return BadLength;
swaps(&f->num_keysyms); swaps(&f->num_keysyms);
} }
if (len != ((sizeof(xStringFeedbackCtl)>>2) + f->num_keysyms)) if (len != ((sizeof(xStringFeedbackCtl) >> 2) + f->num_keysyms)) {
{
SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl,
0, BadLength); 0, BadLength);
return Success; return Success;
} }
for (s = dev->stringfeed; s; s = s->next) for (s = dev->stringfeed; s; s = s->next)
if (s->ctrl.id == ((xStringFeedbackCtl *) &stuff[1])->id) if (s->ctrl.id == ((xStringFeedbackCtl *) & stuff[1])->id) {
{ ChangeStringFeedback(client, dev, stuff->mask, s,
ChangeStringFeedback (client, dev, stuff->mask,s,(xStringFeedbackCtl *)&stuff[1]); (xStringFeedbackCtl *) & stuff[1]);
return Success; return Success;
} }
break; break;
} }
case IntegerFeedbackClass: case IntegerFeedbackClass:
if (len != (sizeof(xIntegerFeedbackCtl)>>2)) if (len != (sizeof(xIntegerFeedbackCtl) >> 2)) {
{
SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl,
0, BadLength); 0, BadLength);
return Success; return Success;
} }
for (i = dev->intfeed; i; i = i->next) for (i = dev->intfeed; i; i = i->next)
if (i->ctrl.id == ((xIntegerFeedbackCtl *) &stuff[1])->id) if (i->ctrl.id == ((xIntegerFeedbackCtl *) & stuff[1])->id) {
{ ChangeIntegerFeedback(client, dev, stuff->mask, i,
ChangeIntegerFeedback (client, dev,stuff->mask,i,(xIntegerFeedbackCtl *)&stuff[1]); (xIntegerFeedbackCtl *) & stuff[1]);
return Success; return Success;
} }
break; break;
case LedFeedbackClass: case LedFeedbackClass:
if (len != (sizeof(xLedFeedbackCtl)>>2)) if (len != (sizeof(xLedFeedbackCtl) >> 2)) {
{
SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl,
0, BadLength); 0, BadLength);
return Success; return Success;
} }
for (l = dev->leds; l; l = l->next) for (l = dev->leds; l; l = l->next)
if (l->ctrl.id == ((xLedFeedbackCtl *) &stuff[1])->id) if (l->ctrl.id == ((xLedFeedbackCtl *) & stuff[1])->id) {
{ ChangeLedFeedback(client, dev, stuff->mask, l,
ChangeLedFeedback (client, dev, stuff->mask, l, (xLedFeedbackCtl *)&stuff[1]); (xLedFeedbackCtl *) & stuff[1]);
return Success; return Success;
} }
break; break;
case BellFeedbackClass: case BellFeedbackClass:
if (len != (sizeof(xBellFeedbackCtl)>>2)) if (len != (sizeof(xBellFeedbackCtl) >> 2)) {
{
SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl,
0, BadLength); 0, BadLength);
return Success; return Success;
} }
for (b = dev->bell; b; b = b->next) for (b = dev->bell; b; b = b->next)
if (b->ctrl.id == ((xBellFeedbackCtl *) &stuff[1])->id) if (b->ctrl.id == ((xBellFeedbackCtl *) & stuff[1])->id) {
{ ChangeBellFeedback(client, dev, stuff->mask, b,
ChangeBellFeedback (client, dev, stuff->mask, b, (xBellFeedbackCtl *)&stuff[1]); (xBellFeedbackCtl *) & stuff[1]);
return Success; return Success;
} }
break; break;
...@@ -233,8 +225,7 @@ ChangeKbdFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask, ...@@ -233,8 +225,7 @@ ChangeKbdFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask,
int t; int t;
int key = DO_ALL; int key = DO_ALL;
if (client->swapped) if (client->swapped) {
{
swaps(&f->length); swaps(&f->length);
swaps(&f->pitch); swaps(&f->pitch);
swaps(&f->duration); swaps(&f->duration);
...@@ -243,13 +234,11 @@ ChangeKbdFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask, ...@@ -243,13 +234,11 @@ ChangeKbdFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask,
} }
kctrl = k->ctrl; kctrl = k->ctrl;
if (mask & DvKeyClickPercent) if (mask & DvKeyClickPercent) {
{
t = f->click; t = f->click;
if (t == -1) if (t == -1)
t = defaultKeyboardControl.click; t = defaultKeyboardControl.click;
else if (t < 0 || t > 100) else if (t < 0 || t > 100) {
{
client->errorValue = t; client->errorValue = t;
SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0, SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0,
BadValue); BadValue);
...@@ -258,13 +247,11 @@ ChangeKbdFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask, ...@@ -258,13 +247,11 @@ ChangeKbdFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask,
kctrl.click = t; kctrl.click = t;
} }
if (mask & DvPercent) if (mask & DvPercent) {
{
t = f->percent; t = f->percent;
if (t == -1) if (t == -1)
t = defaultKeyboardControl.bell; t = defaultKeyboardControl.bell;
else if (t < 0 || t > 100) else if (t < 0 || t > 100) {
{
client->errorValue = t; client->errorValue = t;
SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0, SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0,
BadValue); BadValue);
...@@ -273,13 +260,11 @@ ChangeKbdFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask, ...@@ -273,13 +260,11 @@ ChangeKbdFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask,
kctrl.bell = t; kctrl.bell = t;
} }
if (mask & DvPitch) if (mask & DvPitch) {
{
t = f->pitch; t = f->pitch;
if (t == -1) if (t == -1)
t = defaultKeyboardControl.bell_pitch; t = defaultKeyboardControl.bell_pitch;
else if (t < 0) else if (t < 0) {
{
client->errorValue = t; client->errorValue = t;
SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0, SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0,
BadValue); BadValue);
...@@ -288,13 +273,11 @@ ChangeKbdFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask, ...@@ -288,13 +273,11 @@ ChangeKbdFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask,
kctrl.bell_pitch = t; kctrl.bell_pitch = t;
} }
if (mask & DvDuration) if (mask & DvDuration) {
{
t = f->duration; t = f->duration;
if (t == -1) if (t == -1)
t = defaultKeyboardControl.bell_duration; t = defaultKeyboardControl.bell_duration;
else if (t < 0) else if (t < 0) {
{
client->errorValue = t; client->errorValue = t;
SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0, SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0,
BadValue); BadValue);
...@@ -303,51 +286,41 @@ ChangeKbdFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask, ...@@ -303,51 +286,41 @@ ChangeKbdFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask,
kctrl.bell_duration = t; kctrl.bell_duration = t;
} }
if (mask & DvLed) if (mask & DvLed) {
{
kctrl.leds &= ~(f->led_mask); kctrl.leds &= ~(f->led_mask);
kctrl.leds |= (f->led_mask & f->led_values); kctrl.leds |= (f->led_mask & f->led_values);
} }
if (mask & DvKey) if (mask & DvKey) {
{
key = (KeyCode) f->key; key = (KeyCode) f->key;
if (key < 8 || key > 255) if (key < 8 || key > 255) {
{
client->errorValue = key; client->errorValue = key;
SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0, SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0,
BadValue); BadValue);
return Success; return Success;
} }
if (!(mask & DvAutoRepeatMode)) if (!(mask & DvAutoRepeatMode)) {
{
SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0, SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0,
BadMatch); BadMatch);
return Success; return Success;
} }
} }
if (mask & DvAutoRepeatMode) if (mask & DvAutoRepeatMode) {
{
int inx = (key >> 3); int inx = (key >> 3);
int kmask = (1 << (key & 7)); int kmask = (1 << (key & 7));
t = (CARD8) f->auto_repeat_mode; t = (CARD8) f->auto_repeat_mode;
if (t == AutoRepeatModeOff) if (t == AutoRepeatModeOff) {
{
if (key == DO_ALL) if (key == DO_ALL)
kctrl.autoRepeat = FALSE; kctrl.autoRepeat = FALSE;
else else
kctrl.autoRepeats[inx] &= ~kmask; kctrl.autoRepeats[inx] &= ~kmask;
} } else if (t == AutoRepeatModeOn) {
else if (t == AutoRepeatModeOn)
{
if (key == DO_ALL) if (key == DO_ALL)
kctrl.autoRepeat = TRUE; kctrl.autoRepeat = TRUE;
else else
kctrl.autoRepeats[inx] |= kmask; kctrl.autoRepeats[inx] |= kmask;
} } else if (t == AutoRepeatModeDefault) {
else if (t == AutoRepeatModeDefault)
{
if (key == DO_ALL) if (key == DO_ALL)
kctrl.autoRepeat = defaultKeyboardControl.autoRepeat; kctrl.autoRepeat = defaultKeyboardControl.autoRepeat;
else else
...@@ -355,9 +328,7 @@ ChangeKbdFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask, ...@@ -355,9 +328,7 @@ ChangeKbdFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask,
kctrl.autoRepeats[inx] = kctrl.autoRepeats[inx] =
(kctrl.autoRepeats[inx] & ~kmask) | (kctrl.autoRepeats[inx] & ~kmask) |
(defaultKeyboardControl.autoRepeats[inx] & kmask); (defaultKeyboardControl.autoRepeats[inx] & kmask);
} } else {
else
{
client->errorValue = t; client->errorValue = t;
SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0, SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0,
BadValue); BadValue);
...@@ -382,8 +353,7 @@ ChangePtrFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask, ...@@ -382,8 +353,7 @@ ChangePtrFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask,
{ {
PtrCtrl pctrl; /* might get BadValue part way through */ PtrCtrl pctrl; /* might get BadValue part way through */
if (client->swapped) if (client->swapped) {
{
swaps(&f->length); swaps(&f->length);
swaps(&f->num); swaps(&f->num);
swaps(&f->denom); swaps(&f->denom);
...@@ -391,55 +361,49 @@ ChangePtrFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask, ...@@ -391,55 +361,49 @@ ChangePtrFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask,
} }
pctrl = p->ctrl; pctrl = p->ctrl;
if (mask & DvAccelNum) if (mask & DvAccelNum) {
{
int accelNum; int accelNum;
accelNum = f->num; accelNum = f->num;
if (accelNum == -1) if (accelNum == -1)
pctrl.num = defaultPointerControl.num; pctrl.num = defaultPointerControl.num;
else if (accelNum < 0) else if (accelNum < 0) {
{
client->errorValue = accelNum; client->errorValue = accelNum;
SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0, SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0,
BadValue); BadValue);
return Success; return Success;
} } else
else pctrl.num = accelNum; pctrl.num = accelNum;
} }
if (mask & DvAccelDenom) if (mask & DvAccelDenom) {
{
int accelDenom; int accelDenom;
accelDenom = f->denom; accelDenom = f->denom;
if (accelDenom == -1) if (accelDenom == -1)
pctrl.den = defaultPointerControl.den; pctrl.den = defaultPointerControl.den;
else if (accelDenom <= 0) else if (accelDenom <= 0) {
{
client->errorValue = accelDenom; client->errorValue = accelDenom;
SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0, SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0,
BadValue); BadValue);
return Success; return Success;
} } else
else pctrl.den = accelDenom; pctrl.den = accelDenom;
} }
if (mask & DvThreshold) if (mask & DvThreshold) {
{
int threshold; int threshold;
threshold = f->thresh; threshold = f->thresh;
if (threshold == -1) if (threshold == -1)
pctrl.threshold = defaultPointerControl.threshold; pctrl.threshold = defaultPointerControl.threshold;
else if (threshold < 0) else if (threshold < 0) {
{
client->errorValue = threshold; client->errorValue = threshold;
SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0, SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0,
BadValue); BadValue);
return Success; return Success;
} } else
else pctrl.threshold = threshold; pctrl.threshold = threshold;
} }
p->ctrl = pctrl; p->ctrl = pctrl;
...@@ -483,26 +447,22 @@ ChangeStringFeedback(ClientPtr client, DeviceIntPtr dev, ...@@ -483,26 +447,22 @@ ChangeStringFeedback(ClientPtr client, DeviceIntPtr dev,
KeySym *syms, *sup_syms; KeySym *syms, *sup_syms;
syms = (KeySym *) (f + 1); syms = (KeySym *) (f + 1);
if (client->swapped) if (client->swapped) {
{
swaps(&f->length); /* swapped num_keysyms in calling proc */ swaps(&f->length); /* swapped num_keysyms in calling proc */
SwapLongs((CARD32 *) syms, f->num_keysyms); SwapLongs((CARD32 *) syms, f->num_keysyms);
} }
if (f->num_keysyms > s->ctrl.max_symbols) if (f->num_keysyms > s->ctrl.max_symbols) {
{
SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0, SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0,
BadValue); BadValue);
return Success; return Success;
} }
sup_syms = s->ctrl.symbols_supported; sup_syms = s->ctrl.symbols_supported;
for (i=0; i<f->num_keysyms; i++) for (i = 0; i < f->num_keysyms; i++) {
{
for (j = 0; j < s->ctrl.num_symbols_supported; j++) for (j = 0; j < s->ctrl.num_symbols_supported; j++)
if (*(syms + i) == *(sup_syms + j)) if (*(syms + i) == *(sup_syms + j))
break; break;
if (j==s->ctrl.num_symbols_supported) if (j == s->ctrl.num_symbols_supported) {
{
SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0, SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0,
BadMatch); BadMatch);
return Success; return Success;
...@@ -530,21 +490,18 @@ ChangeBellFeedback(ClientPtr client, DeviceIntPtr dev, ...@@ -530,21 +490,18 @@ ChangeBellFeedback(ClientPtr client, DeviceIntPtr dev,
int t; int t;
BellCtrl bctrl; /* might get BadValue part way through */ BellCtrl bctrl; /* might get BadValue part way through */
if (client->swapped) if (client->swapped) {
{
swaps(&f->length); swaps(&f->length);
swaps(&f->pitch); swaps(&f->pitch);
swaps(&f->duration); swaps(&f->duration);
} }
bctrl = b->ctrl; bctrl = b->ctrl;
if (mask & DvPercent) if (mask & DvPercent) {
{
t = f->percent; t = f->percent;
if (t == -1) if (t == -1)
t = defaultKeyboardControl.bell; t = defaultKeyboardControl.bell;
else if (t < 0 || t > 100) else if (t < 0 || t > 100) {
{
client->errorValue = t; client->errorValue = t;
SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0, SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0,
BadValue); BadValue);
...@@ -553,13 +510,11 @@ ChangeBellFeedback(ClientPtr client, DeviceIntPtr dev, ...@@ -553,13 +510,11 @@ ChangeBellFeedback(ClientPtr client, DeviceIntPtr dev,
bctrl.percent = t; bctrl.percent = t;
} }
if (mask & DvPitch) if (mask & DvPitch) {
{
t = f->pitch; t = f->pitch;
if (t == -1) if (t == -1)
t = defaultKeyboardControl.bell_pitch; t = defaultKeyboardControl.bell_pitch;
else if (t < 0) else if (t < 0) {
{
client->errorValue = t; client->errorValue = t;
SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0, SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0,
BadValue); BadValue);
...@@ -568,13 +523,11 @@ ChangeBellFeedback(ClientPtr client, DeviceIntPtr dev, ...@@ -568,13 +523,11 @@ ChangeBellFeedback(ClientPtr client, DeviceIntPtr dev,
bctrl.pitch = t; bctrl.pitch = t;
} }
if (mask & DvDuration) if (mask & DvDuration) {
{
t = f->duration; t = f->duration;
if (t == -1) if (t == -1)
t = defaultKeyboardControl.bell_duration; t = defaultKeyboardControl.bell_duration;
else if (t < 0) else if (t < 0) {
{
client->errorValue = t; client->errorValue = t;
SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0, SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0,
BadValue); BadValue);
...@@ -599,8 +552,7 @@ ChangeLedFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask, ...@@ -599,8 +552,7 @@ ChangeLedFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask,
{ {
LedCtrl lctrl; /* might get BadValue part way through */ LedCtrl lctrl; /* might get BadValue part way through */
if (client->swapped) if (client->swapped) {
{
swaps(&f->length); swaps(&f->length);
swapl(&f->led_values); swapl(&f->led_values);
swapl(&f->led_mask); swapl(&f->led_mask);
...@@ -608,8 +560,7 @@ ChangeLedFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask, ...@@ -608,8 +560,7 @@ ChangeLedFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask,
f->led_mask &= l->ctrl.led_mask; /* set only supported leds */ f->led_mask &= l->ctrl.led_mask; /* set only supported leds */
f->led_values &= l->ctrl.led_mask; /* set only supported leds */ f->led_values &= l->ctrl.led_mask; /* set only supported leds */
if (mask & DvLed) if (mask & DvLed) {
{
lctrl.led_mask = f->led_mask; lctrl.led_mask = f->led_mask;
lctrl.led_values = f->led_values; lctrl.led_values = f->led_values;
(*l->CtrlProc) (dev, &lctrl); (*l->CtrlProc) (dev, &lctrl);
......
...@@ -114,8 +114,7 @@ ProcXChangeKeyboardDevice(register ClientPtr client) ...@@ -114,8 +114,7 @@ ProcXChangeKeyboardDevice(register ClientPtr client)
rep.sequenceNumber = client->sequence; rep.sequenceNumber = client->sequence;
dev = LookupDeviceIntRec(stuff->deviceid); dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL) if (dev == NULL) {
{
rep.status = -1; rep.status = -1;
SendErrorToClient(client, IReqCode, X_ChangeKeyboardDevice, 0, SendErrorToClient(client, IReqCode, X_ChangeKeyboardDevice, 0,
BadDevice); BadDevice);
...@@ -123,8 +122,7 @@ ProcXChangeKeyboardDevice(register ClientPtr client) ...@@ -123,8 +122,7 @@ ProcXChangeKeyboardDevice(register ClientPtr client)
} }
k = dev->key; k = dev->key;
if (k == NULL) if (k == NULL) {
{
rep.status = -1; rep.status = -1;
SendErrorToClient(client, IReqCode, X_ChangeKeyboardDevice, 0, SendErrorToClient(client, IReqCode, X_ChangeKeyboardDevice, 0,
BadMatch); BadMatch);
...@@ -139,10 +137,8 @@ ProcXChangeKeyboardDevice(register ClientPtr client) ...@@ -139,10 +137,8 @@ ProcXChangeKeyboardDevice(register ClientPtr client)
(xkbd->sync.frozen && (xkbd->sync.frozen &&
xkbd->sync.other && !SameClient(xkbd->sync.other, client))) xkbd->sync.other && !SameClient(xkbd->sync.other, client)))
rep.status = GrabFrozen; rep.status = GrabFrozen;
else else {
{ if (ChangeKeyboardDevice(xkbd, dev) != Success) {
if (ChangeKeyboardDevice (xkbd, dev) != Success)
{
SendErrorToClient(client, IReqCode, X_ChangeKeyboardDevice, 0, SendErrorToClient(client, IReqCode, X_ChangeKeyboardDevice, 0,
BadDevice); BadDevice);
return Success; return Success;
...@@ -157,11 +153,11 @@ ProcXChangeKeyboardDevice(register ClientPtr client) ...@@ -157,11 +153,11 @@ ProcXChangeKeyboardDevice(register ClientPtr client)
df->revert = xf->revert; df->revert = xf->revert;
df->time = xf->time; df->time = xf->time;
df->traceGood = xf->traceGood; df->traceGood = xf->traceGood;
if (df->traceSize != xf->traceSize) if (df->traceSize != xf->traceSize) {
{
Must_have_memory = TRUE; /* XXX */ Must_have_memory = TRUE; /* XXX */
df->trace = (WindowPtr *) realloc(df->trace, df->trace = (WindowPtr *) realloc(df->trace,
xf->traceSize * sizeof(WindowPtr)); xf->traceSize *
sizeof(WindowPtr));
Must_have_memory = FALSE; /* XXX */ Must_have_memory = FALSE; /* XXX */
} }
df->traceSize = xf->traceSize; df->traceSize = xf->traceSize;
...@@ -177,13 +173,13 @@ ProcXChangeKeyboardDevice(register ClientPtr client) ...@@ -177,13 +173,13 @@ ProcXChangeKeyboardDevice(register ClientPtr client)
SendEventToAllWindows(dev, ChangeDeviceNotifyMask, (xEvent *) & ev, 1); SendEventToAllWindows(dev, ChangeDeviceNotifyMask, (xEvent *) & ev, 1);
SendMappingNotify(MappingKeyboard, k->curKeySyms.minKeyCode, SendMappingNotify(MappingKeyboard, k->curKeySyms.minKeyCode,
k->curKeySyms.maxKeyCode - k->curKeySyms.minKeyCode + 1,client); k->curKeySyms.maxKeyCode - k->curKeySyms.minKeyCode +
1, client);
rep.status = 0; rep.status = 0;
} }
WriteReplyToClient (client, sizeof (xChangeKeyboardDeviceReply), WriteReplyToClient(client, sizeof(xChangeKeyboardDeviceReply), &rep);
&rep);
return Success; return Success;
} }
......
...@@ -109,8 +109,7 @@ ProcXChangeDeviceKeyMapping(register ClientPtr client) ...@@ -109,8 +109,7 @@ ProcXChangeDeviceKeyMapping(register ClientPtr client)
REQUEST_FIXED_SIZE(xChangeDeviceKeyMappingReq, count * sizeof(CARD32)); REQUEST_FIXED_SIZE(xChangeDeviceKeyMappingReq, count * sizeof(CARD32));
dev = LookupDeviceIntRec(stuff->deviceid); dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL) if (dev == NULL) {
{
SendErrorToClient(client, IReqCode, X_ChangeDeviceKeyMapping, 0, SendErrorToClient(client, IReqCode, X_ChangeDeviceKeyMapping, 0,
BadDevice); BadDevice);
return Success; return Success;
...@@ -118,11 +117,10 @@ ProcXChangeDeviceKeyMapping(register ClientPtr client) ...@@ -118,11 +117,10 @@ ProcXChangeDeviceKeyMapping(register ClientPtr client)
len = stuff->length - (sizeof(xChangeDeviceKeyMappingReq) >> 2); len = stuff->length - (sizeof(xChangeDeviceKeyMappingReq) >> 2);
ret = ChangeKeyMapping(client, dev, len, DeviceMappingNotify, ret = ChangeKeyMapping(client, dev, len, DeviceMappingNotify,
stuff->firstKeyCode, stuff->keyCodes, stuff->keySymsPerKeyCode, stuff->firstKeyCode, stuff->keyCodes,
(KeySym *)&stuff[1]); stuff->keySymsPerKeyCode, (KeySym *) & stuff[1]);
if (ret != Success) if (ret != Success)
SendErrorToClient (client, IReqCode, X_ChangeDeviceKeyMapping, 0, SendErrorToClient(client, IReqCode, X_ChangeDeviceKeyMapping, 0, ret);
ret);
return Success; return Success;
} }
...@@ -108,24 +108,21 @@ ProcXChangeDeviceDontPropagateList(register ClientPtr client) ...@@ -108,24 +108,21 @@ ProcXChangeDeviceDontPropagateList(register ClientPtr client)
REQUEST_AT_LEAST_SIZE(xChangeDeviceDontPropagateListReq); REQUEST_AT_LEAST_SIZE(xChangeDeviceDontPropagateListReq);
if (stuff->length != (sizeof(xChangeDeviceDontPropagateListReq) >> 2) + if (stuff->length != (sizeof(xChangeDeviceDontPropagateListReq) >> 2) +
stuff->count) stuff->count) {
{
SendErrorToClient(client, IReqCode, X_ChangeDeviceDontPropagateList, 0, SendErrorToClient(client, IReqCode, X_ChangeDeviceDontPropagateList, 0,
BadLength); BadLength);
return Success; return Success;
} }
pWin = (WindowPtr) LookupWindow(stuff->window, client); pWin = (WindowPtr) LookupWindow(stuff->window, client);
if (!pWin) if (!pWin) {
{
client->errorValue = stuff->window; client->errorValue = stuff->window;
SendErrorToClient(client, IReqCode, X_ChangeDeviceDontPropagateList, 0, SendErrorToClient(client, IReqCode, X_ChangeDeviceDontPropagateList, 0,
BadWindow); BadWindow);
return Success; return Success;
} }
if (stuff->mode != AddToList && stuff->mode != DeleteFromList) if (stuff->mode != AddToList && stuff->mode != DeleteFromList) {
{
client->errorValue = stuff->window; client->errorValue = stuff->window;
SendErrorToClient(client, IReqCode, X_ChangeDeviceDontPropagateList, 0, SendErrorToClient(client, IReqCode, X_ChangeDeviceDontPropagateList, 0,
BadMode); BadMode);
...@@ -133,14 +130,14 @@ ProcXChangeDeviceDontPropagateList(register ClientPtr client) ...@@ -133,14 +130,14 @@ ProcXChangeDeviceDontPropagateList(register ClientPtr client)
} }
if (CreateMaskFromList(client, (XEventClass *) & stuff[1], if (CreateMaskFromList(client, (XEventClass *) & stuff[1],
stuff->count, tmp, NULL, X_ChangeDeviceDontPropagateList) != Success) stuff->count, tmp, NULL,
X_ChangeDeviceDontPropagateList) != Success)
return Success; return Success;
others = wOtherInputMasks(pWin); others = wOtherInputMasks(pWin);
if (!others && stuff->mode == DeleteFromList) if (!others && stuff->mode == DeleteFromList)
return Success; return Success;
for (i=0; i<EMASKSIZE; i++) for (i = 0; i < EMASKSIZE; i++) {
{
if (tmp[i].mask == 0) if (tmp[i].mask == 0)
continue; continue;
...@@ -149,10 +146,10 @@ ProcXChangeDeviceDontPropagateList(register ClientPtr client) ...@@ -149,10 +146,10 @@ ProcXChangeDeviceDontPropagateList(register ClientPtr client)
else if (others) else if (others)
tmp[i].mask |= others->dontPropagateMask[i]; tmp[i].mask |= others->dontPropagateMask[i];
if (DeviceEventSuppressForWindow (pWin,client,tmp[i].mask,i) != Success) if (DeviceEventSuppressForWindow(pWin, client, tmp[i].mask, i) !=
{ Success) {
SendErrorToClient ( client, IReqCode, X_ChangeDeviceDontPropagateList, 0, SendErrorToClient(client, IReqCode,
BadClass); X_ChangeDeviceDontPropagateList, 0, BadClass);
return Success; return Success;
} }
} }
......
...@@ -113,8 +113,7 @@ ProcXChangePointerDevice(register ClientPtr client) ...@@ -113,8 +113,7 @@ ProcXChangePointerDevice(register ClientPtr client)
rep.sequenceNumber = client->sequence; rep.sequenceNumber = client->sequence;
dev = LookupDeviceIntRec(stuff->deviceid); dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL) if (dev == NULL) {
{
rep.status = -1; rep.status = -1;
SendErrorToClient(client, IReqCode, X_ChangePointerDevice, 0, SendErrorToClient(client, IReqCode, X_ChangePointerDevice, 0,
BadDevice); BadDevice);
...@@ -123,9 +122,7 @@ ProcXChangePointerDevice(register ClientPtr client) ...@@ -123,9 +122,7 @@ ProcXChangePointerDevice(register ClientPtr client)
v = dev->valuator; v = dev->valuator;
if (v == NULL || v->numAxes < 2 || if (v == NULL || v->numAxes < 2 ||
stuff->xaxis >= v->numAxes || stuff->xaxis >= v->numAxes || stuff->yaxis >= v->numAxes) {
stuff->yaxis >= v->numAxes)
{
rep.status = -1; rep.status = -1;
SendErrorToClient(client, IReqCode, X_ChangePointerDevice, 0, BadMatch); SendErrorToClient(client, IReqCode, X_ChangePointerDevice, 0, BadMatch);
return Success; return Success;
...@@ -139,11 +136,9 @@ ProcXChangePointerDevice(register ClientPtr client) ...@@ -139,11 +136,9 @@ ProcXChangePointerDevice(register ClientPtr client)
(xptr->sync.frozen && (xptr->sync.frozen &&
xptr->sync.other && !SameClient(xptr->sync.other, client))) xptr->sync.other && !SameClient(xptr->sync.other, client)))
rep.status = GrabFrozen; rep.status = GrabFrozen;
else else {
{ if (ChangePointerDevice(xptr, dev, stuff->xaxis, stuff->yaxis) !=
if (ChangePointerDevice ( Success) {
xptr, dev, stuff->xaxis, stuff->yaxis) != Success)
{
SendErrorToClient(client, IReqCode, X_ChangePointerDevice, 0, SendErrorToClient(client, IReqCode, X_ChangePointerDevice, 0,
BadDevice); BadDevice);
return Success; return Success;
...@@ -168,8 +163,7 @@ ProcXChangePointerDevice(register ClientPtr client) ...@@ -168,8 +163,7 @@ ProcXChangePointerDevice(register ClientPtr client)
rep.status = 0; rep.status = 0;
} }
WriteReplyToClient (client, sizeof (xChangePointerDeviceReply), WriteReplyToClient(client, sizeof(xChangePointerDeviceReply), &rep);
&rep);
return Success; return Success;
} }
...@@ -193,8 +187,7 @@ SendEventToAllWindows(DeviceIntPtr dev, Mask mask, xEvent * ev, int count) ...@@ -193,8 +187,7 @@ SendEventToAllWindows(DeviceIntPtr dev, Mask mask, xEvent * ev, int count)
int i; int i;
WindowPtr pWin, p1; WindowPtr pWin, p1;
for (i=0; i<screenInfo.numScreens; i++) for (i = 0; i < screenInfo.numScreens; i++) {
{
pWin = screenInfo.screens[i]->root; pWin = screenInfo.screens[i]->root;
(void)DeliverEventsToWindow(pWin, ev, count, mask, NullGrab, dev->id); (void)DeliverEventsToWindow(pWin, ev, count, mask, NullGrab, dev->id);
p1 = pWin->firstChild; p1 = pWin->firstChild;
...@@ -215,8 +208,7 @@ FindInterestedChildren(DeviceIntPtr dev, WindowPtr p1, Mask mask, ...@@ -215,8 +208,7 @@ FindInterestedChildren(DeviceIntPtr dev, WindowPtr p1, Mask mask,
{ {
WindowPtr p2; WindowPtr p2;
while (p1) while (p1) {
{
p2 = p1->firstChild; p2 = p1->firstChild;
(void)DeliverEventsToWindow(p1, ev, count, mask, NullGrab, dev->id); (void)DeliverEventsToWindow(p1, ev, count, mask, NullGrab, dev->id);
FindInterestedChildren(dev, p2, mask, ev, count); FindInterestedChildren(dev, p2, mask, ev, count);
......
...@@ -101,8 +101,7 @@ ProcXCloseDevice(register ClientPtr client) ...@@ -101,8 +101,7 @@ ProcXCloseDevice(register ClientPtr client)
REQUEST_SIZE_MATCH(xCloseDeviceReq); REQUEST_SIZE_MATCH(xCloseDeviceReq);
d = LookupDeviceIntRec(stuff->deviceid); d = LookupDeviceIntRec(stuff->deviceid);
if (d == NULL) if (d == NULL) {
{
SendErrorToClient(client, IReqCode, X_CloseDevice, 0, BadDevice); SendErrorToClient(client, IReqCode, X_CloseDevice, 0, BadDevice);
return Success; return Success;
} }
...@@ -111,11 +110,10 @@ ProcXCloseDevice(register ClientPtr client) ...@@ -111,11 +110,10 @@ ProcXCloseDevice(register ClientPtr client)
(*d->DeactivateGrab) (d); /* release active grab */ (*d->DeactivateGrab) (d); /* release active grab */
/* Remove event selections from all windows for events from this device /* Remove event selections from all windows for events from this device
and selected by this client. * and selected by this client.
Delete passive grabs from all windows for this device. */ * 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; pWin = screenInfo.screens[i]->root;
DeleteDeviceEvents(d, pWin, client); DeleteDeviceEvents(d, pWin, client);
p1 = pWin->firstChild; p1 = pWin->firstChild;
...@@ -138,8 +136,7 @@ DeleteEventsFromChildren(DeviceIntPtr dev, WindowPtr p1, ClientPtr client) ...@@ -138,8 +136,7 @@ DeleteEventsFromChildren(DeviceIntPtr dev, WindowPtr p1, ClientPtr client)
{ {
WindowPtr p2; WindowPtr p2;
while (p1) while (p1) {
{
p2 = p1->firstChild; p2 = p1->firstChild;
DeleteDeviceEvents(dev, p1, client); DeleteDeviceEvents(dev, p1, client);
DeleteEventsFromChildren(dev, p2, client); DeleteEventsFromChildren(dev, p2, client);
...@@ -162,13 +159,11 @@ DeleteDeviceEvents(DeviceIntPtr dev, WindowPtr pWin, ClientPtr client) ...@@ -162,13 +159,11 @@ DeleteDeviceEvents(DeviceIntPtr dev, WindowPtr pWin, ClientPtr client)
GrabPtr grab, next; GrabPtr grab, next;
if ((pOthers = wOtherInputMasks(pWin)) != 0) if ((pOthers = wOtherInputMasks(pWin)) != 0)
for (others=pOthers->inputClients; others; for (others = pOthers->inputClients; others; others = others->next)
others = others->next)
if (SameClient(others, client)) if (SameClient(others, client))
others->mask[dev->id] = NoEventMask; others->mask[dev->id] = NoEventMask;
for (grab = wPassiveGrabs(pWin); grab; grab=next) for (grab = wPassiveGrabs(pWin); grab; grab = next) {
{
next = grab->next; next = grab->next;
if ((grab->device == dev) && if ((grab->device == dev) &&
(client->clientAsMask == CLIENT_BITS(grab->resource))) (client->clientAsMask == CLIENT_BITS(grab->resource)))
......
...@@ -103,26 +103,22 @@ ProcXDeviceBell(register ClientPtr client) ...@@ -103,26 +103,22 @@ ProcXDeviceBell(register ClientPtr client)
REQUEST_SIZE_MATCH(xDeviceBellReq); REQUEST_SIZE_MATCH(xDeviceBellReq);
dev = LookupDeviceIntRec(stuff->deviceid); dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL) if (dev == NULL) {
{
client->errorValue = stuff->deviceid; client->errorValue = stuff->deviceid;
SendErrorToClient(client, IReqCode, X_DeviceBell, 0, BadDevice); SendErrorToClient(client, IReqCode, X_DeviceBell, 0, BadDevice);
return Success; return Success;
} }
if (stuff->percent < -100 || stuff->percent > 100) if (stuff->percent < -100 || stuff->percent > 100) {
{
client->errorValue = stuff->percent; client->errorValue = stuff->percent;
SendErrorToClient(client, IReqCode, X_DeviceBell, 0, BadValue); SendErrorToClient(client, IReqCode, X_DeviceBell, 0, BadValue);
return Success; return Success;
} }
if (stuff->feedbackclass == KbdFeedbackClass) if (stuff->feedbackclass == KbdFeedbackClass) {
{
for (k = dev->kbdfeed; k; k = k->next) for (k = dev->kbdfeed; k; k = k->next)
if (k->ctrl.id == stuff->feedbackid) if (k->ctrl.id == stuff->feedbackid)
break; break;
if (!k) if (!k) {
{
client->errorValue = stuff->feedbackid; client->errorValue = stuff->feedbackid;
SendErrorToClient(client, IReqCode, X_DeviceBell, 0, BadValue); SendErrorToClient(client, IReqCode, X_DeviceBell, 0, BadValue);
return Success; return Success;
...@@ -131,14 +127,11 @@ ProcXDeviceBell(register ClientPtr client) ...@@ -131,14 +127,11 @@ ProcXDeviceBell(register ClientPtr client)
proc = k->BellProc; proc = k->BellProc;
ctrl = (void *)&(k->ctrl); ctrl = (void *)&(k->ctrl);
class = KbdFeedbackClass; class = KbdFeedbackClass;
} } else if (stuff->feedbackclass == BellFeedbackClass) {
else if (stuff->feedbackclass == BellFeedbackClass)
{
for (b = dev->bell; b; b = b->next) for (b = dev->bell; b; b = b->next)
if (b->ctrl.id == stuff->feedbackid) if (b->ctrl.id == stuff->feedbackid)
break; break;
if (!b) if (!b) {
{
client->errorValue = stuff->feedbackid; client->errorValue = stuff->feedbackid;
SendErrorToClient(client, IReqCode, X_DeviceBell, 0, BadValue); SendErrorToClient(client, IReqCode, X_DeviceBell, 0, BadValue);
return Success; return Success;
...@@ -147,9 +140,7 @@ ProcXDeviceBell(register ClientPtr client) ...@@ -147,9 +140,7 @@ ProcXDeviceBell(register ClientPtr client)
proc = b->BellProc; proc = b->BellProc;
ctrl = (void *)&(b->ctrl); ctrl = (void *)&(b->ctrl);
class = BellFeedbackClass; class = BellFeedbackClass;
} } else {
else
{
client->errorValue = stuff->feedbackclass; client->errorValue = stuff->feedbackclass;
SendErrorToClient(client, IReqCode, X_DeviceBell, 0, BadValue); SendErrorToClient(client, IReqCode, X_DeviceBell, 0, BadValue);
return Success; return Success;
......
...@@ -128,28 +128,29 @@ ProcessOtherEvent(xEventPtr xE, register DeviceIntPtr other, int count) ...@@ -128,28 +128,29 @@ ProcessOtherEvent(xEventPtr xE, register DeviceIntPtr other, int count)
inputInfo.pointer->button->state; inputInfo.pointer->button->state;
bit = 1 << (key & 7); bit = 1 << (key & 7);
} }
if (DeviceEventCallback) if (DeviceEventCallback) {
{
DeviceEventInfoRec eventinfo; DeviceEventInfoRec eventinfo;
eventinfo.events = (xEventPtr) xE; eventinfo.events = (xEventPtr) xE;
eventinfo.count = count; eventinfo.count = count;
CallCallbacks(&DeviceEventCallback, (void *)&eventinfo); CallCallbacks(&DeviceEventCallback, (void *)&eventinfo);
} }
for (i = 1; i < count; i++) for (i = 1; i < count; i++)
if ((++xV)->type == DeviceValuator) if ((++xV)->type == DeviceValuator) {
{
int first = xV->first_valuator; int first = xV->first_valuator;
int *axisvals; int *axisvals;
if (xV->num_valuators && (!v || (xV->num_valuators && (first + xV->num_valuators > v->numAxes)))) if (xV->num_valuators
FatalError("Bad valuators reported for device %s\n",other->name); && (!v
|| (xV->num_valuators
&& (first + xV->num_valuators > v->numAxes))))
FatalError("Bad valuators reported for device %s\n",
other->name);
xV->device_state = 0; xV->device_state = 0;
if (k) if (k)
xV->device_state |= k->state; xV->device_state |= k->state;
if (b) if (b)
xV->device_state |= b->state; xV->device_state |= b->state;
if (v && v->axisVal) if (v && v->axisVal) {
{
axisvals = v->axisVal; axisvals = v->axisVal;
switch (xV->num_valuators) { switch (xV->num_valuators) {
case 6: case 6:
...@@ -171,14 +172,11 @@ ProcessOtherEvent(xEventPtr xE, register DeviceIntPtr other, int count) ...@@ -171,14 +172,11 @@ ProcessOtherEvent(xEventPtr xE, register DeviceIntPtr other, int count)
} }
} }
if (xE->u.u.type == DeviceKeyPress) if (xE->u.u.type == DeviceKeyPress) {
{
modifiers = k->modifierMap[key]; modifiers = k->modifierMap[key];
kptr = &k->down[key >> 3]; kptr = &k->down[key >> 3];
if (*kptr & bit) /* allow ddx to generate multiple downs */ if (*kptr & bit) { /* allow ddx to generate multiple downs */
{ if (!modifiers) {
if (!modifiers)
{
xE->u.u.type = DeviceKeyRelease; xE->u.u.type = DeviceKeyRelease;
ProcessOtherEvent(xE, other, count); ProcessOtherEvent(xE, other, count);
xE->u.u.type = DeviceKeyPress; xE->u.u.type = DeviceKeyPress;
...@@ -191,24 +189,19 @@ ProcessOtherEvent(xEventPtr xE, register DeviceIntPtr other, int count) ...@@ -191,24 +189,19 @@ ProcessOtherEvent(xEventPtr xE, register DeviceIntPtr other, int count)
other->valuator->motionHintWindow = NullWindow; other->valuator->motionHintWindow = NullWindow;
*kptr |= bit; *kptr |= bit;
k->prev_state = k->state; k->prev_state = k->state;
for (i = 0, mask = 1; modifiers; i++, mask <<= 1) for (i = 0, mask = 1; modifiers; i++, mask <<= 1) {
{ if (mask & modifiers) {
if (mask & modifiers)
{
/* This key affects modifier "i" */ /* This key affects modifier "i" */
k->modifierKeyCount[i]++; k->modifierKeyCount[i]++;
k->state |= mask; k->state |= mask;
modifiers &= ~mask; modifiers &= ~mask;
} }
} }
if (!grab && CheckDeviceGrabs(other, xE, 0, count)) if (!grab && CheckDeviceGrabs(other, xE, 0, count)) {
{
other->activatingKey = key; other->activatingKey = key;
return; return;
} }
} } else if (xE->u.u.type == DeviceKeyRelease) {
else if (xE->u.u.type == DeviceKeyRelease)
{
kptr = &k->down[key >> 3]; kptr = &k->down[key >> 3];
if (!(*kptr & bit)) /* guard against duplicates */ if (!(*kptr & bit)) /* guard against duplicates */
return; return;
...@@ -217,13 +210,10 @@ ProcessOtherEvent(xEventPtr xE, register DeviceIntPtr other, int count) ...@@ -217,13 +210,10 @@ ProcessOtherEvent(xEventPtr xE, register DeviceIntPtr other, int count)
other->valuator->motionHintWindow = NullWindow; other->valuator->motionHintWindow = NullWindow;
*kptr &= ~bit; *kptr &= ~bit;
k->prev_state = k->state; k->prev_state = k->state;
for (i = 0, mask = 1; modifiers; i++, mask <<= 1) for (i = 0, mask = 1; modifiers; i++, mask <<= 1) {
{ if (mask & modifiers) {
if (mask & modifiers)
{
/* This key affects modifier "i" */ /* This key affects modifier "i" */
if (--k->modifierKeyCount[i] <= 0) if (--k->modifierKeyCount[i] <= 0) {
{
k->modifierKeyCount[i] = 0; k->modifierKeyCount[i] = 0;
k->state &= ~mask; k->state &= ~mask;
} }
...@@ -233,9 +223,7 @@ ProcessOtherEvent(xEventPtr xE, register DeviceIntPtr other, int count) ...@@ -233,9 +223,7 @@ ProcessOtherEvent(xEventPtr xE, register DeviceIntPtr other, int count)
if (other->fromPassiveGrab && (key == other->activatingKey)) if (other->fromPassiveGrab && (key == other->activatingKey))
deactivateDeviceGrab = TRUE; deactivateDeviceGrab = TRUE;
} } else if (xE->u.u.type == DeviceButtonPress) {
else if (xE->u.u.type == DeviceButtonPress)
{
kptr = &b->down[key >> 3]; kptr = &b->down[key >> 3];
*kptr |= bit; *kptr |= bit;
if (other->valuator) if (other->valuator)
...@@ -252,9 +240,7 @@ ProcessOtherEvent(xEventPtr xE, register DeviceIntPtr other, int count) ...@@ -252,9 +240,7 @@ ProcessOtherEvent(xEventPtr xE, register DeviceIntPtr other, int count)
if (CheckDeviceGrabs(other, xE, 0, count)) if (CheckDeviceGrabs(other, xE, 0, count))
return; return;
} } else if (xE->u.u.type == DeviceButtonRelease) {
else if (xE->u.u.type == DeviceButtonRelease)
{
kptr = &b->down[key >> 3]; kptr = &b->down[key >> 3];
*kptr &= ~bit; *kptr &= ~bit;
if (other->valuator) if (other->valuator)
...@@ -269,8 +255,7 @@ ProcessOtherEvent(xEventPtr xE, register DeviceIntPtr other, int count) ...@@ -269,8 +255,7 @@ ProcessOtherEvent(xEventPtr xE, register DeviceIntPtr other, int count)
SetMaskForEvent(Motion_Filter(b), DeviceMotionNotify); SetMaskForEvent(Motion_Filter(b), DeviceMotionNotify);
if (!b->state && other->fromPassiveGrab) if (!b->state && other->fromPassiveGrab)
deactivateDeviceGrab = TRUE; deactivateDeviceGrab = TRUE;
} } else if (xE->u.u.type == ProximityIn)
else if (xE->u.u.type == ProximityIn)
other->valuator->mode &= ~OutOfProximity; other->valuator->mode &= ~OutOfProximity;
else if (xE->u.u.type == ProximityOut) else if (xE->u.u.type == ProximityOut)
other->valuator->mode |= OutOfProximity; other->valuator->mode |= OutOfProximity;
...@@ -328,8 +313,7 @@ FixDeviceStateNotify(DeviceIntPtr dev, deviceStateNotify * ev, KeyClassPtr k, ...@@ -328,8 +313,7 @@ FixDeviceStateNotify(DeviceIntPtr dev, deviceStateNotify * ev, KeyClassPtr k,
ev->classes_reported |= (1 << ButtonClass); ev->classes_reported |= (1 << ButtonClass);
ev->num_buttons = b->numButtons; ev->num_buttons = b->numButtons;
memmove((char *)&ev->buttons[0], (char *)b->down, 4); memmove((char *)&ev->buttons[0], (char *)b->down, 4);
} } else if (k) {
else if (k) {
ev->classes_reported |= (1 << KeyClass); ev->classes_reported |= (1 << KeyClass);
ev->num_keys = k->curKeySyms.maxKeyCode - k->curKeySyms.minKeyCode; ev->num_keys = k->curKeySyms.maxKeyCode - k->curKeySyms.minKeyCode;
memmove((char *)&ev->keys[0], (char *)k->down, 4); memmove((char *)&ev->keys[0], (char *)k->down, 4);
...@@ -339,8 +323,7 @@ FixDeviceStateNotify(DeviceIntPtr dev, deviceStateNotify * ev, KeyClassPtr k, ...@@ -339,8 +323,7 @@ FixDeviceStateNotify(DeviceIntPtr dev, deviceStateNotify * ev, KeyClassPtr k,
ev->classes_reported |= (1 << ValuatorClass); ev->classes_reported |= (1 << ValuatorClass);
ev->classes_reported |= (dev->valuator->mode << ModeBitsShift); ev->classes_reported |= (dev->valuator->mode << ModeBitsShift);
ev->num_valuators = nval < 3 ? nval : 3; ev->num_valuators = nval < 3 ? nval : 3;
switch (ev->num_valuators) switch (ev->num_valuators) {
{
case 3: case 3:
ev->valuator2 = v->axisVal[first + 2]; ev->valuator2 = v->axisVal[first + 2];
case 2: case 2:
...@@ -505,25 +488,20 @@ GrabButton(ClientPtr client, DeviceIntPtr dev, BYTE this_device_mode, ...@@ -505,25 +488,20 @@ GrabButton(ClientPtr client, DeviceIntPtr dev, BYTE this_device_mode,
GrabPtr grab; GrabPtr grab;
if ((this_device_mode != GrabModeSync) && if ((this_device_mode != GrabModeSync) &&
(this_device_mode != GrabModeAsync)) (this_device_mode != GrabModeAsync)) {
{
client->errorValue = this_device_mode; client->errorValue = this_device_mode;
return BadValue; return BadValue;
} }
if ((other_devices_mode != GrabModeSync) && if ((other_devices_mode != GrabModeSync) &&
(other_devices_mode != GrabModeAsync)) (other_devices_mode != GrabModeAsync)) {
{
client->errorValue = other_devices_mode; client->errorValue = other_devices_mode;
return BadValue; return BadValue;
} }
if ((modifiers != AnyModifier) && if ((modifiers != AnyModifier) && (modifiers & ~AllModifiersMask)) {
(modifiers & ~AllModifiersMask))
{
client->errorValue = modifiers; client->errorValue = modifiers;
return BadValue; return BadValue;
} }
if ((ownerEvents != xFalse) && (ownerEvents != xTrue)) if ((ownerEvents != xFalse) && (ownerEvents != xTrue)) {
{
client->errorValue = ownerEvents; client->errorValue = ownerEvents;
return BadValue; return BadValue;
} }
...@@ -532,28 +510,25 @@ GrabButton(ClientPtr client, DeviceIntPtr dev, BYTE this_device_mode, ...@@ -532,28 +510,25 @@ GrabButton(ClientPtr client, DeviceIntPtr dev, BYTE this_device_mode,
return BadWindow; return BadWindow;
if (rconfineTo == None) if (rconfineTo == None)
confineTo = NullWindow; confineTo = NullWindow;
else else {
{
confineTo = LookupWindow(rconfineTo, client); confineTo = LookupWindow(rconfineTo, client);
if (!confineTo) if (!confineTo)
return BadWindow; return BadWindow;
} }
if (rcursor == None) if (rcursor == None)
cursor = NullCursor; cursor = NullCursor;
else else {
{
cursor = (CursorPtr) LookupIDByType(rcursor, RT_CURSOR); cursor = (CursorPtr) LookupIDByType(rcursor, RT_CURSOR);
if (!cursor) if (!cursor) {
{
client->errorValue = rcursor; client->errorValue = rcursor;
return BadCursor; return BadCursor;
} }
} }
grab = CreateGrab(client->index, dev, pWin, eventMask, grab = CreateGrab(client->index, dev, pWin, eventMask,
(Bool)ownerEvents, (Bool) this_device_mode, (Bool)other_devices_mode, (Bool) ownerEvents, (Bool) this_device_mode,
modifier_device, modifiers, DeviceButtonPress, button, confineTo, (Bool) other_devices_mode, modifier_device, modifiers,
cursor); DeviceButtonPress, button, confineTo, cursor);
if (!grab) if (!grab)
return BadAlloc; return BadAlloc;
return AddPassiveGrabToList(grab); return AddPassiveGrabToList(grab);
...@@ -572,32 +547,25 @@ GrabKey(ClientPtr client, DeviceIntPtr dev, BYTE this_device_mode, ...@@ -572,32 +547,25 @@ GrabKey(ClientPtr client, DeviceIntPtr dev, BYTE this_device_mode,
if (k == NULL) if (k == NULL)
return BadMatch; return BadMatch;
if ((other_devices_mode != GrabModeSync) && if ((other_devices_mode != GrabModeSync) &&
(other_devices_mode != GrabModeAsync)) (other_devices_mode != GrabModeAsync)) {
{
client->errorValue = other_devices_mode; client->errorValue = other_devices_mode;
return BadValue; return BadValue;
} }
if ((this_device_mode != GrabModeSync) && if ((this_device_mode != GrabModeSync) &&
(this_device_mode != GrabModeAsync)) (this_device_mode != GrabModeAsync)) {
{
client->errorValue = this_device_mode; client->errorValue = this_device_mode;
return BadValue; return BadValue;
} }
if (((key > k->curKeySyms.maxKeyCode) || if (((key > k->curKeySyms.maxKeyCode) || (key < k->curKeySyms.minKeyCode))
(key < k->curKeySyms.minKeyCode)) && (key != AnyKey)) {
&& (key != AnyKey))
{
client->errorValue = key; client->errorValue = key;
return BadValue; return BadValue;
} }
if ((modifiers != AnyModifier) && if ((modifiers != AnyModifier) && (modifiers & ~AllModifiersMask)) {
(modifiers & ~AllModifiersMask))
{
client->errorValue = modifiers; client->errorValue = modifiers;
return BadValue; return BadValue;
} }
if ((ownerEvents != xTrue) && (ownerEvents != xFalse)) if ((ownerEvents != xTrue) && (ownerEvents != xFalse)) {
{
client->errorValue = ownerEvents; client->errorValue = ownerEvents;
return BadValue; return BadValue;
} }
...@@ -607,8 +575,8 @@ GrabKey(ClientPtr client, DeviceIntPtr dev, BYTE this_device_mode, ...@@ -607,8 +575,8 @@ GrabKey(ClientPtr client, DeviceIntPtr dev, BYTE this_device_mode,
grab = CreateGrab(client->index, dev, pWin, grab = CreateGrab(client->index, dev, pWin,
mask, ownerEvents, this_device_mode, other_devices_mode, mask, ownerEvents, this_device_mode, other_devices_mode,
modifier_device, modifiers, DeviceKeyPress, key, NullWindow, modifier_device, modifiers, DeviceKeyPress, key,
NullCursor); NullWindow, NullCursor);
if (!grab) if (!grab)
return BadAlloc; return BadAlloc;
return AddPassiveGrabToList(grab); return AddPassiveGrabToList(grab);
...@@ -623,43 +591,35 @@ SelectForWindow(DeviceIntPtr dev, WindowPtr pWin, ClientPtr client, ...@@ -623,43 +591,35 @@ SelectForWindow(DeviceIntPtr dev, WindowPtr pWin, ClientPtr client,
Mask check; Mask check;
InputClientsPtr others; InputClientsPtr others;
if (mask & ~validmasks) if (mask & ~validmasks) {
{
client->errorValue = mask; client->errorValue = mask;
return BadValue; return BadValue;
} }
check = (mask & exclusivemasks); check = (mask & exclusivemasks);
if (wOtherInputMasks(pWin)) if (wOtherInputMasks(pWin)) {
{ if (check & wOtherInputMasks(pWin)->inputEvents[mskidx]) { /* It is illegal for two different
if (check & wOtherInputMasks(pWin)->inputEvents[mskidx]) * clients to select on any of the
{ /* It is illegal for two different * events for maskcheck. However,
clients to select on any of the * it is OK, for some client to
events for maskcheck. However, * continue selecting on one of those
it is OK, for some client to * events. */
continue selecting on one of those
events. */
for (others = wOtherInputMasks(pWin)->inputClients; others; for (others = wOtherInputMasks(pWin)->inputClients; others;
others = others->next) others = others->next) {
{
if (!SameClient(others, client) && (check & if (!SameClient(others, client) && (check &
others->mask[mskidx])) others->mask[mskidx]))
return BadAccess; return BadAccess;
} }
} }
for (others = wOtherInputMasks(pWin)->inputClients; others; for (others = wOtherInputMasks(pWin)->inputClients; others;
others = others->next) others = others->next) {
{ if (SameClient(others, client)) {
if (SameClient(others, client))
{
check = others->mask[mskidx]; check = others->mask[mskidx];
others->mask[mskidx] = mask; others->mask[mskidx] = mask;
if (mask == 0) if (mask == 0) {
{
for (i = 0; i < EMASKSIZE; i++) for (i = 0; i < EMASKSIZE; i++)
if (i != mskidx && others->mask[i] != 0) if (i != mskidx && others->mask[i] != 0)
break; break;
if (i == EMASKSIZE) if (i == EMASKSIZE) {
{
RecalculateDeviceDeliverableEvents(pWin); RecalculateDeviceDeliverableEvents(pWin);
if (ShouldFreeInputMasks(pWin, FALSE)) if (ShouldFreeInputMasks(pWin, FALSE))
FreeResource(others->resource, RT_NONE); FreeResource(others->resource, RT_NONE);
...@@ -728,13 +688,10 @@ RecalculateDeviceDeliverableEvents(WindowPtr pWin) ...@@ -728,13 +688,10 @@ RecalculateDeviceDeliverableEvents(WindowPtr pWin)
int i; int i;
pChild = pWin; pChild = pWin;
while (1) while (1) {
{ if ((inputMasks = wOtherInputMasks(pChild)) != 0) {
if ((inputMasks = wOtherInputMasks(pChild)) != 0)
{
for (others = inputMasks->inputClients; others; for (others = inputMasks->inputClients; others;
others = others->next) others = others->next) {
{
for (i = 0; i < EMASKSIZE; i++) for (i = 0; i < EMASKSIZE; i++)
inputMasks->inputEvents[i] |= others->mask[i]; inputMasks->inputEvents[i] |= others->mask[i];
} }
...@@ -745,10 +702,10 @@ RecalculateDeviceDeliverableEvents(WindowPtr pWin) ...@@ -745,10 +702,10 @@ RecalculateDeviceDeliverableEvents(WindowPtr pWin)
for (i = 0; i < EMASKSIZE; i++) for (i = 0; i < EMASKSIZE; i++)
inputMasks->deliverableEvents[i] |= inputMasks->deliverableEvents[i] |=
(wOtherInputMasks(tmp)->deliverableEvents[i] (wOtherInputMasks(tmp)->deliverableEvents[i]
& ~inputMasks->dontPropagateMask[i] & PropagateMask[i]); & ~inputMasks->
dontPropagateMask[i] & PropagateMask[i]);
} }
if (pChild->firstChild) if (pChild->firstChild) {
{
pChild = pChild->firstChild; pChild = pChild->firstChild;
continue; continue;
} }
...@@ -768,35 +725,25 @@ InputClientGone(register WindowPtr pWin, XID id) ...@@ -768,35 +725,25 @@ InputClientGone(register WindowPtr pWin, XID id)
return (Success); return (Success);
prev = 0; prev = 0;
for (other = wOtherInputMasks(pWin)->inputClients; other; for (other = wOtherInputMasks(pWin)->inputClients; other;
other = other->next) other = other->next) {
{ if (other->resource == id) {
if (other->resource == id) if (prev) {
{
if (prev)
{
prev->next = other->next; prev->next = other->next;
free(other); free(other);
} } else if (!(other->next)) {
else if (!(other->next)) if (ShouldFreeInputMasks(pWin, TRUE)) {
{
if (ShouldFreeInputMasks(pWin, TRUE))
{
wOtherInputMasks(pWin)->inputClients = other->next; wOtherInputMasks(pWin)->inputClients = other->next;
free(wOtherInputMasks(pWin)); free(wOtherInputMasks(pWin));
pWin->optional->inputMasks = (OtherInputMasks *) NULL; pWin->optional->inputMasks = (OtherInputMasks *) NULL;
CheckWindowOptionalNeed(pWin); CheckWindowOptionalNeed(pWin);
free(other); free(other);
} } else {
else
{
other->resource = FakeClientID(0); other->resource = FakeClientID(0);
if (!AddResource(other->resource, RT_INPUTCLIENT, if (!AddResource(other->resource, RT_INPUTCLIENT,
(void *) pWin)) (void *) pWin))
return BadAlloc; return BadAlloc;
} }
} } else {
else
{
wOtherInputMasks(pWin)->inputClients = other->next; wOtherInputMasks(pWin)->inputClients = other->next;
free(other); free(other);
} }
...@@ -819,8 +766,7 @@ SendEvent(ClientPtr client, DeviceIntPtr d, Window dest, Bool propagate, ...@@ -819,8 +766,7 @@ SendEvent(ClientPtr client, DeviceIntPtr d, Window dest, Bool propagate,
if (dest == PointerWindow) if (dest == PointerWindow)
pWin = spriteWin; pWin = spriteWin;
else if (dest == InputFocus) else if (dest == InputFocus) {
{
WindowPtr inputFocus; WindowPtr inputFocus;
if (!d->focus) if (!d->focus)
...@@ -835,32 +781,26 @@ SendEvent(ClientPtr client, DeviceIntPtr d, Window dest, Bool propagate, ...@@ -835,32 +781,26 @@ SendEvent(ClientPtr client, DeviceIntPtr d, Window dest, Bool propagate,
return Success; return Success;
/* If the input focus is PointerRootWin, send the event to where /* If the input focus is PointerRootWin, send the event to where
the pointer is if possible, then perhaps propogate up to root. */ * the pointer is if possible, then perhaps propogate up to root. */
if (inputFocus == PointerRootWin) if (inputFocus == PointerRootWin)
inputFocus = GetCurrentRootWindow(); inputFocus = GetCurrentRootWindow();
if (IsParent(inputFocus, spriteWin)) if (IsParent(inputFocus, spriteWin)) {
{
effectiveFocus = inputFocus; effectiveFocus = inputFocus;
pWin = spriteWin; pWin = spriteWin;
} } else
else
effectiveFocus = pWin = inputFocus; effectiveFocus = pWin = inputFocus;
} } else
else
pWin = LookupWindow(dest, client); pWin = LookupWindow(dest, client);
if (!pWin) if (!pWin)
return BadWindow; return BadWindow;
if ((propagate != xFalse) && (propagate != xTrue)) if ((propagate != xFalse) && (propagate != xTrue)) {
{
client->errorValue = propagate; client->errorValue = propagate;
return BadValue; return BadValue;
} }
ev->u.u.type |= 0x80; ev->u.u.type |= 0x80;
if (propagate) if (propagate) {
{ for (; pWin; pWin = pWin->parent) {
for (;pWin; pWin = pWin->parent)
{
if (DeliverEventsToWindow(pWin, ev, count, mask, NullGrab, d->id)) if (DeliverEventsToWindow(pWin, ev, count, mask, NullGrab, d->id))
return Success; return Success;
if (pWin == effectiveFocus) if (pWin == effectiveFocus)
...@@ -870,8 +810,7 @@ SendEvent(ClientPtr client, DeviceIntPtr d, Window dest, Bool propagate, ...@@ -870,8 +810,7 @@ SendEvent(ClientPtr client, DeviceIntPtr d, Window dest, Bool propagate,
if (!mask) if (!mask)
break; break;
} }
} } else
else
(void)(DeliverEventsToWindow(pWin, ev, count, mask, NullGrab, d->id)); (void)(DeliverEventsToWindow(pWin, ev, count, mask, NullGrab, d->id));
return Success; return Success;
} }
...@@ -885,16 +824,14 @@ SetButtonMapping(ClientPtr client, DeviceIntPtr dev, int nElts, BYTE * map) ...@@ -885,16 +824,14 @@ SetButtonMapping(ClientPtr client, DeviceIntPtr dev, int nElts, BYTE * map)
if (b == NULL) if (b == NULL)
return BadMatch; return BadMatch;
if (nElts != b->numButtons) if (nElts != b->numButtons) {
{
client->errorValue = nElts; client->errorValue = nElts;
return BadValue; return BadValue;
} }
if (BadDeviceMap(&map[0], nElts, 1, 255, &client->errorValue)) if (BadDeviceMap(&map[0], nElts, 1, 255, &client->errorValue))
return BadValue; return BadValue;
for (i = 0; i < nElts; i++) for (i = 0; i < nElts; i++)
if ((b->map[i + 1] != map[i]) && if ((b->map[i + 1] != map[i]) && BitIsOn(b->down, i + 1))
BitIsOn(b->down, i + 1))
return MappingBusy; return MappingBusy;
for (i = 0; i < nElts; i++) for (i = 0; i < nElts; i++)
b->map[i + 1] = map[i]; b->map[i + 1] = map[i];
...@@ -938,10 +875,11 @@ SetModifierMapping(ClientPtr client, DeviceIntPtr dev, int len, int rlen, ...@@ -938,10 +875,11 @@ SetModifierMapping(ClientPtr client, DeviceIntPtr dev, int len, int rlen,
* that the DDX layer likes the choice. * that the DDX layer likes the choice.
*/ */
if (!AllModifierKeysAreUp(dev, (*k)->modifierKeyMap, if (!AllModifierKeysAreUp(dev, (*k)->modifierKeyMap,
(int)(*k)->maxKeysPerModifier, inputMap, (int)numKeyPerModifier) (int)(*k)->maxKeysPerModifier, inputMap,
|| (int)numKeyPerModifier)
!AllModifierKeysAreUp(dev, inputMap, (int)numKeyPerModifier, || !AllModifierKeysAreUp(dev, inputMap, (int)numKeyPerModifier,
(*k)->modifierKeyMap, (int)(*k)->maxKeysPerModifier)) { (*k)->modifierKeyMap,
(int)(*k)->maxKeysPerModifier)) {
return MappingBusy; return MappingBusy;
} else { } else {
for (i = 0; i < inputMapLen; i++) { for (i = 0; i < inputMapLen; i++) {
...@@ -971,7 +909,8 @@ SetModifierMapping(ClientPtr client, DeviceIntPtr dev, int len, int rlen, ...@@ -971,7 +909,8 @@ SetModifierMapping(ClientPtr client, DeviceIntPtr dev, int len, int rlen,
(*k)->maxKeysPerModifier = numKeyPerModifier; (*k)->maxKeysPerModifier = numKeyPerModifier;
for (i = 0; i < MAP_LENGTH; i++) for (i = 0; i < MAP_LENGTH; i++)
(*k)->modifierMap[i] = 0; (*k)->modifierMap[i] = 0;
for (i = 0; i < inputMapLen; i++) if (inputMap[i]) { for (i = 0; i < inputMapLen; i++)
if (inputMap[i]) {
(*k)->modifierMap[inputMap[i]] (*k)->modifierMap[inputMap[i]]
|= (1 << (i / (*k)->maxKeysPerModifier)); |= (1 << (i / (*k)->maxKeysPerModifier));
} }
...@@ -990,8 +929,7 @@ SendDeviceMappingNotify(CARD8 request, ...@@ -990,8 +929,7 @@ SendDeviceMappingNotify(CARD8 request,
ev->request = request; ev->request = request;
ev->deviceid = dev->id; ev->deviceid = dev->id;
ev->time = currentTime.milliseconds; ev->time = currentTime.milliseconds;
if (request == MappingKeyboard) if (request == MappingKeyboard) {
{
ev->firstKeyCode = firstKeyCode; ev->firstKeyCode = firstKeyCode;
ev->count = count; ev->count = count;
} }
...@@ -1017,13 +955,11 @@ ChangeKeyMapping(ClientPtr client, ...@@ -1017,13 +955,11 @@ ChangeKeyMapping(ClientPtr client,
return BadLength; return BadLength;
if ((firstKeyCode < k->curKeySyms.minKeyCode) || if ((firstKeyCode < k->curKeySyms.minKeyCode) ||
(firstKeyCode + keyCodes - 1 > k->curKeySyms.maxKeyCode)) (firstKeyCode + keyCodes - 1 > k->curKeySyms.maxKeyCode)) {
{
client->errorValue = firstKeyCode; client->errorValue = firstKeyCode;
return BadValue; return BadValue;
} }
if (keySymsPerKeyCode == 0) if (keySymsPerKeyCode == 0) {
{
client->errorValue = 0; client->errorValue = 0;
return BadValue; return BadValue;
} }
...@@ -1033,8 +969,7 @@ ChangeKeyMapping(ClientPtr client, ...@@ -1033,8 +969,7 @@ ChangeKeyMapping(ClientPtr client,
keysyms.map = map; keysyms.map = map;
if (!SetKeySymsMap(&k->curKeySyms, &keysyms)) if (!SetKeySymsMap(&k->curKeySyms, &keysyms))
return BadAlloc; return BadAlloc;
SendDeviceMappingNotify(MappingKeyboard, firstKeyCode, keyCodes, SendDeviceMappingNotify(MappingKeyboard, firstKeyCode, keyCodes, dev);
dev);
return client->noClientException; return client->noClientException;
} }
...@@ -1046,10 +981,8 @@ DeleteWindowFromAnyExtEvents(WindowPtr pWin, Bool freeResources) ...@@ -1046,10 +981,8 @@ DeleteWindowFromAnyExtEvents(WindowPtr pWin, Bool freeResources)
InputClientsPtr ic; InputClientsPtr ic;
struct _OtherInputMasks *inputMasks; struct _OtherInputMasks *inputMasks;
for (dev=inputInfo.devices; dev; dev=dev->next) for (dev = inputInfo.devices; dev; dev = dev->next) {
{ if (dev == inputInfo.pointer || dev == inputInfo.keyboard)
if (dev == inputInfo.pointer ||
dev == inputInfo.keyboard)
continue; continue;
DeleteDeviceFromAnyExtEvents(pWin, dev); DeleteDeviceFromAnyExtEvents(pWin, dev);
} }
...@@ -1058,8 +991,7 @@ DeleteWindowFromAnyExtEvents(WindowPtr pWin, Bool freeResources) ...@@ -1058,8 +991,7 @@ DeleteWindowFromAnyExtEvents(WindowPtr pWin, Bool freeResources)
DeleteDeviceFromAnyExtEvents(pWin, dev); DeleteDeviceFromAnyExtEvents(pWin, dev);
if (freeResources) if (freeResources)
while ((inputMasks = wOtherInputMasks(pWin)) != 0) while ((inputMasks = wOtherInputMasks(pWin)) != 0) {
{
ic = inputMasks->inputClients; ic = inputMasks->inputClients;
for (i = 0; i < EMASKSIZE; i++) for (i = 0; i < EMASKSIZE; i++)
inputMasks->dontPropagateMask[i] = 0; inputMasks->dontPropagateMask[i] = 0;
...@@ -1073,17 +1005,16 @@ DeleteDeviceFromAnyExtEvents(WindowPtr pWin, DeviceIntPtr dev) ...@@ -1073,17 +1005,16 @@ DeleteDeviceFromAnyExtEvents(WindowPtr pWin, DeviceIntPtr dev)
WindowPtr parent; WindowPtr parent;
/* Deactivate any grabs performed on this window, before making /* Deactivate any grabs performed on this window, before making
any input focus changes. * any input focus changes.
Deactivating a device grab should cause focus events. */ * Deactivating a device grab should cause focus events. */
if (dev->grab && (dev->grab->window == pWin)) if (dev->grab && (dev->grab->window == pWin))
(*dev->DeactivateGrab) (dev); (*dev->DeactivateGrab) (dev);
/* If the focus window is a root window (ie. has no parent) /* If the focus window is a root window (ie. has no parent)
then don't delete the focus from it. */ * then don't delete the focus from it. */
if (dev->focus && (pWin==dev->focus->win) && (pWin->parent != NullWindow)) if (dev->focus && (pWin == dev->focus->win) && (pWin->parent != NullWindow)) {
{
int focusEventMode = NotifyNormal; int focusEventMode = NotifyNormal;
/* If a grab is in progress, then alter the mode of focus events. */ /* If a grab is in progress, then alter the mode of focus events. */
...@@ -1091,8 +1022,7 @@ DeleteDeviceFromAnyExtEvents(WindowPtr pWin, DeviceIntPtr dev) ...@@ -1091,8 +1022,7 @@ DeleteDeviceFromAnyExtEvents(WindowPtr pWin, DeviceIntPtr dev)
if (dev->grab) if (dev->grab)
focusEventMode = NotifyWhileGrabbed; focusEventMode = NotifyWhileGrabbed;
switch (dev->focus->revert) switch (dev->focus->revert) {
{
case RevertToNone: case RevertToNone:
DoFocusEvents(dev, pWin, NoneWin, focusEventMode); DoFocusEvents(dev, pWin, NoneWin, focusEventMode);
dev->focus->win = NoneWin; dev->focus->win = NoneWin;
...@@ -1100,11 +1030,11 @@ DeleteDeviceFromAnyExtEvents(WindowPtr pWin, DeviceIntPtr dev) ...@@ -1100,11 +1030,11 @@ DeleteDeviceFromAnyExtEvents(WindowPtr pWin, DeviceIntPtr dev)
break; break;
case RevertToParent: case RevertToParent:
parent = pWin; parent = pWin;
do do {
{
parent = parent->parent; parent = parent->parent;
dev->focus->traceGood--; dev->focus->traceGood--;
} while (!parent->realized); }
while (!parent->realized);
DoFocusEvents(dev, pWin, parent, focusEventMode); DoFocusEvents(dev, pWin, parent, focusEventMode);
dev->focus->win = parent; dev->focus->win = parent;
dev->focus->revert = RevertToNone; dev->focus->revert = RevertToNone;
...@@ -1140,18 +1070,13 @@ MaybeSendDeviceMotionNotifyHint(deviceKeyButtonPointer * pEvents, Mask mask) ...@@ -1140,18 +1070,13 @@ MaybeSendDeviceMotionNotifyHint(deviceKeyButtonPointer * pEvents, Mask mask)
DeviceIntPtr dev; DeviceIntPtr dev;
dev = LookupDeviceIntRec(pEvents->deviceid & DEVICE_BITS); dev = LookupDeviceIntRec(pEvents->deviceid & DEVICE_BITS);
if (pEvents->type == DeviceMotionNotify) if (pEvents->type == DeviceMotionNotify) {
{ if (mask & DevicePointerMotionHintMask) {
if (mask & DevicePointerMotionHintMask) if (WID(dev->valuator->motionHintWindow) == pEvents->event) {
{
if (WID(dev->valuator->motionHintWindow) == pEvents->event)
{
return 1; /* don't send, but pretend we did */ return 1; /* don't send, but pretend we did */
} }
pEvents->detail = NotifyHint; pEvents->detail = NotifyHint;
} } else {
else
{
pEvents->detail = NotifyNormal; pEvents->detail = NotifyNormal;
} }
} }
...@@ -1169,14 +1094,14 @@ CheckDeviceGrabAndHintWindow(WindowPtr pWin, int type, ...@@ -1169,14 +1094,14 @@ CheckDeviceGrabAndHintWindow(WindowPtr pWin, int type,
if (type == DeviceMotionNotify) if (type == DeviceMotionNotify)
dev->valuator->motionHintWindow = pWin; dev->valuator->motionHintWindow = pWin;
else if ((type == DeviceButtonPress) && (!grab) && else if ((type == DeviceButtonPress) && (!grab) &&
(deliveryMask & DeviceButtonGrabMask)) (deliveryMask & DeviceButtonGrabMask)) {
{
GrabRec tempGrab; GrabRec tempGrab;
tempGrab.device = dev; tempGrab.device = dev;
tempGrab.resource = client->clientAsMask; tempGrab.resource = client->clientAsMask;
tempGrab.window = pWin; tempGrab.window = pWin;
tempGrab.ownerEvents = (deliveryMask & DeviceOwnerGrabButtonMask) ? TRUE : FALSE; tempGrab.ownerEvents =
(deliveryMask & DeviceOwnerGrabButtonMask) ? TRUE : FALSE;
tempGrab.eventMask = deliveryMask; tempGrab.eventMask = deliveryMask;
tempGrab.keyboardMode = GrabModeAsync; tempGrab.keyboardMode = GrabModeAsync;
tempGrab.pointerMode = GrabModeAsync; tempGrab.pointerMode = GrabModeAsync;
...@@ -1194,8 +1119,7 @@ DeviceEventMaskForClient(DeviceIntPtr dev, WindowPtr pWin, ClientPtr client) ...@@ -1194,8 +1119,7 @@ DeviceEventMaskForClient(DeviceIntPtr dev, WindowPtr pWin, ClientPtr client)
if (!wOtherInputMasks(pWin)) if (!wOtherInputMasks(pWin))
return 0; return 0;
for (other = wOtherInputMasks(pWin)->inputClients; other; for (other = wOtherInputMasks(pWin)->inputClients; other;
other = other->next) other = other->next) {
{
if (SameClient(other, client)) if (SameClient(other, client))
return other->mask[dev->id]; return other->mask[dev->id];
} }
...@@ -1226,19 +1150,15 @@ DeviceEventSuppressForWindow(WindowPtr pWin, ClientPtr client, Mask mask, ...@@ -1226,19 +1150,15 @@ DeviceEventSuppressForWindow(WindowPtr pWin, ClientPtr client, Mask mask,
{ {
struct _OtherInputMasks *inputMasks = wOtherInputMasks(pWin); struct _OtherInputMasks *inputMasks = wOtherInputMasks(pWin);
if (mask & ~PropagateMask[maskndx]) if (mask & ~PropagateMask[maskndx]) {
{
client->errorValue = mask; client->errorValue = mask;
return BadValue; return BadValue;
} }
if (mask == 0) if (mask == 0) {
{
if (inputMasks) if (inputMasks)
inputMasks->dontPropagateMask[maskndx] = mask; inputMasks->dontPropagateMask[maskndx] = mask;
} } else {
else
{
if (!inputMasks) if (!inputMasks)
AddExtensionClient(pWin, client, 0, 0); AddExtensionClient(pWin, client, 0, 0);
inputMasks = wOtherInputMasks(pWin); inputMasks = wOtherInputMasks(pWin);
......
...@@ -120,24 +120,26 @@ struct dev_type ...@@ -120,24 +120,26 @@ struct dev_type
{ {
Atom type; Atom type;
char *name; char *name;
}dev_type [] = {{0,XI_KEYBOARD}, } dev_type[] = {
{0,XI_MOUSE}, {
{0,XI_TABLET}, 0, XI_KEYBOARD}, {
{0,XI_TOUCHSCREEN}, 0, XI_MOUSE}, {
{0,XI_TOUCHPAD}, 0, XI_TABLET}, {
{0,XI_BARCODE}, 0, XI_TOUCHSCREEN}, {
{0,XI_BUTTONBOX}, 0, XI_TOUCHPAD}, {
{0,XI_KNOB_BOX}, 0, XI_BARCODE}, {
{0,XI_ONE_KNOB}, 0, XI_BUTTONBOX}, {
{0,XI_NINE_KNOB}, 0, XI_KNOB_BOX}, {
{0,XI_TRACKBALL}, 0, XI_ONE_KNOB}, {
{0,XI_QUADRATURE}, 0, XI_NINE_KNOB}, {
{0,XI_ID_MODULE}, 0, XI_TRACKBALL}, {
{0,XI_SPACEBALL}, 0, XI_QUADRATURE}, {
{0,XI_DATAGLOVE}, 0, XI_ID_MODULE}, {
{0,XI_EYETRACKER}, 0, XI_SPACEBALL}, {
{0,XI_CURSORKEYS}, 0, XI_DATAGLOVE}, {
{0,XI_FOOTMOUSE}}; 0, XI_EYETRACKER}, {
0, XI_CURSORKEYS}, {
0, XI_FOOTMOUSE}};
CARD8 event_base[numInputClasses]; CARD8 event_base[numInputClasses];
XExtEventInfo EventInfo[32]; XExtEventInfo EventInfo[32];
...@@ -223,8 +225,7 @@ XInputExtensionInit() ...@@ -223,8 +225,7 @@ XInputExtensionInit()
extEntry = AddExtension(INAME, IEVENTS, IERRORS, ProcIDispatch, extEntry = AddExtension(INAME, IEVENTS, IERRORS, ProcIDispatch,
SProcIDispatch, IResetProc, StandardMinorOpcode); SProcIDispatch, IResetProc, StandardMinorOpcode);
if (extEntry) if (extEntry) {
{
IReqCode = extEntry->base; IReqCode = extEntry->base;
AllExtensionVersions[IReqCode - 128] = thisversion; AllExtensionVersions[IReqCode - 128] = thisversion;
MakeDeviceTypeAtoms(); MakeDeviceTypeAtoms();
...@@ -246,9 +247,7 @@ XInputExtensionInit() ...@@ -246,9 +247,7 @@ XInputExtensionInit()
EventSwapVector[DeviceButtonStateNotify] = SEventIDispatch; EventSwapVector[DeviceButtonStateNotify] = SEventIDispatch;
EventSwapVector[DeviceMappingNotify] = SEventIDispatch; EventSwapVector[DeviceMappingNotify] = SEventIDispatch;
EventSwapVector[ChangeDeviceNotify] = SEventIDispatch; EventSwapVector[ChangeDeviceNotify] = SEventIDispatch;
} } else {
else
{
FatalError("IExtensionInit: AddExtensions failed\n"); FatalError("IExtensionInit: AddExtensions failed\n");
} }
} }
...@@ -334,8 +333,7 @@ ProcIDispatch(register ClientPtr client) ...@@ -334,8 +333,7 @@ ProcIDispatch(register ClientPtr client)
return (ProcXGetDeviceControl(client)); return (ProcXGetDeviceControl(client));
else if (stuff->data == X_ChangeDeviceControl) else if (stuff->data == X_ChangeDeviceControl)
return (ProcXChangeDeviceControl(client)); return (ProcXChangeDeviceControl(client));
else else {
{
SendErrorToClient(client, IReqCode, stuff->data, 0, BadRequest); SendErrorToClient(client, IReqCode, stuff->data, 0, BadRequest);
} }
return (BadRequest); return (BadRequest);
...@@ -424,8 +422,7 @@ SProcIDispatch(register ClientPtr client) ...@@ -424,8 +422,7 @@ SProcIDispatch(register ClientPtr client)
return (SProcXGetDeviceControl(client)); return (SProcXGetDeviceControl(client));
else if (stuff->data == X_ChangeDeviceControl) else if (stuff->data == X_ChangeDeviceControl)
return (SProcXChangeDeviceControl(client)); return (SProcXChangeDeviceControl(client));
else else {
{
SendErrorToClient(client, IReqCode, stuff->data, 0, BadRequest); SendErrorToClient(client, IReqCode, stuff->data, 0, BadRequest);
} }
return (BadRequest); return (BadRequest);
...@@ -448,7 +445,8 @@ SReplyIDispatch(ClientPtr client, int len, xGrabDeviceReply * rep) ...@@ -448,7 +445,8 @@ SReplyIDispatch(ClientPtr client, int len, xGrabDeviceReply * rep)
/* All we look at is the type field */ /* All we look at is the type field */
{ /* This is common to all replies */ { /* This is common to all replies */
if (rep->RepType == X_GetExtensionVersion) if (rep->RepType == X_GetExtensionVersion)
SRepXGetExtensionVersion (client, len, (xGetExtensionVersionReply *)rep); SRepXGetExtensionVersion(client, len,
(xGetExtensionVersionReply *) rep);
else if (rep->RepType == X_ListInputDevices) else if (rep->RepType == X_ListInputDevices)
SRepXListInputDevices(client, len, (xListInputDevicesReply *) rep); SRepXListInputDevices(client, len, (xListInputDevicesReply *) rep);
else if (rep->RepType == X_OpenDevice) else if (rep->RepType == X_OpenDevice)
...@@ -456,15 +454,22 @@ SReplyIDispatch(ClientPtr client, int len, xGrabDeviceReply * rep) ...@@ -456,15 +454,22 @@ SReplyIDispatch(ClientPtr client, int len, xGrabDeviceReply * rep)
else if (rep->RepType == X_SetDeviceMode) else if (rep->RepType == X_SetDeviceMode)
SRepXSetDeviceMode(client, len, (xSetDeviceModeReply *) rep); SRepXSetDeviceMode(client, len, (xSetDeviceModeReply *) rep);
else if (rep->RepType == X_GetSelectedExtensionEvents) else if (rep->RepType == X_GetSelectedExtensionEvents)
SRepXGetSelectedExtensionEvents (client, len, (xGetSelectedExtensionEventsReply *) rep); SRepXGetSelectedExtensionEvents(client, len,
(xGetSelectedExtensionEventsReply *)
rep);
else if (rep->RepType == X_GetDeviceDontPropagateList) else if (rep->RepType == X_GetDeviceDontPropagateList)
SRepXGetDeviceDontPropagateList (client, len, (xGetDeviceDontPropagateListReply *)rep); SRepXGetDeviceDontPropagateList(client, len,
(xGetDeviceDontPropagateListReply *)
rep);
else if (rep->RepType == X_GetDeviceMotionEvents) else if (rep->RepType == X_GetDeviceMotionEvents)
SRepXGetDeviceMotionEvents (client, len, (xGetDeviceMotionEventsReply *) rep); SRepXGetDeviceMotionEvents(client, len,
(xGetDeviceMotionEventsReply *) rep);
else if (rep->RepType == X_ChangeKeyboardDevice) else if (rep->RepType == X_ChangeKeyboardDevice)
SRepXChangeKeyboardDevice (client, len, (xChangeKeyboardDeviceReply *) rep); SRepXChangeKeyboardDevice(client, len,
(xChangeKeyboardDeviceReply *) rep);
else if (rep->RepType == X_ChangePointerDevice) else if (rep->RepType == X_ChangePointerDevice)
SRepXChangePointerDevice (client, len, (xChangePointerDeviceReply *)rep); SRepXChangePointerDevice(client, len,
(xChangePointerDeviceReply *) rep);
else if (rep->RepType == X_GrabDevice) else if (rep->RepType == X_GrabDevice)
SRepXGrabDevice(client, len, (xGrabDeviceReply *) rep); SRepXGrabDevice(client, len, (xGrabDeviceReply *) rep);
else if (rep->RepType == X_GetDeviceFocus) else if (rep->RepType == X_GetDeviceFocus)
...@@ -472,15 +477,20 @@ SReplyIDispatch(ClientPtr client, int len, xGrabDeviceReply * rep) ...@@ -472,15 +477,20 @@ SReplyIDispatch(ClientPtr client, int len, xGrabDeviceReply * rep)
else if (rep->RepType == X_GetFeedbackControl) else if (rep->RepType == X_GetFeedbackControl)
SRepXGetFeedbackControl(client, len, (xGetFeedbackControlReply *) rep); SRepXGetFeedbackControl(client, len, (xGetFeedbackControlReply *) rep);
else if (rep->RepType == X_GetDeviceKeyMapping) else if (rep->RepType == X_GetDeviceKeyMapping)
SRepXGetDeviceKeyMapping (client, len, (xGetDeviceKeyMappingReply *)rep); SRepXGetDeviceKeyMapping(client, len,
(xGetDeviceKeyMappingReply *) rep);
else if (rep->RepType == X_GetDeviceModifierMapping) else if (rep->RepType == X_GetDeviceModifierMapping)
SRepXGetDeviceModifierMapping (client, len, (xGetDeviceModifierMappingReply *)rep); SRepXGetDeviceModifierMapping(client, len,
(xGetDeviceModifierMappingReply *) rep);
else if (rep->RepType == X_SetDeviceModifierMapping) else if (rep->RepType == X_SetDeviceModifierMapping)
SRepXSetDeviceModifierMapping (client, len, (xSetDeviceModifierMappingReply *)rep); SRepXSetDeviceModifierMapping(client, len,
(xSetDeviceModifierMappingReply *) rep);
else if (rep->RepType == X_GetDeviceButtonMapping) else if (rep->RepType == X_GetDeviceButtonMapping)
SRepXGetDeviceButtonMapping (client, len, (xGetDeviceButtonMappingReply *)rep); SRepXGetDeviceButtonMapping(client, len,
(xGetDeviceButtonMappingReply *) rep);
else if (rep->RepType == X_SetDeviceButtonMapping) else if (rep->RepType == X_SetDeviceButtonMapping)
SRepXSetDeviceButtonMapping (client, len, (xSetDeviceButtonMappingReply *)rep); SRepXSetDeviceButtonMapping(client, len,
(xSetDeviceButtonMappingReply *) rep);
else if (rep->RepType == X_QueryDeviceState) else if (rep->RepType == X_QueryDeviceState)
SRepXQueryDeviceState(client, len, (xQueryDeviceStateReply *) rep); SRepXQueryDeviceState(client, len, (xQueryDeviceStateReply *) rep);
else if (rep->RepType == X_SetDeviceValuators) else if (rep->RepType == X_SetDeviceValuators)
...@@ -488,9 +498,9 @@ SReplyIDispatch(ClientPtr client, int len, xGrabDeviceReply * rep) ...@@ -488,9 +498,9 @@ SReplyIDispatch(ClientPtr client, int len, xGrabDeviceReply * rep)
else if (rep->RepType == X_GetDeviceControl) else if (rep->RepType == X_GetDeviceControl)
SRepXGetDeviceControl(client, len, (xGetDeviceControlReply *) rep); SRepXGetDeviceControl(client, len, (xGetDeviceControlReply *) rep);
else if (rep->RepType == X_ChangeDeviceControl) else if (rep->RepType == X_ChangeDeviceControl)
SRepXChangeDeviceControl (client, len, (xChangeDeviceControlReply *)rep); SRepXChangeDeviceControl(client, len,
else (xChangeDeviceControlReply *) rep);
{ else {
FatalError("XINPUT confused sending swapped reply"); FatalError("XINPUT confused sending swapped reply");
} }
} }
...@@ -510,46 +520,32 @@ SEventIDispatch(xEvent * from, xEvent * to) ...@@ -510,46 +520,32 @@ SEventIDispatch(xEvent * from, xEvent * to)
if (type == DeviceValuator) if (type == DeviceValuator)
DO_SWAP(SEventDeviceValuator, deviceValuator); DO_SWAP(SEventDeviceValuator, deviceValuator);
else if (type == DeviceKeyPress) else if (type == DeviceKeyPress) {
{
SKeyButtonPtrEvent(from, to); SKeyButtonPtrEvent(from, to);
to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
} } else if (type == DeviceKeyRelease) {
else if (type == DeviceKeyRelease)
{
SKeyButtonPtrEvent(from, to); SKeyButtonPtrEvent(from, to);
to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
} } else if (type == DeviceButtonPress) {
else if (type == DeviceButtonPress)
{
SKeyButtonPtrEvent(from, to); SKeyButtonPtrEvent(from, to);
to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
} } else if (type == DeviceButtonRelease) {
else if (type == DeviceButtonRelease)
{
SKeyButtonPtrEvent(from, to); SKeyButtonPtrEvent(from, to);
to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
} } else if (type == DeviceMotionNotify) {
else if (type == DeviceMotionNotify)
{
SKeyButtonPtrEvent(from, to); SKeyButtonPtrEvent(from, to);
to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
} } else if (type == DeviceFocusIn)
else if (type == DeviceFocusIn)
DO_SWAP(SEventFocus, deviceFocus); DO_SWAP(SEventFocus, deviceFocus);
else if (type == DeviceFocusOut) else if (type == DeviceFocusOut)
DO_SWAP(SEventFocus, deviceFocus); DO_SWAP(SEventFocus, deviceFocus);
else if (type == ProximityIn) else if (type == ProximityIn) {
{
SKeyButtonPtrEvent(from, to); SKeyButtonPtrEvent(from, to);
to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
} } else if (type == ProximityOut) {
else if (type == ProximityOut)
{
SKeyButtonPtrEvent(from, to); SKeyButtonPtrEvent(from, to);
to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
} } else if (type == DeviceStateNotify)
else if (type == DeviceStateNotify)
DO_SWAP(SDeviceStateNotifyEvent, deviceStateNotify); DO_SWAP(SDeviceStateNotifyEvent, deviceStateNotify);
else if (type == DeviceKeyStateNotify) else if (type == DeviceKeyStateNotify)
DO_SWAP(SDeviceKeyStateNotifyEvent, deviceKeyStateNotify); DO_SWAP(SDeviceKeyStateNotifyEvent, deviceKeyStateNotify);
...@@ -559,8 +555,7 @@ SEventIDispatch(xEvent * from, xEvent * to) ...@@ -559,8 +555,7 @@ SEventIDispatch(xEvent * from, xEvent * to)
DO_SWAP(SDeviceMappingNotifyEvent, deviceMappingNotify); DO_SWAP(SDeviceMappingNotifyEvent, deviceMappingNotify);
else if (type == ChangeDeviceNotify) else if (type == ChangeDeviceNotify)
DO_SWAP(SChangeDeviceNotifyEvent, changeDeviceNotify); DO_SWAP(SChangeDeviceNotifyEvent, changeDeviceNotify);
else else {
{
FatalError("XInputExtension: Impossible event!\n"); FatalError("XInputExtension: Impossible event!\n");
} }
} }
...@@ -606,8 +601,7 @@ SDeviceStateNotifyEvent(deviceStateNotify * from, deviceStateNotify * to) ...@@ -606,8 +601,7 @@ SDeviceStateNotifyEvent(deviceStateNotify * from, deviceStateNotify * to)
swaps(&to->sequenceNumber); swaps(&to->sequenceNumber);
swapl(&to->time); swapl(&to->time);
ip = &to->valuator0; ip = &to->valuator0;
for (i=0; i<3; i++) for (i = 0; i < 3; i++) {
{
swapl((ip + i)); /* macro - braces are required */ swapl((ip + i)); /* macro - braces are required */
} }
} }
...@@ -759,8 +753,7 @@ RestoreExtensionEvents() ...@@ -759,8 +753,7 @@ RestoreExtensionEvents()
IReqCode = 0; 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)) if ((EventInfo[i].type >= LASTEvent) && (EventInfo[i].type < 128))
SetMaskForEvent(0, EventInfo[i].type); SetMaskForEvent(0, EventInfo[i].type);
EventInfo[i].mask = 0; EventInfo[i].mask = 0;
...@@ -865,10 +858,8 @@ LookupDeviceIntRec(CARD8 id) ...@@ -865,10 +858,8 @@ LookupDeviceIntRec(CARD8 id)
{ {
DeviceIntPtr dev; DeviceIntPtr dev;
for (dev=inputInfo.devices; dev; dev=dev->next) for (dev = inputInfo.devices; dev; dev = dev->next) {
{ if (dev->id == id) {
if (dev->id == id)
{
if (id == inputInfo.pointer->id || id == inputInfo.keyboard->id) if (id == inputInfo.pointer->id || id == inputInfo.keyboard->id)
return (NULL); return (NULL);
return (dev); return (dev);
...@@ -922,8 +913,7 @@ GetNextExtEventMask() ...@@ -922,8 +913,7 @@ GetNextExtEventMask()
int i; int i;
Mask mask = lastExtEventMask; Mask mask = lastExtEventMask;
if (lastExtEventMask == 0) if (lastExtEventMask == 0) {
{
FatalError("GetNextExtEventMask: no more events are available."); FatalError("GetNextExtEventMask: no more events are available.");
} }
lastExtEventMask <<= 1; lastExtEventMask <<= 1;
......
...@@ -103,16 +103,14 @@ ProcXGetDeviceButtonMapping(register ClientPtr client) ...@@ -103,16 +103,14 @@ ProcXGetDeviceButtonMapping(register ClientPtr client)
rep.sequenceNumber = client->sequence; rep.sequenceNumber = client->sequence;
dev = LookupDeviceIntRec(stuff->deviceid); dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL) if (dev == NULL) {
{
SendErrorToClient(client, IReqCode, X_GetDeviceButtonMapping, 0, SendErrorToClient(client, IReqCode, X_GetDeviceButtonMapping, 0,
BadDevice); BadDevice);
return Success; return Success;
} }
b = dev->button; b = dev->button;
if (b == NULL) if (b == NULL) {
{
SendErrorToClient(client, IReqCode, X_GetDeviceButtonMapping, 0, SendErrorToClient(client, IReqCode, X_GetDeviceButtonMapping, 0,
BadMatch); BadMatch);
return Success; return Success;
...@@ -120,8 +118,7 @@ ProcXGetDeviceButtonMapping(register ClientPtr client) ...@@ -120,8 +118,7 @@ ProcXGetDeviceButtonMapping(register ClientPtr client)
rep.nElts = b->numButtons; rep.nElts = b->numButtons;
rep.length = (rep.nElts + (4 - 1)) / 4; rep.length = (rep.nElts + (4 - 1)) / 4;
WriteReplyToClient(client, sizeof(xGetDeviceButtonMappingReply), &rep); WriteReplyToClient(client, sizeof(xGetDeviceButtonMappingReply), &rep);
WriteToClient(client, rep.nElts, WriteToClient(client, rep.nElts, (char *)&b->map[1]);
(char *)&b->map[1]);
return Success; return Success;
} }
......
...@@ -101,10 +101,8 @@ ProcXGetDeviceControl(ClientPtr client) ...@@ -101,10 +101,8 @@ ProcXGetDeviceControl(ClientPtr client)
REQUEST_SIZE_MATCH(xGetDeviceControlReq); REQUEST_SIZE_MATCH(xGetDeviceControlReq);
dev = LookupDeviceIntRec(stuff->deviceid); dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL) if (dev == NULL) {
{ SendErrorToClient(client, IReqCode, X_GetDeviceControl, 0, BadDevice);
SendErrorToClient (client, IReqCode, X_GetDeviceControl, 0,
BadDevice);
return Success; return Success;
} }
...@@ -113,11 +111,9 @@ ProcXGetDeviceControl(ClientPtr client) ...@@ -113,11 +111,9 @@ ProcXGetDeviceControl(ClientPtr client)
rep.length = 0; rep.length = 0;
rep.sequenceNumber = client->sequence; rep.sequenceNumber = client->sequence;
switch (stuff->control) switch (stuff->control) {
{
case DEVICE_RESOLUTION: case DEVICE_RESOLUTION:
if (!dev->valuator) if (!dev->valuator) {
{
SendErrorToClient(client, IReqCode, X_GetDeviceControl, 0, SendErrorToClient(client, IReqCode, X_GetDeviceControl, 0,
BadMatch); BadMatch);
return Success; return Success;
...@@ -126,25 +122,20 @@ ProcXGetDeviceControl(ClientPtr client) ...@@ -126,25 +122,20 @@ ProcXGetDeviceControl(ClientPtr client)
(3 * sizeof(int) * dev->valuator->numAxes); (3 * sizeof(int) * dev->valuator->numAxes);
break; break;
default: default:
SendErrorToClient (client, IReqCode, X_GetDeviceControl, 0, SendErrorToClient(client, IReqCode, X_GetDeviceControl, 0, BadValue);
BadValue);
return Success; return Success;
} }
buf = (char *)malloc(total_length); buf = (char *)malloc(total_length);
if (!buf) if (!buf) {
{ SendErrorToClient(client, IReqCode, X_GetDeviceControl, 0, BadAlloc);
SendErrorToClient(client, IReqCode, X_GetDeviceControl, 0,
BadAlloc);
return Success; return Success;
} }
savbuf = buf; savbuf = buf;
switch (stuff->control) switch (stuff->control) {
{
case DEVICE_RESOLUTION: case DEVICE_RESOLUTION:
CopySwapDeviceResolution(client, dev->valuator, buf, CopySwapDeviceResolution(client, dev->valuator, buf, total_length);
total_length);
break; break;
default: default:
break; break;
...@@ -183,14 +174,12 @@ CopySwapDeviceResolution(ClientPtr client, ValuatorClassPtr v, char *buf, ...@@ -183,14 +174,12 @@ CopySwapDeviceResolution(ClientPtr client, ValuatorClassPtr v, char *buf,
*iptr++ = a->min_resolution; *iptr++ = a->min_resolution;
for (i = 0, a = v->axes; i < v->numAxes; i++, a++) for (i = 0, a = v->axes; i < v->numAxes; i++, a++)
*iptr++ = a->max_resolution; *iptr++ = a->max_resolution;
if (client->swapped) if (client->swapped) {
{
swaps(&r->control); swaps(&r->control);
swaps(&r->length); swaps(&r->length);
swapl(&r->num_valuators); swapl(&r->num_valuators);
iptr = (int *)buf; iptr = (int *)buf;
for (i=0; i < (3 * v->numAxes); i++,iptr++) for (i = 0; i < (3 * v->numAxes); i++, iptr++) {
{
swapl(iptr); swapl(iptr);
} }
} }
......
...@@ -105,10 +105,8 @@ ProcXGetFeedbackControl(ClientPtr client) ...@@ -105,10 +105,8 @@ ProcXGetFeedbackControl(ClientPtr client)
REQUEST_SIZE_MATCH(xGetFeedbackControlReq); REQUEST_SIZE_MATCH(xGetFeedbackControlReq);
dev = LookupDeviceIntRec(stuff->deviceid); dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL) if (dev == NULL) {
{ SendErrorToClient(client, IReqCode, X_GetFeedbackControl, 0, BadDevice);
SendErrorToClient (client, IReqCode, X_GetFeedbackControl, 0,
BadDevice);
return Success; return Success;
} }
...@@ -118,50 +116,40 @@ ProcXGetFeedbackControl(ClientPtr client) ...@@ -118,50 +116,40 @@ ProcXGetFeedbackControl(ClientPtr client)
rep.sequenceNumber = client->sequence; rep.sequenceNumber = client->sequence;
rep.num_feedbacks = 0; rep.num_feedbacks = 0;
for (k=dev->kbdfeed; k; k=k->next) for (k = dev->kbdfeed; k; k = k->next) {
{
rep.num_feedbacks++; rep.num_feedbacks++;
total_length += sizeof(xKbdFeedbackState); total_length += sizeof(xKbdFeedbackState);
} }
for (p=dev->ptrfeed; p; p=p->next) for (p = dev->ptrfeed; p; p = p->next) {
{
rep.num_feedbacks++; rep.num_feedbacks++;
total_length += sizeof(xPtrFeedbackState); total_length += sizeof(xPtrFeedbackState);
} }
for (s=dev->stringfeed; s; s=s->next) for (s = dev->stringfeed; s; s = s->next) {
{
rep.num_feedbacks++; rep.num_feedbacks++;
total_length += sizeof(xStringFeedbackState) + total_length += sizeof(xStringFeedbackState) +
(s->ctrl.num_symbols_supported * sizeof(KeySym)); (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++; rep.num_feedbacks++;
total_length += sizeof(xIntegerFeedbackState); total_length += sizeof(xIntegerFeedbackState);
} }
for (l=dev->leds; l; l=l->next) for (l = dev->leds; l; l = l->next) {
{
rep.num_feedbacks++; rep.num_feedbacks++;
total_length += sizeof(xLedFeedbackState); total_length += sizeof(xLedFeedbackState);
} }
for (b=dev->bell; b; b=b->next) for (b = dev->bell; b; b = b->next) {
{
rep.num_feedbacks++; rep.num_feedbacks++;
total_length += sizeof(xBellFeedbackState); total_length += sizeof(xBellFeedbackState);
} }
if (total_length == 0) if (total_length == 0) {
{ SendErrorToClient(client, IReqCode, X_GetFeedbackControl, 0, BadMatch);
SendErrorToClient(client, IReqCode, X_GetFeedbackControl, 0,
BadMatch);
return Success; return Success;
} }
buf = (char *)malloc(total_length); buf = (char *)malloc(total_length);
if (!buf) if (!buf) {
{ SendErrorToClient(client, IReqCode, X_GetFeedbackControl, 0, BadAlloc);
SendErrorToClient(client, IReqCode, X_GetFeedbackControl, 0,
BadAlloc);
return Success; return Success;
} }
savbuf = buf; savbuf = buf;
...@@ -210,8 +198,7 @@ CopySwapKbdFeedback(ClientPtr client, KbdFeedbackPtr k, char **buf) ...@@ -210,8 +198,7 @@ CopySwapKbdFeedback(ClientPtr client, KbdFeedbackPtr k, char **buf)
k2->global_auto_repeat = k->ctrl.autoRepeat; k2->global_auto_repeat = k->ctrl.autoRepeat;
for (i = 0; i < 32; i++) for (i = 0; i < 32; i++)
k2->auto_repeats[i] = k->ctrl.autoRepeats[i]; k2->auto_repeats[i] = k->ctrl.autoRepeats[i];
if (client->swapped) if (client->swapped) {
{
swaps(&k2->length); swaps(&k2->length);
swaps(&k2->pitch); swaps(&k2->pitch);
swaps(&k2->duration); swaps(&k2->duration);
...@@ -239,8 +226,7 @@ CopySwapPtrFeedback(ClientPtr client, PtrFeedbackPtr p, char **buf) ...@@ -239,8 +226,7 @@ CopySwapPtrFeedback(ClientPtr client, PtrFeedbackPtr p, char **buf)
p2->accelNum = p->ctrl.num; p2->accelNum = p->ctrl.num;
p2->accelDenom = p->ctrl.den; p2->accelDenom = p->ctrl.den;
p2->threshold = p->ctrl.threshold; p2->threshold = p->ctrl.threshold;
if (client->swapped) if (client->swapped) {
{
swaps(&p2->length); swaps(&p2->length);
swaps(&p2->accelNum); swaps(&p2->accelNum);
swaps(&p2->accelDenom); swaps(&p2->accelDenom);
...@@ -267,8 +253,7 @@ CopySwapIntegerFeedback(ClientPtr client, IntegerFeedbackPtr i, char **buf) ...@@ -267,8 +253,7 @@ CopySwapIntegerFeedback(ClientPtr client, IntegerFeedbackPtr i, char **buf)
i2->resolution = i->ctrl.resolution; i2->resolution = i->ctrl.resolution;
i2->min_value = i->ctrl.min_value; i2->min_value = i->ctrl.min_value;
i2->max_value = i->ctrl.max_value; i2->max_value = i->ctrl.max_value;
if (client->swapped) if (client->swapped) {
{
swaps(&i2->length); swaps(&i2->length);
swapl(&i2->resolution); swapl(&i2->resolution);
swapl(&i2->min_value); swapl(&i2->min_value);
...@@ -301,14 +286,12 @@ CopySwapStringFeedback(ClientPtr client, StringFeedbackPtr s, char **buf) ...@@ -301,14 +286,12 @@ CopySwapStringFeedback(ClientPtr client, StringFeedbackPtr s, char **buf)
kptr = (KeySym *) (*buf); kptr = (KeySym *) (*buf);
for (i = 0; i < s->ctrl.num_symbols_supported; i++) for (i = 0; i < s->ctrl.num_symbols_supported; i++)
*kptr++ = *(s->ctrl.symbols_supported + i); *kptr++ = *(s->ctrl.symbols_supported + i);
if (client->swapped) if (client->swapped) {
{
swaps(&s2->length); swaps(&s2->length);
swaps(&s2->max_symbols); swaps(&s2->max_symbols);
swaps(&s2->num_syms_supported); swaps(&s2->num_syms_supported);
kptr = (KeySym *) (*buf); 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); swapl(kptr);
} }
} }
...@@ -332,8 +315,7 @@ CopySwapLedFeedback(ClientPtr client, LedFeedbackPtr l, char **buf) ...@@ -332,8 +315,7 @@ CopySwapLedFeedback(ClientPtr client, LedFeedbackPtr l, char **buf)
l2->id = l->ctrl.id; l2->id = l->ctrl.id;
l2->led_values = l->ctrl.led_values; l2->led_values = l->ctrl.led_values;
l2->led_mask = l->ctrl.led_mask; l2->led_mask = l->ctrl.led_mask;
if (client->swapped) if (client->swapped) {
{
swaps(&l2->length); swaps(&l2->length);
swapl(&l2->led_values); swapl(&l2->led_values);
swapl(&l2->led_mask); swapl(&l2->led_mask);
...@@ -359,8 +341,7 @@ CopySwapBellFeedback(ClientPtr client, BellFeedbackPtr b, char **buf) ...@@ -359,8 +341,7 @@ CopySwapBellFeedback(ClientPtr client, BellFeedbackPtr b, char **buf)
b2->percent = b->ctrl.percent; b2->percent = b->ctrl.percent;
b2->pitch = b->ctrl.pitch; b2->pitch = b->ctrl.pitch;
b2->duration = b->ctrl.duration; b2->duration = b->ctrl.duration;
if (client->swapped) if (client->swapped) {
{
swaps(&b2->length); swaps(&b2->length);
swaps(&b2->pitch); swaps(&b2->pitch);
swaps(&b2->duration); swaps(&b2->duration);
......
...@@ -98,8 +98,7 @@ ProcXGetDeviceFocus(ClientPtr client) ...@@ -98,8 +98,7 @@ ProcXGetDeviceFocus(ClientPtr client)
REQUEST_SIZE_MATCH(xGetDeviceFocusReq); REQUEST_SIZE_MATCH(xGetDeviceFocusReq);
dev = LookupDeviceIntRec(stuff->deviceid); dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL || !dev->focus) if (dev == NULL || !dev->focus) {
{
SendErrorToClient(client, IReqCode, X_GetDeviceFocus, 0, BadDevice); SendErrorToClient(client, IReqCode, X_GetDeviceFocus, 0, BadDevice);
return Success; return Success;
} }
......
...@@ -99,35 +99,28 @@ ProcXGetDeviceKeyMapping(register ClientPtr client) ...@@ -99,35 +99,28 @@ ProcXGetDeviceKeyMapping(register ClientPtr client)
REQUEST_SIZE_MATCH(xGetDeviceKeyMappingReq); REQUEST_SIZE_MATCH(xGetDeviceKeyMappingReq);
dev = LookupDeviceIntRec(stuff->deviceid); dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL) if (dev == NULL) {
{
SendErrorToClient(client, IReqCode, X_GetDeviceKeyMapping, 0, SendErrorToClient(client, IReqCode, X_GetDeviceKeyMapping, 0,
BadDevice); BadDevice);
return Success; return Success;
} }
if (dev->key == NULL) if (dev->key == NULL) {
{ SendErrorToClient(client, IReqCode, X_GetDeviceKeyMapping, 0, BadMatch);
SendErrorToClient (client, IReqCode, X_GetDeviceKeyMapping, 0,
BadMatch);
return Success; return Success;
} }
k = &dev->key->curKeySyms; k = &dev->key->curKeySyms;
if ((stuff->firstKeyCode < k->minKeyCode) || if ((stuff->firstKeyCode < k->minKeyCode) ||
(stuff->firstKeyCode > k->maxKeyCode)) (stuff->firstKeyCode > k->maxKeyCode)) {
{
client->errorValue = stuff->firstKeyCode; client->errorValue = stuff->firstKeyCode;
SendErrorToClient (client, IReqCode, X_GetDeviceKeyMapping, 0, SendErrorToClient(client, IReqCode, X_GetDeviceKeyMapping, 0, BadValue);
BadValue);
return Success; return Success;
} }
if (stuff->firstKeyCode + stuff->count > k->maxKeyCode + 1) if (stuff->firstKeyCode + stuff->count > k->maxKeyCode + 1) {
{
client->errorValue = stuff->count; client->errorValue = stuff->count;
SendErrorToClient (client, IReqCode, X_GetDeviceKeyMapping, 0, SendErrorToClient(client, IReqCode, X_GetDeviceKeyMapping, 0, BadValue);
BadValue);
return Success; return Success;
} }
...@@ -139,8 +132,7 @@ ProcXGetDeviceKeyMapping(register ClientPtr client) ...@@ -139,8 +132,7 @@ ProcXGetDeviceKeyMapping(register ClientPtr client)
WriteReplyToClient(client, sizeof(xGetDeviceKeyMappingReply), &rep); WriteReplyToClient(client, sizeof(xGetDeviceKeyMappingReply), &rep);
client->pSwapReplyFunc = (ReplySwapPtr) CopySwap32Write; client->pSwapReplyFunc = (ReplySwapPtr) CopySwap32Write;
WriteSwappedDataToClient( WriteSwappedDataToClient(client,
client,
k->mapWidth * stuff->count * sizeof(KeySym), k->mapWidth * stuff->count * sizeof(KeySym),
&k->map[(stuff->firstKeyCode - k->minKeyCode) * &k->map[(stuff->firstKeyCode - k->minKeyCode) *
k->mapWidth]); k->mapWidth]);
......
...@@ -99,16 +99,14 @@ ProcXGetDeviceModifierMapping(ClientPtr client) ...@@ -99,16 +99,14 @@ ProcXGetDeviceModifierMapping(ClientPtr client)
REQUEST_SIZE_MATCH(xGetDeviceModifierMappingReq); REQUEST_SIZE_MATCH(xGetDeviceModifierMappingReq);
dev = LookupDeviceIntRec(stuff->deviceid); dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL) if (dev == NULL) {
{
SendErrorToClient(client, IReqCode, X_GetDeviceModifierMapping, 0, SendErrorToClient(client, IReqCode, X_GetDeviceModifierMapping, 0,
BadDevice); BadDevice);
return Success; return Success;
} }
kp = dev->key; kp = dev->key;
if (kp == NULL) if (kp == NULL) {
{
SendErrorToClient(client, IReqCode, X_GetDeviceModifierMapping, 0, SendErrorToClient(client, IReqCode, X_GetDeviceModifierMapping, 0,
BadMatch); BadMatch);
return Success; return Success;
......
...@@ -113,21 +113,18 @@ ProcXGetDeviceDontPropagateList(register ClientPtr client) ...@@ -113,21 +113,18 @@ ProcXGetDeviceDontPropagateList(register ClientPtr client)
rep.count = 0; rep.count = 0;
pWin = (WindowPtr) LookupWindow(stuff->window, client); pWin = (WindowPtr) LookupWindow(stuff->window, client);
if (!pWin) if (!pWin) {
{
client->errorValue = stuff->window; client->errorValue = stuff->window;
SendErrorToClient(client, IReqCode, X_GetDeviceDontPropagateList, 0, SendErrorToClient(client, IReqCode, X_GetDeviceDontPropagateList, 0,
BadWindow); BadWindow);
return Success; return Success;
} }
if ((others = wOtherInputMasks(pWin)) != 0) if ((others = wOtherInputMasks(pWin)) != 0) {
{
for (i = 0; i < EMASKSIZE; i++) for (i = 0; i < EMASKSIZE; i++)
tbuf = ClassFromMask(NULL, others->dontPropagateMask[i], i, tbuf = ClassFromMask(NULL, others->dontPropagateMask[i], i,
&count, COUNT); &count, COUNT);
if (count) if (count) {
{
rep.count = count; rep.count = count;
buf = (XEventClass *) malloc(rep.count * sizeof(XEventClass)); buf = (XEventClass *) malloc(rep.count * sizeof(XEventClass));
rep.length = (rep.count * sizeof(XEventClass) + 3) >> 2; rep.length = (rep.count * sizeof(XEventClass) + 3) >> 2;
...@@ -139,11 +136,9 @@ ProcXGetDeviceDontPropagateList(register ClientPtr client) ...@@ -139,11 +136,9 @@ ProcXGetDeviceDontPropagateList(register ClientPtr client)
} }
} }
WriteReplyToClient (client, sizeof (xGetDeviceDontPropagateListReply), WriteReplyToClient(client, sizeof(xGetDeviceDontPropagateListReply), &rep);
&rep);
if (count) if (count) {
{
client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write; client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
WriteSwappedDataToClient(client, count * sizeof(XEventClass), buf); WriteSwappedDataToClient(client, count * sizeof(XEventClass), buf);
free(buf); free(buf);
...@@ -167,11 +162,9 @@ XEventClass ...@@ -167,11 +162,9 @@ XEventClass
Mask tmask = 0x80000000; Mask tmask = 0x80000000;
for (i = 0; i < 32; i++, tmask >>= 1) for (i = 0; i < 32; i++, tmask >>= 1)
if (tmask & mask) if (tmask & mask) {
{
for (j = 0; j < ExtEventIndex; j++) for (j = 0; j < ExtEventIndex; j++)
if (EventInfo[j].mask == tmask) if (EventInfo[j].mask == tmask) {
{
if (mode == COUNT) if (mode == COUNT)
(*count)++; (*count)++;
else else
......
...@@ -115,23 +115,20 @@ ProcXGetSelectedExtensionEvents(register ClientPtr client) ...@@ -115,23 +115,20 @@ ProcXGetSelectedExtensionEvents(register ClientPtr client)
rep.this_client_count = 0; rep.this_client_count = 0;
rep.all_clients_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, SendErrorToClient(client, IReqCode, X_GetSelectedExtensionEvents, 0,
BadWindow); BadWindow);
return Success; return Success;
} }
if ((pOthers = wOtherInputMasks(pWin)) != 0) if ((pOthers = wOtherInputMasks(pWin)) != 0) {
{
for (others = pOthers->inputClients; others; others = others->next) for (others = pOthers->inputClients; others; others = others->next)
for (i = 0; i < EMASKSIZE; i++) for (i = 0; i < EMASKSIZE; i++)
tclient = ClassFromMask(NULL, others->mask[i], i, tclient = ClassFromMask(NULL, others->mask[i], i,
&rep.all_clients_count, COUNT); &rep.all_clients_count, COUNT);
for (others = pOthers->inputClients; others; others = others->next) for (others = pOthers->inputClients; others; others = others->next)
if (SameClient(others, client)) if (SameClient(others, client)) {
{
for (i = 0; i < EMASKSIZE; i++) for (i = 0; i < EMASKSIZE; i++)
tclient = ClassFromMask(NULL, others->mask[i], i, tclient = ClassFromMask(NULL, others->mask[i], i,
&rep.this_client_count, COUNT); &rep.this_client_count, COUNT);
...@@ -147,17 +144,18 @@ ProcXGetSelectedExtensionEvents(register ClientPtr client) ...@@ -147,17 +144,18 @@ ProcXGetSelectedExtensionEvents(register ClientPtr client)
aclient = buf + rep.this_client_count; aclient = buf + rep.this_client_count;
if (others) if (others)
for (i = 0; i < EMASKSIZE; i++) 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 (others = pOthers->inputClients; others; others = others->next)
for (i = 0; i < EMASKSIZE; i++) 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); WriteReplyToClient(client, sizeof(xGetSelectedExtensionEventsReply), &rep);
if (total_length) if (total_length) {
{
client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write; client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
WriteSwappedDataToClient(client, total_length, buf); WriteSwappedDataToClient(client, total_length, buf);
free(buf); free(buf);
......
...@@ -99,8 +99,7 @@ ProcXGetExtensionVersion(register ClientPtr client) ...@@ -99,8 +99,7 @@ ProcXGetExtensionVersion(register ClientPtr client)
REQUEST_AT_LEAST_SIZE(xGetExtensionVersionReq); REQUEST_AT_LEAST_SIZE(xGetExtensionVersionReq);
if (stuff->length != (sizeof(xGetExtensionVersionReq) + if (stuff->length != (sizeof(xGetExtensionVersionReq) +
stuff->nbytes + 3)>>2) stuff->nbytes + 3) >> 2) {
{
SendErrorToClient(client, IReqCode, X_GetExtensionVersion, 0, SendErrorToClient(client, IReqCode, X_GetExtensionVersion, 0,
BadLength); BadLength);
return Success; return Success;
...@@ -115,12 +114,9 @@ ProcXGetExtensionVersion(register ClientPtr client) ...@@ -115,12 +114,9 @@ ProcXGetExtensionVersion(register ClientPtr client)
rep.minor_version = 0; rep.minor_version = 0;
rep.present = TRUE; rep.present = TRUE;
if (rep.present) if (rep.present) {
{ rep.major_version = AllExtensionVersions[IReqCode - 128].major_version;
rep.major_version = rep.minor_version = AllExtensionVersions[IReqCode - 128].minor_version;
AllExtensionVersions[IReqCode-128].major_version;
rep.minor_version =
AllExtensionVersions[IReqCode-128].minor_version;
} }
WriteReplyToClient(client, sizeof(xGetExtensionVersionReply), &rep); WriteReplyToClient(client, sizeof(xGetExtensionVersionReply), &rep);
......
...@@ -113,8 +113,7 @@ ProcXGrabDevice(ClientPtr client) ...@@ -113,8 +113,7 @@ ProcXGrabDevice(ClientPtr client)
REQUEST(xGrabDeviceReq); REQUEST(xGrabDeviceReq);
REQUEST_AT_LEAST_SIZE(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); SendErrorToClient(client, IReqCode, X_GrabDevice, 0, BadLength);
return Success; return Success;
} }
...@@ -125,22 +124,22 @@ ProcXGrabDevice(ClientPtr client) ...@@ -125,22 +124,22 @@ ProcXGrabDevice(ClientPtr client)
rep.length = 0; rep.length = 0;
dev = LookupDeviceIntRec(stuff->deviceid); dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL) if (dev == NULL) {
{
SendErrorToClient(client, IReqCode, X_GrabDevice, 0, BadDevice); SendErrorToClient(client, IReqCode, X_GrabDevice, 0, BadDevice);
return Success; return Success;
} }
if (CreateMaskFromList(client, (XEventClass *) & stuff[1], if (CreateMaskFromList(client, (XEventClass *) & stuff[1],
stuff->event_count, tmp, dev, X_GrabDevice) != Success) stuff->event_count, tmp, dev,
X_GrabDevice) != Success)
return Success; return Success;
error = GrabDevice(client, dev, stuff->this_device_mode, error = GrabDevice(client, dev, stuff->this_device_mode,
stuff->other_devices_mode, stuff->grabWindow, stuff->ownerEvents, stuff->other_devices_mode, stuff->grabWindow,
stuff->time, tmp[stuff->deviceid].mask, &rep.status); stuff->ownerEvents, stuff->time,
tmp[stuff->deviceid].mask, &rep.status);
if (error != Success) if (error != Success) {
{
SendErrorToClient(client, IReqCode, X_GrabDevice, 0, error); SendErrorToClient(client, IReqCode, X_GrabDevice, 0, error);
return Success; return Success;
} }
...@@ -163,30 +162,25 @@ CreateMaskFromList(ClientPtr client, XEventClass * list, int count, ...@@ -163,30 +162,25 @@ CreateMaskFromList(ClientPtr client, XEventClass * list, int count,
int device; int device;
DeviceIntPtr tdev; DeviceIntPtr tdev;
for (i=0; i<EMASKSIZE; i++) for (i = 0; i < EMASKSIZE; i++) {
{
mask[i].mask = 0; mask[i].mask = 0;
mask[i].dev = NULL; mask[i].dev = NULL;
} }
for (i=0; i<count; i++, list++) for (i = 0; i < count; i++, list++) {
{
device = *list >> 8; device = *list >> 8;
if (device > 255) if (device > 255) {
{
SendErrorToClient(client, IReqCode, req, 0, BadClass); SendErrorToClient(client, IReqCode, req, 0, BadClass);
return BadClass; return BadClass;
} }
tdev = LookupDeviceIntRec(device); tdev = LookupDeviceIntRec(device);
if (tdev==NULL || (dev != NULL && tdev != dev)) if (tdev == NULL || (dev != NULL && tdev != dev)) {
{
SendErrorToClient(client, IReqCode, req, 0, BadClass); SendErrorToClient(client, IReqCode, req, 0, BadClass);
return BadClass; return BadClass;
} }
for (j = 0; j < ExtEventIndex; j++) 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].mask |= EventInfo[j].mask;
mask[device].dev = (Pointer) tdev; mask[device].dev = (Pointer) tdev;
break; break;
......
...@@ -109,47 +109,42 @@ ProcXGrabDeviceButton(ClientPtr client) ...@@ -109,47 +109,42 @@ ProcXGrabDeviceButton(ClientPtr client)
REQUEST(xGrabDeviceButtonReq); REQUEST(xGrabDeviceButtonReq);
REQUEST_AT_LEAST_SIZE(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); SendErrorToClient(client, IReqCode, X_GrabDeviceButton, 0, BadLength);
return Success; return Success;
} }
dev = LookupDeviceIntRec(stuff->grabbed_device); dev = LookupDeviceIntRec(stuff->grabbed_device);
if (dev == NULL) if (dev == NULL) {
{ SendErrorToClient(client, IReqCode, X_GrabDeviceButton, 0, BadDevice);
SendErrorToClient(client, IReqCode, X_GrabDeviceButton, 0,
BadDevice);
return Success; return Success;
} }
if (stuff->modifier_device != UseXKeyboard) if (stuff->modifier_device != UseXKeyboard) {
{
mdev = LookupDeviceIntRec(stuff->modifier_device); mdev = LookupDeviceIntRec(stuff->modifier_device);
if (mdev == NULL) if (mdev == NULL) {
{
SendErrorToClient(client, IReqCode, X_GrabDeviceButton, 0, SendErrorToClient(client, IReqCode, X_GrabDeviceButton, 0,
BadDevice); BadDevice);
return Success; return Success;
} }
if (mdev->key == NULL) if (mdev->key == NULL) {
{
SendErrorToClient(client, IReqCode, X_GrabDeviceButton, 0, SendErrorToClient(client, IReqCode, X_GrabDeviceButton, 0,
BadMatch); BadMatch);
return Success; return Success;
} }
} } else
else
mdev = (DeviceIntPtr) LookupKeyboardDevice(); mdev = (DeviceIntPtr) LookupKeyboardDevice();
class = (XEventClass *) (&stuff[1]); /* first word of values */ class = (XEventClass *) (&stuff[1]); /* first word of values */
if ((ret = CreateMaskFromList(client, class, if ((ret = CreateMaskFromList(client, class,
stuff->event_count, tmp, dev, X_GrabDeviceButton)) != Success) stuff->event_count, tmp, dev,
X_GrabDeviceButton)) != Success)
return Success; return Success;
ret = GrabButton(client, dev, stuff->this_device_mode, ret = GrabButton(client, dev, stuff->this_device_mode,
stuff->other_devices_mode, stuff->modifiers, mdev, stuff->button, stuff->other_devices_mode, stuff->modifiers, mdev,
stuff->grabWindow, stuff->ownerEvents, (Cursor)0, (Window)0, stuff->button, stuff->grabWindow, stuff->ownerEvents,
tmp[stuff->grabbed_device].mask); (Cursor) 0, (Window) 0, tmp[stuff->grabbed_device].mask);
if (ret != Success) if (ret != Success)
SendErrorToClient(client, IReqCode, X_GrabDeviceButton, 0, ret); SendErrorToClient(client, IReqCode, X_GrabDeviceButton, 0, ret);
......
...@@ -107,51 +107,43 @@ ProcXGrabDeviceKey(ClientPtr client) ...@@ -107,51 +107,43 @@ ProcXGrabDeviceKey(ClientPtr client)
REQUEST(xGrabDeviceKeyReq); REQUEST(xGrabDeviceKeyReq);
REQUEST_AT_LEAST_SIZE(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); SendErrorToClient(client, IReqCode, X_GrabDeviceKey, 0, BadLength);
return Success; return Success;
} }
dev = LookupDeviceIntRec(stuff->grabbed_device); dev = LookupDeviceIntRec(stuff->grabbed_device);
if (dev == NULL) if (dev == NULL) {
{ SendErrorToClient(client, IReqCode, X_GrabDeviceKey, 0, BadDevice);
SendErrorToClient(client, IReqCode, X_GrabDeviceKey, 0,
BadDevice);
return Success; return Success;
} }
if (stuff->modifier_device != UseXKeyboard) if (stuff->modifier_device != UseXKeyboard) {
{
mdev = LookupDeviceIntRec(stuff->modifier_device); mdev = LookupDeviceIntRec(stuff->modifier_device);
if (mdev == NULL) if (mdev == NULL) {
{ SendErrorToClient(client, IReqCode, X_GrabDeviceKey, 0, BadDevice);
SendErrorToClient(client, IReqCode, X_GrabDeviceKey, 0,
BadDevice);
return Success; return Success;
} }
if (mdev->key == NULL) if (mdev->key == NULL) {
{ SendErrorToClient(client, IReqCode, X_GrabDeviceKey, 0, BadMatch);
SendErrorToClient(client, IReqCode, X_GrabDeviceKey, 0,
BadMatch);
return Success; return Success;
} }
} } else
else
mdev = (DeviceIntPtr) LookupKeyboardDevice(); mdev = (DeviceIntPtr) LookupKeyboardDevice();
class = (XEventClass *) (&stuff[1]); /* first word of values */ class = (XEventClass *) (&stuff[1]); /* first word of values */
if ((ret = CreateMaskFromList(client, class, if ((ret = CreateMaskFromList(client, class,
stuff->event_count, tmp, dev, X_GrabDeviceKey)) != Success) stuff->event_count, tmp, dev,
X_GrabDeviceKey)) != Success)
return Success; return Success;
ret = GrabKey(client, dev, stuff->this_device_mode, ret = GrabKey(client, dev, stuff->this_device_mode,
stuff->other_devices_mode, stuff->modifiers, mdev, stuff->key, stuff->other_devices_mode, stuff->modifiers, mdev,
stuff->grabWindow, stuff->ownerEvents, tmp[stuff->grabbed_device].mask); stuff->key, stuff->grabWindow, stuff->ownerEvents,
tmp[stuff->grabbed_device].mask);
if (ret != Success) if (ret != Success) {
{
SendErrorToClient(client, IReqCode, X_GrabDeviceKey, 0, ret); SendErrorToClient(client, IReqCode, X_GrabDeviceKey, 0, ret);
return Success; return Success;
} }
......
...@@ -107,15 +107,13 @@ ProcXGetDeviceMotionEvents(ClientPtr client) ...@@ -107,15 +107,13 @@ ProcXGetDeviceMotionEvents(ClientPtr client)
REQUEST_SIZE_MATCH(xGetDeviceMotionEventsReq); REQUEST_SIZE_MATCH(xGetDeviceMotionEventsReq);
dev = LookupDeviceIntRec(stuff->deviceid); dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL) if (dev == NULL) {
{
SendErrorToClient(client, IReqCode, X_GetDeviceMotionEvents, 0, SendErrorToClient(client, IReqCode, X_GetDeviceMotionEvents, 0,
BadDevice); BadDevice);
return Success; return Success;
} }
v = dev->valuator; v = dev->valuator;
if (v==NULL || v->numAxes == 0) if (v == NULL || v->numAxes == 0) {
{
SendErrorToClient(client, IReqCode, X_GetDeviceMotionEvents, 0, SendErrorToClient(client, IReqCode, X_GetDeviceMotionEvents, 0,
BadMatch); BadMatch);
return Success; return Success;
...@@ -133,16 +131,14 @@ ProcXGetDeviceMotionEvents(ClientPtr client) ...@@ -133,16 +131,14 @@ ProcXGetDeviceMotionEvents(ClientPtr client)
start = ClientTimeToServerTime(stuff->start); start = ClientTimeToServerTime(stuff->start);
stop = ClientTimeToServerTime(stuff->stop); 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);
return Success; return Success;
} }
if (CompareTimeStamps(stop, currentTime) == LATER) if (CompareTimeStamps(stop, currentTime) == LATER)
stop = currentTime; stop = currentTime;
num_events = v->numMotionEvents; num_events = v->numMotionEvents;
if (num_events) if (num_events) {
{
size = sizeof(Time) + (axes * sizeof(INT32)); size = sizeof(Time) + (axes * sizeof(INT32));
tsize = num_events * size; tsize = num_events * size;
coords = (INT32 *) malloc(tsize); coords = (INT32 *) malloc(tsize);
...@@ -152,24 +148,20 @@ ProcXGetDeviceMotionEvents(ClientPtr client) ...@@ -152,24 +148,20 @@ ProcXGetDeviceMotionEvents(ClientPtr client)
BadAlloc); BadAlloc);
return Success; return Success;
} }
rep.nEvents = (v->GetMotionProc) ( rep.nEvents = (v->GetMotionProc) (dev, (xTimecoord *) coords, /* XXX */
dev, (xTimecoord *)coords, /* XXX */ start.milliseconds, stop.milliseconds,
start.milliseconds, stop.milliseconds, (ScreenPtr)NULL); (ScreenPtr) NULL);
} }
if (rep.nEvents > 0) if (rep.nEvents > 0) {
{
length = (rep.nEvents * size + 3) >> 2; length = (rep.nEvents * size + 3) >> 2;
rep.length = length; rep.length = length;
} }
nEvents = rep.nEvents; nEvents = rep.nEvents;
WriteReplyToClient(client, sizeof(xGetDeviceMotionEventsReply), &rep); WriteReplyToClient(client, sizeof(xGetDeviceMotionEventsReply), &rep);
if (nEvents) if (nEvents) {
{ if (client->swapped) {
if (client->swapped)
{
bufptr = coords; bufptr = coords;
for (i=0; i<nEvents * (axes+1); i++) for (i = 0; i < nEvents * (axes + 1); i++) {
{
swapl(bufptr); swapl(bufptr);
bufptr++; bufptr++;
} }
......
...@@ -159,8 +159,7 @@ SizeDeviceInfo(DeviceIntPtr d, int *namesize, int *size) ...@@ -159,8 +159,7 @@ SizeDeviceInfo(DeviceIntPtr d, int *namesize, int *size)
*size += sizeof(xKeyInfo); *size += sizeof(xKeyInfo);
if (d->button != NULL) if (d->button != NULL)
*size += sizeof(xButtonInfo); *size += sizeof(xButtonInfo);
if (d->valuator != NULL) if (d->valuator != NULL) {
{
chunks = ((int)d->valuator->numAxes + 19) / VPC; chunks = ((int)d->valuator->numAxes + 19) / VPC;
*size += (chunks * sizeof(xValuatorInfo) + *size += (chunks * sizeof(xValuatorInfo) +
d->valuator->numAxes * sizeof(xAxisInfo)); d->valuator->numAxes * sizeof(xAxisInfo));
...@@ -179,19 +178,17 @@ ListDeviceInfo(ClientPtr client, DeviceIntPtr d, xDeviceInfoPtr dev, ...@@ -179,19 +178,17 @@ ListDeviceInfo(ClientPtr client, DeviceIntPtr d, xDeviceInfoPtr dev,
{ {
CopyDeviceName(namebuf, d->name); CopyDeviceName(namebuf, d->name);
CopySwapDevice(client, d, 0, devbuf); CopySwapDevice(client, d, 0, devbuf);
if (d->key != NULL) if (d->key != NULL) {
{
CopySwapKeyClass(client, d->key, classbuf); CopySwapKeyClass(client, d->key, classbuf);
dev->num_classes++; dev->num_classes++;
} }
if (d->button != NULL) if (d->button != NULL) {
{
CopySwapButtonClass(client, d->button, classbuf); CopySwapButtonClass(client, d->button, classbuf);
dev->num_classes++; dev->num_classes++;
} }
if (d->valuator != NULL) if (d->valuator != NULL) {
{ dev->num_classes +=
dev->num_classes += CopySwapValuatorClass(client, d->valuator, classbuf); CopySwapValuatorClass(client, d->valuator, classbuf);
} }
} }
...@@ -210,14 +207,11 @@ CopyDeviceName(char **namebuf, char *name) ...@@ -210,14 +207,11 @@ CopyDeviceName(char **namebuf, char *name)
{ {
char *nameptr = (char *)*namebuf; char *nameptr = (char *)*namebuf;
if (name) if (name) {
{
*nameptr++ = strlen(name); *nameptr++ = strlen(name);
strcpy(nameptr, name); strcpy(nameptr, name);
*namebuf += (strlen(name) + 1); *namebuf += (strlen(name) + 1);
} } else {
else
{
*nameptr++ = 0; *nameptr++ = 0;
*namebuf += 1; *namebuf += 1;
} }
...@@ -246,8 +240,7 @@ CopySwapDevice(register ClientPtr client, DeviceIntPtr d, int num_classes, ...@@ -246,8 +240,7 @@ CopySwapDevice(register ClientPtr client, DeviceIntPtr d, int num_classes,
dev->use = IsXPointer; dev->use = IsXPointer;
else else
dev->use = IsXExtensionDevice; dev->use = IsXExtensionDevice;
if (client->swapped) if (client->swapped) {
{
swapl(&dev->type); /* macro - braces are required */ swapl(&dev->type); /* macro - braces are required */
} }
*buf += sizeof(xDeviceInfo); *buf += sizeof(xDeviceInfo);
...@@ -270,8 +263,7 @@ CopySwapKeyClass(register ClientPtr client, KeyClassPtr k, char **buf) ...@@ -270,8 +263,7 @@ CopySwapKeyClass(register ClientPtr client, KeyClassPtr k, char **buf)
k2->min_keycode = k->curKeySyms.minKeyCode; k2->min_keycode = k->curKeySyms.minKeyCode;
k2->max_keycode = k->curKeySyms.maxKeyCode; k2->max_keycode = k->curKeySyms.maxKeyCode;
k2->num_keys = k2->max_keycode - k2->min_keycode + 1; k2->num_keys = k2->max_keycode - k2->min_keycode + 1;
if (client->swapped) if (client->swapped) {
{
swaps(&k2->num_keys); swaps(&k2->num_keys);
} }
*buf += sizeof(xKeyInfo); *buf += sizeof(xKeyInfo);
...@@ -292,8 +284,7 @@ CopySwapButtonClass(register ClientPtr client, ButtonClassPtr b, char **buf) ...@@ -292,8 +284,7 @@ CopySwapButtonClass(register ClientPtr client, ButtonClassPtr b, char **buf)
b2->class = ButtonClass; b2->class = ButtonClass;
b2->length = sizeof(xButtonInfo); b2->length = sizeof(xButtonInfo);
b2->num_buttons = b->numButtons; b2->num_buttons = b->numButtons;
if (client->swapped) if (client->swapped) {
{
swaps(&b2->num_buttons); /* macro - braces are required */ swaps(&b2->num_buttons); /* macro - braces are required */
} }
*buf += sizeof(xButtonInfo); *buf += sizeof(xButtonInfo);
...@@ -319,7 +310,8 @@ CopySwapValuatorClass(register ClientPtr client, ValuatorClassPtr v, char **buf) ...@@ -319,7 +310,8 @@ CopySwapValuatorClass(register ClientPtr client, ValuatorClassPtr v, char **buf)
AxisInfo *a; AxisInfo *a;
xAxisInfoPtr a2; 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; t_axes = axes < VPC ? axes : VPC;
if (t_axes < 0) if (t_axes < 0)
t_axes = v->numAxes % VPC; t_axes = v->numAxes % VPC;
...@@ -329,8 +321,7 @@ CopySwapValuatorClass(register ClientPtr client, ValuatorClassPtr v, char **buf) ...@@ -329,8 +321,7 @@ CopySwapValuatorClass(register ClientPtr client, ValuatorClassPtr v, char **buf)
v2->num_axes = t_axes; v2->num_axes = t_axes;
v2->mode = v->mode & DeviceMode; v2->mode = v->mode & DeviceMode;
v2->motion_buffer_size = v->numMotionEvents; v2->motion_buffer_size = v->numMotionEvents;
if (client->swapped) if (client->swapped) {
{
swapl(&v2->motion_buffer_size); swapl(&v2->motion_buffer_size);
} }
*buf += sizeof(xValuatorInfo); *buf += sizeof(xValuatorInfo);
......
...@@ -105,19 +105,16 @@ ProcXOpenDevice(register ClientPtr client) ...@@ -105,19 +105,16 @@ ProcXOpenDevice(register ClientPtr client)
REQUEST_SIZE_MATCH(xOpenDeviceReq); REQUEST_SIZE_MATCH(xOpenDeviceReq);
if (stuff->deviceid == inputInfo.pointer->id || if (stuff->deviceid == inputInfo.pointer->id ||
stuff->deviceid == inputInfo.keyboard->id) stuff->deviceid == inputInfo.keyboard->id) {
{
SendErrorToClient(client, IReqCode, X_OpenDevice, 0, BadDevice); SendErrorToClient(client, IReqCode, X_OpenDevice, 0, BadDevice);
return Success; 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) for (dev = inputInfo.off_devices; dev; dev = dev->next)
if (dev->id == stuff->deviceid) if (dev->id == stuff->deviceid)
break; break;
if (dev == NULL) if (dev == NULL) {
{
SendErrorToClient(client, IReqCode, X_OpenDevice, 0, BadDevice); SendErrorToClient(client, IReqCode, X_OpenDevice, 0, BadDevice);
return Success; return Success;
} }
...@@ -125,8 +122,7 @@ ProcXOpenDevice(register ClientPtr client) ...@@ -125,8 +122,7 @@ ProcXOpenDevice(register ClientPtr client)
} }
OpenInputDevice(dev, client, &status); OpenInputDevice(dev, client, &status);
if (status != Success) if (status != Success) {
{
SendErrorToClient(client, IReqCode, X_OpenDevice, 0, status); SendErrorToClient(client, IReqCode, X_OpenDevice, 0, status);
return Success; return Success;
} }
...@@ -137,34 +133,28 @@ ProcXOpenDevice(register ClientPtr client) ...@@ -137,34 +133,28 @@ ProcXOpenDevice(register ClientPtr client)
rep.repType = X_Reply; rep.repType = X_Reply;
rep.RepType = X_OpenDevice; rep.RepType = X_OpenDevice;
rep.sequenceNumber = client->sequence; rep.sequenceNumber = client->sequence;
if (dev->key != NULL) if (dev->key != NULL) {
{
evbase[j].class = KeyClass; evbase[j].class = KeyClass;
evbase[j++].event_type_base = event_base[KeyClass]; evbase[j++].event_type_base = event_base[KeyClass];
} }
if (dev->button != NULL) if (dev->button != NULL) {
{
evbase[j].class = ButtonClass; evbase[j].class = ButtonClass;
evbase[j++].event_type_base = event_base[ButtonClass]; evbase[j++].event_type_base = event_base[ButtonClass];
} }
if (dev->valuator != NULL) if (dev->valuator != NULL) {
{
evbase[j].class = ValuatorClass; evbase[j].class = ValuatorClass;
evbase[j++].event_type_base = event_base[ValuatorClass]; evbase[j++].event_type_base = event_base[ValuatorClass];
} }
if (dev->kbdfeed != NULL || dev->ptrfeed != NULL || dev->leds != NULL || 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].class = FeedbackClass;
evbase[j++].event_type_base = event_base[FeedbackClass]; evbase[j++].event_type_base = event_base[FeedbackClass];
} }
if (dev->focus != NULL) if (dev->focus != NULL) {
{
evbase[j].class = FocusClass; evbase[j].class = FocusClass;
evbase[j++].event_type_base = event_base[FocusClass]; evbase[j++].event_type_base = event_base[FocusClass];
} }
if (dev->proximity != NULL) if (dev->proximity != NULL) {
{
evbase[j].class = ProximityClass; evbase[j].class = ProximityClass;
evbase[j++].event_type_base = event_base[ProximityClass]; evbase[j++].event_type_base = event_base[ProximityClass];
} }
......
...@@ -95,10 +95,8 @@ ProcXQueryDeviceState(register ClientPtr client) ...@@ -95,10 +95,8 @@ ProcXQueryDeviceState(register ClientPtr client)
rep.sequenceNumber = client->sequence; rep.sequenceNumber = client->sequence;
dev = LookupDeviceIntRec(stuff->deviceid); dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL) if (dev == NULL) {
{ SendErrorToClient(client, IReqCode, X_QueryDeviceState, 0, BadDevice);
SendErrorToClient(client, IReqCode, X_QueryDeviceState, 0,
BadDevice);
return Success; return Success;
} }
...@@ -107,36 +105,29 @@ ProcXQueryDeviceState(register ClientPtr client) ...@@ -107,36 +105,29 @@ ProcXQueryDeviceState(register ClientPtr client)
MaybeStopDeviceHint(dev, client); MaybeStopDeviceHint(dev, client);
k = dev->key; k = dev->key;
if (k != NULL) if (k != NULL) {
{
total_length += sizeof(xKeyState); total_length += sizeof(xKeyState);
num_classes++; num_classes++;
} }
b = dev->button; b = dev->button;
if (b != NULL) if (b != NULL) {
{
total_length += sizeof(xButtonState); total_length += sizeof(xButtonState);
num_classes++; num_classes++;
} }
if (v != NULL) if (v != NULL) {
{ total_length += (sizeof(xValuatorState) + (v->numAxes * sizeof(int)));
total_length += (sizeof(xValuatorState) +
(v->numAxes * sizeof(int)));
num_classes++; num_classes++;
} }
buf = (char *)malloc(total_length); buf = (char *)malloc(total_length);
if (!buf) if (!buf) {
{ SendErrorToClient(client, IReqCode, X_QueryDeviceState, 0, BadAlloc);
SendErrorToClient(client, IReqCode, X_QueryDeviceState, 0,
BadAlloc);
return Success; return Success;
} }
savbuf = buf; savbuf = buf;
if (k != NULL) if (k != NULL) {
{
tk = (xKeyState *) buf; tk = (xKeyState *) buf;
tk->class = KeyClass; tk->class = KeyClass;
tk->length = sizeof(xKeyState); tk->length = sizeof(xKeyState);
...@@ -146,8 +137,7 @@ ProcXQueryDeviceState(register ClientPtr client) ...@@ -146,8 +137,7 @@ ProcXQueryDeviceState(register ClientPtr client)
buf += sizeof(xKeyState); buf += sizeof(xKeyState);
} }
if (b != NULL) if (b != NULL) {
{
tb = (xButtonState *) buf; tb = (xButtonState *) buf;
tb->class = ButtonClass; tb->class = ButtonClass;
tb->length = sizeof(xButtonState); tb->length = sizeof(xButtonState);
...@@ -157,19 +147,16 @@ ProcXQueryDeviceState(register ClientPtr client) ...@@ -157,19 +147,16 @@ ProcXQueryDeviceState(register ClientPtr client)
buf += sizeof(xButtonState); buf += sizeof(xButtonState);
} }
if (v != NULL) if (v != NULL) {
{
tv = (xValuatorState *) buf; tv = (xValuatorState *) buf;
tv->class = ValuatorClass; tv->class = ValuatorClass;
tv->length = sizeof(xValuatorState); tv->length = sizeof(xValuatorState);
tv->num_valuators = v->numAxes; tv->num_valuators = v->numAxes;
tv->mode = v->mode; tv->mode = v->mode;
buf += sizeof(xValuatorState); 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++; *((int *)buf) = *values++;
if (client->swapped) if (client->swapped) {
{
swapl((int *)buf); /* macro - braces needed */ swapl((int *)buf); /* macro - braces needed */
} }
buf += sizeof(int); buf += sizeof(int);
......
...@@ -110,16 +110,14 @@ ProcXSelectExtensionEvent(register ClientPtr client) ...@@ -110,16 +110,14 @@ ProcXSelectExtensionEvent(register ClientPtr client)
REQUEST(xSelectExtensionEventReq); REQUEST(xSelectExtensionEventReq);
REQUEST_AT_LEAST_SIZE(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, SendErrorToClient(client, IReqCode, X_SelectExtensionEvent, 0,
BadLength); BadLength);
return Success; return Success;
} }
pWin = (WindowPtr) LookupWindow(stuff->window, client); pWin = (WindowPtr) LookupWindow(stuff->window, client);
if (!pWin) if (!pWin) {
{
client->errorValue = stuff->window; client->errorValue = stuff->window;
SendErrorToClient(client, IReqCode, X_SelectExtensionEvent, 0, SendErrorToClient(client, IReqCode, X_SelectExtensionEvent, 0,
BadWindow); BadWindow);
...@@ -127,15 +125,16 @@ ProcXSelectExtensionEvent(register ClientPtr client) ...@@ -127,15 +125,16 @@ ProcXSelectExtensionEvent(register ClientPtr client)
} }
if ((ret = CreateMaskFromList(client, (XEventClass *) & stuff[1], if ((ret = CreateMaskFromList(client, (XEventClass *) & stuff[1],
stuff->count, tmp, NULL, X_SelectExtensionEvent)) != Success) stuff->count, tmp, NULL,
X_SelectExtensionEvent)) != Success)
return Success; return Success;
for (i = 0; i < EMASKSIZE; i++) for (i = 0; i < EMASKSIZE; i++)
if (tmp[i].dev != NULL) if (tmp[i].dev != NULL) {
{ if ((ret =
if ((ret = SelectForWindow((DeviceIntPtr)tmp[i].dev, pWin, client, tmp[i].mask, SelectForWindow((DeviceIntPtr) tmp[i].dev, pWin, client,
ExtExclusiveMasks[i], ExtValidMasks[i])) != Success) tmp[i].mask, ExtExclusiveMasks[i],
{ ExtValidMasks[i])) != Success) {
SendErrorToClient(client, IReqCode, X_SelectExtensionEvent, 0, SendErrorToClient(client, IReqCode, X_SelectExtensionEvent, 0,
ret); ret);
return Success; return Success;
......
...@@ -98,8 +98,7 @@ SProcXSendExtensionEvent(register ClientPtr client) ...@@ -98,8 +98,7 @@ SProcXSendExtensionEvent(register ClientPtr client)
return BadLength; return BadLength;
eventP = (xEvent *) & stuff[1]; 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]; proc = EventSwapVector[eventP->u.u.type & 0177];
if (proc == NotImplemented) /* no swapping proc; invalid event type? */ if (proc == NotImplemented) /* no swapping proc; invalid event type? */
return (BadValue); return (BadValue);
...@@ -132,18 +131,14 @@ ProcXSendExtensionEvent(register ClientPtr client) ...@@ -132,18 +131,14 @@ ProcXSendExtensionEvent(register ClientPtr client)
REQUEST_AT_LEAST_SIZE(xSendExtensionEventReq); REQUEST_AT_LEAST_SIZE(xSendExtensionEventReq);
if (stuff->length != (sizeof(xSendExtensionEventReq) >> 2) + stuff->count + if (stuff->length != (sizeof(xSendExtensionEventReq) >> 2) + stuff->count +
(stuff->num_events * (sizeof (xEvent) >> 2))) (stuff->num_events * (sizeof(xEvent) >> 2))) {
{ SendErrorToClient(client, IReqCode, X_SendExtensionEvent, 0, BadLength);
SendErrorToClient (client, IReqCode, X_SendExtensionEvent, 0,
BadLength);
return Success; return Success;
} }
dev = LookupDeviceIntRec(stuff->deviceid); dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL) if (dev == NULL) {
{ SendErrorToClient(client, IReqCode, X_SendExtensionEvent, 0, BadDevice);
SendErrorToClient(client, IReqCode, X_SendExtensionEvent, 0,
BadDevice);
return Success; return Success;
} }
...@@ -160,11 +155,9 @@ ProcXSendExtensionEvent(register ClientPtr client) ...@@ -160,11 +155,9 @@ ProcXSendExtensionEvent(register ClientPtr client)
first = ((xEvent *) & stuff[1]); first = ((xEvent *) & stuff[1]);
if (!((EXTENSION_EVENT_BASE <= first->u.u.type) && if (!((EXTENSION_EVENT_BASE <= first->u.u.type) &&
(first->u.u.type < lastEvent)) ) (first->u.u.type < lastEvent))) {
{
client->errorValue = first->u.u.type; client->errorValue = first->u.u.type;
SendErrorToClient(client, IReqCode, X_SendExtensionEvent, 0, SendErrorToClient(client, IReqCode, X_SendExtensionEvent, 0, BadValue);
BadValue);
return Success; return Success;
} }
...@@ -174,8 +167,8 @@ ProcXSendExtensionEvent(register ClientPtr client) ...@@ -174,8 +167,8 @@ ProcXSendExtensionEvent(register ClientPtr client)
return Success; return Success;
ret = (SendEvent(client, dev, stuff->destination, ret = (SendEvent(client, dev, stuff->destination,
stuff->propagate, (xEvent *)&stuff[1], tmp[stuff->deviceid].mask, stuff->propagate, (xEvent *) & stuff[1],
stuff->num_events)); tmp[stuff->deviceid].mask, stuff->num_events));
if (ret != Success) if (ret != Success)
SendErrorToClient(client, IReqCode, X_SendExtensionEvent, 0, ret); SendErrorToClient(client, IReqCode, X_SendExtensionEvent, 0, ret);
......
...@@ -101,8 +101,7 @@ ProcXSetDeviceButtonMapping(register ClientPtr client) ...@@ -101,8 +101,7 @@ ProcXSetDeviceButtonMapping(register ClientPtr client)
REQUEST_AT_LEAST_SIZE(xSetDeviceButtonMappingReq); REQUEST_AT_LEAST_SIZE(xSetDeviceButtonMappingReq);
if (stuff->length != (sizeof(xSetDeviceButtonMappingReq) + if (stuff->length != (sizeof(xSetDeviceButtonMappingReq) +
stuff->map_length + 3)>>2) stuff->map_length + 3) >> 2) {
{
SendErrorToClient(client, IReqCode, X_SetDeviceButtonMapping, 0, SendErrorToClient(client, IReqCode, X_SetDeviceButtonMapping, 0,
BadLength); BadLength);
return Success; return Success;
...@@ -115,8 +114,7 @@ ProcXSetDeviceButtonMapping(register ClientPtr client) ...@@ -115,8 +114,7 @@ ProcXSetDeviceButtonMapping(register ClientPtr client)
rep.status = MappingSuccess; rep.status = MappingSuccess;
dev = LookupDeviceIntRec(stuff->deviceid); dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL) if (dev == NULL) {
{
SendErrorToClient(client, IReqCode, X_SetDeviceButtonMapping, 0, SendErrorToClient(client, IReqCode, X_SetDeviceButtonMapping, 0,
BadDevice); BadDevice);
return Success; return Success;
...@@ -124,14 +122,10 @@ ProcXSetDeviceButtonMapping(register ClientPtr client) ...@@ -124,14 +122,10 @@ ProcXSetDeviceButtonMapping(register ClientPtr client)
ret = SetButtonMapping(client, dev, stuff->map_length, (BYTE *) & stuff[1]); ret = SetButtonMapping(client, dev, stuff->map_length, (BYTE *) & stuff[1]);
if (ret == BadValue || ret == BadMatch) if (ret == BadValue || ret == BadMatch) {
{ SendErrorToClient(client, IReqCode, X_SetDeviceButtonMapping, 0, ret);
SendErrorToClient(client, IReqCode, X_SetDeviceButtonMapping, 0,
ret);
return Success; return Success;
} } else {
else
{
rep.status = ret; rep.status = ret;
WriteReplyToClient(client, sizeof(xSetDeviceButtonMappingReply), &rep); WriteReplyToClient(client, sizeof(xSetDeviceButtonMappingReply), &rep);
} }
......
...@@ -103,30 +103,22 @@ ProcXSetDeviceValuators(register ClientPtr client) ...@@ -103,30 +103,22 @@ ProcXSetDeviceValuators(register ClientPtr client)
rep.sequenceNumber = client->sequence; rep.sequenceNumber = client->sequence;
if (stuff->length != (sizeof(xSetDeviceValuatorsReq) >> 2) + if (stuff->length != (sizeof(xSetDeviceValuatorsReq) >> 2) +
stuff->num_valuators) stuff->num_valuators) {
{ SendErrorToClient(client, IReqCode, X_SetDeviceValuators, 0, BadLength);
SendErrorToClient (client, IReqCode, X_SetDeviceValuators, 0,
BadLength);
return Success; return Success;
} }
dev = LookupDeviceIntRec(stuff->deviceid); dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL) if (dev == NULL) {
{ SendErrorToClient(client, IReqCode, X_SetDeviceValuators, 0, BadDevice);
SendErrorToClient (client, IReqCode, X_SetDeviceValuators, 0,
BadDevice);
return Success; return Success;
} }
if (dev->valuator == NULL) if (dev->valuator == NULL) {
{ SendErrorToClient(client, IReqCode, X_SetDeviceValuators, 0, BadMatch);
SendErrorToClient(client, IReqCode, X_SetDeviceValuators, 0,
BadMatch);
return Success; return Success;
} }
if (stuff->first_valuator + stuff->num_valuators > dev->valuator->numAxes) if (stuff->first_valuator + stuff->num_valuators > dev->valuator->numAxes) {
{ SendErrorToClient(client, IReqCode, X_SetDeviceValuators, 0, BadValue);
SendErrorToClient(client, IReqCode, X_SetDeviceValuators, 0,
BadValue);
return Success; return Success;
} }
...@@ -134,7 +126,8 @@ ProcXSetDeviceValuators(register ClientPtr client) ...@@ -134,7 +126,8 @@ ProcXSetDeviceValuators(register ClientPtr client)
rep.status = AlreadyGrabbed; rep.status = AlreadyGrabbed;
else else
rep.status = SetDeviceValuators(client, dev, (int *)&stuff[1], 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) if (rep.status != Success && rep.status != AlreadyGrabbed)
SendErrorToClient(client, IReqCode, X_SetDeviceValuators, 0, SendErrorToClient(client, IReqCode, X_SetDeviceValuators, 0,
......
...@@ -103,8 +103,7 @@ ProcXSetDeviceFocus(register ClientPtr client) ...@@ -103,8 +103,7 @@ ProcXSetDeviceFocus(register ClientPtr client)
REQUEST_SIZE_MATCH(xSetDeviceFocusReq); REQUEST_SIZE_MATCH(xSetDeviceFocusReq);
dev = LookupDeviceIntRec(stuff->device); dev = LookupDeviceIntRec(stuff->device);
if (dev==NULL || !dev->focus) if (dev == NULL || !dev->focus) {
{
SendErrorToClient(client, IReqCode, X_SetDeviceFocus, 0, BadDevice); SendErrorToClient(client, IReqCode, X_SetDeviceFocus, 0, BadDevice);
return Success; return Success;
} }
......
...@@ -100,8 +100,7 @@ ProcXSetDeviceModifierMapping(ClientPtr client) ...@@ -100,8 +100,7 @@ ProcXSetDeviceModifierMapping(ClientPtr client)
REQUEST_AT_LEAST_SIZE(xSetDeviceModifierMappingReq); REQUEST_AT_LEAST_SIZE(xSetDeviceModifierMappingReq);
dev = LookupDeviceIntRec(stuff->deviceid); dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL) if (dev == NULL) {
{
SendErrorToClient(client, IReqCode, X_SetDeviceModifierMapping, 0, SendErrorToClient(client, IReqCode, X_SetDeviceModifierMapping, 0,
BadDevice); BadDevice);
return Success; return Success;
...@@ -113,18 +112,17 @@ ProcXSetDeviceModifierMapping(ClientPtr client) ...@@ -113,18 +112,17 @@ ProcXSetDeviceModifierMapping(ClientPtr client)
rep.sequenceNumber = client->sequence; rep.sequenceNumber = client->sequence;
ret = SetModifierMapping(client, dev, stuff->length, ret = SetModifierMapping(client, dev, stuff->length,
(sizeof (xSetDeviceModifierMappingReq)>>2), stuff->numKeyPerModifier, (sizeof(xSetDeviceModifierMappingReq) >> 2),
(BYTE *)&stuff[1], &kp); stuff->numKeyPerModifier, (BYTE *) & stuff[1],
&kp);
if (ret==MappingSuccess || ret==MappingBusy || ret==MappingFailed) if (ret == MappingSuccess || ret == MappingBusy || ret == MappingFailed) {
{
rep.success = ret; rep.success = ret;
if (ret == MappingSuccess) if (ret == MappingSuccess)
SendDeviceMappingNotify(MappingModifier, 0, 0, dev); SendDeviceMappingNotify(MappingModifier, 0, 0, dev);
WriteReplyToClient(client, sizeof(xSetDeviceModifierMappingReply),&rep); WriteReplyToClient(client, sizeof(xSetDeviceModifierMappingReply),
} &rep);
else } else {
{
if (ret == -1) if (ret == -1)
ret = BadValue; ret = BadValue;
SendErrorToClient(client, IReqCode, X_SetDeviceModifierMapping, 0, ret); SendErrorToClient(client, IReqCode, X_SetDeviceModifierMapping, 0, ret);
......
...@@ -102,13 +102,11 @@ ProcXSetDeviceMode(register ClientPtr client) ...@@ -102,13 +102,11 @@ ProcXSetDeviceMode(register ClientPtr client)
rep.sequenceNumber = client->sequence; rep.sequenceNumber = client->sequence;
dev = LookupDeviceIntRec(stuff->deviceid); dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL) if (dev == NULL) {
{
SendErrorToClient(client, IReqCode, X_SetDeviceMode, 0, BadDevice); SendErrorToClient(client, IReqCode, X_SetDeviceMode, 0, BadDevice);
return Success; return Success;
} }
if (dev->valuator == NULL) if (dev->valuator == NULL) {
{
SendErrorToClient(client, IReqCode, X_SetDeviceMode, 0, BadMatch); SendErrorToClient(client, IReqCode, X_SetDeviceMode, 0, BadMatch);
return Success; return Success;
} }
...@@ -119,8 +117,7 @@ ProcXSetDeviceMode(register ClientPtr client) ...@@ -119,8 +117,7 @@ ProcXSetDeviceMode(register ClientPtr client)
if (rep.status == Success) if (rep.status == Success)
dev->valuator->mode = stuff->mode; dev->valuator->mode = stuff->mode;
else if (rep.status != AlreadyGrabbed) else if (rep.status != AlreadyGrabbed) {
{
SendErrorToClient(client, IReqCode, X_SetDeviceMode, 0, rep.status); SendErrorToClient(client, IReqCode, X_SetDeviceMode, 0, rep.status);
return Success; return Success;
} }
......
...@@ -99,8 +99,7 @@ ProcXUngrabDevice(register ClientPtr client) ...@@ -99,8 +99,7 @@ ProcXUngrabDevice(register ClientPtr client)
REQUEST_SIZE_MATCH(xUngrabDeviceReq); REQUEST_SIZE_MATCH(xUngrabDeviceReq);
dev = LookupDeviceIntRec(stuff->deviceid); dev = LookupDeviceIntRec(stuff->deviceid);
if (dev == NULL) if (dev == NULL) {
{
SendErrorToClient(client, IReqCode, X_UngrabDevice, 0, BadDevice); SendErrorToClient(client, IReqCode, X_UngrabDevice, 0, BadDevice);
return Success; return Success;
} }
......
...@@ -107,51 +107,39 @@ ProcXUngrabDeviceButton(ClientPtr client) ...@@ -107,51 +107,39 @@ ProcXUngrabDeviceButton(ClientPtr client)
REQUEST_SIZE_MATCH(xUngrabDeviceButtonReq); REQUEST_SIZE_MATCH(xUngrabDeviceButtonReq);
dev = LookupDeviceIntRec(stuff->grabbed_device); dev = LookupDeviceIntRec(stuff->grabbed_device);
if (dev == NULL) if (dev == NULL) {
{ SendErrorToClient(client, IReqCode, X_UngrabDeviceButton, 0, BadDevice);
SendErrorToClient(client, IReqCode, X_UngrabDeviceButton, 0,
BadDevice);
return Success; return Success;
} }
if (dev->button == NULL) if (dev->button == NULL) {
{ SendErrorToClient(client, IReqCode, X_UngrabDeviceButton, 0, BadMatch);
SendErrorToClient(client, IReqCode, X_UngrabDeviceButton, 0,
BadMatch);
return Success; return Success;
} }
if (stuff->modifier_device != UseXKeyboard) if (stuff->modifier_device != UseXKeyboard) {
{
mdev = LookupDeviceIntRec(stuff->modifier_device); mdev = LookupDeviceIntRec(stuff->modifier_device);
if (mdev == NULL) if (mdev == NULL) {
{
SendErrorToClient(client, IReqCode, X_UngrabDeviceButton, 0, SendErrorToClient(client, IReqCode, X_UngrabDeviceButton, 0,
BadDevice); BadDevice);
return Success; return Success;
} }
if (mdev->key == NULL) if (mdev->key == NULL) {
{
SendErrorToClient(client, IReqCode, X_UngrabDeviceButton, 0, SendErrorToClient(client, IReqCode, X_UngrabDeviceButton, 0,
BadMatch); BadMatch);
return Success; return Success;
} }
} } else
else
mdev = (DeviceIntPtr) LookupKeyboardDevice(); mdev = (DeviceIntPtr) LookupKeyboardDevice();
pWin = LookupWindow(stuff->grabWindow, client); pWin = LookupWindow(stuff->grabWindow, client);
if (!pWin) if (!pWin) {
{ SendErrorToClient(client, IReqCode, X_UngrabDeviceButton, 0, BadWindow);
SendErrorToClient(client, IReqCode, X_UngrabDeviceButton, 0,
BadWindow);
return Success; return Success;
} }
if ((stuff->modifiers != AnyModifier) && if ((stuff->modifiers != AnyModifier) &&
(stuff->modifiers & ~AllModifiersMask)) (stuff->modifiers & ~AllModifiersMask)) {
{ SendErrorToClient(client, IReqCode, X_UngrabDeviceButton, 0, BadValue);
SendErrorToClient(client, IReqCode, X_UngrabDeviceButton, 0,
BadValue);
return Success; return Success;
} }
......
...@@ -107,57 +107,43 @@ ProcXUngrabDeviceKey(ClientPtr client) ...@@ -107,57 +107,43 @@ ProcXUngrabDeviceKey(ClientPtr client)
REQUEST_SIZE_MATCH(xUngrabDeviceKeyReq); REQUEST_SIZE_MATCH(xUngrabDeviceKeyReq);
dev = LookupDeviceIntRec(stuff->grabbed_device); dev = LookupDeviceIntRec(stuff->grabbed_device);
if (dev == NULL) if (dev == NULL) {
{ SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0, BadDevice);
SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0,
BadDevice);
return Success; return Success;
} }
if (dev->key == NULL) if (dev->key == NULL) {
{
SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0, BadMatch); SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0, BadMatch);
return Success; return Success;
} }
if (stuff->modifier_device != UseXKeyboard) if (stuff->modifier_device != UseXKeyboard) {
{
mdev = LookupDeviceIntRec(stuff->modifier_device); mdev = LookupDeviceIntRec(stuff->modifier_device);
if (mdev == NULL) if (mdev == NULL) {
{
SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0, SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0,
BadDevice); BadDevice);
return Success; return Success;
} }
if (mdev->key == NULL) if (mdev->key == NULL) {
{ SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0, BadMatch);
SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0,
BadMatch);
return Success; return Success;
} }
} } else
else
mdev = (DeviceIntPtr) LookupKeyboardDevice(); mdev = (DeviceIntPtr) LookupKeyboardDevice();
pWin = LookupWindow(stuff->grabWindow, client); pWin = LookupWindow(stuff->grabWindow, client);
if (!pWin) if (!pWin) {
{ SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0, BadWindow);
SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0,
BadWindow);
return Success; return Success;
} }
if (((stuff->key > dev->key->curKeySyms.maxKeyCode) || if (((stuff->key > dev->key->curKeySyms.maxKeyCode) ||
(stuff->key < dev->key->curKeySyms.minKeyCode)) (stuff->key < dev->key->curKeySyms.minKeyCode))
&& (stuff->key != AnyKey)) && (stuff->key != AnyKey)) {
{ SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0, BadValue);
SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0,
BadValue);
return Success; return Success;
} }
if ((stuff->modifiers != AnyModifier) && if ((stuff->modifiers != AnyModifier) &&
(stuff->modifiers & ~AllModifiersMask)) (stuff->modifiers & ~AllModifiersMask)) {
{ SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0, BadValue);
SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0,
BadValue);
return Success; 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