~ubuntu-branches/ubuntu/intrepid/xserver-xgl/intrepid

« back to all changes in this revision

Viewing changes to Xi/closedev.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthew Garrett
  • Date: 2006-02-13 14:21:43 UTC
  • Revision ID: james.westby@ubuntu.com-20060213142143-mad6z9xzem7hzxz9
Tags: upstream-7.0.0
ImportĀ upstreamĀ versionĀ 7.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $Xorg: closedev.c,v 1.4 2001/02/09 02:04:33 xorgcvs Exp $ */
 
2
 
 
3
/************************************************************
 
4
 
 
5
Copyright 1989, 1998  The Open Group
 
6
 
 
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
 
11
documentation.
 
12
 
 
13
The above copyright notice and this permission notice shall be included in
 
14
all copies or substantial portions of the Software.
 
15
 
 
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.
 
22
 
 
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.
 
26
 
 
27
Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
 
28
 
 
29
                        All Rights Reserved
 
30
 
 
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.
 
38
 
 
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
 
45
SOFTWARE.
 
46
 
 
47
********************************************************/
 
48
/* $XFree86: xc/programs/Xserver/Xi/closedev.c,v 3.3 2001/08/23 14:56:19 alanh Exp $ */
 
49
 
 
50
/***********************************************************************
 
51
 *
 
52
 * Extension function to close an extension input device.
 
53
 *
 
54
 */
 
55
 
 
56
#define  NEED_EVENTS
 
57
#define  NEED_REPLIES
 
58
#ifdef HAVE_DIX_CONFIG_H
 
59
#include <dix-config.h>
 
60
#endif
 
61
 
 
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>
 
69
#include "XIstubs.h"
 
70
#include "extnsionst.h"
 
71
#include "extinit.h"                    /* LookupDeviceIntRec */
 
72
#include "exglobals.h"
 
73
 
 
74
#include "closedev.h"
 
75
 
 
76
/***********************************************************************
 
77
 *
 
78
 * This procedure closes an input device.
 
79
 *
 
80
 */
 
81
 
 
82
int
 
83
SProcXCloseDevice(client)
 
84
    register ClientPtr client;
 
85
    {
 
86
    register char n;
 
87
 
 
88
    REQUEST(xCloseDeviceReq);
 
89
    swaps(&stuff->length, n);
 
90
    REQUEST_SIZE_MATCH(xCloseDeviceReq);
 
91
    return(ProcXCloseDevice(client));
 
92
    }
 
93
 
 
94
/***********************************************************************
 
95
 *
 
96
 * This procedure closes an input device.
 
97
 *
 
98
 */
 
99
 
 
100
int
 
101
ProcXCloseDevice(client)
 
102
    register ClientPtr client;
 
103
    {
 
104
    int                 i;
 
105
    WindowPtr           pWin, p1;
 
106
    DeviceIntPtr        d;
 
107
 
 
108
    REQUEST(xCloseDeviceReq);
 
109
    REQUEST_SIZE_MATCH(xCloseDeviceReq);
 
110
 
 
111
    d = LookupDeviceIntRec (stuff->deviceid);
 
112
    if (d == NULL)
 
113
        {
 
114
        SendErrorToClient(client, IReqCode, X_CloseDevice, 0, BadDevice);
 
115
        return Success;
 
116
        }
 
117
 
 
118
    if (d->grab && SameClient(d->grab, client))
 
119
        (*d->DeactivateGrab)(d);                       /* release active grab */
 
120
 
 
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.      */
 
124
 
 
125
    for (i=0; i<screenInfo.numScreens; i++)
 
126
        {
 
127
        pWin = WindowTable[i];
 
128
        DeleteDeviceEvents (d, pWin, client);
 
129
        p1 = pWin->firstChild;
 
130
        DeleteEventsFromChildren (d, p1, client);
 
131
        }
 
132
 
 
133
    CloseInputDevice (d, client);
 
134
    return Success;
 
135
    }
 
136
 
 
137
/***********************************************************************
 
138
 *
 
139
 * Walk througth the window tree, deleting event selections for this client
 
140
 * from this device from all windows.
 
141
 *
 
142
 */
 
143
 
 
144
void
 
145
DeleteEventsFromChildren(dev, p1, client)
 
146
    DeviceIntPtr        dev;
 
147
    WindowPtr           p1;
 
148
    ClientPtr           client;
 
149
    {
 
150
    WindowPtr p2;
 
151
 
 
152
    while (p1)
 
153
        {
 
154
        p2 = p1->firstChild;
 
155
        DeleteDeviceEvents (dev, p1, client);
 
156
        DeleteEventsFromChildren(dev, p2, client);
 
157
        p1 = p1->nextSib;
 
158
        }
 
159
    }
 
160
 
 
161
/***********************************************************************
 
162
 *
 
163
 * Clear out event selections and passive grabs from a window for the
 
164
 * specified device.
 
165
 *
 
166
 */
 
167
 
 
168
void
 
169
DeleteDeviceEvents (dev, pWin, client)
 
170
    DeviceIntPtr        dev;
 
171
    WindowPtr           pWin;
 
172
    ClientPtr           client;
 
173
    {
 
174
    InputClientsPtr     others;
 
175
    OtherInputMasks     *pOthers;
 
176
    GrabPtr             grab, next;
 
177
 
 
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;
 
183
 
 
184
    for (grab = wPassiveGrabs(pWin); grab; grab=next)
 
185
        {
 
186
        next = grab->next;
 
187
        if ((grab->device == dev) &&
 
188
            (client->clientAsMask == CLIENT_BITS(grab->resource)))
 
189
                FreeResource (grab->resource, RT_NONE);
 
190
        }
 
191
    }