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

« back to all changes in this revision

Viewing changes to Xi/chgdctl.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: chgdctl.c,v 1.4 2001/02/09 02:04:33 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/chgdctl.c,v 3.3 2001/01/17 22:13:23 dawes Exp $ */
49
46
 
50
47
/********************************************************************
51
48
 *
53
50
 *
54
51
 */
55
52
 
56
 
#define  NEED_EVENTS                    /* for inputstr.h    */
 
53
#define  NEED_EVENTS    /* for inputstr.h    */
57
54
#define  NEED_REPLIES
58
55
#ifdef HAVE_DIX_CONFIG_H
59
56
#include <dix-config.h>
60
57
#endif
61
58
 
62
 
#include <X11/X.h>                              /* for inputstr.h    */
63
 
#include <X11/Xproto.h>                 /* Request macro     */
64
 
#include "inputstr.h"                   /* DeviceIntPtr      */
 
59
#include <X11/X.h>      /* for inputstr.h    */
 
60
#include <X11/Xproto.h> /* Request macro     */
 
61
#include "inputstr.h"   /* DeviceIntPtr      */
65
62
#include <X11/extensions/XI.h>
66
 
#include <X11/extensions/XIproto.h>                     /* control constants */
 
63
#include <X11/extensions/XIproto.h>     /* control constants */
67
64
#include "XIstubs.h"
68
65
 
69
66
#include "extnsionst.h"
70
 
#include "extinit.h"                    /* LookupDeviceIntRec */
 
67
#include "extinit.h"    /* LookupDeviceIntRec */
71
68
#include "exglobals.h"
72
69
 
73
70
#include "chgdctl.h"
80
77
 */
81
78
 
82
79
int
83
 
SProcXChangeDeviceControl(client)
84
 
    register ClientPtr client;
85
 
    {
 
80
SProcXChangeDeviceControl(register ClientPtr client)
 
81
{
86
82
    register char n;
87
83
 
88
84
    REQUEST(xChangeDeviceControlReq);
89
85
    swaps(&stuff->length, n);
90
86
    REQUEST_AT_LEAST_SIZE(xChangeDeviceControlReq);
91
87
    swaps(&stuff->control, n);
92
 
    return(ProcXChangeDeviceControl(client));
93
 
    }
 
88
    return (ProcXChangeDeviceControl(client));
 
89
}
94
90
 
95
91
/***********************************************************************
96
92
 *
99
95
 */
100
96
 
101
97
int
102
 
ProcXChangeDeviceControl(client)
103
 
    ClientPtr client;
104
 
    {
 
98
ProcXChangeDeviceControl(ClientPtr client)
 
99
{
105
100
    unsigned len;
106
101
    int i, status;
107
102
    DeviceIntPtr dev;
113
108
    REQUEST(xChangeDeviceControlReq);
114
109
    REQUEST_AT_LEAST_SIZE(xChangeDeviceControlReq);
115
110
 
116
 
    len = stuff->length - (sizeof(xChangeDeviceControlReq) >>2);
117
 
    dev = LookupDeviceIntRec (stuff->deviceid);
118
 
    if (dev == NULL)
119
 
        {
120
 
        SendErrorToClient (client, IReqCode, X_ChangeDeviceControl, 0, 
121
 
                BadDevice);
 
111
    len = stuff->length - (sizeof(xChangeDeviceControlReq) >> 2);
 
112
    dev = LookupDeviceIntRec(stuff->deviceid);
 
113
    if (dev == NULL) {
 
114
        SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0,
 
115
                          BadDevice);
122
116
        return Success;
123
 
        }
 
117
    }
124
118
 
125
119
    rep.repType = X_Reply;
126
120
    rep.RepType = X_ChangeDeviceControl;
127
121
    rep.length = 0;
128
122
    rep.sequenceNumber = client->sequence;
129
123
 
130
 
    switch (stuff->control) 
131
 
        {
132
 
        case DEVICE_RESOLUTION:
133
 
            r = (xDeviceResolutionCtl *) &stuff[1];
134
 
            if ((len < (sizeof(xDeviceResolutionCtl)>>2)) ||
135
 
                (len != (sizeof(xDeviceResolutionCtl)>>2) +
136
 
                 r->num_valuators))
137
 
                {
138
 
                SendErrorToClient (client, IReqCode, X_ChangeDeviceControl, 
139
 
                        0, BadLength);
140
 
                return Success;
141
 
                }
142
 
            if (!dev->valuator)
143
 
                {
144
 
                SendErrorToClient (client, IReqCode, X_ChangeDeviceControl, 0, 
145
 
                    BadMatch);
146
 
                return Success;
147
 
                }
148
 
            if ((dev->grab) && !SameClient(dev->grab, client))
149
 
                {
150
 
                rep.status = AlreadyGrabbed;
151
 
                WriteReplyToClient(client, sizeof(xChangeDeviceControlReply), 
152
 
                    &rep);
153
 
                return Success;
154
 
                }
155
 
            resolution = (CARD32 *) (r + 1);
156
 
            if (r->first_valuator + r->num_valuators > dev->valuator->numAxes)
157
 
                {
158
 
                SendErrorToClient (client, IReqCode, X_ChangeDeviceControl, 0, 
159
 
                    BadValue);
160
 
                return Success;
161
 
                }
162
 
            status = ChangeDeviceControl(client, dev, (xDeviceCtl*) r);
163
 
            if (status == Success)
164
 
                {
165
 
                a = &dev->valuator->axes[r->first_valuator];
166
 
                for (i=0; i<r->num_valuators; i++)
167
 
                    if (*(resolution+i) < (a+i)->min_resolution ||
168
 
                        *(resolution+i) > (a+i)->max_resolution)
169
 
                        {
170
 
                        SendErrorToClient (client, IReqCode, 
171
 
                            X_ChangeDeviceControl, 0, BadValue);
172
 
                        return Success;
173
 
                        }
174
 
                for (i=0; i<r->num_valuators; i++)
175
 
                    (a++)->resolution = *resolution++; 
176
 
                }
177
 
            else if (status == DeviceBusy)
178
 
                {
179
 
                rep.status = DeviceBusy;
180
 
                WriteReplyToClient(client, sizeof(xChangeDeviceControlReply), 
181
 
                    &rep);
182
 
                return Success;
183
 
                }
184
 
            else 
185
 
                {
186
 
                SendErrorToClient (client, IReqCode, X_ChangeDeviceControl, 0, 
187
 
                    BadMatch);
188
 
                return Success;
189
 
                }
190
 
            break;
191
 
        default:
192
 
            SendErrorToClient (client, IReqCode, X_ChangeDeviceControl, 0, 
193
 
                BadValue);
194
 
            return Success;
195
 
        }
 
124
    switch (stuff->control) {
 
125
    case DEVICE_RESOLUTION:
 
126
        r = (xDeviceResolutionCtl *) & stuff[1];
 
127
        if ((len < (sizeof(xDeviceResolutionCtl) >> 2)) ||
 
128
            (len != (sizeof(xDeviceResolutionCtl) >> 2) + r->num_valuators)) {
 
129
            SendErrorToClient(client, IReqCode, X_ChangeDeviceControl,
 
130
                              0, BadLength);
 
131
            return Success;
 
132
        }
 
133
        if (!dev->valuator) {
 
134
            SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0,
 
135
                              BadMatch);
 
136
            return Success;
 
137
        }
 
138
        if ((dev->grab) && !SameClient(dev->grab, client)) {
 
139
            rep.status = AlreadyGrabbed;
 
140
            WriteReplyToClient(client, sizeof(xChangeDeviceControlReply), &rep);
 
141
            return Success;
 
142
        }
 
143
        resolution = (CARD32 *) (r + 1);
 
144
        if (r->first_valuator + r->num_valuators > dev->valuator->numAxes) {
 
145
            SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0,
 
146
                              BadValue);
 
147
            return Success;
 
148
        }
 
149
        status = ChangeDeviceControl(client, dev, (xDeviceCtl *) r);
 
150
        if (status == Success) {
 
151
            a = &dev->valuator->axes[r->first_valuator];
 
152
            for (i = 0; i < r->num_valuators; i++)
 
153
                if (*(resolution + i) < (a + i)->min_resolution ||
 
154
                    *(resolution + i) > (a + i)->max_resolution) {
 
155
                    SendErrorToClient(client, IReqCode,
 
156
                                      X_ChangeDeviceControl, 0, BadValue);
 
157
                    return Success;
 
158
                }
 
159
            for (i = 0; i < r->num_valuators; i++)
 
160
                (a++)->resolution = *resolution++;
 
161
        } else if (status == DeviceBusy) {
 
162
            rep.status = DeviceBusy;
 
163
            WriteReplyToClient(client, sizeof(xChangeDeviceControlReply), &rep);
 
164
            return Success;
 
165
        } else {
 
166
            SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0,
 
167
                              BadMatch);
 
168
            return Success;
 
169
        }
 
170
        break;
 
171
    default:
 
172
        SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0, BadValue);
 
173
        return Success;
 
174
    }
196
175
    WriteReplyToClient(client, sizeof(xChangeDeviceControlReply), &rep);
197
176
    return Success;
198
 
    }
 
177
}
199
178
 
200
179
/***********************************************************************
201
180
 *
205
184
 */
206
185
 
207
186
void
208
 
SRepXChangeDeviceControl (client, size, rep)
209
 
    ClientPtr   client;
210
 
    int         size;
211
 
    xChangeDeviceControlReply   *rep;
212
 
    {
 
187
SRepXChangeDeviceControl(ClientPtr client, int size,
 
188
                         xChangeDeviceControlReply * rep)
 
189
{
213
190
    register char n;
214
191
 
215
192
    swaps(&rep->sequenceNumber, n);
216
193
    swapl(&rep->length, n);
217
194
    WriteToClient(client, size, (char *)rep);
218
 
    }
219
 
 
 
195
}