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/closedev.c | |
parent | 33b2029f322f3c238b7ba528083195ad8dde33e1 (diff) |
xserver 1.5.2. tested by ckuethe@, oga@, and others.
Diffstat (limited to 'xserver/Xi/closedev.c')
-rw-r--r-- | xserver/Xi/closedev.c | 98 |
1 files changed, 46 insertions, 52 deletions
diff --git a/xserver/Xi/closedev.c b/xserver/Xi/closedev.c index cc83e6a5b..94b7391fb 100644 --- a/xserver/Xi/closedev.c +++ b/xserver/Xi/closedev.c @@ -56,16 +56,12 @@ 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 "scrnintstr.h" /* screen structure */ #include <X11/extensions/XI.h> #include <X11/extensions/XIproto.h> #include "XIstubs.h" -#include "extnsionst.h" -#include "extinit.h" /* LookupDeviceIntRec */ #include "exglobals.h" #include "closedev.h" @@ -77,9 +73,9 @@ SOFTWARE. */ int -SProcXCloseDevice(register ClientPtr client) +SProcXCloseDevice(ClientPtr client) { - register char n; + char n; REQUEST(xCloseDeviceReq); swaps(&stuff->length, n); @@ -89,42 +85,29 @@ SProcXCloseDevice(register ClientPtr client) /*********************************************************************** * - * This procedure closes an input device. + * Clear out event selections and passive grabs from a window for the + * specified device. * */ -int -ProcXCloseDevice(register ClientPtr client) +static void +DeleteDeviceEvents(DeviceIntPtr dev, WindowPtr pWin, ClientPtr client) { - int i; - WindowPtr pWin, p1; - DeviceIntPtr d; - - REQUEST(xCloseDeviceReq); - REQUEST_SIZE_MATCH(xCloseDeviceReq); - - d = LookupDeviceIntRec(stuff->deviceid); - if (d == NULL) { - SendErrorToClient(client, IReqCode, X_CloseDevice, 0, BadDevice); - return Success; - } - - if (d->grab && SameClient(d->grab, client)) - (*d->DeactivateGrab) (d); /* release active grab */ + InputClientsPtr others; + OtherInputMasks *pOthers; + GrabPtr grab, next; - /* Remove event selections from all windows for events from this device - * and selected by this client. - * Delete passive grabs from all windows for this device. */ + if ((pOthers = wOtherInputMasks(pWin)) != 0) + for (others = pOthers->inputClients; others; others = others->next) + if (SameClient(others, client)) + others->mask[dev->id] = NoEventMask; - for (i = 0; i < screenInfo.numScreens; i++) { - pWin = WindowTable[i]; - DeleteDeviceEvents(d, pWin, client); - p1 = pWin->firstChild; - DeleteEventsFromChildren(d, p1, client); + for (grab = wPassiveGrabs(pWin); grab; grab = next) { + next = grab->next; + if ((grab->device == dev) && + (client->clientAsMask == CLIENT_BITS(grab->resource))) + FreeResource(grab->resource, RT_NONE); } - - CloseInputDevice(d, client); - return Success; } /*********************************************************************** @@ -134,7 +117,7 @@ ProcXCloseDevice(register ClientPtr client) * */ -void +static void DeleteEventsFromChildren(DeviceIntPtr dev, WindowPtr p1, ClientPtr client) { WindowPtr p2; @@ -149,27 +132,38 @@ DeleteEventsFromChildren(DeviceIntPtr dev, WindowPtr p1, ClientPtr client) /*********************************************************************** * - * Clear out event selections and passive grabs from a window for the - * specified device. + * This procedure closes an input device. * */ -void -DeleteDeviceEvents(DeviceIntPtr dev, WindowPtr pWin, ClientPtr client) +int +ProcXCloseDevice(ClientPtr client) { - InputClientsPtr others; - OtherInputMasks *pOthers; - GrabPtr grab, next; + int rc, i; + WindowPtr pWin, p1; + DeviceIntPtr d; - if ((pOthers = wOtherInputMasks(pWin)) != 0) - for (others = pOthers->inputClients; others; others = others->next) - if (SameClient(others, client)) - others->mask[dev->id] = NoEventMask; + REQUEST(xCloseDeviceReq); + REQUEST_SIZE_MATCH(xCloseDeviceReq); - for (grab = wPassiveGrabs(pWin); grab; grab = next) { - next = grab->next; - if ((grab->device == dev) && - (client->clientAsMask == CLIENT_BITS(grab->resource))) - FreeResource(grab->resource, RT_NONE); + rc = dixLookupDevice(&d, stuff->deviceid, client, DixUseAccess); + if (rc != Success) + return rc; + + if (d->grab && SameClient(d->grab, client)) + (*d->DeactivateGrab) (d); /* release active grab */ + + /* Remove event selections from all windows for events from this device + * and selected by this client. + * Delete passive grabs from all windows for this device. */ + + for (i = 0; i < screenInfo.numScreens; i++) { + pWin = WindowTable[i]; + DeleteDeviceEvents(d, pWin, client); + p1 = pWin->firstChild; + DeleteEventsFromChildren(d, p1, client); } + + CloseInputDevice(d, client); + return Success; } |