1
/* $XFree86: xc/programs/Xserver/Xi/getselev.c,v 3.5 2001/10/28 03:32:53 tsi Exp $ */
2
/************************************************************
4
Copyright 1989, 1998 The Open Group
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
12
The above copyright notice and this permission notice shall be included in
13
all copies or substantial portions of the Software.
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.
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.
26
Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
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.
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
46
********************************************************/
48
/* $Xorg: getselev.c,v 1.4 2001/02/09 02:04:34 xorgcvs Exp $ */
50
/***********************************************************************
52
* Extension function to get the current selected events for a given window.
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 <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"
76
/***********************************************************************
78
* This procedure gets the current selected extension events.
83
SProcXGetSelectedExtensionEvents(client)
84
register ClientPtr client;
88
REQUEST(xGetSelectedExtensionEventsReq);
89
swaps(&stuff->length, n);
90
REQUEST_SIZE_MATCH(xGetSelectedExtensionEventsReq);
91
swapl(&stuff->window, n);
92
return(ProcXGetSelectedExtensionEvents(client));
95
/***********************************************************************
97
* This procedure gets the current device select mask,
98
* if the client and server have a different byte ordering.
103
ProcXGetSelectedExtensionEvents(client)
104
register ClientPtr client;
107
int total_length = 0;
108
xGetSelectedExtensionEventsReply rep;
110
XEventClass *buf = NULL;
111
XEventClass *tclient;
112
XEventClass *aclient;
113
OtherInputMasks *pOthers;
114
InputClientsPtr others;
116
REQUEST(xGetSelectedExtensionEventsReq);
117
REQUEST_SIZE_MATCH(xGetSelectedExtensionEventsReq);
119
rep.repType = X_Reply;
120
rep.RepType = X_GetSelectedExtensionEvents;
122
rep.sequenceNumber = client->sequence;
123
rep.this_client_count = 0;
124
rep.all_clients_count = 0;
126
if (!(pWin = LookupWindow(stuff->window, client)))
128
SendErrorToClient(client, IReqCode, X_GetSelectedExtensionEvents, 0,
133
if ((pOthers = wOtherInputMasks(pWin)) != 0)
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);
140
for (others = pOthers->inputClients; others; others=others->next)
141
if (SameClient(others, client))
143
for (i=0; i<EMASKSIZE; i++)
144
tclient = ClassFromMask (NULL, others->mask[i], i,
145
&rep.this_client_count, COUNT);
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);
155
aclient = buf + rep.this_client_count;
157
for (i=0; i<EMASKSIZE; i++)
158
tclient = ClassFromMask (tclient, others->mask[i], i, NULL, CREATE);
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);
165
WriteReplyToClient (client, sizeof(xGetSelectedExtensionEventsReply), &rep);
169
client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
170
WriteSwappedDataToClient( client, total_length, buf);
176
/***********************************************************************
178
* This procedure writes the reply for the XGetSelectedExtensionEvents function,
179
* if the client and server have a different byte ordering.
184
SRepXGetSelectedExtensionEvents (client, size, rep)
187
xGetSelectedExtensionEventsReply *rep;
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);