57
53
#define NEED_EVENTS
58
54
#define NEED_REPLIES
59
55
#ifdef HAVE_DIX_CONFIG_H
60
56
#include <dix-config.h>
63
#include <X11/X.h> /* for inputstr.h */
64
#include <X11/Xproto.h> /* Request macro */
65
#include "inputstr.h" /* DeviceIntPtr */
66
#include "windowstr.h" /* window structure */
59
#include <X11/X.h> /* for inputstr.h */
60
#include <X11/Xproto.h> /* Request macro */
61
#include "inputstr.h" /* DeviceIntPtr */
62
#include "windowstr.h" /* window structure */
67
63
#include <X11/extensions/XI.h>
68
64
#include <X11/extensions/XIproto.h>
69
65
#include "extnsionst.h"
70
#include "extinit.h" /* LookupDeviceIntRec */
66
#include "extinit.h" /* LookupDeviceIntRec */
71
67
#include "exglobals.h"
72
#include "dixevents.h" /* GrabDevice */
68
#include "dixevents.h" /* GrabDevice */
74
70
#include "grabdev.h"
76
extern XExtEventInfo EventInfo[];
77
extern int ExtEventIndex;
72
extern XExtEventInfo EventInfo[];
73
extern int ExtEventIndex;
79
75
/***********************************************************************
96
91
swapl(&stuff->grabWindow, n);
97
92
swapl(&stuff->time, n);
98
93
swaps(&stuff->event_count, n);
99
p = (long *) &stuff[1];
100
for (i=0; i<stuff->event_count; i++)
94
p = (long *)&stuff[1];
95
for (i = 0; i < stuff->event_count; i++) {
106
return(ProcXGrabDevice(client));
100
return (ProcXGrabDevice(client));
109
103
/***********************************************************************
111
105
* Grab an extension device.
116
ProcXGrabDevice(client)
120
xGrabDeviceReply rep;
122
struct tmask tmp[EMASKSIZE];
110
ProcXGrabDevice(ClientPtr client)
113
xGrabDeviceReply rep;
115
struct tmask tmp[EMASKSIZE];
124
117
REQUEST(xGrabDeviceReq);
125
118
REQUEST_AT_LEAST_SIZE(xGrabDeviceReq);
127
if (stuff->length !=(sizeof(xGrabDeviceReq)>>2) + stuff->event_count)
129
SendErrorToClient (client, IReqCode, X_GrabDevice, 0, BadLength);
120
if (stuff->length != (sizeof(xGrabDeviceReq) >> 2) + stuff->event_count) {
121
SendErrorToClient(client, IReqCode, X_GrabDevice, 0, BadLength);
133
125
rep.repType = X_Reply;
134
126
rep.RepType = X_GrabDevice;
135
127
rep.sequenceNumber = client->sequence;
138
dev = LookupDeviceIntRec (stuff->deviceid);
130
dev = LookupDeviceIntRec(stuff->deviceid);
141
132
SendErrorToClient(client, IReqCode, X_GrabDevice, 0, BadDevice);
145
if (CreateMaskFromList (client, (XEventClass *)&stuff[1],
146
stuff->event_count, tmp, dev, X_GrabDevice) != Success)
136
if (CreateMaskFromList(client, (XEventClass *) & stuff[1],
137
stuff->event_count, tmp, dev,
138
X_GrabDevice) != Success)
149
error = GrabDevice (client, dev, stuff->this_device_mode,
150
stuff->other_devices_mode, stuff->grabWindow, stuff->ownerEvents,
151
stuff->time, tmp[stuff->deviceid].mask, &rep.status);
141
error = GrabDevice(client, dev, stuff->this_device_mode,
142
stuff->other_devices_mode, stuff->grabWindow,
143
stuff->ownerEvents, stuff->time,
144
tmp[stuff->deviceid].mask, &rep.status);
153
if (error != Success)
146
if (error != Success) {
155
147
SendErrorToClient(client, IReqCode, X_GrabDevice, 0, error);
158
150
WriteReplyToClient(client, sizeof(xGrabDeviceReply), &rep);
163
154
/***********************************************************************
170
CreateMaskFromList (client, list, count, mask, dev, req)
161
CreateMaskFromList(ClientPtr client, XEventClass * list, int count,
162
struct tmask *mask, DeviceIntPtr dev, int req)
182
for (i=0; i<EMASKSIZE; i++)
168
for (i = 0; i < EMASKSIZE; i++) {
184
169
mask[i].mask = 0;
185
170
mask[i].dev = NULL;
188
for (i=0; i<count; i++, list++)
173
for (i = 0; i < count; i++, list++) {
190
174
device = *list >> 8;
193
SendErrorToClient(client, IReqCode, req, 0, BadClass);
196
tdev = LookupDeviceIntRec (device);
197
if (tdev==NULL || (dev != NULL && tdev != dev))
199
SendErrorToClient(client, IReqCode, req, 0, BadClass);
176
SendErrorToClient(client, IReqCode, req, 0, BadClass);
179
tdev = LookupDeviceIntRec(device);
180
if (tdev == NULL || (dev != NULL && tdev != dev)) {
181
SendErrorToClient(client, IReqCode, req, 0, BadClass);
203
for (j=0; j<ExtEventIndex; j++)
204
if (EventInfo[j].type == (*list & 0xff))
185
for (j = 0; j < ExtEventIndex; j++)
186
if (EventInfo[j].type == (*list & 0xff)) {
206
187
mask[device].mask |= EventInfo[j].mask;
207
188
mask[device].dev = (Pointer) tdev;
214
195
/***********************************************************************
222
SRepXGrabDevice (client, size, rep)
225
xGrabDeviceReply *rep;
203
SRepXGrabDevice(ClientPtr client, int size, xGrabDeviceReply * rep)
229
207
swaps(&rep->sequenceNumber, n);
230
208
swapl(&rep->length, n);
231
209
WriteToClient(client, size, (char *)rep);