1
/* $Xorg: closedev.c,v 1.4 2001/02/09 02:04:33 xorgcvs Exp $ */
3
/************************************************************
5
Copyright 1989, 1998 The Open Group
7
Permission to use, copy, modify, distribute, and sell this software and its
8
documentation for any purpose is hereby granted without fee, provided that
9
the above copyright notice appear in all copies and that both that
10
copyright notice and this permission notice appear in supporting
13
The above copyright notice and this permission notice shall be included in
14
all copies or substantial portions of the Software.
16
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
Except as contained in this notice, the name of The Open Group shall not be
24
used in advertising or otherwise to promote the sale, use or other dealings
25
in this Software without prior written authorization from The Open Group.
27
Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
31
Permission to use, copy, modify, and distribute this software and its
32
documentation for any purpose and without fee is hereby granted,
33
provided that the above copyright notice appear in all copies and that
34
both that copyright notice and this permission notice appear in
35
supporting documentation, and that the name of Hewlett-Packard not be
36
used in advertising or publicity pertaining to distribution of the
37
software without specific, written prior permission.
39
HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
40
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
41
HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
42
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
43
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
44
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
47
********************************************************/
48
/* $XFree86: xc/programs/Xserver/Xi/closedev.c,v 3.3 2001/08/23 14:56:19 alanh Exp $ */
50
/***********************************************************************
52
* Extension function to close an extension input device.
58
#ifdef HAVE_DIX_CONFIG_H
59
#include <dix-config.h>
62
#include <X11/X.h> /* for inputstr.h */
63
#include <X11/Xproto.h> /* Request macro */
64
#include "inputstr.h" /* DeviceIntPtr */
65
#include "windowstr.h" /* window structure */
66
#include "scrnintstr.h" /* screen structure */
67
#include <X11/extensions/XI.h>
68
#include <X11/extensions/XIproto.h>
70
#include "extnsionst.h"
71
#include "extinit.h" /* LookupDeviceIntRec */
72
#include "exglobals.h"
76
/***********************************************************************
78
* This procedure closes an input device.
83
SProcXCloseDevice(client)
84
register ClientPtr client;
88
REQUEST(xCloseDeviceReq);
89
swaps(&stuff->length, n);
90
REQUEST_SIZE_MATCH(xCloseDeviceReq);
91
return(ProcXCloseDevice(client));
94
/***********************************************************************
96
* This procedure closes an input device.
101
ProcXCloseDevice(client)
102
register ClientPtr client;
108
REQUEST(xCloseDeviceReq);
109
REQUEST_SIZE_MATCH(xCloseDeviceReq);
111
d = LookupDeviceIntRec (stuff->deviceid);
114
SendErrorToClient(client, IReqCode, X_CloseDevice, 0, BadDevice);
118
if (d->grab && SameClient(d->grab, client))
119
(*d->DeactivateGrab)(d); /* release active grab */
121
/* Remove event selections from all windows for events from this device
122
and selected by this client.
123
Delete passive grabs from all windows for this device. */
125
for (i=0; i<screenInfo.numScreens; i++)
127
pWin = WindowTable[i];
128
DeleteDeviceEvents (d, pWin, client);
129
p1 = pWin->firstChild;
130
DeleteEventsFromChildren (d, p1, client);
133
CloseInputDevice (d, client);
137
/***********************************************************************
139
* Walk througth the window tree, deleting event selections for this client
140
* from this device from all windows.
145
DeleteEventsFromChildren(dev, p1, client)
155
DeleteDeviceEvents (dev, p1, client);
156
DeleteEventsFromChildren(dev, p2, client);
161
/***********************************************************************
163
* Clear out event selections and passive grabs from a window for the
169
DeleteDeviceEvents (dev, pWin, client)
174
InputClientsPtr others;
175
OtherInputMasks *pOthers;
178
if ((pOthers = wOtherInputMasks(pWin)) != 0)
179
for (others=pOthers->inputClients; others;
180
others = others->next)
181
if (SameClient(others,client))
182
others->mask[dev->id] = NoEventMask;
184
for (grab = wPassiveGrabs(pWin); grab; grab=next)
187
if ((grab->device == dev) &&
188
(client->clientAsMask == CLIENT_BITS(grab->resource)))
189
FreeResource (grab->resource, RT_NONE);