~ubuntu-branches/ubuntu/edgy/xorg-server/edgy-updates

« back to all changes in this revision

Viewing changes to Xi/grabdev.c

  • Committer: Bazaar Package Importer
  • Author(s): Rodrigo Parra Novo
  • Date: 2006-07-25 20:06:28 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20060725200628-gjmmd9gxfxdc4ejs
Tags: 1:1.1.1-0ubuntu1
* New Upstream version
* Changed Build-Depends from mesa-swrast-source to mesa-swx11-source,
  following Debian package nomenclature
* Re-did 12_security_policy_in_etc.diff for 1.1.1
* Dropped 15_security_allocate_local.diff (applied upstream)
* Dropped 16_SECURITY_setuid.diff (applied upstream)
* Dropped 000_ubuntu_fix_read_kernel_mapping.patch (applied upstream)
* Dropped 002_ubuntu_fix_for_certain_intel_chipsets.patch (applied upstream)
* Updated versioned Build-Depends on mesa-swx11-source to version
  6.5.0.cvs.20060725-0ubuntu1
* Added arrayobj.c, arrayobj.h, bitset.h & rbadaptors.h to
  GL/symlink-mesa.sh (linked from mesa-swx11-source)
* Added arrayobj.c to default build target on GL/mesa/main

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Xorg: grabdev.c,v 1.4 2001/02/09 02:04:34 xorgcvs Exp $ */
2
 
 
3
1
/************************************************************
4
2
 
5
3
Copyright 1989, 1998  The Open Group
45
43
SOFTWARE.
46
44
 
47
45
********************************************************/
48
 
/* $XFree86: xc/programs/Xserver/Xi/grabdev.c,v 3.2 2001/01/17 22:13:25 dawes Exp $ */
49
46
 
50
47
/***********************************************************************
51
48
 *
53
50
 *
54
51
 */
55
52
 
56
 
 
57
53
#define  NEED_EVENTS
58
54
#define  NEED_REPLIES
59
55
#ifdef HAVE_DIX_CONFIG_H
60
56
#include <dix-config.h>
61
57
#endif
62
58
 
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 */
73
69
 
74
70
#include "grabdev.h"
75
71
 
76
 
extern  XExtEventInfo   EventInfo[];
77
 
extern int              ExtEventIndex;
 
72
extern XExtEventInfo EventInfo[];
 
73
extern int ExtEventIndex;
78
74
 
79
75
/***********************************************************************
80
76
 *
83
79
 */
84
80
 
85
81
int
86
 
SProcXGrabDevice(client)
87
 
    register ClientPtr client;
88
 
    {
 
82
SProcXGrabDevice(register ClientPtr client)
 
83
{
89
84
    register char n;
90
85
    register long *p;
91
86
    register int i;
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++)
101
 
        {
102
 
        swapl(p, n);
 
94
    p = (long *)&stuff[1];
 
95
    for (i = 0; i < stuff->event_count; i++) {
 
96
        swapl(p, n);
103
97
        p++;
104
 
        }
105
 
 
106
 
    return(ProcXGrabDevice(client));
107
98
    }
108
99
 
 
100
    return (ProcXGrabDevice(client));
 
101
}
 
102
 
109
103
/***********************************************************************
110
104
 *
111
105
 * Grab an extension device.
113
107
 */
114
108
 
115
109
int
116
 
ProcXGrabDevice(client)
117
 
    ClientPtr client;
118
 
    {
119
 
    int                 error;
120
 
    xGrabDeviceReply    rep;
121
 
    DeviceIntPtr        dev;
122
 
    struct tmask        tmp[EMASKSIZE];
 
110
ProcXGrabDevice(ClientPtr client)
 
111
{
 
112
    int error;
 
113
    xGrabDeviceReply rep;
 
114
    DeviceIntPtr dev;
 
115
    struct tmask tmp[EMASKSIZE];
123
116
 
124
117
    REQUEST(xGrabDeviceReq);
125
118
    REQUEST_AT_LEAST_SIZE(xGrabDeviceReq);
126
119
 
127
 
    if (stuff->length !=(sizeof(xGrabDeviceReq)>>2) + stuff->event_count)
128
 
        {
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);
130
122
        return Success;
131
 
        }
 
123
    }
132
124
 
133
125
    rep.repType = X_Reply;
134
126
    rep.RepType = X_GrabDevice;
135
127
    rep.sequenceNumber = client->sequence;
136
128
    rep.length = 0;
137
129
 
138
 
    dev = LookupDeviceIntRec (stuff->deviceid);
139
 
    if (dev == NULL)
140
 
        {
 
130
    dev = LookupDeviceIntRec(stuff->deviceid);
 
131
    if (dev == NULL) {
141
132
        SendErrorToClient(client, IReqCode, X_GrabDevice, 0, BadDevice);
142
133
        return Success;
143
 
        }
 
134
    }
144
135
 
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)
147
139
        return Success;
148
140
 
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);
152
145
 
153
 
    if (error != Success)
154
 
        {
 
146
    if (error != Success) {
155
147
        SendErrorToClient(client, IReqCode, X_GrabDevice, 0, error);
156
148
        return Success;
157
 
        }
 
149
    }
158
150
    WriteReplyToClient(client, sizeof(xGrabDeviceReply), &rep);
159
151
    return Success;
160
 
    }
161
 
 
 
152
}
162
153
 
163
154
/***********************************************************************
164
155
 *
167
158
 */
168
159
 
169
160
int
170
 
CreateMaskFromList (client, list, count, mask, dev, req)
171
 
    ClientPtr           client;
172
 
    XEventClass         *list;
173
 
    int                 count;
174
 
    struct tmask        mask[];
175
 
    DeviceIntPtr        dev;
176
 
    int                 req;
177
 
    {
178
 
    int                 i,j;
179
 
    int                 device;
180
 
    DeviceIntPtr        tdev;
 
161
CreateMaskFromList(ClientPtr client, XEventClass * list, int count,
 
162
                   struct tmask *mask, DeviceIntPtr dev, int req)
 
163
{
 
164
    int i, j;
 
165
    int device;
 
166
    DeviceIntPtr tdev;
181
167
 
182
 
    for (i=0; i<EMASKSIZE; i++)
183
 
        {
 
168
    for (i = 0; i < EMASKSIZE; i++) {
184
169
        mask[i].mask = 0;
185
170
        mask[i].dev = NULL;
186
 
        }
 
171
    }
187
172
 
188
 
    for (i=0; i<count; i++, list++)
189
 
        {
 
173
    for (i = 0; i < count; i++, list++) {
190
174
        device = *list >> 8;
191
 
        if (device > 255)
192
 
            {
193
 
            SendErrorToClient(client, IReqCode, req, 0, BadClass);
194
 
            return BadClass;
195
 
            }
196
 
        tdev = LookupDeviceIntRec (device);
197
 
        if (tdev==NULL || (dev != NULL && tdev != dev))
198
 
            {
199
 
            SendErrorToClient(client, IReqCode, req, 0, BadClass);
200
 
            return BadClass;
201
 
            }
 
175
        if (device > 255) {
 
176
            SendErrorToClient(client, IReqCode, req, 0, BadClass);
 
177
            return BadClass;
 
178
        }
 
179
        tdev = LookupDeviceIntRec(device);
 
180
        if (tdev == NULL || (dev != NULL && tdev != dev)) {
 
181
            SendErrorToClient(client, IReqCode, req, 0, BadClass);
 
182
            return BadClass;
 
183
        }
202
184
 
203
 
        for (j=0; j<ExtEventIndex; j++)
204
 
            if (EventInfo[j].type == (*list & 0xff))
205
 
                {
 
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;
208
189
                break;
209
 
                }
210
 
        }
 
190
            }
 
191
    }
211
192
    return Success;
212
 
    }
 
193
}
213
194
 
214
195
/***********************************************************************
215
196
 *
219
200
 */
220
201
 
221
202
void
222
 
SRepXGrabDevice (client, size, rep)
223
 
    ClientPtr   client;
224
 
    int         size;
225
 
    xGrabDeviceReply    *rep;
226
 
    {
 
203
SRepXGrabDevice(ClientPtr client, int size, xGrabDeviceReply * rep)
 
204
{
227
205
    register char n;
228
206
 
229
207
    swaps(&rep->sequenceNumber, n);
230
208
    swapl(&rep->length, n);
231
209
    WriteToClient(client, size, (char *)rep);
232
 
    }
 
210
}