int ProcXCloseDevice(register 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 */ /* 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; }
int ProcXCloseDevice(ClientPtr client) { int rc, i; WindowPtr pWin, p1; DeviceIntPtr d; REQUEST(xCloseDeviceReq); REQUEST_SIZE_MATCH(xCloseDeviceReq); rc = dixLookupDevice(&d, stuff->deviceid, client, DixUseAccess); if (rc != Success) return rc; if (d->deviceGrab.grab && SameClient(d->deviceGrab.grab, client)) (*d->deviceGrab.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; }
void DeleteEventsFromChildren(DeviceIntPtr dev, WindowPtr p1, ClientPtr client) { WindowPtr p2; while (p1) { p2 = p1->firstChild; DeleteDeviceEvents(dev, p1, client); DeleteEventsFromChildren(dev, p2, client); p1 = p1->nextSib; } }