aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/programs/Xserver/Xi/chgdctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'nx-X11/programs/Xserver/Xi/chgdctl.c')
-rw-r--r--nx-X11/programs/Xserver/Xi/chgdctl.c161
1 files changed, 70 insertions, 91 deletions
diff --git a/nx-X11/programs/Xserver/Xi/chgdctl.c b/nx-X11/programs/Xserver/Xi/chgdctl.c
index b07885f9c..566df5906 100644
--- a/nx-X11/programs/Xserver/Xi/chgdctl.c
+++ b/nx-X11/programs/Xserver/Xi/chgdctl.c
@@ -55,15 +55,15 @@ SOFTWARE.
#include <dix-config.h>
#endif
-#include <nx-X11/X.h> /* for inputstr.h */
-#include <nx-X11/Xproto.h> /* Request macro */
-#include "inputstr.h" /* DeviceIntPtr */
+#include <nx-X11/X.h> /* for inputstr.h */
+#include <nx-X11/Xproto.h> /* Request macro */
+#include "inputstr.h" /* DeviceIntPtr */
#include <nx-X11/extensions/XI.h>
-#include <nx-X11/extensions/XIproto.h> /* control constants */
+#include <nx-X11/extensions/XIproto.h> /* control constants */
#include "XIstubs.h"
#include "extnsionst.h"
-#include "extinit.h" /* LookupDeviceIntRec */
+#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h"
#include "chgdctl.h"
@@ -76,15 +76,14 @@ SOFTWARE.
*/
int
-SProcXChangeDeviceControl(client)
- register ClientPtr client;
- {
+SProcXChangeDeviceControl(register ClientPtr client)
+{
REQUEST(xChangeDeviceControlReq);
swaps(&stuff->length);
REQUEST_AT_LEAST_EXTRA_SIZE(xChangeDeviceControlReq, sizeof(xDeviceCtl));
swaps(&stuff->control);
- return(ProcXChangeDeviceControl(client));
- }
+ return (ProcXChangeDeviceControl(client));
+}
/***********************************************************************
*
@@ -93,9 +92,8 @@ SProcXChangeDeviceControl(client)
*/
int
-ProcXChangeDeviceControl(client)
- ClientPtr client;
- {
+ProcXChangeDeviceControl(ClientPtr client)
+{
unsigned len;
int i, status;
DeviceIntPtr dev;
@@ -107,89 +105,73 @@ ProcXChangeDeviceControl(client)
REQUEST(xChangeDeviceControlReq);
REQUEST_AT_LEAST_EXTRA_SIZE(xChangeDeviceControlReq, sizeof(xDeviceCtl));
- len = stuff->length - (sizeof(xChangeDeviceControlReq) >>2);
- dev = LookupDeviceIntRec (stuff->deviceid);
- if (dev == NULL)
- {
- SendErrorToClient (client, IReqCode, X_ChangeDeviceControl, 0,
- BadDevice);
+ len = stuff->length - (sizeof(xChangeDeviceControlReq) >> 2);
+ dev = LookupDeviceIntRec(stuff->deviceid);
+ if (dev == NULL) {
+ SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0,
+ BadDevice);
return Success;
- }
+ }
rep.repType = X_Reply;
rep.RepType = X_ChangeDeviceControl;
rep.length = 0;
rep.sequenceNumber = client->sequence;
- switch (stuff->control)
- {
- case DEVICE_RESOLUTION:
- r = (xDeviceResolutionCtl *) &stuff[1];
- if ((len < (sizeof(xDeviceResolutionCtl)>>2)) ||
- (len != (sizeof(xDeviceResolutionCtl)>>2) +
- r->num_valuators))
- {
- SendErrorToClient (client, IReqCode, X_ChangeDeviceControl,
- 0, BadLength);
- return Success;
- }
- if (!dev->valuator)
- {
- SendErrorToClient (client, IReqCode, X_ChangeDeviceControl, 0,
- BadMatch);
- return Success;
- }
- if ((dev->grab) && !SameClient(dev->grab, client))
- {
- rep.status = AlreadyGrabbed;
- WriteReplyToClient(client, sizeof(xChangeDeviceControlReply),
- &rep);
- return Success;
- }
- resolution = (CARD32 *) (r + 1);
- if (r->first_valuator + r->num_valuators > dev->valuator->numAxes)
- {
- SendErrorToClient (client, IReqCode, X_ChangeDeviceControl, 0,
- BadValue);
- return Success;
- }
- status = ChangeDeviceControl(client, dev, (xDeviceCtl*) r);
- if (status == Success)
- {
- a = &dev->valuator->axes[r->first_valuator];
- for (i=0; i<r->num_valuators; i++)
- if (*(resolution+i) < (a+i)->min_resolution ||
- *(resolution+i) > (a+i)->max_resolution)
- {
- SendErrorToClient (client, IReqCode,
- X_ChangeDeviceControl, 0, BadValue);
- return Success;
- }
- for (i=0; i<r->num_valuators; i++)
- (a++)->resolution = *resolution++;
- }
- else if (status == DeviceBusy)
- {
- rep.status = DeviceBusy;
- WriteReplyToClient(client, sizeof(xChangeDeviceControlReply),
- &rep);
- return Success;
- }
- else
- {
- SendErrorToClient (client, IReqCode, X_ChangeDeviceControl, 0,
- BadMatch);
- return Success;
+ switch (stuff->control) {
+ case DEVICE_RESOLUTION:
+ r = (xDeviceResolutionCtl *) & stuff[1];
+ if ((len < (sizeof(xDeviceResolutionCtl) >> 2)) ||
+ (len != (sizeof(xDeviceResolutionCtl) >> 2) + r->num_valuators)) {
+ SendErrorToClient(client, IReqCode, X_ChangeDeviceControl,
+ 0, BadLength);
+ return Success;
+ }
+ if (!dev->valuator) {
+ SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0,
+ BadMatch);
+ return Success;
+ }
+ if ((dev->grab) && !SameClient(dev->grab, client)) {
+ rep.status = AlreadyGrabbed;
+ WriteReplyToClient(client, sizeof(xChangeDeviceControlReply), &rep);
+ return Success;
+ }
+ resolution = (CARD32 *) (r + 1);
+ if (r->first_valuator + r->num_valuators > dev->valuator->numAxes) {
+ SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0,
+ BadValue);
+ return Success;
+ }
+ status = ChangeDeviceControl(client, dev, (xDeviceCtl *) r);
+ if (status == Success) {
+ a = &dev->valuator->axes[r->first_valuator];
+ for (i = 0; i < r->num_valuators; i++)
+ if (*(resolution + i) < (a + i)->min_resolution ||
+ *(resolution + i) > (a + i)->max_resolution) {
+ SendErrorToClient(client, IReqCode,
+ X_ChangeDeviceControl, 0, BadValue);
+ return Success;
}
- break;
- default:
- SendErrorToClient (client, IReqCode, X_ChangeDeviceControl, 0,
- BadValue);
+ for (i = 0; i < r->num_valuators; i++)
+ (a++)->resolution = *resolution++;
+ } else if (status == DeviceBusy) {
+ rep.status = DeviceBusy;
+ WriteReplyToClient(client, sizeof(xChangeDeviceControlReply), &rep);
+ return Success;
+ } else {
+ SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0,
+ BadMatch);
return Success;
}
+ break;
+ default:
+ SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0, BadValue);
+ return Success;
+ }
WriteReplyToClient(client, sizeof(xChangeDeviceControlReply), &rep);
return Success;
- }
+}
/***********************************************************************
*
@@ -199,13 +181,10 @@ ProcXChangeDeviceControl(client)
*/
void
-SRepXChangeDeviceControl (client, size, rep)
- ClientPtr client;
- int size;
- xChangeDeviceControlReply *rep;
- {
+SRepXChangeDeviceControl(ClientPtr client, int size,
+ xChangeDeviceControlReply * rep)
+{
swaps(&rep->sequenceNumber);
swapl(&rep->length);
WriteToClient(client, size, rep);
- }
-
+}