diff options
author | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2008-11-02 15:26:35 +0000 |
---|---|---|
committer | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2008-11-02 15:26:35 +0000 |
commit | dbca69c8a4f3e2d1ccb4f89152213b2861b33af6 (patch) | |
tree | f8963ef73903a7b4374adc2354dffbaa905112ac /xserver/Xi/grabdev.c | |
parent | 33b2029f322f3c238b7ba528083195ad8dde33e1 (diff) |
xserver 1.5.2. tested by ckuethe@, oga@, and others.
Diffstat (limited to 'xserver/Xi/grabdev.c')
-rw-r--r-- | xserver/Xi/grabdev.c | 58 |
1 files changed, 24 insertions, 34 deletions
diff --git a/xserver/Xi/grabdev.c b/xserver/Xi/grabdev.c index d0b4ae74c..0671e0ea7 100644 --- a/xserver/Xi/grabdev.c +++ b/xserver/Xi/grabdev.c @@ -56,14 +56,10 @@ SOFTWARE. #include <dix-config.h> #endif -#include <X11/X.h> /* for inputstr.h */ -#include <X11/Xproto.h> /* Request macro */ #include "inputstr.h" /* DeviceIntPtr */ #include "windowstr.h" /* window structure */ #include <X11/extensions/XI.h> #include <X11/extensions/XIproto.h> -#include "extnsionst.h" -#include "extinit.h" /* LookupDeviceIntRec */ #include "exglobals.h" #include "dixevents.h" /* GrabDevice */ @@ -107,7 +103,7 @@ SProcXGrabDevice(ClientPtr client) int ProcXGrabDevice(ClientPtr client) { - int error; + int rc; xGrabDeviceReply rep; DeviceIntPtr dev; struct tmask tmp[EMASKSIZE]; @@ -115,36 +111,31 @@ ProcXGrabDevice(ClientPtr client) REQUEST(xGrabDeviceReq); REQUEST_AT_LEAST_SIZE(xGrabDeviceReq); - if (stuff->length != (sizeof(xGrabDeviceReq) >> 2) + stuff->event_count) { - SendErrorToClient(client, IReqCode, X_GrabDevice, 0, BadLength); - return Success; - } + if (stuff->length != (sizeof(xGrabDeviceReq) >> 2) + stuff->event_count) + return BadLength; rep.repType = X_Reply; rep.RepType = X_GrabDevice; rep.sequenceNumber = client->sequence; rep.length = 0; - dev = LookupDeviceIntRec(stuff->deviceid); - if (dev == NULL) { - SendErrorToClient(client, IReqCode, X_GrabDevice, 0, BadDevice); - return Success; - } + rc = dixLookupDevice(&dev, stuff->deviceid, client, DixGrabAccess); + if (rc != Success) + return rc; - if (CreateMaskFromList(client, (XEventClass *) & stuff[1], - stuff->event_count, tmp, dev, - X_GrabDevice) != Success) - return Success; + if ((rc = CreateMaskFromList(client, (XEventClass *) & stuff[1], + stuff->event_count, tmp, dev, + X_GrabDevice)) != Success) + return rc; - error = GrabDevice(client, dev, stuff->this_device_mode, - stuff->other_devices_mode, stuff->grabWindow, - stuff->ownerEvents, stuff->time, - tmp[stuff->deviceid].mask, &rep.status); + rc = GrabDevice(client, dev, stuff->this_device_mode, + stuff->other_devices_mode, stuff->grabWindow, + stuff->ownerEvents, stuff->time, + tmp[stuff->deviceid].mask, &rep.status); + + if (rc != Success) + return rc; - if (error != Success) { - SendErrorToClient(client, IReqCode, X_GrabDevice, 0, error); - return Success; - } WriteReplyToClient(client, sizeof(xGrabDeviceReply), &rep); return Success; } @@ -159,7 +150,7 @@ int CreateMaskFromList(ClientPtr client, XEventClass * list, int count, struct tmask *mask, DeviceIntPtr dev, int req) { - int i, j; + int rc, i, j; int device; DeviceIntPtr tdev; @@ -170,15 +161,14 @@ CreateMaskFromList(ClientPtr client, XEventClass * list, int count, for (i = 0; i < count; i++, list++) { device = *list >> 8; - if (device > 255) { - SendErrorToClient(client, IReqCode, req, 0, BadClass); + if (device > 255) return BadClass; - } - tdev = LookupDeviceIntRec(device); - if (tdev == NULL || (dev != NULL && tdev != dev)) { - SendErrorToClient(client, IReqCode, req, 0, BadClass); + + rc = dixLookupDevice(&tdev, device, client, DixReadAccess); + if (rc != BadDevice && rc != Success) + return rc; + if (rc == BadDevice || (dev != NULL && tdev != dev)) return BadClass; - } for (j = 0; j < ExtEventIndex; j++) if (EventInfo[j].type == (*list & 0xff)) { |