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

« back to all changes in this revision

Viewing changes to Xi/getselev.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
/* $XFree86: xc/programs/Xserver/Xi/getselev.c,v 3.5 2001/10/28 03:32:53 tsi Exp $ */
 
2
/************************************************************
 
3
 
 
4
Copyright 1989, 1998  The Open Group
 
5
 
 
6
Permission to use, copy, modify, distribute, and sell this software and its
 
7
documentation for any purpose is hereby granted without fee, provided that
 
8
the above copyright notice appear in all copies and that both that
 
9
copyright notice and this permission notice appear in supporting
 
10
documentation.
 
11
 
 
12
The above copyright notice and this permission notice shall be included in
 
13
all copies or substantial portions of the Software.
 
14
 
 
15
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
16
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
17
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
 
18
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
 
19
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 
20
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
21
 
 
22
Except as contained in this notice, the name of The Open Group shall not be
 
23
used in advertising or otherwise to promote the sale, use or other dealings
 
24
in this Software without prior written authorization from The Open Group.
 
25
 
 
26
Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
 
27
 
 
28
                        All Rights Reserved
 
29
 
 
30
Permission to use, copy, modify, and distribute this software and its
 
31
documentation for any purpose and without fee is hereby granted,
 
32
provided that the above copyright notice appear in all copies and that
 
33
both that copyright notice and this permission notice appear in
 
34
supporting documentation, and that the name of Hewlett-Packard not be
 
35
used in advertising or publicity pertaining to distribution of the
 
36
software without specific, written prior permission.
 
37
 
 
38
HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 
39
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
 
40
HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
 
41
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
 
42
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
 
43
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 
44
SOFTWARE.
 
45
 
 
46
********************************************************/
 
47
 
 
48
/* $Xorg: getselev.c,v 1.4 2001/02/09 02:04:34 xorgcvs Exp $ */
 
49
 
 
50
/***********************************************************************
 
51
 *
 
52
 * Extension function to get the current selected events for a given window.
 
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 <X11/extensions/XI.h>
 
65
#include <X11/extensions/XIproto.h>
 
66
#include "inputstr.h"                   /* DeviceIntPtr      */
 
67
#include "windowstr.h"                  /* window struct     */
 
68
#include "extnsionst.h"
 
69
#include "extinit.h"                    /* LookupDeviceIntRec */
 
70
#include "exglobals.h"
 
71
#include "swaprep.h"
 
72
 
 
73
#include "getprop.h"
 
74
#include "getselev.h"
 
75
 
 
76
/***********************************************************************
 
77
 *
 
78
 * This procedure gets the current selected extension events.
 
79
 *
 
80
 */
 
81
 
 
82
int
 
83
SProcXGetSelectedExtensionEvents(client)
 
84
    register ClientPtr client;
 
85
    {
 
86
    register char n;
 
87
 
 
88
    REQUEST(xGetSelectedExtensionEventsReq);
 
89
    swaps(&stuff->length, n);
 
90
    REQUEST_SIZE_MATCH(xGetSelectedExtensionEventsReq);
 
91
    swapl(&stuff->window, n);
 
92
    return(ProcXGetSelectedExtensionEvents(client));
 
93
    }
 
94
 
 
95
/***********************************************************************
 
96
 *
 
97
 * This procedure gets the current device select mask,
 
98
 * if the client and server have a different byte ordering.
 
99
 *
 
100
 */
 
101
 
 
102
int
 
103
ProcXGetSelectedExtensionEvents(client)
 
104
    register ClientPtr client;
 
105
    {
 
106
    int                                 i;
 
107
    int                                 total_length = 0;
 
108
    xGetSelectedExtensionEventsReply    rep;
 
109
    WindowPtr                           pWin;
 
110
    XEventClass                         *buf = NULL;
 
111
    XEventClass                         *tclient;
 
112
    XEventClass                         *aclient;
 
113
    OtherInputMasks                     *pOthers;
 
114
    InputClientsPtr                     others;
 
115
 
 
116
    REQUEST(xGetSelectedExtensionEventsReq);
 
117
    REQUEST_SIZE_MATCH(xGetSelectedExtensionEventsReq);
 
118
 
 
119
    rep.repType = X_Reply;
 
120
    rep.RepType = X_GetSelectedExtensionEvents;
 
121
    rep.length = 0;
 
122
    rep.sequenceNumber = client->sequence;
 
123
    rep.this_client_count = 0;
 
124
    rep.all_clients_count = 0;
 
125
 
 
126
    if (!(pWin = LookupWindow(stuff->window, client)))
 
127
        {
 
128
        SendErrorToClient(client, IReqCode, X_GetSelectedExtensionEvents, 0, 
 
129
                BadWindow);
 
130
        return Success;
 
131
        }
 
132
 
 
133
    if ((pOthers = wOtherInputMasks(pWin)) != 0)
 
134
        {
 
135
        for (others = pOthers->inputClients; others; others=others->next)
 
136
            for (i=0; i<EMASKSIZE; i++)
 
137
                tclient = ClassFromMask (NULL, others->mask[i], i, 
 
138
                    &rep.all_clients_count, COUNT);
 
139
 
 
140
        for (others = pOthers->inputClients; others; others=others->next)
 
141
            if (SameClient(others, client))
 
142
                {
 
143
                for (i=0; i<EMASKSIZE; i++)
 
144
                    tclient = ClassFromMask (NULL, others->mask[i], i, 
 
145
                        &rep.this_client_count, COUNT);
 
146
                break;
 
147
                }
 
148
 
 
149
        total_length = (rep.all_clients_count + rep.this_client_count) * 
 
150
            sizeof (XEventClass);
 
151
        rep.length = (total_length + 3) >> 2;
 
152
        buf = (XEventClass *) xalloc (total_length);
 
153
 
 
154
        tclient = buf;
 
155
        aclient = buf + rep.this_client_count;
 
156
        if (others)
 
157
            for (i=0; i<EMASKSIZE; i++)
 
158
                tclient = ClassFromMask (tclient, others->mask[i], i, NULL, CREATE);
 
159
 
 
160
        for (others = pOthers->inputClients; others; others=others->next)
 
161
            for (i=0; i<EMASKSIZE; i++)
 
162
                aclient = ClassFromMask (aclient, others->mask[i], i, NULL, CREATE);
 
163
        }
 
164
 
 
165
    WriteReplyToClient (client, sizeof(xGetSelectedExtensionEventsReply), &rep);
 
166
 
 
167
    if (total_length)
 
168
        {
 
169
        client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
 
170
        WriteSwappedDataToClient( client, total_length, buf);
 
171
        xfree (buf);
 
172
        }
 
173
    return Success;
 
174
    }
 
175
 
 
176
/***********************************************************************
 
177
 *
 
178
 * This procedure writes the reply for the XGetSelectedExtensionEvents function,
 
179
 * if the client and server have a different byte ordering.
 
180
 *
 
181
 */
 
182
 
 
183
void
 
184
SRepXGetSelectedExtensionEvents (client, size, rep)
 
185
    ClientPtr   client;
 
186
    int         size;
 
187
    xGetSelectedExtensionEventsReply    *rep;
 
188
    {
 
189
    register char n;
 
190
 
 
191
    swaps(&rep->sequenceNumber, n);
 
192
    swapl(&rep->length, n);
 
193
    swaps(&rep->this_client_count, n);
 
194
    swaps(&rep->all_clients_count, n);
 
195
    WriteToClient(client, size, (char *)rep);
 
196
    }