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

« back to all changes in this revision

Viewing changes to Xi/chgkbd.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: chgkbd.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/chgkbd.c,v 3.5 2001/08/23 14:56:19 alanh Exp $ */
49
46
 
50
47
/***********************************************************************
51
48
 *
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
63
#include <X11/extensions/XIproto.h>
67
64
#include "XIstubs.h"
68
65
#include "globals.h"
69
66
#include "extnsionst.h"
70
 
#include "extinit.h"                    /* LookupDeviceIntRec */
 
67
#include "extinit.h"    /* LookupDeviceIntRec */
71
68
 
72
69
#include "exevents.h"
73
70
#include "exglobals.h"
82
79
 */
83
80
 
84
81
int
85
 
SProcXChangeKeyboardDevice(client)
86
 
    register ClientPtr client;
87
 
    {
 
82
SProcXChangeKeyboardDevice(register ClientPtr client)
 
83
{
88
84
    register char n;
89
85
 
90
86
    REQUEST(xChangeKeyboardDeviceReq);
91
87
    swaps(&stuff->length, n);
92
88
    REQUEST_SIZE_MATCH(xChangeKeyboardDeviceReq);
93
 
    return(ProcXChangeKeyboardDevice(client));
94
 
    }
 
89
    return (ProcXChangeKeyboardDevice(client));
 
90
}
95
91
 
96
92
/***********************************************************************
97
93
 *
101
97
 */
102
98
 
103
99
int
104
 
ProcXChangeKeyboardDevice (client)
105
 
    register ClientPtr client;
106
 
    {
107
 
    int                         i;
108
 
    DeviceIntPtr                xkbd = inputInfo.keyboard;
109
 
    DeviceIntPtr                dev;
110
 
    FocusClassPtr               xf = xkbd->focus;
111
 
    FocusClassPtr               df;
112
 
    KeyClassPtr                 k;
113
 
    xChangeKeyboardDeviceReply  rep;
114
 
    changeDeviceNotify          ev;
 
100
ProcXChangeKeyboardDevice(register ClientPtr client)
 
101
{
 
102
    int i;
 
103
    DeviceIntPtr xkbd = inputInfo.keyboard;
 
104
    DeviceIntPtr dev;
 
105
    FocusClassPtr xf = xkbd->focus;
 
106
    FocusClassPtr df;
 
107
    KeyClassPtr k;
 
108
    xChangeKeyboardDeviceReply rep;
 
109
    changeDeviceNotify ev;
115
110
 
116
111
    REQUEST(xChangeKeyboardDeviceReq);
117
112
    REQUEST_SIZE_MATCH(xChangeKeyboardDeviceReq);
121
116
    rep.length = 0;
122
117
    rep.sequenceNumber = client->sequence;
123
118
 
124
 
    dev = LookupDeviceIntRec (stuff->deviceid);
125
 
    if (dev == NULL)
126
 
        {
 
119
    dev = LookupDeviceIntRec(stuff->deviceid);
 
120
    if (dev == NULL) {
127
121
        rep.status = -1;
128
 
        SendErrorToClient(client, IReqCode, X_ChangeKeyboardDevice, 0, 
129
 
                BadDevice);
 
122
        SendErrorToClient(client, IReqCode, X_ChangeKeyboardDevice, 0,
 
123
                          BadDevice);
130
124
        return Success;
131
 
        }
 
125
    }
132
126
 
133
127
    k = dev->key;
134
 
    if (k == NULL)
135
 
        {
 
128
    if (k == NULL) {
136
129
        rep.status = -1;
137
 
        SendErrorToClient(client, IReqCode, X_ChangeKeyboardDevice, 0, 
138
 
                BadMatch);
 
130
        SendErrorToClient(client, IReqCode, X_ChangeKeyboardDevice, 0,
 
131
                          BadMatch);
139
132
        return Success;
140
 
        }
 
133
    }
141
134
 
142
135
    if (((dev->grab) && !SameClient(dev->grab, client)) ||
143
 
        ((xkbd->grab) && !SameClient(xkbd->grab, client)))
 
136
        ((xkbd->grab) && !SameClient(xkbd->grab, client)))
144
137
        rep.status = AlreadyGrabbed;
145
138
    else if ((dev->sync.frozen &&
146
 
             dev->sync.other && !SameClient(dev->sync.other, client)) ||
 
139
              dev->sync.other && !SameClient(dev->sync.other, client)) ||
147
140
             (xkbd->sync.frozen &&
148
141
              xkbd->sync.other && !SameClient(xkbd->sync.other, client)))
149
142
        rep.status = GrabFrozen;
150
 
    else
151
 
        {
152
 
        if (ChangeKeyboardDevice (xkbd, dev) != Success)
153
 
            {
154
 
            SendErrorToClient(client, IReqCode, X_ChangeKeyboardDevice, 0, 
155
 
                BadDevice);
 
143
    else {
 
144
        if (ChangeKeyboardDevice(xkbd, dev) != Success) {
 
145
            SendErrorToClient(client, IReqCode, X_ChangeKeyboardDevice, 0,
 
146
                              BadDevice);
156
147
            return Success;
157
 
            }
 
148
        }
158
149
        if (!dev->focus)
159
 
            InitFocusClassDeviceStruct (dev);
 
150
            InitFocusClassDeviceStruct(dev);
160
151
        if (!dev->kbdfeed)
161
 
           InitKbdFeedbackClassDeviceStruct(dev, (BellProcPtr)NoopDDA,
162
 
                                            (KbdCtrlProcPtr)NoopDDA);
 
152
            InitKbdFeedbackClassDeviceStruct(dev, (BellProcPtr) NoopDDA,
 
153
                                             (KbdCtrlProcPtr) NoopDDA);
163
154
        df = dev->focus;
164
155
        df->win = xf->win;
165
156
        df->revert = xf->revert;
166
157
        df->time = xf->time;
167
158
        df->traceGood = xf->traceGood;
168
 
        if (df->traceSize != xf->traceSize)
169
 
            {
170
 
            Must_have_memory = TRUE; /* XXX */
171
 
            df->trace = (WindowPtr *) xrealloc(df->trace, 
172
 
                xf->traceSize * sizeof(WindowPtr));
173
 
            Must_have_memory = FALSE; /* XXX */
174
 
            }
 
159
        if (df->traceSize != xf->traceSize) {
 
160
            Must_have_memory = TRUE;    /* XXX */
 
161
            df->trace = (WindowPtr *) xrealloc(df->trace,
 
162
                                               xf->traceSize *
 
163
                                               sizeof(WindowPtr));
 
164
            Must_have_memory = FALSE;   /* XXX */
 
165
        }
175
166
        df->traceSize = xf->traceSize;
176
 
        for (i=0; i<df->traceSize; i++)
 
167
        for (i = 0; i < df->traceSize; i++)
177
168
            df->trace[i] = xf->trace[i];
178
 
        RegisterOtherDevice (xkbd);
179
 
        RegisterKeyboardDevice (dev);
 
169
        RegisterOtherDevice(xkbd);
 
170
        RegisterKeyboardDevice(dev);
180
171
 
181
172
        ev.type = ChangeDeviceNotify;
182
173
        ev.deviceid = stuff->deviceid;
183
174
        ev.time = currentTime.milliseconds;
184
175
        ev.request = NewKeyboard;
185
176
 
186
 
        SendEventToAllWindows (dev, ChangeDeviceNotifyMask, (xEvent *)&ev, 1);
187
 
        SendMappingNotify (MappingKeyboard, k->curKeySyms.minKeyCode, 
188
 
            k->curKeySyms.maxKeyCode - k->curKeySyms.minKeyCode + 1,client);
 
177
        SendEventToAllWindows(dev, ChangeDeviceNotifyMask, (xEvent *) & ev, 1);
 
178
        SendMappingNotify(MappingKeyboard, k->curKeySyms.minKeyCode,
 
179
                          k->curKeySyms.maxKeyCode - k->curKeySyms.minKeyCode +
 
180
                          1, client);
189
181
 
190
182
        rep.status = 0;
191
 
        }
 
183
    }
192
184
 
193
 
    WriteReplyToClient (client, sizeof (xChangeKeyboardDeviceReply), 
194
 
        &rep);
 
185
    WriteReplyToClient(client, sizeof(xChangeKeyboardDeviceReply), &rep);
195
186
    return Success;
196
 
    }
 
187
}
197
188
 
198
189
/***********************************************************************
199
190
 *
203
194
 */
204
195
 
205
196
void
206
 
SRepXChangeKeyboardDevice (client, size, rep)
207
 
    ClientPtr   client;
208
 
    int         size;
209
 
    xChangeKeyboardDeviceReply  *rep;
210
 
    {
 
197
SRepXChangeKeyboardDevice(ClientPtr client, int size,
 
198
                          xChangeKeyboardDeviceReply * rep)
 
199
{
211
200
    register char n;
212
201
 
213
202
    swaps(&rep->sequenceNumber, n);
214
203
    swapl(&rep->length, n);
215
204
    WriteToClient(client, size, (char *)rep);
216
 
    }
 
205
}