File: | xkb/xkb.c |
Location: | line 2737, column 17 |
Description: | Value stored to 'wire' is never read |
1 | /************************************************************ |
2 | Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc. |
3 | |
4 | Permission to use, copy, modify, and distribute this |
5 | software and its documentation for any purpose and without |
6 | fee is hereby granted, provided that the above copyright |
7 | notice appear in all copies and that both that copyright |
8 | notice and this permission notice appear in supporting |
9 | documentation, and that the name of Silicon Graphics not be |
10 | used in advertising or publicity pertaining to distribution |
11 | of the software without specific prior written permission. |
12 | Silicon Graphics makes no representation about the suitability |
13 | of this software for any purpose. It is provided "as is" |
14 | without any express or implied warranty. |
15 | |
16 | SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS |
17 | SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY |
18 | AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON |
19 | GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL |
20 | DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, |
21 | DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE |
22 | OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH |
23 | THE USE OR PERFORMANCE OF THIS SOFTWARE. |
24 | |
25 | ********************************************************/ |
26 | |
27 | #ifdef HAVE_DIX_CONFIG_H1 |
28 | #include <dix-config.h> |
29 | #endif |
30 | |
31 | #include <stdio.h> |
32 | #include <X11/X.h> |
33 | #include <X11/Xproto.h> |
34 | #include "misc.h" |
35 | #include "inputstr.h" |
36 | #define XKBSRV_NEED_FILE_FUNCS |
37 | #include <xkbsrv.h> |
38 | #include "extnsionst.h" |
39 | #include "extinit.h" |
40 | #include "xace.h" |
41 | #include "xkb.h" |
42 | #include "protocol-versions.h" |
43 | |
44 | #include <X11/extensions/XI.h> |
45 | #include <X11/extensions/XKMformat.h> |
46 | |
47 | int XkbEventBase; |
48 | static int XkbErrorBase; |
49 | int XkbReqCode; |
50 | int XkbKeyboardErrorCode; |
51 | CARD32 xkbDebugFlags = 0; |
52 | static CARD32 xkbDebugCtrls = 0; |
53 | |
54 | static RESTYPE RT_XKBCLIENT; |
55 | |
56 | /***====================================================================***/ |
57 | |
58 | #define CHK_DEVICE(dev, id, client, access_mode, lf){ int why; int tmprc = lf(&(dev), id, client, access_mode , &why); if (tmprc != 0) { client->errorValue = ((XID) ((((unsigned int)(why))<<24)|((id)&0xffffff))); return tmprc; }} {\ |
59 | int why;\ |
60 | int tmprc = lf(&(dev), id, client, access_mode, &why);\ |
61 | if (tmprc != Success0) {\ |
62 | client->errorValue = _XkbErrCode2(why, id)((XID)((((unsigned int)(why))<<24)|((id)&0xffffff)) );\ |
63 | return tmprc;\ |
64 | }\ |
65 | } |
66 | |
67 | #define CHK_KBD_DEVICE(dev, id, client, mode){ int why; int tmprc = _XkbLookupKeyboard(&(dev), id, client , mode, &why); if (tmprc != 0) { client->errorValue = ( (XID)((((unsigned int)(why))<<24)|((id)&0xffffff))) ; return tmprc; }} \ |
68 | CHK_DEVICE(dev, id, client, mode, _XkbLookupKeyboard){ int why; int tmprc = _XkbLookupKeyboard(&(dev), id, client , mode, &why); if (tmprc != 0) { client->errorValue = ( (XID)((((unsigned int)(why))<<24)|((id)&0xffffff))) ; return tmprc; }} |
69 | #define CHK_LED_DEVICE(dev, id, client, mode){ int why; int tmprc = _XkbLookupLedDevice(&(dev), id, client , mode, &why); if (tmprc != 0) { client->errorValue = ( (XID)((((unsigned int)(why))<<24)|((id)&0xffffff))) ; return tmprc; }} \ |
70 | CHK_DEVICE(dev, id, client, mode, _XkbLookupLedDevice){ int why; int tmprc = _XkbLookupLedDevice(&(dev), id, client , mode, &why); if (tmprc != 0) { client->errorValue = ( (XID)((((unsigned int)(why))<<24)|((id)&0xffffff))) ; return tmprc; }} |
71 | #define CHK_BELL_DEVICE(dev, id, client, mode){ int why; int tmprc = _XkbLookupBellDevice(&(dev), id, client , mode, &why); if (tmprc != 0) { client->errorValue = ( (XID)((((unsigned int)(why))<<24)|((id)&0xffffff))) ; return tmprc; }} \ |
72 | CHK_DEVICE(dev, id, client, mode, _XkbLookupBellDevice){ int why; int tmprc = _XkbLookupBellDevice(&(dev), id, client , mode, &why); if (tmprc != 0) { client->errorValue = ( (XID)((((unsigned int)(why))<<24)|((id)&0xffffff))) ; return tmprc; }} |
73 | #define CHK_ANY_DEVICE(dev, id, client, mode){ int why; int tmprc = _XkbLookupAnyDevice(&(dev), id, client , mode, &why); if (tmprc != 0) { client->errorValue = ( (XID)((((unsigned int)(why))<<24)|((id)&0xffffff))) ; return tmprc; }} \ |
74 | CHK_DEVICE(dev, id, client, mode, _XkbLookupAnyDevice){ int why; int tmprc = _XkbLookupAnyDevice(&(dev), id, client , mode, &why); if (tmprc != 0) { client->errorValue = ( (XID)((((unsigned int)(why))<<24)|((id)&0xffffff))) ; return tmprc; }} |
75 | |
76 | #define CHK_ATOM_ONLY2(a,ev,er){ if (((a)==0L)||(!ValidAtom((a)))) { (ev)= (XID)(a); return er ; }} {\ |
77 | if (((a)==None0L)||(!ValidAtom((a)))) {\ |
78 | (ev)= (XID)(a);\ |
79 | return er;\ |
80 | }\ |
81 | } |
82 | #define CHK_ATOM_ONLY(a){ if (((a)==0L)||(!ValidAtom((a)))) { (client->errorValue) = (XID)(a); return 5; }} \ |
83 | CHK_ATOM_ONLY2(a,client->errorValue,BadAtom){ if (((a)==0L)||(!ValidAtom((a)))) { (client->errorValue) = (XID)(a); return 5; }} |
84 | |
85 | #define CHK_ATOM_OR_NONE3(a,ev,er,ret){ if (((a)!=0L)&&(!ValidAtom((a)))) { (ev)= (XID)(a); (er)= 5; return ret; }} {\ |
86 | if (((a)!=None0L)&&(!ValidAtom((a)))) {\ |
87 | (ev)= (XID)(a);\ |
88 | (er)= BadAtom5;\ |
89 | return ret;\ |
90 | }\ |
91 | } |
92 | #define CHK_ATOM_OR_NONE2(a,ev,er){ if (((a)!=0L)&&(!ValidAtom((a)))) { (ev)= (XID)(a); return er; }} {\ |
93 | if (((a)!=None0L)&&(!ValidAtom((a)))) {\ |
94 | (ev)= (XID)(a);\ |
95 | return er;\ |
96 | }\ |
97 | } |
98 | #define CHK_ATOM_OR_NONE(a){ if (((a)!=0L)&&(!ValidAtom((a)))) { (client->errorValue )= (XID)(a); return 5; }} \ |
99 | CHK_ATOM_OR_NONE2(a,client->errorValue,BadAtom){ if (((a)!=0L)&&(!ValidAtom((a)))) { (client->errorValue )= (XID)(a); return 5; }} |
100 | |
101 | #define CHK_MASK_LEGAL3(err,mask,legal,ev,er,ret){ if ((mask)&(~(legal))) { (ev)= ((XID)((((unsigned int)( (err)))<<24)|((((mask)&(~(legal))))&0xffffff))) ; (er)= 2; return ret; }} {\ |
102 | if ((mask)&(~(legal))) { \ |
103 | (ev)= _XkbErrCode2((err),((mask)&(~(legal))))((XID)((((unsigned int)((err)))<<24)|((((mask)&(~(legal ))))&0xffffff)));\ |
104 | (er)= BadValue2;\ |
105 | return ret;\ |
106 | }\ |
107 | } |
108 | #define CHK_MASK_LEGAL2(err,mask,legal,ev,er){ if ((mask)&(~(legal))) { (ev)= ((XID)((((unsigned int)( (err)))<<24)|((((mask)&(~(legal))))&0xffffff))) ; return er; }} {\ |
109 | if ((mask)&(~(legal))) { \ |
110 | (ev)= _XkbErrCode2((err),((mask)&(~(legal))))((XID)((((unsigned int)((err)))<<24)|((((mask)&(~(legal ))))&0xffffff)));\ |
111 | return er;\ |
112 | }\ |
113 | } |
114 | #define CHK_MASK_LEGAL(err,mask,legal){ if ((mask)&(~(legal))) { (client->errorValue)= ((XID )((((unsigned int)((err)))<<24)|((((mask)&(~(legal) )))&0xffffff))); return 2; }} \ |
115 | CHK_MASK_LEGAL2(err,mask,legal,client->errorValue,BadValue){ if ((mask)&(~(legal))) { (client->errorValue)= ((XID )((((unsigned int)((err)))<<24)|((((mask)&(~(legal) )))&0xffffff))); return 2; }} |
116 | |
117 | #define CHK_MASK_MATCH(err,affect,value){ if ((value)&(~(affect))) { client->errorValue= ((XID )((((unsigned int)((err)))<<24)|((((value)&(~(affect ))))&0xffffff))); return 8; }} {\ |
118 | if ((value)&(~(affect))) { \ |
119 | client->errorValue= _XkbErrCode2((err),((value)&(~(affect))))((XID)((((unsigned int)((err)))<<24)|((((value)&(~( affect))))&0xffffff)));\ |
120 | return BadMatch8;\ |
121 | }\ |
122 | } |
123 | #define CHK_MASK_OVERLAP(err,m1,m2){ if ((m1)&(m2)) { client->errorValue= ((XID)((((unsigned int)((err)))<<24)|((((m1)&(m2)))&0xffffff))); return 8; }} {\ |
124 | if ((m1)&(m2)) { \ |
125 | client->errorValue= _XkbErrCode2((err),((m1)&(m2)))((XID)((((unsigned int)((err)))<<24)|((((m1)&(m2))) &0xffffff)));\ |
126 | return BadMatch8;\ |
127 | }\ |
128 | } |
129 | #define CHK_KEY_RANGE2(err,first,num,x,ev,er){ if (((unsigned)(first)+(num)-1)>(x)->max_key_code) { ( ev)=((XID)((((unsigned int)(err))<<24)|(((((unsigned int )((first)))<<16)|(((((unsigned int)((num)))<<8)|( (x)->max_key_code))))&0xffffff))); return er; } else if ( (first)<(x)->min_key_code ) { (ev)=((XID)((((unsigned int)(err+1))<<24)|(((((unsigned int)((first)))<< 16)|(xkb->min_key_code))&0xffffff))); return er; }} {\ |
130 | if (((unsigned)(first)+(num)-1)>(x)->max_key_code) {\ |
131 | (ev)=_XkbErrCode4(err,(first),(num),(x)->max_key_code)((XID)((((unsigned int)(err))<<24)|(((((unsigned int)(( first)))<<16)|(((((unsigned int)((num)))<<8)|((x) ->max_key_code))))&0xffffff)));\ |
132 | return er;\ |
133 | }\ |
134 | else if ( (first)<(x)->min_key_code ) {\ |
135 | (ev)=_XkbErrCode3(err+1,(first),xkb->min_key_code)((XID)((((unsigned int)(err+1))<<24)|(((((unsigned int) ((first)))<<16)|(xkb->min_key_code))&0xffffff)));\ |
136 | return er;\ |
137 | }\ |
138 | } |
139 | #define CHK_KEY_RANGE(err,first,num,x){ if (((unsigned)(first)+(num)-1)>(x)->max_key_code) { ( client->errorValue)=((XID)((((unsigned int)(err))<<24 )|(((((unsigned int)((first)))<<16)|(((((unsigned int)( (num)))<<8)|((x)->max_key_code))))&0xffffff))); return 2; } else if ( (first)<(x)->min_key_code ) { (client-> errorValue)=((XID)((((unsigned int)(err+1))<<24)|(((((unsigned int)((first)))<<16)|(xkb->min_key_code))&0xffffff ))); return 2; }} \ |
140 | CHK_KEY_RANGE2(err,first,num,x,client->errorValue,BadValue){ if (((unsigned)(first)+(num)-1)>(x)->max_key_code) { ( client->errorValue)=((XID)((((unsigned int)(err))<<24 )|(((((unsigned int)((first)))<<16)|(((((unsigned int)( (num)))<<8)|((x)->max_key_code))))&0xffffff))); return 2; } else if ( (first)<(x)->min_key_code ) { (client-> errorValue)=((XID)((((unsigned int)(err+1))<<24)|(((((unsigned int)((first)))<<16)|(xkb->min_key_code))&0xffffff ))); return 2; }} |
141 | |
142 | #define CHK_REQ_KEY_RANGE2(err,first,num,r,ev,er){ if (((unsigned)(first)+(num)-1)>(r)->maxKeyCode) { (ev )=((XID)((((unsigned int)(err))<<24)|(((((unsigned int) ((first)))<<16)|(((((unsigned int)((num)))<<8)|(( r)->maxKeyCode))))&0xffffff))); return er; } else if ( (first)<(r)->minKeyCode ) { (ev)=((XID)((((unsigned int )(err+1))<<24)|(((((unsigned int)((first)))<<16)| ((r)->minKeyCode))&0xffffff))); return er; }} {\ |
143 | if (((unsigned)(first)+(num)-1)>(r)->maxKeyCode) {\ |
144 | (ev)=_XkbErrCode4(err,(first),(num),(r)->maxKeyCode)((XID)((((unsigned int)(err))<<24)|(((((unsigned int)(( first)))<<16)|(((((unsigned int)((num)))<<8)|((r) ->maxKeyCode))))&0xffffff)));\ |
145 | return er;\ |
146 | }\ |
147 | else if ( (first)<(r)->minKeyCode ) {\ |
148 | (ev)=_XkbErrCode3(err+1,(first),(r)->minKeyCode)((XID)((((unsigned int)(err+1))<<24)|(((((unsigned int) ((first)))<<16)|((r)->minKeyCode))&0xffffff)));\ |
149 | return er;\ |
150 | }\ |
151 | } |
152 | #define CHK_REQ_KEY_RANGE(err,first,num,r){ if (((unsigned)(first)+(num)-1)>(r)->maxKeyCode) { (client ->errorValue)=((XID)((((unsigned int)(err))<<24)|((( ((unsigned int)((first)))<<16)|(((((unsigned int)((num) ))<<8)|((r)->maxKeyCode))))&0xffffff))); return 2 ; } else if ( (first)<(r)->minKeyCode ) { (client->errorValue )=((XID)((((unsigned int)(err+1))<<24)|(((((unsigned int )((first)))<<16)|((r)->minKeyCode))&0xffffff))); return 2; }} \ |
153 | CHK_REQ_KEY_RANGE2(err,first,num,r,client->errorValue,BadValue){ if (((unsigned)(first)+(num)-1)>(r)->maxKeyCode) { (client ->errorValue)=((XID)((((unsigned int)(err))<<24)|((( ((unsigned int)((first)))<<16)|(((((unsigned int)((num) ))<<8)|((r)->maxKeyCode))))&0xffffff))); return 2 ; } else if ( (first)<(r)->minKeyCode ) { (client->errorValue )=((XID)((((unsigned int)(err+1))<<24)|(((((unsigned int )((first)))<<16)|((r)->minKeyCode))&0xffffff))); return 2; }} |
154 | |
155 | /***====================================================================***/ |
156 | |
157 | int |
158 | ProcXkbUseExtension(ClientPtr client) |
159 | { |
160 | REQUEST(xkbUseExtensionReq)xkbUseExtensionReq *stuff = (xkbUseExtensionReq *)client-> requestBuffer; |
161 | xkbUseExtensionReply rep; |
162 | int supported; |
163 | |
164 | REQUEST_SIZE_MATCH(xkbUseExtensionReq)if ((sizeof(xkbUseExtensionReq) >> 2) != client->req_len ) return(16); |
165 | if (stuff->wantedMajor != SERVER_XKB_MAJOR_VERSION1) { |
166 | /* pre-release version 0.65 is compatible with 1.00 */ |
167 | supported = ((SERVER_XKB_MAJOR_VERSION1 == 1) && |
168 | (stuff->wantedMajor == 0) && (stuff->wantedMinor == 65)); |
169 | } |
170 | else |
171 | supported = 1; |
172 | |
173 | if ((supported) && (!(client->xkbClientFlags & _XkbClientInitialized(1<<15)))) { |
174 | client->xkbClientFlags = _XkbClientInitialized(1<<15); |
175 | client->vMajor = stuff->wantedMajor; |
176 | client->vMinor = stuff->wantedMinor; |
177 | } |
178 | else if (xkbDebugFlags & 0x1) { |
179 | ErrorF |
180 | ("[xkb] Rejecting client %d (0x%lx) (wants %d.%02d, have %d.%02d)\n", |
181 | client->index, (long) client->clientAsMask, stuff->wantedMajor, |
182 | stuff->wantedMinor, SERVER_XKB_MAJOR_VERSION1, |
183 | SERVER_XKB_MINOR_VERSION0); |
184 | } |
185 | rep = (xkbUseExtensionReply) { |
186 | .type = X_Reply1, |
187 | .supported = supported, |
188 | .sequenceNumber = client->sequence, |
189 | .length = 0, |
190 | .serverMajor = SERVER_XKB_MAJOR_VERSION1, |
191 | .serverMinor = SERVER_XKB_MINOR_VERSION0 |
192 | }; |
193 | if (client->swapped) { |
194 | swaps(&rep.sequenceNumber)do { if (sizeof(*(&rep.sequenceNumber)) != 2) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&rep.sequenceNumber ) & 1) && ((uintptr_t)(&rep.sequenceNumber) & 1) == 0) *(&rep.sequenceNumber) = lswaps(*(&rep.sequenceNumber )); else swap_uint16((uint16_t *)(&rep.sequenceNumber)); } while (0); |
195 | swaps(&rep.serverMajor)do { if (sizeof(*(&rep.serverMajor)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&rep.serverMajor) & 1) && ((uintptr_t)(&rep.serverMajor) & 1) == 0) *(&rep.serverMajor) = lswaps(*(&rep.serverMajor)) ; else swap_uint16((uint16_t *)(&rep.serverMajor)); } while (0); |
196 | swaps(&rep.serverMinor)do { if (sizeof(*(&rep.serverMinor)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&rep.serverMinor) & 1) && ((uintptr_t)(&rep.serverMinor) & 1) == 0) *(&rep.serverMinor) = lswaps(*(&rep.serverMinor)) ; else swap_uint16((uint16_t *)(&rep.serverMinor)); } while (0); |
197 | } |
198 | WriteToClient(client, SIZEOF(xkbUseExtensionReply)32, &rep); |
199 | return Success0; |
200 | } |
201 | |
202 | /***====================================================================***/ |
203 | |
204 | int |
205 | ProcXkbSelectEvents(ClientPtr client) |
206 | { |
207 | unsigned legal; |
208 | DeviceIntPtr dev; |
209 | XkbInterestPtr masks; |
210 | |
211 | REQUEST(xkbSelectEventsReq)xkbSelectEventsReq *stuff = (xkbSelectEventsReq *)client-> requestBuffer; |
212 | |
213 | REQUEST_AT_LEAST_SIZE(xkbSelectEventsReq)if ((sizeof(xkbSelectEventsReq) >> 2) > client->req_len ) return(16); |
214 | |
215 | if (!(client->xkbClientFlags & _XkbClientInitialized(1<<15))) |
216 | return BadAccess10; |
217 | |
218 | CHK_ANY_DEVICE(dev, stuff->deviceSpec, client, DixUseAccess){ int why; int tmprc = _XkbLookupAnyDevice(&(dev), stuff-> deviceSpec, client, (1<<24), &why); if (tmprc != 0) { client->errorValue = ((XID)((((unsigned int)(why))<< 24)|((stuff->deviceSpec)&0xffffff))); return tmprc; }}; |
219 | |
220 | if (((stuff->affectWhich & XkbMapNotifyMask(1L << 1)) != 0) && (stuff->affectMap)) { |
221 | client->mapNotifyMask &= ~stuff->affectMap; |
222 | client->mapNotifyMask |= (stuff->affectMap & stuff->map); |
223 | } |
224 | if ((stuff->affectWhich & (~XkbMapNotifyMask(1L << 1))) == 0) |
225 | return Success0; |
226 | |
227 | masks = XkbFindClientResource((DevicePtr) dev, client); |
228 | if (!masks) { |
229 | XID id = FakeClientID(client->index); |
230 | |
231 | if (!AddResourceDarwin_X_AddResource(id, RT_XKBCLIENT, dev)) |
232 | return BadAlloc11; |
233 | masks = XkbAddClientResource((DevicePtr) dev, client, id); |
234 | } |
235 | if (masks) { |
236 | union { |
237 | CARD8 *c8; |
238 | CARD16 *c16; |
239 | CARD32 *c32; |
240 | } from, to; |
241 | register unsigned bit, ndx, maskLeft, dataLeft, size; |
242 | |
243 | from.c8 = (CARD8 *) &stuff[1]; |
244 | dataLeft = (stuff->length * 4) - SIZEOF(xkbSelectEventsReq)16; |
245 | maskLeft = (stuff->affectWhich & (~XkbMapNotifyMask(1L << 1))); |
246 | for (ndx = 0, bit = 1; (maskLeft != 0); ndx++, bit <<= 1) { |
247 | if ((bit & maskLeft) == 0) |
248 | continue; |
249 | maskLeft &= ~bit; |
250 | switch (ndx) { |
251 | case XkbNewKeyboardNotify0: |
252 | to.c16 = &client->newKeyboardNotifyMask; |
253 | legal = XkbAllNewKeyboardEventsMask(0x7); |
254 | size = 2; |
255 | break; |
256 | case XkbStateNotify2: |
257 | to.c16 = &masks->stateNotifyMask; |
258 | legal = XkbAllStateEventsMask(0x3fff); |
259 | size = 2; |
260 | break; |
261 | case XkbControlsNotify3: |
262 | to.c32 = &masks->ctrlsNotifyMask; |
263 | legal = XkbAllControlEventsMask(0xF8001FFF); |
264 | size = 4; |
265 | break; |
266 | case XkbIndicatorStateNotify4: |
267 | to.c32 = &masks->iStateNotifyMask; |
268 | legal = XkbAllIndicatorEventsMask(0xffffffff); |
269 | size = 4; |
270 | break; |
271 | case XkbIndicatorMapNotify5: |
272 | to.c32 = &masks->iMapNotifyMask; |
273 | legal = XkbAllIndicatorEventsMask(0xffffffff); |
274 | size = 4; |
275 | break; |
276 | case XkbNamesNotify6: |
277 | to.c16 = &masks->namesNotifyMask; |
278 | legal = XkbAllNameEventsMask(0x3fff); |
279 | size = 2; |
280 | break; |
281 | case XkbCompatMapNotify7: |
282 | to.c8 = &masks->compatNotifyMask; |
283 | legal = XkbAllCompatMapEventsMask(0x3); |
284 | size = 1; |
285 | break; |
286 | case XkbBellNotify8: |
287 | to.c8 = &masks->bellNotifyMask; |
288 | legal = XkbAllBellEventsMask(1L << 0); |
289 | size = 1; |
290 | break; |
291 | case XkbActionMessage9: |
292 | to.c8 = &masks->actionMessageMask; |
293 | legal = XkbAllActionMessagesMask(1L << 0); |
294 | size = 1; |
295 | break; |
296 | case XkbAccessXNotify10: |
297 | to.c16 = &masks->accessXNotifyMask; |
298 | legal = XkbAllAccessXEventsMask(0x7f); |
299 | size = 2; |
300 | break; |
301 | case XkbExtensionDeviceNotify11: |
302 | to.c16 = &masks->extDevNotifyMask; |
303 | legal = XkbAllExtensionDeviceEventsMask(0x801f); |
304 | size = 2; |
305 | break; |
306 | default: |
307 | client->errorValue = _XkbErrCode2(33, bit)((XID)((((unsigned int)(33))<<24)|((bit)&0xffffff)) ); |
308 | return BadValue2; |
309 | } |
310 | |
311 | if (stuff->clear & bit) { |
312 | if (size == 2) |
313 | to.c16[0] = 0; |
314 | else if (size == 4) |
315 | to.c32[0] = 0; |
316 | else |
317 | to.c8[0] = 0; |
318 | } |
319 | else if (stuff->selectAll & bit) { |
320 | if (size == 2) |
321 | to.c16[0] = ~0; |
322 | else if (size == 4) |
323 | to.c32[0] = ~0; |
324 | else |
325 | to.c8[0] = ~0; |
326 | } |
327 | else { |
328 | if (dataLeft < (size * 2)) |
329 | return BadLength16; |
330 | if (size == 2) { |
331 | CHK_MASK_MATCH(ndx, from.c16[0], from.c16[1]){ if ((from.c16[1])&(~(from.c16[0]))) { client->errorValue = ((XID)((((unsigned int)((ndx)))<<24)|((((from.c16[1]) &(~(from.c16[0]))))&0xffffff))); return 8; }}; |
332 | CHK_MASK_LEGAL(ndx, from.c16[0], legal){ if ((from.c16[0])&(~(legal))) { (client->errorValue) = ((XID)((((unsigned int)((ndx)))<<24)|((((from.c16[0]) &(~(legal))))&0xffffff))); return 2; }}; |
333 | to.c16[0] &= ~from.c16[0]; |
334 | to.c16[0] |= (from.c16[0] & from.c16[1]); |
335 | } |
336 | else if (size == 4) { |
337 | CHK_MASK_MATCH(ndx, from.c32[0], from.c32[1]){ if ((from.c32[1])&(~(from.c32[0]))) { client->errorValue = ((XID)((((unsigned int)((ndx)))<<24)|((((from.c32[1]) &(~(from.c32[0]))))&0xffffff))); return 8; }}; |
338 | CHK_MASK_LEGAL(ndx, from.c32[0], legal){ if ((from.c32[0])&(~(legal))) { (client->errorValue) = ((XID)((((unsigned int)((ndx)))<<24)|((((from.c32[0]) &(~(legal))))&0xffffff))); return 2; }}; |
339 | to.c32[0] &= ~from.c32[0]; |
340 | to.c32[0] |= (from.c32[0] & from.c32[1]); |
341 | } |
342 | else { |
343 | CHK_MASK_MATCH(ndx, from.c8[0], from.c8[1]){ if ((from.c8[1])&(~(from.c8[0]))) { client->errorValue = ((XID)((((unsigned int)((ndx)))<<24)|((((from.c8[1])& (~(from.c8[0]))))&0xffffff))); return 8; }}; |
344 | CHK_MASK_LEGAL(ndx, from.c8[0], legal){ if ((from.c8[0])&(~(legal))) { (client->errorValue)= ((XID)((((unsigned int)((ndx)))<<24)|((((from.c8[0])& (~(legal))))&0xffffff))); return 2; }}; |
345 | to.c8[0] &= ~from.c8[0]; |
346 | to.c8[0] |= (from.c8[0] & from.c8[1]); |
347 | size = 2; |
348 | } |
349 | from.c8 += (size * 2); |
350 | dataLeft -= (size * 2); |
351 | } |
352 | } |
353 | if (dataLeft > 2) { |
354 | ErrorF("[xkb] Extra data (%d bytes) after SelectEvents\n", |
355 | dataLeft); |
356 | return BadLength16; |
357 | } |
358 | return Success0; |
359 | } |
360 | return BadAlloc11; |
361 | } |
362 | |
363 | /***====================================================================***/ |
364 | /** |
365 | * Ring a bell on the given device for the given client. |
366 | */ |
367 | static int |
368 | _XkbBell(ClientPtr client, DeviceIntPtr dev, WindowPtr pWin, |
369 | int bellClass, int bellID, int pitch, int duration, |
370 | int percent, int forceSound, int eventOnly, Atom name) |
371 | { |
372 | int base; |
373 | void *ctrl; |
374 | int oldPitch, oldDuration; |
375 | int newPercent; |
376 | |
377 | if (bellClass == KbdFeedbackClass0) { |
378 | KbdFeedbackPtr k; |
379 | |
380 | if (bellID == XkbDfltXIId0x0400) |
381 | k = dev->kbdfeed; |
382 | else { |
383 | for (k = dev->kbdfeed; k; k = k->next) { |
384 | if (k->ctrl.id == bellID) |
385 | break; |
386 | } |
387 | } |
388 | if (!k) { |
389 | client->errorValue = _XkbErrCode2(0x5, bellID)((XID)((((unsigned int)(0x5))<<24)|((bellID)&0xffffff ))); |
390 | return BadValue2; |
391 | } |
392 | base = k->ctrl.bell; |
393 | ctrl = (void *) &(k->ctrl); |
394 | oldPitch = k->ctrl.bell_pitch; |
395 | oldDuration = k->ctrl.bell_duration; |
396 | if (pitch != 0) { |
397 | if (pitch == -1) |
398 | k->ctrl.bell_pitch = defaultKeyboardControl.bell_pitch; |
399 | else |
400 | k->ctrl.bell_pitch = pitch; |
401 | } |
402 | if (duration != 0) { |
403 | if (duration == -1) |
404 | k->ctrl.bell_duration = defaultKeyboardControl.bell_duration; |
405 | else |
406 | k->ctrl.bell_duration = duration; |
407 | } |
408 | } |
409 | else if (bellClass == BellFeedbackClass5) { |
410 | BellFeedbackPtr b; |
411 | |
412 | if (bellID == XkbDfltXIId0x0400) |
413 | b = dev->bell; |
414 | else { |
415 | for (b = dev->bell; b; b = b->next) { |
416 | if (b->ctrl.id == bellID) |
417 | break; |
418 | } |
419 | } |
420 | if (!b) { |
421 | client->errorValue = _XkbErrCode2(0x6, bellID)((XID)((((unsigned int)(0x6))<<24)|((bellID)&0xffffff ))); |
422 | return BadValue2; |
423 | } |
424 | base = b->ctrl.percent; |
425 | ctrl = (void *) &(b->ctrl); |
426 | oldPitch = b->ctrl.pitch; |
427 | oldDuration = b->ctrl.duration; |
428 | if (pitch != 0) { |
429 | if (pitch == -1) |
430 | b->ctrl.pitch = defaultKeyboardControl.bell_pitch; |
431 | else |
432 | b->ctrl.pitch = pitch; |
433 | } |
434 | if (duration != 0) { |
435 | if (duration == -1) |
436 | b->ctrl.duration = defaultKeyboardControl.bell_duration; |
437 | else |
438 | b->ctrl.duration = duration; |
439 | } |
440 | } |
441 | else { |
442 | client->errorValue = _XkbErrCode2(0x7, bellClass)((XID)((((unsigned int)(0x7))<<24)|((bellClass)&0xffffff ))); |
443 | return BadValue2; |
444 | } |
445 | |
446 | newPercent = (base * percent) / 100; |
447 | if (percent < 0) |
448 | newPercent = base + newPercent; |
449 | else |
450 | newPercent = base - newPercent + percent; |
451 | |
452 | XkbHandleBell(forceSound, eventOnly, |
453 | dev, newPercent, ctrl, bellClass, name, pWin, client); |
454 | if ((pitch != 0) || (duration != 0)) { |
455 | if (bellClass == KbdFeedbackClass0) { |
456 | KbdFeedbackPtr k; |
457 | |
458 | k = (KbdFeedbackPtr) ctrl; |
459 | if (pitch != 0) |
460 | k->ctrl.bell_pitch = oldPitch; |
461 | if (duration != 0) |
462 | k->ctrl.bell_duration = oldDuration; |
463 | } |
464 | else { |
465 | BellFeedbackPtr b; |
466 | |
467 | b = (BellFeedbackPtr) ctrl; |
468 | if (pitch != 0) |
469 | b->ctrl.pitch = oldPitch; |
470 | if (duration != 0) |
471 | b->ctrl.duration = oldDuration; |
472 | } |
473 | } |
474 | |
475 | return Success0; |
476 | } |
477 | |
478 | int |
479 | ProcXkbBell(ClientPtr client) |
480 | { |
481 | REQUEST(xkbBellReq)xkbBellReq *stuff = (xkbBellReq *)client->requestBuffer; |
482 | DeviceIntPtr dev; |
483 | WindowPtr pWin; |
484 | int rc; |
485 | |
486 | REQUEST_SIZE_MATCH(xkbBellReq)if ((sizeof(xkbBellReq) >> 2) != client->req_len) return (16); |
487 | |
488 | if (!(client->xkbClientFlags & _XkbClientInitialized(1<<15))) |
489 | return BadAccess10; |
490 | |
491 | CHK_BELL_DEVICE(dev, stuff->deviceSpec, client, DixBellAccess){ int why; int tmprc = _XkbLookupBellDevice(&(dev), stuff ->deviceSpec, client, (1<<27), &why); if (tmprc != 0) { client->errorValue = ((XID)((((unsigned int)(why))<< 24)|((stuff->deviceSpec)&0xffffff))); return tmprc; }}; |
492 | CHK_ATOM_OR_NONE(stuff->name){ if (((stuff->name)!=0L)&&(!ValidAtom((stuff-> name)))) { (client->errorValue)= (XID)(stuff->name); return 5; }}; |
493 | |
494 | /* device-independent checks request for sane values */ |
495 | if ((stuff->forceSound) && (stuff->eventOnly)) { |
496 | client->errorValue = |
497 | _XkbErrCode3(0x1, stuff->forceSound, stuff->eventOnly)((XID)((((unsigned int)(0x1))<<24)|(((((unsigned int)(stuff ->forceSound))<<16)|(stuff->eventOnly))&0xffffff ))); |
498 | return BadMatch8; |
499 | } |
500 | if (stuff->percent < -100 || stuff->percent > 100) { |
501 | client->errorValue = _XkbErrCode2(0x2, stuff->percent)((XID)((((unsigned int)(0x2))<<24)|((stuff->percent) &0xffffff))); |
502 | return BadValue2; |
503 | } |
504 | if (stuff->duration < -1) { |
505 | client->errorValue = _XkbErrCode2(0x3, stuff->duration)((XID)((((unsigned int)(0x3))<<24)|((stuff->duration )&0xffffff))); |
506 | return BadValue2; |
507 | } |
508 | if (stuff->pitch < -1) { |
509 | client->errorValue = _XkbErrCode2(0x4, stuff->pitch)((XID)((((unsigned int)(0x4))<<24)|((stuff->pitch)& 0xffffff))); |
510 | return BadValue2; |
511 | } |
512 | |
513 | if (stuff->bellClass == XkbDfltXIClass0x0300) { |
514 | if (dev->kbdfeed != NULL((void*)0)) |
515 | stuff->bellClass = KbdFeedbackClass0; |
516 | else |
517 | stuff->bellClass = BellFeedbackClass5; |
518 | } |
519 | |
520 | if (stuff->window != None0L) { |
521 | rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess(1<<4)); |
522 | if (rc != Success0) { |
523 | client->errorValue = stuff->window; |
524 | return rc; |
525 | } |
526 | } |
527 | else |
528 | pWin = NULL((void*)0); |
529 | |
530 | /* Client wants to ring a bell on the core keyboard? |
531 | Ring the bell on the core keyboard (which does nothing, but if that |
532 | fails the client is screwed anyway), and then on all extension devices. |
533 | Fail if the core keyboard fails but not the extension devices. this |
534 | may cause some keyboards to ding and others to stay silent. Fix |
535 | your client to use explicit keyboards to avoid this. |
536 | |
537 | dev is the device the client requested. |
538 | */ |
539 | rc = _XkbBell(client, dev, pWin, stuff->bellClass, stuff->bellID, |
540 | stuff->pitch, stuff->duration, stuff->percent, |
541 | stuff->forceSound, stuff->eventOnly, stuff->name); |
542 | |
543 | if ((rc == Success0) && ((stuff->deviceSpec == XkbUseCoreKbd0x0100) || |
544 | (stuff->deviceSpec == XkbUseCorePtr0x0200))) { |
545 | DeviceIntPtr other; |
546 | |
547 | for (other = inputInfo.devices; other; other = other->next) { |
548 | if ((other != dev) && other->key && !IsMaster(other) && |
549 | GetMaster(other, MASTER_KEYBOARD2) == dev) { |
550 | rc = XaceHook(XACE_DEVICE_ACCESS3, client, other, DixBellAccess(1<<27)); |
551 | if (rc == Success0) |
552 | _XkbBell(client, other, pWin, stuff->bellClass, |
553 | stuff->bellID, stuff->pitch, stuff->duration, |
554 | stuff->percent, stuff->forceSound, |
555 | stuff->eventOnly, stuff->name); |
556 | } |
557 | } |
558 | rc = Success0; /* reset to success, that's what we got for the VCK */ |
559 | } |
560 | |
561 | return rc; |
562 | } |
563 | |
564 | /***====================================================================***/ |
565 | |
566 | int |
567 | ProcXkbGetState(ClientPtr client) |
568 | { |
569 | REQUEST(xkbGetStateReq)xkbGetStateReq *stuff = (xkbGetStateReq *)client->requestBuffer; |
570 | DeviceIntPtr dev; |
571 | xkbGetStateReply rep; |
572 | XkbStateRec *xkb; |
573 | |
574 | REQUEST_SIZE_MATCH(xkbGetStateReq)if ((sizeof(xkbGetStateReq) >> 2) != client->req_len ) return(16); |
575 | |
576 | if (!(client->xkbClientFlags & _XkbClientInitialized(1<<15))) |
577 | return BadAccess10; |
578 | |
579 | CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixGetAttrAccess){ int why; int tmprc = _XkbLookupKeyboard(&(dev), stuff-> deviceSpec, client, (1<<4), &why); if (tmprc != 0) { client->errorValue = ((XID)((((unsigned int)(why))<< 24)|((stuff->deviceSpec)&0xffffff))); return tmprc; }}; |
580 | |
581 | xkb = &dev->key->xkbInfo->state; |
582 | rep = (xkbGetStateReply) { |
583 | .type = X_Reply1, |
584 | .deviceID = dev->id, |
585 | .sequenceNumber = client->sequence, |
586 | .length = 0, |
587 | .mods = XkbStateFieldFromRec(xkb)(((((xkb)->group)&0x3)<<13)|(((xkb)->lookup_mods )&0xff)) & 0xff, |
588 | .baseMods = xkb->base_mods, |
589 | .latchedMods = xkb->latched_mods, |
590 | .lockedMods = xkb->locked_mods, |
591 | .group = xkb->group, |
592 | .lockedGroup = xkb->locked_group, |
593 | .baseGroup = xkb->base_group, |
594 | .latchedGroup = xkb->latched_group, |
595 | .compatState = xkb->compat_state, |
596 | .ptrBtnState = xkb->ptr_buttons |
597 | }; |
598 | if (client->swapped) { |
599 | swaps(&rep.sequenceNumber)do { if (sizeof(*(&rep.sequenceNumber)) != 2) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&rep.sequenceNumber ) & 1) && ((uintptr_t)(&rep.sequenceNumber) & 1) == 0) *(&rep.sequenceNumber) = lswaps(*(&rep.sequenceNumber )); else swap_uint16((uint16_t *)(&rep.sequenceNumber)); } while (0); |
600 | swaps(&rep.ptrBtnState)do { if (sizeof(*(&rep.ptrBtnState)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&rep.ptrBtnState) & 1) && ((uintptr_t)(&rep.ptrBtnState) & 1) == 0) *(&rep.ptrBtnState) = lswaps(*(&rep.ptrBtnState)) ; else swap_uint16((uint16_t *)(&rep.ptrBtnState)); } while (0); |
601 | } |
602 | WriteToClient(client, SIZEOF(xkbGetStateReply)32, &rep); |
603 | return Success0; |
604 | } |
605 | |
606 | /***====================================================================***/ |
607 | |
608 | int |
609 | ProcXkbLatchLockState(ClientPtr client) |
610 | { |
611 | int status; |
612 | DeviceIntPtr dev, tmpd; |
613 | XkbStateRec oldState, *newState; |
614 | CARD16 changed; |
615 | xkbStateNotify sn; |
616 | XkbEventCauseRec cause; |
617 | |
618 | REQUEST(xkbLatchLockStateReq)xkbLatchLockStateReq *stuff = (xkbLatchLockStateReq *)client-> requestBuffer; |
619 | REQUEST_SIZE_MATCH(xkbLatchLockStateReq)if ((sizeof(xkbLatchLockStateReq) >> 2) != client->req_len ) return(16); |
620 | |
621 | if (!(client->xkbClientFlags & _XkbClientInitialized(1<<15))) |
622 | return BadAccess10; |
623 | |
624 | CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixSetAttrAccess){ int why; int tmprc = _XkbLookupKeyboard(&(dev), stuff-> deviceSpec, client, (1<<5), &why); if (tmprc != 0) { client->errorValue = ((XID)((((unsigned int)(why))<< 24)|((stuff->deviceSpec)&0xffffff))); return tmprc; }}; |
625 | CHK_MASK_MATCH(0x01, stuff->affectModLocks, stuff->modLocks){ if ((stuff->modLocks)&(~(stuff->affectModLocks))) { client->errorValue= ((XID)((((unsigned int)((0x01)))<< 24)|((((stuff->modLocks)&(~(stuff->affectModLocks)) ))&0xffffff))); return 8; }}; |
626 | CHK_MASK_MATCH(0x01, stuff->affectModLatches, stuff->modLatches){ if ((stuff->modLatches)&(~(stuff->affectModLatches ))) { client->errorValue= ((XID)((((unsigned int)((0x01))) <<24)|((((stuff->modLatches)&(~(stuff->affectModLatches ))))&0xffffff))); return 8; }}; |
627 | |
628 | status = Success0; |
629 | |
630 | for (tmpd = inputInfo.devices; tmpd; tmpd = tmpd->next) { |
631 | if ((tmpd == dev) || |
632 | (!IsMaster(tmpd) && GetMaster(tmpd, MASTER_KEYBOARD2) == dev)) { |
633 | if (!tmpd->key || !tmpd->key->xkbInfo) |
634 | continue; |
635 | |
636 | oldState = tmpd->key->xkbInfo->state; |
637 | newState = &tmpd->key->xkbInfo->state; |
638 | if (stuff->affectModLocks) { |
639 | newState->locked_mods &= ~stuff->affectModLocks; |
640 | newState->locked_mods |= |
641 | (stuff->affectModLocks & stuff->modLocks); |
642 | } |
643 | if (status == Success0 && stuff->lockGroup) |
644 | newState->locked_group = stuff->groupLock; |
645 | if (status == Success0 && stuff->affectModLatches) |
646 | status = XkbLatchModifiersSrvXkbLatchModifiers(tmpd, stuff->affectModLatches, |
647 | stuff->modLatches); |
648 | if (status == Success0 && stuff->latchGroup) |
649 | status = XkbLatchGroupSrvXkbLatchGroup(tmpd, stuff->groupLatch); |
650 | |
651 | if (status != Success0) |
652 | return status; |
653 | |
654 | XkbComputeDerivedState(tmpd->key->xkbInfo); |
655 | |
656 | changed = XkbStateChangedFlags(&oldState, newState); |
657 | if (changed) { |
658 | sn.keycode = 0; |
659 | sn.eventType = 0; |
660 | sn.requestMajor = XkbReqCode; |
661 | sn.requestMinor = X_kbLatchLockState5; |
662 | sn.changed = changed; |
663 | XkbSendStateNotify(tmpd, &sn); |
664 | changed = XkbIndicatorsToUpdate(tmpd, changed, FALSE0); |
665 | if (changed) { |
666 | XkbSetCauseXkbReq(&cause, X_kbLatchLockState, client){ (&cause)->kc= (&cause)->event= 0, (&cause )->mjr= (XkbReqCode),(&cause)->mnr= (5); (&cause )->client= (client); }; |
667 | XkbUpdateIndicators(tmpd, changed, TRUE1, NULL((void*)0), &cause); |
668 | } |
669 | } |
670 | } |
671 | } |
672 | |
673 | return Success0; |
674 | } |
675 | |
676 | /***====================================================================***/ |
677 | |
678 | int |
679 | ProcXkbGetControls(ClientPtr client) |
680 | { |
681 | xkbGetControlsReply rep; |
682 | XkbControlsPtr xkb; |
683 | DeviceIntPtr dev; |
684 | |
685 | REQUEST(xkbGetControlsReq)xkbGetControlsReq *stuff = (xkbGetControlsReq *)client->requestBuffer; |
686 | REQUEST_SIZE_MATCH(xkbGetControlsReq)if ((sizeof(xkbGetControlsReq) >> 2) != client->req_len ) return(16); |
687 | |
688 | if (!(client->xkbClientFlags & _XkbClientInitialized(1<<15))) |
689 | return BadAccess10; |
690 | |
691 | CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixGetAttrAccess){ int why; int tmprc = _XkbLookupKeyboard(&(dev), stuff-> deviceSpec, client, (1<<4), &why); if (tmprc != 0) { client->errorValue = ((XID)((((unsigned int)(why))<< 24)|((stuff->deviceSpec)&0xffffff))); return tmprc; }}; |
692 | |
693 | xkb = dev->key->xkbInfo->desc->ctrls; |
694 | rep = (xkbGetControlsReply) { |
695 | .type = X_Reply1, |
696 | .deviceID = ((DeviceIntPtr) dev)->id, |
697 | .sequenceNumber = client->sequence, |
698 | .length = bytes_to_int32(SIZEOF(xkbGetControlsReply)92 - |
699 | SIZEOF(xGenericReply)32), |
700 | .mkDfltBtn = xkb->mk_dflt_btn, |
701 | .numGroups = xkb->num_groups, |
702 | .groupsWrap = xkb->groups_wrap, |
703 | .internalMods = xkb->internal.mask, |
704 | .ignoreLockMods = xkb->ignore_lock.mask, |
705 | .internalRealMods = xkb->internal.real_mods, |
706 | .ignoreLockRealMods = xkb->ignore_lock.real_mods, |
707 | .internalVMods = xkb->internal.vmods, |
708 | .ignoreLockVMods = xkb->ignore_lock.vmods, |
709 | .repeatDelay = xkb->repeat_delay, |
710 | .repeatInterval = xkb->repeat_interval, |
711 | .slowKeysDelay = xkb->slow_keys_delay, |
712 | .debounceDelay = xkb->debounce_delay, |
713 | .mkDelay = xkb->mk_delay, |
714 | .mkInterval = xkb->mk_interval, |
715 | .mkTimeToMax = xkb->mk_time_to_max, |
716 | .mkMaxSpeed = xkb->mk_max_speed, |
717 | .mkCurve = xkb->mk_curve, |
718 | .axOptions = xkb->ax_options, |
719 | .axTimeout = xkb->ax_timeout, |
720 | .axtOptsMask = xkb->axt_opts_mask, |
721 | .axtOptsValues = xkb->axt_opts_values, |
722 | .axtCtrlsMask = xkb->axt_ctrls_mask, |
723 | .axtCtrlsValues = xkb->axt_ctrls_values, |
724 | .enabledCtrls = xkb->enabled_ctrls, |
725 | }; |
726 | memcpy(rep.perKeyRepeat, xkb->per_key_repeat, XkbPerKeyBitArraySize)__builtin___memcpy_chk (rep.perKeyRepeat, xkb->per_key_repeat , ((255 +1)/8), __builtin_object_size (rep.perKeyRepeat, 0)); |
727 | if (client->swapped) { |
728 | swaps(&rep.sequenceNumber)do { if (sizeof(*(&rep.sequenceNumber)) != 2) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&rep.sequenceNumber ) & 1) && ((uintptr_t)(&rep.sequenceNumber) & 1) == 0) *(&rep.sequenceNumber) = lswaps(*(&rep.sequenceNumber )); else swap_uint16((uint16_t *)(&rep.sequenceNumber)); } while (0); |
729 | swapl(&rep.length)do { if (sizeof(*(&rep.length)) != 4) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&rep.length) & 3) && ((uintptr_t )(&rep.length) & 3) == 0) *(&rep.length) = lswapl (*(&rep.length)); else swap_uint32((uint32_t *)(&rep. length)); } while (0); |
730 | swaps(&rep.internalVMods)do { if (sizeof(*(&rep.internalVMods)) != 2) wrong_size() ; if (__builtin_constant_p((uintptr_t)(&rep.internalVMods ) & 1) && ((uintptr_t)(&rep.internalVMods) & 1) == 0) *(&rep.internalVMods) = lswaps(*(&rep.internalVMods )); else swap_uint16((uint16_t *)(&rep.internalVMods)); } while (0); |
731 | swaps(&rep.ignoreLockVMods)do { if (sizeof(*(&rep.ignoreLockVMods)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&rep.ignoreLockVMods ) & 1) && ((uintptr_t)(&rep.ignoreLockVMods) & 1) == 0) *(&rep.ignoreLockVMods) = lswaps(*(&rep.ignoreLockVMods )); else swap_uint16((uint16_t *)(&rep.ignoreLockVMods)); } while (0); |
732 | swapl(&rep.enabledCtrls)do { if (sizeof(*(&rep.enabledCtrls)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&rep.enabledCtrls) & 3) && ((uintptr_t)(&rep.enabledCtrls) & 3) == 0) *(&rep.enabledCtrls) = lswapl(*(&rep.enabledCtrls )); else swap_uint32((uint32_t *)(&rep.enabledCtrls)); } while (0); |
733 | swaps(&rep.repeatDelay)do { if (sizeof(*(&rep.repeatDelay)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&rep.repeatDelay) & 1) && ((uintptr_t)(&rep.repeatDelay) & 1) == 0) *(&rep.repeatDelay) = lswaps(*(&rep.repeatDelay)) ; else swap_uint16((uint16_t *)(&rep.repeatDelay)); } while (0); |
734 | swaps(&rep.repeatInterval)do { if (sizeof(*(&rep.repeatInterval)) != 2) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&rep.repeatInterval ) & 1) && ((uintptr_t)(&rep.repeatInterval) & 1) == 0) *(&rep.repeatInterval) = lswaps(*(&rep.repeatInterval )); else swap_uint16((uint16_t *)(&rep.repeatInterval)); } while (0); |
735 | swaps(&rep.slowKeysDelay)do { if (sizeof(*(&rep.slowKeysDelay)) != 2) wrong_size() ; if (__builtin_constant_p((uintptr_t)(&rep.slowKeysDelay ) & 1) && ((uintptr_t)(&rep.slowKeysDelay) & 1) == 0) *(&rep.slowKeysDelay) = lswaps(*(&rep.slowKeysDelay )); else swap_uint16((uint16_t *)(&rep.slowKeysDelay)); } while (0); |
736 | swaps(&rep.debounceDelay)do { if (sizeof(*(&rep.debounceDelay)) != 2) wrong_size() ; if (__builtin_constant_p((uintptr_t)(&rep.debounceDelay ) & 1) && ((uintptr_t)(&rep.debounceDelay) & 1) == 0) *(&rep.debounceDelay) = lswaps(*(&rep.debounceDelay )); else swap_uint16((uint16_t *)(&rep.debounceDelay)); } while (0); |
737 | swaps(&rep.mkDelay)do { if (sizeof(*(&rep.mkDelay)) != 2) wrong_size(); if ( __builtin_constant_p((uintptr_t)(&rep.mkDelay) & 1) && ((uintptr_t)(&rep.mkDelay) & 1) == 0) *(&rep.mkDelay ) = lswaps(*(&rep.mkDelay)); else swap_uint16((uint16_t * )(&rep.mkDelay)); } while (0); |
738 | swaps(&rep.mkInterval)do { if (sizeof(*(&rep.mkInterval)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&rep.mkInterval) & 1) && ((uintptr_t)(&rep.mkInterval) & 1) == 0 ) *(&rep.mkInterval) = lswaps(*(&rep.mkInterval)); else swap_uint16((uint16_t *)(&rep.mkInterval)); } while (0); |
739 | swaps(&rep.mkTimeToMax)do { if (sizeof(*(&rep.mkTimeToMax)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&rep.mkTimeToMax) & 1) && ((uintptr_t)(&rep.mkTimeToMax) & 1) == 0) *(&rep.mkTimeToMax) = lswaps(*(&rep.mkTimeToMax)) ; else swap_uint16((uint16_t *)(&rep.mkTimeToMax)); } while (0); |
740 | swaps(&rep.mkMaxSpeed)do { if (sizeof(*(&rep.mkMaxSpeed)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&rep.mkMaxSpeed) & 1) && ((uintptr_t)(&rep.mkMaxSpeed) & 1) == 0 ) *(&rep.mkMaxSpeed) = lswaps(*(&rep.mkMaxSpeed)); else swap_uint16((uint16_t *)(&rep.mkMaxSpeed)); } while (0); |
741 | swaps(&rep.mkCurve)do { if (sizeof(*(&rep.mkCurve)) != 2) wrong_size(); if ( __builtin_constant_p((uintptr_t)(&rep.mkCurve) & 1) && ((uintptr_t)(&rep.mkCurve) & 1) == 0) *(&rep.mkCurve ) = lswaps(*(&rep.mkCurve)); else swap_uint16((uint16_t * )(&rep.mkCurve)); } while (0); |
742 | swaps(&rep.axTimeout)do { if (sizeof(*(&rep.axTimeout)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&rep.axTimeout) & 1 ) && ((uintptr_t)(&rep.axTimeout) & 1) == 0) * (&rep.axTimeout) = lswaps(*(&rep.axTimeout)); else swap_uint16 ((uint16_t *)(&rep.axTimeout)); } while (0); |
743 | swapl(&rep.axtCtrlsMask)do { if (sizeof(*(&rep.axtCtrlsMask)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&rep.axtCtrlsMask) & 3) && ((uintptr_t)(&rep.axtCtrlsMask) & 3) == 0) *(&rep.axtCtrlsMask) = lswapl(*(&rep.axtCtrlsMask )); else swap_uint32((uint32_t *)(&rep.axtCtrlsMask)); } while (0); |
744 | swapl(&rep.axtCtrlsValues)do { if (sizeof(*(&rep.axtCtrlsValues)) != 4) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&rep.axtCtrlsValues ) & 3) && ((uintptr_t)(&rep.axtCtrlsValues) & 3) == 0) *(&rep.axtCtrlsValues) = lswapl(*(&rep.axtCtrlsValues )); else swap_uint32((uint32_t *)(&rep.axtCtrlsValues)); } while (0); |
745 | swaps(&rep.axtOptsMask)do { if (sizeof(*(&rep.axtOptsMask)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&rep.axtOptsMask) & 1) && ((uintptr_t)(&rep.axtOptsMask) & 1) == 0) *(&rep.axtOptsMask) = lswaps(*(&rep.axtOptsMask)) ; else swap_uint16((uint16_t *)(&rep.axtOptsMask)); } while (0); |
746 | swaps(&rep.axtOptsValues)do { if (sizeof(*(&rep.axtOptsValues)) != 2) wrong_size() ; if (__builtin_constant_p((uintptr_t)(&rep.axtOptsValues ) & 1) && ((uintptr_t)(&rep.axtOptsValues) & 1) == 0) *(&rep.axtOptsValues) = lswaps(*(&rep.axtOptsValues )); else swap_uint16((uint16_t *)(&rep.axtOptsValues)); } while (0); |
747 | swaps(&rep.axOptions)do { if (sizeof(*(&rep.axOptions)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&rep.axOptions) & 1 ) && ((uintptr_t)(&rep.axOptions) & 1) == 0) * (&rep.axOptions) = lswaps(*(&rep.axOptions)); else swap_uint16 ((uint16_t *)(&rep.axOptions)); } while (0); |
748 | } |
749 | WriteToClient(client, SIZEOF(xkbGetControlsReply)92, &rep); |
750 | return Success0; |
751 | } |
752 | |
753 | int |
754 | ProcXkbSetControls(ClientPtr client) |
755 | { |
756 | DeviceIntPtr dev, tmpd; |
757 | XkbSrvInfoPtr xkbi; |
758 | XkbControlsPtr ctrl; |
759 | XkbControlsRec new, old; |
760 | xkbControlsNotify cn; |
761 | XkbEventCauseRec cause; |
762 | XkbSrvLedInfoPtr sli; |
763 | |
764 | REQUEST(xkbSetControlsReq)xkbSetControlsReq *stuff = (xkbSetControlsReq *)client->requestBuffer; |
765 | REQUEST_SIZE_MATCH(xkbSetControlsReq)if ((sizeof(xkbSetControlsReq) >> 2) != client->req_len ) return(16); |
766 | |
767 | if (!(client->xkbClientFlags & _XkbClientInitialized(1<<15))) |
768 | return BadAccess10; |
769 | |
770 | CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixManageAccess){ int why; int tmprc = _XkbLookupKeyboard(&(dev), stuff-> deviceSpec, client, (1<<25), &why); if (tmprc != 0) { client->errorValue = ((XID)((((unsigned int)(why))<< 24)|((stuff->deviceSpec)&0xffffff))); return tmprc; }}; |
771 | CHK_MASK_LEGAL(0x01, stuff->changeCtrls, XkbAllControlsMask){ if ((stuff->changeCtrls)&(~((0xF8001FFF)))) { (client ->errorValue)= ((XID)((((unsigned int)((0x01)))<<24) |((((stuff->changeCtrls)&(~((0xF8001FFF)))))&0xffffff ))); return 2; }}; |
772 | |
773 | for (tmpd = inputInfo.devices; tmpd; tmpd = tmpd->next) { |
774 | if (!tmpd->key || !tmpd->key->xkbInfo) |
775 | continue; |
776 | if ((tmpd == dev) || |
777 | (!IsMaster(tmpd) && GetMaster(tmpd, MASTER_KEYBOARD2) == dev)) { |
778 | xkbi = tmpd->key->xkbInfo; |
779 | ctrl = xkbi->desc->ctrls; |
780 | new = *ctrl; |
781 | XkbSetCauseXkbReq(&cause, X_kbSetControls, client){ (&cause)->kc= (&cause)->event= 0, (&cause )->mjr= (XkbReqCode),(&cause)->mnr= (7); (&cause )->client= (client); }; |
782 | |
783 | if (stuff->changeCtrls & XkbInternalModsMask(1L << 28)) { |
784 | CHK_MASK_MATCH(0x02, stuff->affectInternalMods,{ if ((stuff->internalMods)&(~(stuff->affectInternalMods ))) { client->errorValue= ((XID)((((unsigned int)((0x02))) <<24)|((((stuff->internalMods)&(~(stuff->affectInternalMods ))))&0xffffff))); return 8; }} |
785 | stuff->internalMods){ if ((stuff->internalMods)&(~(stuff->affectInternalMods ))) { client->errorValue= ((XID)((((unsigned int)((0x02))) <<24)|((((stuff->internalMods)&(~(stuff->affectInternalMods ))))&0xffffff))); return 8; }}; |
786 | CHK_MASK_MATCH(0x03, stuff->affectInternalVMods,{ if ((stuff->internalVMods)&(~(stuff->affectInternalVMods ))) { client->errorValue= ((XID)((((unsigned int)((0x03))) <<24)|((((stuff->internalVMods)&(~(stuff->affectInternalVMods ))))&0xffffff))); return 8; }} |
787 | stuff->internalVMods){ if ((stuff->internalVMods)&(~(stuff->affectInternalVMods ))) { client->errorValue= ((XID)((((unsigned int)((0x03))) <<24)|((((stuff->internalVMods)&(~(stuff->affectInternalVMods ))))&0xffffff))); return 8; }}; |
788 | |
789 | new.internal.real_mods &= ~(stuff->affectInternalMods); |
790 | new.internal.real_mods |= (stuff->affectInternalMods & |
791 | stuff->internalMods); |
792 | new.internal.vmods &= ~(stuff->affectInternalVMods); |
793 | new.internal.vmods |= (stuff->affectInternalVMods & |
794 | stuff->internalVMods); |
795 | new.internal.mask = new.internal.real_mods | |
796 | XkbMaskForVMask(xkbi->desc, new.internal.vmods); |
797 | } |
798 | |
799 | if (stuff->changeCtrls & XkbIgnoreLockModsMask(1L << 29)) { |
800 | CHK_MASK_MATCH(0x4, stuff->affectIgnoreLockMods,{ if ((stuff->ignoreLockMods)&(~(stuff->affectIgnoreLockMods ))) { client->errorValue= ((XID)((((unsigned int)((0x4)))<< 24)|((((stuff->ignoreLockMods)&(~(stuff->affectIgnoreLockMods ))))&0xffffff))); return 8; }} |
801 | stuff->ignoreLockMods){ if ((stuff->ignoreLockMods)&(~(stuff->affectIgnoreLockMods ))) { client->errorValue= ((XID)((((unsigned int)((0x4)))<< 24)|((((stuff->ignoreLockMods)&(~(stuff->affectIgnoreLockMods ))))&0xffffff))); return 8; }}; |
802 | CHK_MASK_MATCH(0x5, stuff->affectIgnoreLockVMods,{ if ((stuff->ignoreLockVMods)&(~(stuff->affectIgnoreLockVMods ))) { client->errorValue= ((XID)((((unsigned int)((0x5)))<< 24)|((((stuff->ignoreLockVMods)&(~(stuff->affectIgnoreLockVMods ))))&0xffffff))); return 8; }} |
803 | stuff->ignoreLockVMods){ if ((stuff->ignoreLockVMods)&(~(stuff->affectIgnoreLockVMods ))) { client->errorValue= ((XID)((((unsigned int)((0x5)))<< 24)|((((stuff->ignoreLockVMods)&(~(stuff->affectIgnoreLockVMods ))))&0xffffff))); return 8; }}; |
804 | |
805 | new.ignore_lock.real_mods &= ~(stuff->affectIgnoreLockMods); |
806 | new.ignore_lock.real_mods |= (stuff->affectIgnoreLockMods & |
807 | stuff->ignoreLockMods); |
808 | new.ignore_lock.vmods &= ~(stuff->affectIgnoreLockVMods); |
809 | new.ignore_lock.vmods |= (stuff->affectIgnoreLockVMods & |
810 | stuff->ignoreLockVMods); |
811 | new.ignore_lock.mask = new.ignore_lock.real_mods | |
812 | XkbMaskForVMask(xkbi->desc, new.ignore_lock.vmods); |
813 | } |
814 | |
815 | CHK_MASK_MATCH(0x06, stuff->affectEnabledCtrls,{ if ((stuff->enabledCtrls)&(~(stuff->affectEnabledCtrls ))) { client->errorValue= ((XID)((((unsigned int)((0x06))) <<24)|((((stuff->enabledCtrls)&(~(stuff->affectEnabledCtrls ))))&0xffffff))); return 8; }} |
816 | stuff->enabledCtrls){ if ((stuff->enabledCtrls)&(~(stuff->affectEnabledCtrls ))) { client->errorValue= ((XID)((((unsigned int)((0x06))) <<24)|((((stuff->enabledCtrls)&(~(stuff->affectEnabledCtrls ))))&0xffffff))); return 8; }}; |
817 | if (stuff->affectEnabledCtrls) { |
818 | CHK_MASK_LEGAL(0x07, stuff->affectEnabledCtrls,{ if ((stuff->affectEnabledCtrls)&(~((0x00001FFF)))) { (client->errorValue)= ((XID)((((unsigned int)((0x07)))<< 24)|((((stuff->affectEnabledCtrls)&(~((0x00001FFF))))) &0xffffff))); return 2; }} |
819 | XkbAllBooleanCtrlsMask){ if ((stuff->affectEnabledCtrls)&(~((0x00001FFF)))) { (client->errorValue)= ((XID)((((unsigned int)((0x07)))<< 24)|((((stuff->affectEnabledCtrls)&(~((0x00001FFF))))) &0xffffff))); return 2; }}; |
820 | |
821 | new.enabled_ctrls &= ~(stuff->affectEnabledCtrls); |
822 | new.enabled_ctrls |= (stuff->affectEnabledCtrls & |
823 | stuff->enabledCtrls); |
824 | } |
825 | |
826 | if (stuff->changeCtrls & XkbRepeatKeysMask(1L << 0)) { |
827 | if (stuff->repeatDelay < 1 || stuff->repeatInterval < 1) { |
828 | client->errorValue = _XkbErrCode3(0x08, stuff->repeatDelay,((XID)((((unsigned int)(0x08))<<24)|(((((unsigned int)( stuff->repeatDelay))<<16)|(stuff->repeatInterval) )&0xffffff))) |
829 | stuff->repeatInterval)((XID)((((unsigned int)(0x08))<<24)|(((((unsigned int)( stuff->repeatDelay))<<16)|(stuff->repeatInterval) )&0xffffff))); |
830 | return BadValue2; |
831 | } |
832 | |
833 | new.repeat_delay = stuff->repeatDelay; |
834 | new.repeat_interval = stuff->repeatInterval; |
835 | } |
836 | |
837 | if (stuff->changeCtrls & XkbSlowKeysMask(1L << 1)) { |
838 | if (stuff->slowKeysDelay < 1) { |
839 | client->errorValue = _XkbErrCode2(0x09,((XID)((((unsigned int)(0x09))<<24)|((stuff->slowKeysDelay )&0xffffff))) |
840 | stuff->slowKeysDelay)((XID)((((unsigned int)(0x09))<<24)|((stuff->slowKeysDelay )&0xffffff))); |
841 | return BadValue2; |
842 | } |
843 | |
844 | new.slow_keys_delay = stuff->slowKeysDelay; |
845 | } |
846 | |
847 | if (stuff->changeCtrls & XkbBounceKeysMask(1L << 2)) { |
848 | if (stuff->debounceDelay < 1) { |
849 | client->errorValue = _XkbErrCode2(0x0A,((XID)((((unsigned int)(0x0A))<<24)|((stuff->debounceDelay )&0xffffff))) |
850 | stuff->debounceDelay)((XID)((((unsigned int)(0x0A))<<24)|((stuff->debounceDelay )&0xffffff))); |
851 | return BadValue2; |
852 | } |
853 | |
854 | new.debounce_delay = stuff->debounceDelay; |
855 | } |
856 | |
857 | if (stuff->changeCtrls & XkbMouseKeysMask(1L << 4)) { |
858 | if (stuff->mkDfltBtn > XkbMaxMouseKeysBtn4) { |
859 | client->errorValue = _XkbErrCode2(0x0B, stuff->mkDfltBtn)((XID)((((unsigned int)(0x0B))<<24)|((stuff->mkDfltBtn )&0xffffff))); |
860 | return BadValue2; |
861 | } |
862 | |
863 | new.mk_dflt_btn = stuff->mkDfltBtn; |
864 | } |
865 | |
866 | if (stuff->changeCtrls & XkbMouseKeysAccelMask(1L << 5)) { |
867 | if (stuff->mkDelay < 1 || stuff->mkInterval < 1 || |
868 | stuff->mkTimeToMax < 1 || stuff->mkMaxSpeed < 1 || |
869 | stuff->mkCurve < -1000) { |
870 | client->errorValue = _XkbErrCode2(0x0C, 0)((XID)((((unsigned int)(0x0C))<<24)|((0)&0xffffff)) ); |
871 | return BadValue2; |
872 | } |
873 | |
874 | new.mk_delay = stuff->mkDelay; |
875 | new.mk_interval = stuff->mkInterval; |
876 | new.mk_time_to_max = stuff->mkTimeToMax; |
877 | new.mk_max_speed = stuff->mkMaxSpeed; |
878 | new.mk_curve = stuff->mkCurve; |
879 | AccessXComputeCurveFactor(xkbi, &new); |
880 | } |
881 | |
882 | if (stuff->changeCtrls & XkbGroupsWrapMask(1L << 27)) { |
883 | unsigned act, num; |
884 | |
885 | act = XkbOutOfRangeGroupAction(stuff->groupsWrap)((stuff->groupsWrap)&0xc0); |
886 | switch (act) { |
887 | case XkbRedirectIntoRange(0x80): |
888 | num = XkbOutOfRangeGroupNumber(stuff->groupsWrap)(((stuff->groupsWrap)&0x30)>>4); |
889 | if (num >= new.num_groups) { |
890 | client->errorValue = _XkbErrCode3(0x0D, new.num_groups,((XID)((((unsigned int)(0x0D))<<24)|(((((unsigned int)( new.num_groups))<<16)|(num))&0xffffff))) |
891 | num)((XID)((((unsigned int)(0x0D))<<24)|(((((unsigned int)( new.num_groups))<<16)|(num))&0xffffff))); |
892 | return BadValue2; |
893 | } |
894 | case XkbWrapIntoRange(0x00): |
895 | case XkbClampIntoRange(0x40): |
896 | break; |
897 | default: |
898 | client->errorValue = _XkbErrCode2(0x0E, act)((XID)((((unsigned int)(0x0E))<<24)|((act)&0xffffff ))); |
899 | return BadValue2; |
900 | } |
901 | |
902 | new.groups_wrap = stuff->groupsWrap; |
903 | } |
904 | |
905 | CHK_MASK_LEGAL(0x0F, stuff->axOptions, XkbAX_AllOptionsMask){ if ((stuff->axOptions)&(~((0xFFF)))) { (client->errorValue )= ((XID)((((unsigned int)((0x0F)))<<24)|((((stuff-> axOptions)&(~((0xFFF)))))&0xffffff))); return 2; }}; |
906 | if (stuff->changeCtrls & XkbAccessXKeysMask(1L << 6)) { |
907 | new.ax_options = stuff->axOptions & XkbAX_AllOptionsMask(0xFFF); |
908 | } |
909 | else { |
910 | if (stuff->changeCtrls & XkbStickyKeysMask(1L << 3)) { |
911 | new.ax_options &= ~(XkbAX_SKOptionsMask(0x0C0)); |
912 | new.ax_options |= (stuff->axOptions & XkbAX_SKOptionsMask(0x0C0)); |
913 | } |
914 | |
915 | if (stuff->changeCtrls & XkbAccessXFeedbackMask(1L << 8)) { |
916 | new.ax_options &= ~(XkbAX_FBOptionsMask(0xF3F)); |
917 | new.ax_options |= (stuff->axOptions & XkbAX_FBOptionsMask(0xF3F)); |
918 | } |
919 | } |
920 | |
921 | if (stuff->changeCtrls & XkbAccessXTimeoutMask(1L << 7)) { |
922 | if (stuff->axTimeout < 1) { |
923 | client->errorValue = _XkbErrCode2(0x10, stuff->axTimeout)((XID)((((unsigned int)(0x10))<<24)|((stuff->axTimeout )&0xffffff))); |
924 | return BadValue2; |
925 | } |
926 | CHK_MASK_MATCH(0x11, stuff->axtCtrlsMask,{ if ((stuff->axtCtrlsValues)&(~(stuff->axtCtrlsMask ))) { client->errorValue= ((XID)((((unsigned int)((0x11))) <<24)|((((stuff->axtCtrlsValues)&(~(stuff->axtCtrlsMask ))))&0xffffff))); return 8; }} |
927 | stuff->axtCtrlsValues){ if ((stuff->axtCtrlsValues)&(~(stuff->axtCtrlsMask ))) { client->errorValue= ((XID)((((unsigned int)((0x11))) <<24)|((((stuff->axtCtrlsValues)&(~(stuff->axtCtrlsMask ))))&0xffffff))); return 8; }}; |
928 | CHK_MASK_LEGAL(0x12, stuff->axtCtrlsMask,{ if ((stuff->axtCtrlsMask)&(~((0x00001FFF)))) { (client ->errorValue)= ((XID)((((unsigned int)((0x12)))<<24) |((((stuff->axtCtrlsMask)&(~((0x00001FFF)))))&0xffffff ))); return 2; }} |
929 | XkbAllBooleanCtrlsMask){ if ((stuff->axtCtrlsMask)&(~((0x00001FFF)))) { (client ->errorValue)= ((XID)((((unsigned int)((0x12)))<<24) |((((stuff->axtCtrlsMask)&(~((0x00001FFF)))))&0xffffff ))); return 2; }}; |
930 | CHK_MASK_MATCH(0x13, stuff->axtOptsMask, stuff->axtOptsValues){ if ((stuff->axtOptsValues)&(~(stuff->axtOptsMask) )) { client->errorValue= ((XID)((((unsigned int)((0x13)))<< 24)|((((stuff->axtOptsValues)&(~(stuff->axtOptsMask ))))&0xffffff))); return 8; }}; |
931 | CHK_MASK_LEGAL(0x14, stuff->axtOptsMask, XkbAX_AllOptionsMask){ if ((stuff->axtOptsMask)&(~((0xFFF)))) { (client-> errorValue)= ((XID)((((unsigned int)((0x14)))<<24)|(((( stuff->axtOptsMask)&(~((0xFFF)))))&0xffffff))); return 2; }}; |
932 | new.ax_timeout = stuff->axTimeout; |
933 | new.axt_ctrls_mask = stuff->axtCtrlsMask; |
934 | new.axt_ctrls_values = (stuff->axtCtrlsValues & |
935 | stuff->axtCtrlsMask); |
936 | new.axt_opts_mask = stuff->axtOptsMask; |
937 | new.axt_opts_values = (stuff->axtOptsValues & |
938 | stuff->axtOptsMask); |
939 | } |
940 | |
941 | if (stuff->changeCtrls & XkbPerKeyRepeatMask(1L << 30)) { |
942 | memcpy(new.per_key_repeat, stuff->perKeyRepeat,__builtin___memcpy_chk (new.per_key_repeat, stuff->perKeyRepeat , ((255 +1)/8), __builtin_object_size (new.per_key_repeat, 0) ) |
943 | XkbPerKeyBitArraySize)__builtin___memcpy_chk (new.per_key_repeat, stuff->perKeyRepeat , ((255 +1)/8), __builtin_object_size (new.per_key_repeat, 0) ); |
944 | if (xkbi->repeatKey && |
945 | !BitIsOn(new.per_key_repeat, xkbi->repeatKey)(!!(((const BYTE *) (new.per_key_repeat))[(xkbi->repeatKey )>>3] & (1 << ((xkbi->repeatKey) & 7)) ))) { |
946 | AccessXCancelRepeatKey(xkbi, xkbi->repeatKey); |
947 | } |
948 | } |
949 | |
950 | old = *ctrl; |
951 | *ctrl = new; |
952 | XkbDDXChangeControls(tmpd, &old, ctrl); |
953 | |
954 | if (XkbComputeControlsNotify(tmpd, &old, ctrl, &cn, FALSE0)) { |
955 | cn.keycode = 0; |
956 | cn.eventType = 0; |
957 | cn.requestMajor = XkbReqCode; |
958 | cn.requestMinor = X_kbSetControls7; |
959 | XkbSendControlsNotify(tmpd, &cn); |
960 | } |
961 | |
962 | sli = XkbFindSrvLedInfo(tmpd, XkbDfltXIClass0x0300, XkbDfltXIId0x0400, 0); |
963 | if (sli) |
964 | XkbUpdateIndicators(tmpd, sli->usesControls, TRUE1, NULL((void*)0), |
965 | &cause); |
966 | |
967 | /* If sticky keys were disabled, clear all locks and latches */ |
968 | if ((old.enabled_ctrls & XkbStickyKeysMask(1L << 3)) && |
969 | !(ctrl->enabled_ctrls & XkbStickyKeysMask(1L << 3))) |
970 | XkbClearAllLatchesAndLocks(tmpd, xkbi, TRUE1, &cause); |
971 | } |
972 | } |
973 | |
974 | return Success0; |
975 | } |
976 | |
977 | /***====================================================================***/ |
978 | |
979 | static int |
980 | XkbSizeKeyTypes(XkbDescPtr xkb, xkbGetMapReply * rep) |
981 | { |
982 | XkbKeyTypeRec *type; |
983 | unsigned i, len; |
984 | |
985 | len = 0; |
986 | if (((rep->present & XkbKeyTypesMask(1<<0)) == 0) || (rep->nTypes < 1) || |
987 | (!xkb) || (!xkb->map) || (!xkb->map->types)) { |
988 | rep->present &= ~XkbKeyTypesMask(1<<0); |
989 | rep->firstType = rep->nTypes = 0; |
990 | return 0; |
991 | } |
992 | type = &xkb->map->types[rep->firstType]; |
993 | for (i = 0; i < rep->nTypes; i++, type++) { |
994 | len += SIZEOF(xkbKeyTypeWireDesc)8; |
995 | if (type->map_count > 0) { |
996 | len += (type->map_count * SIZEOF(xkbKTMapEntryWireDesc)8); |
997 | if (type->preserve) |
998 | len += (type->map_count * SIZEOF(xkbModsWireDesc)4); |
999 | } |
1000 | } |
1001 | return len; |
1002 | } |
1003 | |
1004 | static char * |
1005 | XkbWriteKeyTypes(XkbDescPtr xkb, |
1006 | xkbGetMapReply * rep, char *buf, ClientPtr client) |
1007 | { |
1008 | XkbKeyTypePtr type; |
1009 | unsigned i; |
1010 | xkbKeyTypeWireDesc *wire; |
1011 | |
1012 | type = &xkb->map->types[rep->firstType]; |
1013 | for (i = 0; i < rep->nTypes; i++, type++) { |
1014 | register unsigned n; |
1015 | |
1016 | wire = (xkbKeyTypeWireDesc *) buf; |
1017 | wire->mask = type->mods.mask; |
1018 | wire->realMods = type->mods.real_mods; |
1019 | wire->virtualMods = type->mods.vmods; |
1020 | wire->numLevels = type->num_levels; |
1021 | wire->nMapEntries = type->map_count; |
1022 | wire->preserve = (type->preserve != NULL((void*)0)); |
1023 | if (client->swapped) { |
1024 | swaps(&wire->virtualMods)do { if (sizeof(*(&wire->virtualMods)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&wire->virtualMods ) & 1) && ((uintptr_t)(&wire->virtualMods) & 1) == 0) *(&wire->virtualMods) = lswaps(*(& wire->virtualMods)); else swap_uint16((uint16_t *)(&wire ->virtualMods)); } while (0); |
1025 | } |
1026 | |
1027 | buf = (char *) &wire[1]; |
1028 | if (wire->nMapEntries > 0) { |
1029 | xkbKTMapEntryWireDesc *ewire; |
1030 | XkbKTMapEntryPtr entry; |
1031 | |
1032 | ewire = (xkbKTMapEntryWireDesc *) buf; |
1033 | entry = type->map; |
1034 | for (n = 0; n < type->map_count; n++, ewire++, entry++) { |
1035 | ewire->active = entry->active; |
1036 | ewire->mask = entry->mods.mask; |
1037 | ewire->level = entry->level; |
1038 | ewire->realMods = entry->mods.real_mods; |
1039 | ewire->virtualMods = entry->mods.vmods; |
1040 | if (client->swapped) { |
1041 | swaps(&ewire->virtualMods)do { if (sizeof(*(&ewire->virtualMods)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&ewire->virtualMods ) & 1) && ((uintptr_t)(&ewire->virtualMods ) & 1) == 0) *(&ewire->virtualMods) = lswaps(*(& ewire->virtualMods)); else swap_uint16((uint16_t *)(&ewire ->virtualMods)); } while (0); |
1042 | } |
1043 | } |
1044 | buf = (char *) ewire; |
1045 | if (type->preserve != NULL((void*)0)) { |
1046 | xkbModsWireDesc *pwire; |
1047 | XkbModsPtr preserve; |
1048 | |
1049 | pwire = (xkbModsWireDesc *) buf; |
1050 | preserve = type->preserve; |
1051 | for (n = 0; n < type->map_count; n++, pwire++, preserve++) { |
1052 | pwire->mask = preserve->mask; |
1053 | pwire->realMods = preserve->real_mods; |
1054 | pwire->virtualMods = preserve->vmods; |
1055 | if (client->swapped) { |
1056 | swaps(&pwire->virtualMods)do { if (sizeof(*(&pwire->virtualMods)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&pwire->virtualMods ) & 1) && ((uintptr_t)(&pwire->virtualMods ) & 1) == 0) *(&pwire->virtualMods) = lswaps(*(& pwire->virtualMods)); else swap_uint16((uint16_t *)(&pwire ->virtualMods)); } while (0); |
1057 | } |
1058 | } |
1059 | buf = (char *) pwire; |
1060 | } |
1061 | } |
1062 | } |
1063 | return buf; |
1064 | } |
1065 | |
1066 | static int |
1067 | XkbSizeKeySyms(XkbDescPtr xkb, xkbGetMapReply * rep) |
1068 | { |
1069 | XkbSymMapPtr symMap; |
1070 | unsigned i, len; |
1071 | unsigned nSyms, nSymsThisKey; |
1072 | |
1073 | if (((rep->present & XkbKeySymsMask(1<<1)) == 0) || (rep->nKeySyms < 1) || |
1074 | (!xkb) || (!xkb->map) || (!xkb->map->key_sym_map)) { |
1075 | rep->present &= ~XkbKeySymsMask(1<<1); |
1076 | rep->firstKeySym = rep->nKeySyms = 0; |
1077 | rep->totalSyms = 0; |
1078 | return 0; |
1079 | } |
1080 | len = rep->nKeySyms * SIZEOF(xkbSymMapWireDesc)8; |
1081 | symMap = &xkb->map->key_sym_map[rep->firstKeySym]; |
1082 | for (i = nSyms = 0; i < rep->nKeySyms; i++, symMap++) { |
1083 | if (symMap->offset != 0) { |
1084 | nSymsThisKey = XkbNumGroups(symMap->group_info)((symMap->group_info)&0x0f) * symMap->width; |
1085 | nSyms += nSymsThisKey; |
1086 | } |
1087 | } |
1088 | len += nSyms * 4; |
1089 | rep->totalSyms = nSyms; |
1090 | return len; |
1091 | } |
1092 | |
1093 | static int |
1094 | XkbSizeVirtualMods(XkbDescPtr xkb, xkbGetMapReply * rep) |
1095 | { |
1096 | register unsigned i, nMods, bit; |
1097 | |
1098 | if (((rep->present & XkbVirtualModsMask(1<<6)) == 0) || (rep->virtualMods == 0) || |
1099 | (!xkb) || (!xkb->server)) { |
1100 | rep->present &= ~XkbVirtualModsMask(1<<6); |
1101 | rep->virtualMods = 0; |
1102 | return 0; |
1103 | } |
1104 | for (i = nMods = 0, bit = 1; i < XkbNumVirtualMods16; i++, bit <<= 1) { |
1105 | if (rep->virtualMods & bit) |
1106 | nMods++; |
1107 | } |
1108 | return XkbPaddedSize(nMods)((((unsigned int)(nMods)+3) >> 2) << 2); |
1109 | } |
1110 | |
1111 | static char * |
1112 | XkbWriteKeySyms(XkbDescPtr xkb, xkbGetMapReply * rep, char *buf, |
1113 | ClientPtr client) |
1114 | { |
1115 | register KeySym *pSym; |
1116 | XkbSymMapPtr symMap; |
1117 | xkbSymMapWireDesc *outMap; |
1118 | register unsigned i; |
1119 | |
1120 | symMap = &xkb->map->key_sym_map[rep->firstKeySym]; |
1121 | for (i = 0; i < rep->nKeySyms; i++, symMap++) { |
1122 | outMap = (xkbSymMapWireDesc *) buf; |
1123 | outMap->ktIndex[0] = symMap->kt_index[0]; |
1124 | outMap->ktIndex[1] = symMap->kt_index[1]; |
1125 | outMap->ktIndex[2] = symMap->kt_index[2]; |
1126 | outMap->ktIndex[3] = symMap->kt_index[3]; |
1127 | outMap->groupInfo = symMap->group_info; |
1128 | outMap->width = symMap->width; |
1129 | outMap->nSyms = symMap->width * XkbNumGroups(symMap->group_info)((symMap->group_info)&0x0f); |
1130 | buf = (char *) &outMap[1]; |
1131 | if (outMap->nSyms == 0) |
1132 | continue; |
1133 | |
1134 | pSym = &xkb->map->syms[symMap->offset]; |
1135 | memcpy((char *) buf, (char *) pSym, outMap->nSyms * 4)__builtin___memcpy_chk ((char *) buf, (char *) pSym, outMap-> nSyms * 4, __builtin_object_size ((char *) buf, 0)); |
1136 | if (client->swapped) { |
1137 | register int nSyms = outMap->nSyms; |
1138 | |
1139 | swaps(&outMap->nSyms)do { if (sizeof(*(&outMap->nSyms)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&outMap->nSyms) & 1) && ((uintptr_t)(&outMap->nSyms) & 1) == 0) *(&outMap->nSyms) = lswaps(*(&outMap->nSyms )); else swap_uint16((uint16_t *)(&outMap->nSyms)); } while (0); |
1140 | while (nSyms-- > 0) { |
1141 | swapl((int *) buf)do { if (sizeof(*((int *) buf)) != 4) wrong_size(); if (__builtin_constant_p ((uintptr_t)((int *) buf) & 3) && ((uintptr_t)((int *) buf) & 3) == 0) *((int *) buf) = lswapl(*((int *) buf )); else swap_uint32((uint32_t *)((int *) buf)); } while (0); |
1142 | buf += 4; |
1143 | } |
1144 | } |
1145 | else |
1146 | buf += outMap->nSyms * 4; |
1147 | } |
1148 | return buf; |
1149 | } |
1150 | |
1151 | static int |
1152 | XkbSizeKeyActions(XkbDescPtr xkb, xkbGetMapReply * rep) |
1153 | { |
1154 | unsigned i, len, nActs; |
1155 | register KeyCode firstKey; |
1156 | |
1157 | if (((rep->present & XkbKeyActionsMask(1<<4)) == 0) || (rep->nKeyActs < 1) || |
1158 | (!xkb) || (!xkb->server) || (!xkb->server->key_acts)) { |
1159 | rep->present &= ~XkbKeyActionsMask(1<<4); |
1160 | rep->firstKeyAct = rep->nKeyActs = 0; |
1161 | rep->totalActs = 0; |
1162 | return 0; |
1163 | } |
1164 | firstKey = rep->firstKeyAct; |
1165 | for (nActs = i = 0; i < rep->nKeyActs; i++) { |
1166 | if (xkb->server->key_acts[i + firstKey] != 0) |
1167 | nActs += XkbKeyNumActions(xkb, i + firstKey)((!!((xkb))->server->key_acts[((i + firstKey))]) ? (((( (((xkb))->map))->key_sym_map[((((i + firstKey))))].width ) * (((((((xkb))->map))->key_sym_map[((((i + firstKey)) ))].group_info)&0x0f)))) : 1); |
1168 | } |
1169 | len = XkbPaddedSize(rep->nKeyActs)((((unsigned int)(rep->nKeyActs)+3) >> 2) << 2 ) + (nActs * SIZEOF(xkbActionWireDesc)8); |
1170 | rep->totalActs = nActs; |
1171 | return len; |
1172 | } |
1173 | |
1174 | static char * |
1175 | XkbWriteKeyActions(XkbDescPtr xkb, xkbGetMapReply * rep, char *buf, |
1176 | ClientPtr client) |
1177 | { |
1178 | unsigned i; |
1179 | CARD8 *numDesc; |
1180 | XkbAnyAction *actDesc; |
1181 | |
1182 | numDesc = (CARD8 *) buf; |
1183 | for (i = 0; i < rep->nKeyActs; i++) { |
1184 | if (xkb->server->key_acts[i + rep->firstKeyAct] == 0) |
1185 | numDesc[i] = 0; |
1186 | else |
1187 | numDesc[i] = XkbKeyNumActions(xkb, (i + rep->firstKeyAct))((!!((xkb))->server->key_acts[(((i + rep->firstKeyAct )))]) ? (((((((xkb))->map))->key_sym_map[(((((i + rep-> firstKeyAct)))))].width) * (((((((xkb))->map))->key_sym_map [(((((i + rep->firstKeyAct)))))].group_info)&0x0f)))) : 1); |
1188 | } |
1189 | buf += XkbPaddedSize(rep->nKeyActs)((((unsigned int)(rep->nKeyActs)+3) >> 2) << 2 ); |
1190 | |
1191 | actDesc = (XkbAnyAction *) buf; |
1192 | for (i = 0; i < rep->nKeyActs; i++) { |
1193 | if (xkb->server->key_acts[i + rep->firstKeyAct] != 0) { |
1194 | unsigned int num; |
1195 | |
1196 | num = XkbKeyNumActions(xkb, (i + rep->firstKeyAct))((!!((xkb))->server->key_acts[(((i + rep->firstKeyAct )))]) ? (((((((xkb))->map))->key_sym_map[(((((i + rep-> firstKeyAct)))))].width) * (((((((xkb))->map))->key_sym_map [(((((i + rep->firstKeyAct)))))].group_info)&0x0f)))) : 1); |
1197 | memcpy((char *) actDesc,__builtin___memcpy_chk ((char *) actDesc, (char *) ((&((xkb )->server)->acts[((xkb)->server)->key_acts[(((i + rep->firstKeyAct)))]])), num * 8, __builtin_object_size ( (char *) actDesc, 0)) |
1198 | (char *) XkbKeyActionsPtr(xkb, (i + rep->firstKeyAct)),__builtin___memcpy_chk ((char *) actDesc, (char *) ((&((xkb )->server)->acts[((xkb)->server)->key_acts[(((i + rep->firstKeyAct)))]])), num * 8, __builtin_object_size ( (char *) actDesc, 0)) |
1199 | num * SIZEOF(xkbActionWireDesc))__builtin___memcpy_chk ((char *) actDesc, (char *) ((&((xkb )->server)->acts[((xkb)->server)->key_acts[(((i + rep->firstKeyAct)))]])), num * 8, __builtin_object_size ( (char *) actDesc, 0)); |
1200 | actDesc += num; |
1201 | } |
1202 | } |
1203 | buf = (char *) actDesc; |
1204 | return buf; |
1205 | } |
1206 | |
1207 | static int |
1208 | XkbSizeKeyBehaviors(XkbDescPtr xkb, xkbGetMapReply * rep) |
1209 | { |
1210 | unsigned i, len, nBhvr; |
1211 | XkbBehavior *bhv; |
1212 | |
1213 | if (((rep->present & XkbKeyBehaviorsMask(1<<5)) == 0) || (rep->nKeyBehaviors < 1) |
1214 | || (!xkb) || (!xkb->server) || (!xkb->server->behaviors)) { |
1215 | rep->present &= ~XkbKeyBehaviorsMask(1<<5); |
1216 | rep->firstKeyBehavior = rep->nKeyBehaviors = 0; |
1217 | rep->totalKeyBehaviors = 0; |
1218 | return 0; |
1219 | } |
1220 | bhv = &xkb->server->behaviors[rep->firstKeyBehavior]; |
1221 | for (nBhvr = i = 0; i < rep->nKeyBehaviors; i++, bhv++) { |
1222 | if (bhv->type != XkbKB_Default0x00) |
1223 | nBhvr++; |
1224 | } |
1225 | len = nBhvr * SIZEOF(xkbBehaviorWireDesc)4; |
1226 | rep->totalKeyBehaviors = nBhvr; |
1227 | return len; |
1228 | } |
1229 | |
1230 | static char * |
1231 | XkbWriteKeyBehaviors(XkbDescPtr xkb, xkbGetMapReply * rep, char *buf, |
1232 | ClientPtr client) |
1233 | { |
1234 | unsigned i; |
1235 | xkbBehaviorWireDesc *wire; |
1236 | XkbBehavior *pBhvr; |
1237 | |
1238 | wire = (xkbBehaviorWireDesc *) buf; |
1239 | pBhvr = &xkb->server->behaviors[rep->firstKeyBehavior]; |
1240 | for (i = 0; i < rep->nKeyBehaviors; i++, pBhvr++) { |
1241 | if (pBhvr->type != XkbKB_Default0x00) { |
1242 | wire->key = i + rep->firstKeyBehavior; |
1243 | wire->type = pBhvr->type; |
1244 | wire->data = pBhvr->data; |
1245 | wire++; |
1246 | } |
1247 | } |
1248 | buf = (char *) wire; |
1249 | return buf; |
1250 | } |
1251 | |
1252 | static int |
1253 | XkbSizeExplicit(XkbDescPtr xkb, xkbGetMapReply * rep) |
1254 | { |
1255 | unsigned i, len, nRtrn; |
1256 | |
1257 | if (((rep->present & XkbExplicitComponentsMask(1<<3)) == 0) || |
1258 | (rep->nKeyExplicit < 1) || (!xkb) || (!xkb->server) || |
1259 | (!xkb->server->explicit)) { |
1260 | rep->present &= ~XkbExplicitComponentsMask(1<<3); |
1261 | rep->firstKeyExplicit = rep->nKeyExplicit = 0; |
1262 | rep->totalKeyExplicit = 0; |
1263 | return 0; |
1264 | } |
1265 | for (nRtrn = i = 0; i < rep->nKeyExplicit; i++) { |
1266 | if (xkb->server->explicit[i + rep->firstKeyExplicit] != 0) |
1267 | nRtrn++; |
1268 | } |
1269 | rep->totalKeyExplicit = nRtrn; |
1270 | len = XkbPaddedSize(nRtrn * 2)((((unsigned int)(nRtrn * 2)+3) >> 2) << 2); /* two bytes per non-zero explicit component */ |
1271 | return len; |
1272 | } |
1273 | |
1274 | static char * |
1275 | XkbWriteExplicit(XkbDescPtr xkb, xkbGetMapReply * rep, char *buf, |
1276 | ClientPtr client) |
1277 | { |
1278 | unsigned i; |
1279 | char *start; |
1280 | unsigned char *pExp; |
1281 | |
1282 | start = buf; |
1283 | pExp = &xkb->server->explicit[rep->firstKeyExplicit]; |
1284 | for (i = 0; i < rep->nKeyExplicit; i++, pExp++) { |
1285 | if (*pExp != 0) { |
1286 | *buf++ = i + rep->firstKeyExplicit; |
1287 | *buf++ = *pExp; |
1288 | } |
1289 | } |
1290 | i = XkbPaddedSize(buf - start)((((unsigned int)(buf - start)+3) >> 2) << 2) - (buf - start); /* pad to word boundary */ |
1291 | return buf + i; |
1292 | } |
1293 | |
1294 | static int |
1295 | XkbSizeModifierMap(XkbDescPtr xkb, xkbGetMapReply * rep) |
1296 | { |
1297 | unsigned i, len, nRtrn; |
1298 | |
1299 | if (((rep->present & XkbModifierMapMask(1<<2)) == 0) || (rep->nModMapKeys < 1) || |
1300 | (!xkb) || (!xkb->map) || (!xkb->map->modmap)) { |
1301 | rep->present &= ~XkbModifierMapMask(1<<2); |
1302 | rep->firstModMapKey = rep->nModMapKeys = 0; |
1303 | rep->totalModMapKeys = 0; |
1304 | return 0; |
1305 | } |
1306 | for (nRtrn = i = 0; i < rep->nModMapKeys; i++) { |
1307 | if (xkb->map->modmap[i + rep->firstModMapKey] != 0) |
1308 | nRtrn++; |
1309 | } |
1310 | rep->totalModMapKeys = nRtrn; |
1311 | len = XkbPaddedSize(nRtrn * 2)((((unsigned int)(nRtrn * 2)+3) >> 2) << 2); /* two bytes per non-zero modmap component */ |
1312 | return len; |
1313 | } |
1314 | |
1315 | static char * |
1316 | XkbWriteModifierMap(XkbDescPtr xkb, xkbGetMapReply * rep, char *buf, |
1317 | ClientPtr client) |
1318 | { |
1319 | unsigned i; |
1320 | char *start; |
1321 | unsigned char *pMap; |
1322 | |
1323 | start = buf; |
1324 | pMap = &xkb->map->modmap[rep->firstModMapKey]; |
1325 | for (i = 0; i < rep->nModMapKeys; i++, pMap++) { |
1326 | if (*pMap != 0) { |
1327 | *buf++ = i + rep->firstModMapKey; |
1328 | *buf++ = *pMap; |
1329 | } |
1330 | } |
1331 | i = XkbPaddedSize(buf - start)((((unsigned int)(buf - start)+3) >> 2) << 2) - (buf - start); /* pad to word boundary */ |
1332 | return buf + i; |
1333 | } |
1334 | |
1335 | static int |
1336 | XkbSizeVirtualModMap(XkbDescPtr xkb, xkbGetMapReply * rep) |
1337 | { |
1338 | unsigned i, len, nRtrn; |
1339 | |
1340 | if (((rep->present & XkbVirtualModMapMask(1<<7)) == 0) || (rep->nVModMapKeys < 1) |
1341 | || (!xkb) || (!xkb->server) || (!xkb->server->vmodmap)) { |
1342 | rep->present &= ~XkbVirtualModMapMask(1<<7); |
1343 | rep->firstVModMapKey = rep->nVModMapKeys = 0; |
1344 | rep->totalVModMapKeys = 0; |
1345 | return 0; |
1346 | } |
1347 | for (nRtrn = i = 0; i < rep->nVModMapKeys; i++) { |
1348 | if (xkb->server->vmodmap[i + rep->firstVModMapKey] != 0) |
1349 | nRtrn++; |
1350 | } |
1351 | rep->totalVModMapKeys = nRtrn; |
1352 | len = nRtrn * SIZEOF(xkbVModMapWireDesc)4; |
1353 | return len; |
1354 | } |
1355 | |
1356 | static char * |
1357 | XkbWriteVirtualModMap(XkbDescPtr xkb, xkbGetMapReply * rep, char *buf, |
1358 | ClientPtr client) |
1359 | { |
1360 | unsigned i; |
1361 | xkbVModMapWireDesc *wire; |
1362 | unsigned short *pMap; |
1363 | |
1364 | wire = (xkbVModMapWireDesc *) buf; |
1365 | pMap = &xkb->server->vmodmap[rep->firstVModMapKey]; |
1366 | for (i = 0; i < rep->nVModMapKeys; i++, pMap++) { |
1367 | if (*pMap != 0) { |
1368 | wire->key = i + rep->firstVModMapKey; |
1369 | wire->vmods = *pMap; |
1370 | wire++; |
1371 | } |
1372 | } |
1373 | return (char *) wire; |
1374 | } |
1375 | |
1376 | static Statusint |
1377 | XkbComputeGetMapReplySize(XkbDescPtr xkb, xkbGetMapReply * rep) |
1378 | { |
1379 | int len; |
1380 | |
1381 | rep->minKeyCode = xkb->min_key_code; |
1382 | rep->maxKeyCode = xkb->max_key_code; |
1383 | len = XkbSizeKeyTypes(xkb, rep); |
1384 | len += XkbSizeKeySyms(xkb, rep); |
1385 | len += XkbSizeKeyActions(xkb, rep); |
1386 | len += XkbSizeKeyBehaviors(xkb, rep); |
1387 | len += XkbSizeVirtualMods(xkb, rep); |
1388 | len += XkbSizeExplicit(xkb, rep); |
1389 | len += XkbSizeModifierMap(xkb, rep); |
1390 | len += XkbSizeVirtualModMap(xkb, rep); |
1391 | rep->length += (len / 4); |
1392 | return Success0; |
1393 | } |
1394 | |
1395 | static int |
1396 | XkbSendMap(ClientPtr client, XkbDescPtr xkb, xkbGetMapReply * rep) |
1397 | { |
1398 | unsigned i, len; |
1399 | char *desc, *start; |
1400 | |
1401 | len = (rep->length * 4) - (SIZEOF(xkbGetMapReply)40 - SIZEOF(xGenericReply)32); |
1402 | start = desc = calloc(1, len); |
1403 | if (!start) |
1404 | return BadAlloc11; |
1405 | if (rep->nTypes > 0) |
1406 | desc = XkbWriteKeyTypes(xkb, rep, desc, client); |
1407 | if (rep->nKeySyms > 0) |
1408 | desc = XkbWriteKeySyms(xkb, rep, desc, client); |
1409 | if (rep->nKeyActs > 0) |
1410 | desc = XkbWriteKeyActions(xkb, rep, desc, client); |
1411 | if (rep->totalKeyBehaviors > 0) |
1412 | desc = XkbWriteKeyBehaviors(xkb, rep, desc, client); |
1413 | if (rep->virtualMods) { |
1414 | register int sz, bit; |
1415 | |
1416 | for (i = sz = 0, bit = 1; i < XkbNumVirtualMods16; i++, bit <<= 1) { |
1417 | if (rep->virtualMods & bit) { |
1418 | desc[sz++] = xkb->server->vmods[i]; |
1419 | } |
1420 | } |
1421 | desc += XkbPaddedSize(sz)((((unsigned int)(sz)+3) >> 2) << 2); |
1422 | } |
1423 | if (rep->totalKeyExplicit > 0) |
1424 | desc = XkbWriteExplicit(xkb, rep, desc, client); |
1425 | if (rep->totalModMapKeys > 0) |
1426 | desc = XkbWriteModifierMap(xkb, rep, desc, client); |
1427 | if (rep->totalVModMapKeys > 0) |
1428 | desc = XkbWriteVirtualModMap(xkb, rep, desc, client); |
1429 | if ((desc - start) != (len)) { |
1430 | ErrorF |
1431 | ("[xkb] BOGUS LENGTH in write keyboard desc, expected %d, got %ld\n", |
1432 | len, (unsigned long) (desc - start)); |
1433 | } |
1434 | if (client->swapped) { |
1435 | swaps(&rep->sequenceNumber)do { if (sizeof(*(&rep->sequenceNumber)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&rep->sequenceNumber ) & 1) && ((uintptr_t)(&rep->sequenceNumber ) & 1) == 0) *(&rep->sequenceNumber) = lswaps(*(& rep->sequenceNumber)); else swap_uint16((uint16_t *)(& rep->sequenceNumber)); } while (0); |
1436 | swapl(&rep->length)do { if (sizeof(*(&rep->length)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&rep->length) & 3) && ((uintptr_t)(&rep->length) & 3) == 0 ) *(&rep->length) = lswapl(*(&rep->length)); else swap_uint32((uint32_t *)(&rep->length)); } while (0); |
1437 | swaps(&rep->present)do { if (sizeof(*(&rep->present)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&rep->present) & 1) && ((uintptr_t)(&rep->present) & 1) == 0) *(&rep->present) = lswaps(*(&rep->present)) ; else swap_uint16((uint16_t *)(&rep->present)); } while (0); |
1438 | swaps(&rep->totalSyms)do { if (sizeof(*(&rep->totalSyms)) != 2) wrong_size() ; if (__builtin_constant_p((uintptr_t)(&rep->totalSyms ) & 1) && ((uintptr_t)(&rep->totalSyms) & 1) == 0) *(&rep->totalSyms) = lswaps(*(&rep->totalSyms )); else swap_uint16((uint16_t *)(&rep->totalSyms)); } while (0); |
1439 | swaps(&rep->totalActs)do { if (sizeof(*(&rep->totalActs)) != 2) wrong_size() ; if (__builtin_constant_p((uintptr_t)(&rep->totalActs ) & 1) && ((uintptr_t)(&rep->totalActs) & 1) == 0) *(&rep->totalActs) = lswaps(*(&rep->totalActs )); else swap_uint16((uint16_t *)(&rep->totalActs)); } while (0); |
1440 | } |
1441 | WriteToClient(client, (i = SIZEOF(xkbGetMapReply)40), rep); |
1442 | WriteToClient(client, len, start); |
1443 | free((char *) start); |
1444 | return Success0; |
1445 | } |
1446 | |
1447 | int |
1448 | ProcXkbGetMap(ClientPtr client) |
1449 | { |
1450 | DeviceIntPtr dev; |
1451 | xkbGetMapReply rep; |
1452 | XkbDescRec *xkb; |
1453 | int n, status; |
1454 | |
1455 | REQUEST(xkbGetMapReq)xkbGetMapReq *stuff = (xkbGetMapReq *)client->requestBuffer; |
1456 | REQUEST_SIZE_MATCH(xkbGetMapReq)if ((sizeof(xkbGetMapReq) >> 2) != client->req_len) return (16); |
1457 | |
1458 | if (!(client->xkbClientFlags & _XkbClientInitialized(1<<15))) |
1459 | return BadAccess10; |
1460 | |
1461 | CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixGetAttrAccess){ int why; int tmprc = _XkbLookupKeyboard(&(dev), stuff-> deviceSpec, client, (1<<4), &why); if (tmprc != 0) { client->errorValue = ((XID)((((unsigned int)(why))<< 24)|((stuff->deviceSpec)&0xffffff))); return tmprc; }}; |
1462 | CHK_MASK_OVERLAP(0x01, stuff->full, stuff->partial){ if ((stuff->full)&(stuff->partial)) { client-> errorValue= ((XID)((((unsigned int)((0x01)))<<24)|((((stuff ->full)&(stuff->partial)))&0xffffff))); return 8 ; }}; |
1463 | CHK_MASK_LEGAL(0x02, stuff->full, XkbAllMapComponentsMask){ if ((stuff->full)&(~((((1<<0)|(1<<1)|(1<< 2))|((1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<< 7)))))) { (client->errorValue)= ((XID)((((unsigned int)((0x02 )))<<24)|((((stuff->full)&(~((((1<<0)|(1<< 1)|(1<<2))|((1<<3)|(1<<4)|(1<<5)|(1<< 6)|(1<<7)))))))&0xffffff))); return 2; }}; |
1464 | CHK_MASK_LEGAL(0x03, stuff->partial, XkbAllMapComponentsMask){ if ((stuff->partial)&(~((((1<<0)|(1<<1)| (1<<2))|((1<<3)|(1<<4)|(1<<5)|(1<< 6)|(1<<7)))))) { (client->errorValue)= ((XID)((((unsigned int)((0x03)))<<24)|((((stuff->partial)&(~((((1<< 0)|(1<<1)|(1<<2))|((1<<3)|(1<<4)|(1<< 5)|(1<<6)|(1<<7)))))))&0xffffff))); return 2; }}; |
1465 | |
1466 | xkb = dev->key->xkbInfo->desc; |
1467 | rep = (xkbGetMapReply) { |
1468 | .type = X_Reply1, |
1469 | .deviceID = dev->id, |
1470 | .sequenceNumber = client->sequence, |
1471 | .length = (SIZEOF(xkbGetMapReply)40 - SIZEOF(xGenericReply)32) >> 2, |
1472 | .present = stuff->partial | stuff->full, |
1473 | .minKeyCode = xkb->min_key_code, |
1474 | .maxKeyCode = xkb->max_key_code |
1475 | }; |
1476 | |
1477 | if (stuff->full & XkbKeyTypesMask(1<<0)) { |
1478 | rep.firstType = 0; |
1479 | rep.nTypes = xkb->map->num_types; |
1480 | } |
1481 | else if (stuff->partial & XkbKeyTypesMask(1<<0)) { |
1482 | if (((unsigned) stuff->firstType + stuff->nTypes) > xkb->map->num_types) { |
1483 | client->errorValue = _XkbErrCode4(0x04, xkb->map->num_types,((XID)((((unsigned int)(0x04))<<24)|(((((unsigned int)( xkb->map->num_types))<<16)|(((((unsigned int)(stuff ->firstType))<<8)|(stuff->nTypes))))&0xffffff ))) |
1484 | stuff->firstType, stuff->nTypes)((XID)((((unsigned int)(0x04))<<24)|(((((unsigned int)( xkb->map->num_types))<<16)|(((((unsigned int)(stuff ->firstType))<<8)|(stuff->nTypes))))&0xffffff ))); |
1485 | return BadValue2; |
1486 | } |
1487 | rep.firstType = stuff->firstType; |
1488 | rep.nTypes = stuff->nTypes; |
1489 | } |
1490 | else |
1491 | rep.nTypes = 0; |
1492 | rep.totalTypes = xkb->map->num_types; |
1493 | |
1494 | n = XkbNumKeys(xkb)((xkb)->max_key_code-(xkb)->min_key_code+1); |
1495 | if (stuff->full & XkbKeySymsMask(1<<1)) { |
1496 | rep.firstKeySym = xkb->min_key_code; |
1497 | rep.nKeySyms = n; |
1498 | } |
1499 | else if (stuff->partial & XkbKeySymsMask(1<<1)) { |
1500 | CHK_KEY_RANGE(0x05, stuff->firstKeySym, stuff->nKeySyms, xkb){ if (((unsigned)(stuff->firstKeySym)+(stuff->nKeySyms) -1)>(xkb)->max_key_code) { (client->errorValue)=((XID )((((unsigned int)(0x05))<<24)|(((((unsigned int)((stuff ->firstKeySym)))<<16)|(((((unsigned int)((stuff-> nKeySyms)))<<8)|((xkb)->max_key_code))))&0xffffff ))); return 2; } else if ( (stuff->firstKeySym)<(xkb)-> min_key_code ) { (client->errorValue)=((XID)((((unsigned int )(0x05 +1))<<24)|(((((unsigned int)((stuff->firstKeySym )))<<16)|(xkb->min_key_code))&0xffffff))); return 2; }}; |
1501 | rep.firstKeySym = stuff->firstKeySym; |
1502 | rep.nKeySyms = stuff->nKeySyms; |
1503 | } |
1504 | else |
1505 | rep.nKeySyms = 0; |
1506 | rep.totalSyms = 0; |
1507 | |
1508 | if (stuff->full & XkbKeyActionsMask(1<<4)) { |
1509 | rep.firstKeyAct = xkb->min_key_code; |
1510 | rep.nKeyActs = n; |
1511 | } |
1512 | else if (stuff->partial & XkbKeyActionsMask(1<<4)) { |
1513 | CHK_KEY_RANGE(0x07, stuff->firstKeyAct, stuff->nKeyActs, xkb){ if (((unsigned)(stuff->firstKeyAct)+(stuff->nKeyActs) -1)>(xkb)->max_key_code) { (client->errorValue)=((XID )((((unsigned int)(0x07))<<24)|(((((unsigned int)((stuff ->firstKeyAct)))<<16)|(((((unsigned int)((stuff-> nKeyActs)))<<8)|((xkb)->max_key_code))))&0xffffff ))); return 2; } else if ( (stuff->firstKeyAct)<(xkb)-> min_key_code ) { (client->errorValue)=((XID)((((unsigned int )(0x07 +1))<<24)|(((((unsigned int)((stuff->firstKeyAct )))<<16)|(xkb->min_key_code))&0xffffff))); return 2; }}; |
1514 | rep.firstKeyAct = stuff->firstKeyAct; |
1515 | rep.nKeyActs = stuff->nKeyActs; |
1516 | } |
1517 | else |
1518 | rep.nKeyActs = 0; |
1519 | rep.totalActs = 0; |
1520 | |
1521 | if (stuff->full & XkbKeyBehaviorsMask(1<<5)) { |
1522 | rep.firstKeyBehavior = xkb->min_key_code; |
1523 | rep.nKeyBehaviors = n; |
1524 | } |
1525 | else if (stuff->partial & XkbKeyBehaviorsMask(1<<5)) { |
1526 | CHK_KEY_RANGE(0x09, stuff->firstKeyBehavior, stuff->nKeyBehaviors, xkb){ if (((unsigned)(stuff->firstKeyBehavior)+(stuff->nKeyBehaviors )-1)>(xkb)->max_key_code) { (client->errorValue)=((XID )((((unsigned int)(0x09))<<24)|(((((unsigned int)((stuff ->firstKeyBehavior)))<<16)|(((((unsigned int)((stuff ->nKeyBehaviors)))<<8)|((xkb)->max_key_code))))& 0xffffff))); return 2; } else if ( (stuff->firstKeyBehavior )<(xkb)->min_key_code ) { (client->errorValue)=((XID )((((unsigned int)(0x09 +1))<<24)|(((((unsigned int)((stuff ->firstKeyBehavior)))<<16)|(xkb->min_key_code))& 0xffffff))); return 2; }}; |
1527 | rep.firstKeyBehavior = stuff->firstKeyBehavior; |
1528 | rep.nKeyBehaviors = stuff->nKeyBehaviors; |
1529 | } |
1530 | else |
1531 | rep.nKeyBehaviors = 0; |
1532 | rep.totalKeyBehaviors = 0; |
1533 | |
1534 | if (stuff->full & XkbVirtualModsMask(1<<6)) |
1535 | rep.virtualMods = ~0; |
1536 | else if (stuff->partial & XkbVirtualModsMask(1<<6)) |
1537 | rep.virtualMods = stuff->virtualMods; |
1538 | |
1539 | if (stuff->full & XkbExplicitComponentsMask(1<<3)) { |
1540 | rep.firstKeyExplicit = xkb->min_key_code; |
1541 | rep.nKeyExplicit = n; |
1542 | } |
1543 | else if (stuff->partial & XkbExplicitComponentsMask(1<<3)) { |
1544 | CHK_KEY_RANGE(0x0B, stuff->firstKeyExplicit, stuff->nKeyExplicit, xkb){ if (((unsigned)(stuff->firstKeyExplicit)+(stuff->nKeyExplicit )-1)>(xkb)->max_key_code) { (client->errorValue)=((XID )((((unsigned int)(0x0B))<<24)|(((((unsigned int)((stuff ->firstKeyExplicit)))<<16)|(((((unsigned int)((stuff ->nKeyExplicit)))<<8)|((xkb)->max_key_code))))& 0xffffff))); return 2; } else if ( (stuff->firstKeyExplicit )<(xkb)->min_key_code ) { (client->errorValue)=((XID )((((unsigned int)(0x0B +1))<<24)|(((((unsigned int)((stuff ->firstKeyExplicit)))<<16)|(xkb->min_key_code))& 0xffffff))); return 2; }}; |
1545 | rep.firstKeyExplicit = stuff->firstKeyExplicit; |
1546 | rep.nKeyExplicit = stuff->nKeyExplicit; |
1547 | } |
1548 | else |
1549 | rep.nKeyExplicit = 0; |
1550 | rep.totalKeyExplicit = 0; |
1551 | |
1552 | if (stuff->full & XkbModifierMapMask(1<<2)) { |
1553 | rep.firstModMapKey = xkb->min_key_code; |
1554 | rep.nModMapKeys = n; |
1555 | } |
1556 | else if (stuff->partial & XkbModifierMapMask(1<<2)) { |
1557 | CHK_KEY_RANGE(0x0D, stuff->firstModMapKey, stuff->nModMapKeys, xkb){ if (((unsigned)(stuff->firstModMapKey)+(stuff->nModMapKeys )-1)>(xkb)->max_key_code) { (client->errorValue)=((XID )((((unsigned int)(0x0D))<<24)|(((((unsigned int)((stuff ->firstModMapKey)))<<16)|(((((unsigned int)((stuff-> nModMapKeys)))<<8)|((xkb)->max_key_code))))&0xffffff ))); return 2; } else if ( (stuff->firstModMapKey)<(xkb )->min_key_code ) { (client->errorValue)=((XID)((((unsigned int)(0x0D +1))<<24)|(((((unsigned int)((stuff->firstModMapKey )))<<16)|(xkb->min_key_code))&0xffffff))); return 2; }}; |
1558 | rep.firstModMapKey = stuff->firstModMapKey; |
1559 | rep.nModMapKeys = stuff->nModMapKeys; |
1560 | } |
1561 | else |
1562 | rep.nModMapKeys = 0; |
1563 | rep.totalModMapKeys = 0; |
1564 | |
1565 | if (stuff->full & XkbVirtualModMapMask(1<<7)) { |
1566 | rep.firstVModMapKey = xkb->min_key_code; |
1567 | rep.nVModMapKeys = n; |
1568 | } |
1569 | else if (stuff->partial & XkbVirtualModMapMask(1<<7)) { |
1570 | CHK_KEY_RANGE(0x0F, stuff->firstVModMapKey, stuff->nVModMapKeys, xkb){ if (((unsigned)(stuff->firstVModMapKey)+(stuff->nVModMapKeys )-1)>(xkb)->max_key_code) { (client->errorValue)=((XID )((((unsigned int)(0x0F))<<24)|(((((unsigned int)((stuff ->firstVModMapKey)))<<16)|(((((unsigned int)((stuff-> nVModMapKeys)))<<8)|((xkb)->max_key_code))))&0xffffff ))); return 2; } else if ( (stuff->firstVModMapKey)<(xkb )->min_key_code ) { (client->errorValue)=((XID)((((unsigned int)(0x0F +1))<<24)|(((((unsigned int)((stuff->firstVModMapKey )))<<16)|(xkb->min_key_code))&0xffffff))); return 2; }}; |
1571 | rep.firstVModMapKey = stuff->firstVModMapKey; |
1572 | rep.nVModMapKeys = stuff->nVModMapKeys; |
1573 | } |
1574 | else |
1575 | rep.nVModMapKeys = 0; |
1576 | rep.totalVModMapKeys = 0; |
1577 | |
1578 | if ((status = XkbComputeGetMapReplySize(xkb, &rep)) != Success0) |
1579 | return status; |
1580 | return XkbSendMap(client, xkb, &rep); |
1581 | } |
1582 | |
1583 | /***====================================================================***/ |
1584 | |
1585 | static int |
1586 | CheckKeyTypes(ClientPtr client, |
1587 | XkbDescPtr xkb, |
1588 | xkbSetMapReq * req, |
1589 | xkbKeyTypeWireDesc ** wireRtrn, |
1590 | int *nMapsRtrn, CARD8 *mapWidthRtrn) |
1591 | { |
1592 | unsigned nMaps; |
1593 | register unsigned i, n; |
1594 | register CARD8 *map; |
1595 | register xkbKeyTypeWireDesc *wire = *wireRtrn; |
1596 | |
1597 | if (req->firstType > ((unsigned) xkb->map->num_types)) { |
1598 | *nMapsRtrn = _XkbErrCode3(0x01, req->firstType, xkb->map->num_types)((XID)((((unsigned int)(0x01))<<24)|(((((unsigned int)( req->firstType))<<16)|(xkb->map->num_types))& 0xffffff))); |
1599 | return 0; |
1600 | } |
1601 | if (req->flags & XkbSetMapResizeTypes(1L<<0)) { |
1602 | nMaps = req->firstType + req->nTypes; |
1603 | if (nMaps < XkbNumRequiredTypes(3 +1)) { /* canonical types must be there */ |
1604 | *nMapsRtrn = _XkbErrCode4(0x02, req->firstType, req->nTypes, 4)((XID)((((unsigned int)(0x02))<<24)|(((((unsigned int)( req->firstType))<<16)|(((((unsigned int)(req->nTypes ))<<8)|(4))))&0xffffff))); |
1605 | return 0; |
1606 | } |
1607 | } |
1608 | else if (req->present & XkbKeyTypesMask(1<<0)) { |
1609 | nMaps = xkb->map->num_types; |
1610 | if ((req->firstType + req->nTypes) > nMaps) { |
1611 | *nMapsRtrn = req->firstType + req->nTypes; |
1612 | return 0; |
1613 | } |
1614 | } |
1615 | else { |
1616 | *nMapsRtrn = xkb->map->num_types; |
1617 | for (i = 0; i < xkb->map->num_types; i++) { |
1618 | mapWidthRtrn[i] = xkb->map->types[i].num_levels; |
1619 | } |
1620 | return 1; |
1621 | } |
1622 | |
1623 | for (i = 0; i < req->firstType; i++) { |
1624 | mapWidthRtrn[i] = xkb->map->types[i].num_levels; |
1625 | } |
1626 | for (i = 0; i < req->nTypes; i++) { |
1627 | unsigned width; |
1628 | |
1629 | if (client->swapped) { |
1630 | swaps(&wire->virtualMods)do { if (sizeof(*(&wire->virtualMods)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&wire->virtualMods ) & 1) && ((uintptr_t)(&wire->virtualMods) & 1) == 0) *(&wire->virtualMods) = lswaps(*(& wire->virtualMods)); else swap_uint16((uint16_t *)(&wire ->virtualMods)); } while (0); |
1631 | } |
1632 | n = i + req->firstType; |
1633 | width = wire->numLevels; |
1634 | if (width < 1) { |
1635 | *nMapsRtrn = _XkbErrCode3(0x04, n, width)((XID)((((unsigned int)(0x04))<<24)|(((((unsigned int)( n))<<16)|(width))&0xffffff))); |
1636 | return 0; |
1637 | } |
1638 | else if ((n == XkbOneLevelIndex0) && (width != 1)) { /* must be width 1 */ |
1639 | *nMapsRtrn = _XkbErrCode3(0x05, n, width)((XID)((((unsigned int)(0x05))<<24)|(((((unsigned int)( n))<<16)|(width))&0xffffff))); |
1640 | return 0; |
1641 | } |
1642 | else if ((width != 2) && |
1643 | ((n == XkbTwoLevelIndex1) || (n == XkbKeypadIndex3) || |
1644 | (n == XkbAlphabeticIndex2))) { |
1645 | /* TWO_LEVEL, ALPHABETIC and KEYPAD must be width 2 */ |
1646 | *nMapsRtrn = _XkbErrCode3(0x05, n, width)((XID)((((unsigned int)(0x05))<<24)|(((((unsigned int)( n))<<16)|(width))&0xffffff))); |
1647 | return 0; |
1648 | } |
1649 | if (wire->nMapEntries > 0) { |
1650 | xkbKTSetMapEntryWireDesc *mapWire; |
1651 | xkbModsWireDesc *preWire; |
1652 | |
1653 | mapWire = (xkbKTSetMapEntryWireDesc *) &wire[1]; |
1654 | preWire = (xkbModsWireDesc *) &mapWire[wire->nMapEntries]; |
1655 | for (n = 0; n < wire->nMapEntries; n++) { |
1656 | if (client->swapped) { |
1657 | swaps(&mapWire[n].virtualMods)do { if (sizeof(*(&mapWire[n].virtualMods)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&mapWire[n].virtualMods ) & 1) && ((uintptr_t)(&mapWire[n].virtualMods ) & 1) == 0) *(&mapWire[n].virtualMods) = lswaps(*(& mapWire[n].virtualMods)); else swap_uint16((uint16_t *)(& mapWire[n].virtualMods)); } while (0); |
1658 | } |
1659 | if (mapWire[n].realMods & (~wire->realMods)) { |
1660 | *nMapsRtrn = _XkbErrCode4(0x06, n, mapWire[n].realMods,((XID)((((unsigned int)(0x06))<<24)|(((((unsigned int)( n))<<16)|(((((unsigned int)(mapWire[n].realMods))<< 8)|(wire->realMods))))&0xffffff))) |
1661 | wire->realMods)((XID)((((unsigned int)(0x06))<<24)|(((((unsigned int)( n))<<16)|(((((unsigned int)(mapWire[n].realMods))<< 8)|(wire->realMods))))&0xffffff))); |
1662 | return 0; |
1663 | } |
1664 | if (mapWire[n].virtualMods & (~wire->virtualMods)) { |
1665 | *nMapsRtrn = _XkbErrCode3(0x07, n, mapWire[n].virtualMods)((XID)((((unsigned int)(0x07))<<24)|(((((unsigned int)( n))<<16)|(mapWire[n].virtualMods))&0xffffff))); |
1666 | return 0; |
1667 | } |
1668 | if (mapWire[n].level >= wire->numLevels) { |
1669 | *nMapsRtrn = _XkbErrCode4(0x08, n, wire->numLevels,((XID)((((unsigned int)(0x08))<<24)|(((((unsigned int)( n))<<16)|(((((unsigned int)(wire->numLevels))<< 8)|(mapWire[n].level))))&0xffffff))) |
1670 | mapWire[n].level)((XID)((((unsigned int)(0x08))<<24)|(((((unsigned int)( n))<<16)|(((((unsigned int)(wire->numLevels))<< 8)|(mapWire[n].level))))&0xffffff))); |
1671 | return 0; |
1672 | } |
1673 | if (wire->preserve) { |
1674 | if (client->swapped) { |
1675 | swaps(&preWire[n].virtualMods)do { if (sizeof(*(&preWire[n].virtualMods)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&preWire[n].virtualMods ) & 1) && ((uintptr_t)(&preWire[n].virtualMods ) & 1) == 0) *(&preWire[n].virtualMods) = lswaps(*(& preWire[n].virtualMods)); else swap_uint16((uint16_t *)(& preWire[n].virtualMods)); } while (0); |
1676 | } |
1677 | if (preWire[n].realMods & (~mapWire[n].realMods)) { |
1678 | *nMapsRtrn = _XkbErrCode4(0x09, n, preWire[n].realMods,((XID)((((unsigned int)(0x09))<<24)|(((((unsigned int)( n))<<16)|(((((unsigned int)(preWire[n].realMods))<< 8)|(mapWire[n].realMods))))&0xffffff))) |
1679 | mapWire[n].realMods)((XID)((((unsigned int)(0x09))<<24)|(((((unsigned int)( n))<<16)|(((((unsigned int)(preWire[n].realMods))<< 8)|(mapWire[n].realMods))))&0xffffff))); |
1680 | return 0; |
1681 | } |
1682 | if (preWire[n].virtualMods & (~mapWire[n].virtualMods)) { |
1683 | *nMapsRtrn = |
1684 | _XkbErrCode3(0x0a, n, preWire[n].virtualMods)((XID)((((unsigned int)(0x0a))<<24)|(((((unsigned int)( n))<<16)|(preWire[n].virtualMods))&0xffffff))); |
1685 | return 0; |
1686 | } |
1687 | } |
1688 | } |
1689 | if (wire->preserve) |
1690 | map = (CARD8 *) &preWire[wire->nMapEntries]; |
1691 | else |
1692 | map = (CARD8 *) &mapWire[wire->nMapEntries]; |
1693 | } |
1694 | else |
1695 | map = (CARD8 *) &wire[1]; |
1696 | mapWidthRtrn[i + req->firstType] = wire->numLevels; |
1697 | wire = (xkbKeyTypeWireDesc *) map; |
1698 | } |
1699 | for (i = req->firstType + req->nTypes; i < nMaps; i++) { |
1700 | mapWidthRtrn[i] = xkb->map->types[i].num_levels; |
1701 | } |
1702 | *nMapsRtrn = nMaps; |
1703 | *wireRtrn = wire; |
1704 | return 1; |
1705 | } |
1706 | |
1707 | static int |
1708 | CheckKeySyms(ClientPtr client, |
1709 | XkbDescPtr xkb, |
1710 | xkbSetMapReq * req, |
1711 | int nTypes, |
1712 | CARD8 *mapWidths, |
1713 | CARD16 *symsPerKey, xkbSymMapWireDesc ** wireRtrn, int *errorRtrn) |
1714 | { |
1715 | register unsigned i; |
1716 | XkbSymMapPtr map; |
1717 | xkbSymMapWireDesc *wire = *wireRtrn; |
1718 | |
1719 | if (!(XkbKeySymsMask(1<<1) & req->present)) |
1720 | return 1; |
1721 | CHK_REQ_KEY_RANGE2(0x11, req->firstKeySym, req->nKeySyms, req, (*errorRtrn),{ if (((unsigned)(req->firstKeySym)+(req->nKeySyms)-1)> (req)->maxKeyCode) { ((*errorRtrn))=((XID)((((unsigned int )(0x11))<<24)|(((((unsigned int)((req->firstKeySym)) )<<16)|(((((unsigned int)((req->nKeySyms)))<<8 )|((req)->maxKeyCode))))&0xffffff))); return 0; } else if ( (req->firstKeySym)<(req)->minKeyCode ) { ((*errorRtrn ))=((XID)((((unsigned int)(0x11 +1))<<24)|(((((unsigned int)((req->firstKeySym)))<<16)|((req)->minKeyCode ))&0xffffff))); return 0; }} |
1722 | 0){ if (((unsigned)(req->firstKeySym)+(req->nKeySyms)-1)> (req)->maxKeyCode) { ((*errorRtrn))=((XID)((((unsigned int )(0x11))<<24)|(((((unsigned int)((req->firstKeySym)) )<<16)|(((((unsigned int)((req->nKeySyms)))<<8 )|((req)->maxKeyCode))))&0xffffff))); return 0; } else if ( (req->firstKeySym)<(req)->minKeyCode ) { ((*errorRtrn ))=((XID)((((unsigned int)(0x11 +1))<<24)|(((((unsigned int)((req->firstKeySym)))<<16)|((req)->minKeyCode ))&0xffffff))); return 0; }}; |
1723 | for (i = 0; i < req->nKeySyms; i++) { |
1724 | KeySym *pSyms; |
1725 | register unsigned nG; |
1726 | |
1727 | if (client->swapped) { |
1728 | swaps(&wire->nSyms)do { if (sizeof(*(&wire->nSyms)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&wire->nSyms) & 1) && ((uintptr_t)(&wire->nSyms) & 1) == 0 ) *(&wire->nSyms) = lswaps(*(&wire->nSyms)); else swap_uint16((uint16_t *)(&wire->nSyms)); } while (0); |
1729 | } |
1730 | nG = XkbNumGroups(wire->groupInfo)((wire->groupInfo)&0x0f); |
1731 | if (nG > XkbNumKbdGroups4) { |
1732 | *errorRtrn = _XkbErrCode3(0x14, i + req->firstKeySym, nG)((XID)((((unsigned int)(0x14))<<24)|(((((unsigned int)( i + req->firstKeySym))<<16)|(nG))&0xffffff))); |
1733 | return 0; |
1734 | } |
1735 | if (nG > 0) { |
1736 | register int g, w; |
1737 | |
1738 | for (g = w = 0; g < nG; g++) { |
1739 | if (wire->ktIndex[g] >= (unsigned) nTypes) { |
1740 | *errorRtrn = _XkbErrCode4(0x15, i + req->firstKeySym, g,((XID)((((unsigned int)(0x15))<<24)|(((((unsigned int)( i + req->firstKeySym))<<16)|(((((unsigned int)(g))<< 8)|(wire->ktIndex[g]))))&0xffffff))) |
1741 | wire->ktIndex[g])((XID)((((unsigned int)(0x15))<<24)|(((((unsigned int)( i + req->firstKeySym))<<16)|(((((unsigned int)(g))<< 8)|(wire->ktIndex[g]))))&0xffffff))); |
1742 | return 0; |
1743 | } |
1744 | if (mapWidths[wire->ktIndex[g]] > w) |
1745 | w = mapWidths[wire->ktIndex[g]]; |
1746 | } |
1747 | if (wire->width != w) { |
1748 | *errorRtrn = |
1749 | _XkbErrCode3(0x16, i + req->firstKeySym, wire->width)((XID)((((unsigned int)(0x16))<<24)|(((((unsigned int)( i + req->firstKeySym))<<16)|(wire->width))&0xffffff ))); |
1750 | return 0; |
1751 | } |
1752 | w *= nG; |
1753 | symsPerKey[i + req->firstKeySym] = w; |
1754 | if (w != wire->nSyms) { |
1755 | *errorRtrn = |
1756 | _XkbErrCode4(0x16, i + req->firstKeySym, wire->nSyms, w)((XID)((((unsigned int)(0x16))<<24)|(((((unsigned int)( i + req->firstKeySym))<<16)|(((((unsigned int)(wire-> nSyms))<<8)|(w))))&0xffffff))); |
1757 | return 0; |
1758 | } |
1759 | } |
1760 | else if (wire->nSyms != 0) { |
1761 | *errorRtrn = _XkbErrCode3(0x17, i + req->firstKeySym, wire->nSyms)((XID)((((unsigned int)(0x17))<<24)|(((((unsigned int)( i + req->firstKeySym))<<16)|(wire->nSyms))&0xffffff ))); |
1762 | return 0; |
1763 | } |
1764 | pSyms = (KeySym *) &wire[1]; |
1765 | wire = (xkbSymMapWireDesc *) &pSyms[wire->nSyms]; |
1766 | } |
1767 | |
1768 | map = &xkb->map->key_sym_map[i]; |
1769 | for (; i <= (unsigned) xkb->max_key_code; i++, map++) { |
1770 | register int g, nG, w; |
1771 | |
1772 | nG = XkbKeyNumGroups(xkb, i)((((((xkb)->map)->key_sym_map[((i))].group_info)&0x0f ))); |
1773 | for (w = g = 0; g < nG; g++) { |
1774 | if (map->kt_index[g] >= (unsigned) nTypes) { |
1775 | *errorRtrn = _XkbErrCode4(0x18, i, g, map->kt_index[g])((XID)((((unsigned int)(0x18))<<24)|(((((unsigned int)( i))<<16)|(((((unsigned int)(g))<<8)|(map->kt_index [g]))))&0xffffff))); |
1776 | return 0; |
1777 | } |
1778 | if (mapWidths[map->kt_index[g]] > w) |
1779 | w = mapWidths[map->kt_index[g]]; |
1780 | } |
1781 | symsPerKey[i] = w * nG; |
1782 | } |
1783 | *wireRtrn = wire; |
1784 | return 1; |
1785 | } |
1786 | |
1787 | static int |
1788 | CheckKeyActions(XkbDescPtr xkb, |
1789 | xkbSetMapReq * req, |
1790 | int nTypes, |
1791 | CARD8 *mapWidths, |
1792 | CARD16 *symsPerKey, CARD8 **wireRtrn, int *nActsRtrn) |
1793 | { |
1794 | int nActs; |
1795 | CARD8 *wire = *wireRtrn; |
1796 | register unsigned i; |
1797 | |
1798 | if (!(XkbKeyActionsMask(1<<4) & req->present)) |
1799 | return 1; |
1800 | CHK_REQ_KEY_RANGE2(0x21, req->firstKeyAct, req->nKeyActs, req, (*nActsRtrn),{ if (((unsigned)(req->firstKeyAct)+(req->nKeyActs)-1)> (req)->maxKeyCode) { ((*nActsRtrn))=((XID)((((unsigned int )(0x21))<<24)|(((((unsigned int)((req->firstKeyAct)) )<<16)|(((((unsigned int)((req->nKeyActs)))<<8 )|((req)->maxKeyCode))))&0xffffff))); return 0; } else if ( (req->firstKeyAct)<(req)->minKeyCode ) { ((*nActsRtrn ))=((XID)((((unsigned int)(0x21 +1))<<24)|(((((unsigned int)((req->firstKeyAct)))<<16)|((req)->minKeyCode ))&0xffffff))); return 0; }} |
1801 | 0){ if (((unsigned)(req->firstKeyAct)+(req->nKeyActs)-1)> (req)->maxKeyCode) { ((*nActsRtrn))=((XID)((((unsigned int )(0x21))<<24)|(((((unsigned int)((req->firstKeyAct)) )<<16)|(((((unsigned int)((req->nKeyActs)))<<8 )|((req)->maxKeyCode))))&0xffffff))); return 0; } else if ( (req->firstKeyAct)<(req)->minKeyCode ) { ((*nActsRtrn ))=((XID)((((unsigned int)(0x21 +1))<<24)|(((((unsigned int)((req->firstKeyAct)))<<16)|((req)->minKeyCode ))&0xffffff))); return 0; }}; |
1802 | for (nActs = i = 0; i < req->nKeyActs; i++) { |
1803 | if (wire[0] != 0) { |
1804 | if (wire[0] == symsPerKey[i + req->firstKeyAct]) |
1805 | nActs += wire[0]; |
1806 | else { |
1807 | *nActsRtrn = _XkbErrCode3(0x23, i + req->firstKeyAct, wire[0])((XID)((((unsigned int)(0x23))<<24)|(((((unsigned int)( i + req->firstKeyAct))<<16)|(wire[0]))&0xffffff) )); |
1808 | return 0; |
1809 | } |
1810 | } |
1811 | wire++; |
1812 | } |
1813 | if (req->nKeyActs % 4) |
1814 | wire += 4 - (req->nKeyActs % 4); |
1815 | *wireRtrn = (CARD8 *) (((XkbAnyAction *) wire) + nActs); |
1816 | *nActsRtrn = nActs; |
1817 | return 1; |
1818 | } |
1819 | |
1820 | static int |
1821 | CheckKeyBehaviors(XkbDescPtr xkb, |
1822 | xkbSetMapReq * req, |
1823 | xkbBehaviorWireDesc ** wireRtrn, int *errorRtrn) |
1824 | { |
1825 | register xkbBehaviorWireDesc *wire = *wireRtrn; |
1826 | register XkbServerMapPtr server = xkb->server; |
1827 | register unsigned i; |
1828 | unsigned first, last; |
1829 | |
1830 | if (((req->present & XkbKeyBehaviorsMask(1<<5)) == 0) || (req->nKeyBehaviors < 1)) { |
1831 | req->present &= ~XkbKeyBehaviorsMask(1<<5); |
1832 | req->nKeyBehaviors = 0; |
1833 | return 1; |
1834 | } |
1835 | first = req->firstKeyBehavior; |
1836 | last = req->firstKeyBehavior + req->nKeyBehaviors - 1; |
1837 | if (first < req->minKeyCode) { |
1838 | *errorRtrn = _XkbErrCode3(0x31, first, req->minKeyCode)((XID)((((unsigned int)(0x31))<<24)|(((((unsigned int)( first))<<16)|(req->minKeyCode))&0xffffff))); |
1839 | return 0; |
1840 | } |
1841 | if (last > req->maxKeyCode) { |
1842 | *errorRtrn = _XkbErrCode3(0x32, last, req->maxKeyCode)((XID)((((unsigned int)(0x32))<<24)|(((((unsigned int)( last))<<16)|(req->maxKeyCode))&0xffffff))); |
1843 | return 0; |
1844 | } |
1845 | |
1846 | for (i = 0; i < req->totalKeyBehaviors; i++, wire++) { |
1847 | if ((wire->key < first) || (wire->key > last)) { |
1848 | *errorRtrn = _XkbErrCode4(0x33, first, last, wire->key)((XID)((((unsigned int)(0x33))<<24)|(((((unsigned int)( first))<<16)|(((((unsigned int)(last))<<8)|(wire-> key))))&0xffffff))); |
1849 | return 0; |
1850 | } |
1851 | if ((wire->type & XkbKB_Permanent0x80) && |
1852 | ((server->behaviors[wire->key].type != wire->type) || |
1853 | (server->behaviors[wire->key].data != wire->data))) { |
1854 | *errorRtrn = _XkbErrCode3(0x33, wire->key, wire->type)((XID)((((unsigned int)(0x33))<<24)|(((((unsigned int)( wire->key))<<16)|(wire->type))&0xffffff))); |
1855 | return 0; |
1856 | } |
1857 | if ((wire->type == XkbKB_RadioGroup0x02) && |
1858 | ((wire->data & (~XkbKB_RGAllowNone0x80)) > XkbMaxRadioGroups32)) { |
1859 | *errorRtrn = _XkbErrCode4(0x34, wire->key, wire->data,((XID)((((unsigned int)(0x34))<<24)|(((((unsigned int)( wire->key))<<16)|(((((unsigned int)(wire->data))<< 8)|(32))))&0xffffff))) |
1860 | XkbMaxRadioGroups)((XID)((((unsigned int)(0x34))<<24)|(((((unsigned int)( wire->key))<<16)|(((((unsigned int)(wire->data))<< 8)|(32))))&0xffffff))); |
1861 | return 0; |
1862 | } |
1863 | if ((wire->type == XkbKB_Overlay10x03) || (wire->type == XkbKB_Overlay20x04)) { |
1864 | CHK_KEY_RANGE2(0x35, wire->key, 1, xkb, *errorRtrn, 0){ if (((unsigned)(wire->key)+(1)-1)>(xkb)->max_key_code ) { (*errorRtrn)=((XID)((((unsigned int)(0x35))<<24)|(( (((unsigned int)((wire->key)))<<16)|(((((unsigned int )((1)))<<8)|((xkb)->max_key_code))))&0xffffff))) ; return 0; } else if ( (wire->key)<(xkb)->min_key_code ) { (*errorRtrn)=((XID)((((unsigned int)(0x35 +1))<<24 )|(((((unsigned int)((wire->key)))<<16)|(xkb->min_key_code ))&0xffffff))); return 0; }}; |
1865 | } |
1866 | } |
1867 | *wireRtrn = wire; |
1868 | return 1; |
1869 | } |
1870 | |
1871 | static int |
1872 | CheckVirtualMods(XkbDescRec * xkb, |
1873 | xkbSetMapReq * req, CARD8 **wireRtrn, int *errorRtrn) |
1874 | { |
1875 | register CARD8 *wire = *wireRtrn; |
1876 | register unsigned i, nMods, bit; |
1877 | |
1878 | if (((req->present & XkbVirtualModsMask(1<<6)) == 0) || (req->virtualMods == 0)) |
1879 | return 1; |
1880 | for (i = nMods = 0, bit = 1; i < XkbNumVirtualMods16; i++, bit <<= 1) { |
1881 | if (req->virtualMods & bit) |
1882 | nMods++; |
1883 | } |
1884 | *wireRtrn = (wire + XkbPaddedSize(nMods)((((unsigned int)(nMods)+3) >> 2) << 2)); |
1885 | return 1; |
1886 | } |
1887 | |
1888 | static int |
1889 | CheckKeyExplicit(XkbDescPtr xkb, |
1890 | xkbSetMapReq * req, CARD8 **wireRtrn, int *errorRtrn) |
1891 | { |
1892 | register CARD8 *wire = *wireRtrn; |
1893 | CARD8 *start; |
1894 | register unsigned i; |
1895 | int first, last; |
1896 | |
1897 | if (((req->present & XkbExplicitComponentsMask(1<<3)) == 0) || |
1898 | (req->nKeyExplicit < 1)) { |
1899 | req->present &= ~XkbExplicitComponentsMask(1<<3); |
1900 | req->nKeyExplicit = 0; |
1901 | return 1; |
1902 | } |
1903 | first = req->firstKeyExplicit; |
1904 | last = first + req->nKeyExplicit - 1; |
1905 | if (first < req->minKeyCode) { |
1906 | *errorRtrn = _XkbErrCode3(0x51, first, req->minKeyCode)((XID)((((unsigned int)(0x51))<<24)|(((((unsigned int)( first))<<16)|(req->minKeyCode))&0xffffff))); |
1907 | return 0; |
1908 | } |
1909 | if (last > req->maxKeyCode) { |
1910 | *errorRtrn = _XkbErrCode3(0x52, last, req->maxKeyCode)((XID)((((unsigned int)(0x52))<<24)|(((((unsigned int)( last))<<16)|(req->maxKeyCode))&0xffffff))); |
1911 | return 0; |
1912 | } |
1913 | start = wire; |
1914 | for (i = 0; i < req->totalKeyExplicit; i++, wire += 2) { |
1915 | if ((wire[0] < first) || (wire[0] > last)) { |
1916 | *errorRtrn = _XkbErrCode4(0x53, first, last, wire[0])((XID)((((unsigned int)(0x53))<<24)|(((((unsigned int)( first))<<16)|(((((unsigned int)(last))<<8)|(wire[ 0]))))&0xffffff))); |
1917 | return 0; |
1918 | } |
1919 | if (wire[1] & (~XkbAllExplicitMask(0xff))) { |
1920 | *errorRtrn = _XkbErrCode3(0x52, ~XkbAllExplicitMask, wire[1])((XID)((((unsigned int)(0x52))<<24)|(((((unsigned int)( ~(0xff)))<<16)|(wire[1]))&0xffffff))); |
1921 | return 0; |
1922 | } |
1923 | } |
1924 | wire += XkbPaddedSize(wire - start)((((unsigned int)(wire - start)+3) >> 2) << 2) - (wire - start); |
1925 | *wireRtrn = wire; |
1926 | return 1; |
1927 | } |
1928 | |
1929 | static int |
1930 | CheckModifierMap(XkbDescPtr xkb, xkbSetMapReq * req, CARD8 **wireRtrn, |
1931 | int *errRtrn) |
1932 | { |
1933 | register CARD8 *wire = *wireRtrn; |
1934 | CARD8 *start; |
1935 | register unsigned i; |
1936 | int first, last; |
1937 | |
1938 | if (((req->present & XkbModifierMapMask(1<<2)) == 0) || (req->nModMapKeys < 1)) { |
1939 | req->present &= ~XkbModifierMapMask(1<<2); |
1940 | req->nModMapKeys = 0; |
1941 | return 1; |
1942 | } |
1943 | first = req->firstModMapKey; |
1944 | last = first + req->nModMapKeys - 1; |
1945 | if (first < req->minKeyCode) { |
1946 | *errRtrn = _XkbErrCode3(0x61, first, req->minKeyCode)((XID)((((unsigned int)(0x61))<<24)|(((((unsigned int)( first))<<16)|(req->minKeyCode))&0xffffff))); |
1947 | return 0; |
1948 | } |
1949 | if (last > req->maxKeyCode) { |
1950 | *errRtrn = _XkbErrCode3(0x62, last, req->maxKeyCode)((XID)((((unsigned int)(0x62))<<24)|(((((unsigned int)( last))<<16)|(req->maxKeyCode))&0xffffff))); |
1951 | return 0; |
1952 | } |
1953 | start = wire; |
1954 | for (i = 0; i < req->totalModMapKeys; i++, wire += 2) { |
1955 | if ((wire[0] < first) || (wire[0] > last)) { |
1956 | *errRtrn = _XkbErrCode4(0x63, first, last, wire[0])((XID)((((unsigned int)(0x63))<<24)|(((((unsigned int)( first))<<16)|(((((unsigned int)(last))<<8)|(wire[ 0]))))&0xffffff))); |
1957 | return 0; |
1958 | } |
1959 | } |
1960 | wire += XkbPaddedSize(wire - start)((((unsigned int)(wire - start)+3) >> 2) << 2) - (wire - start); |
1961 | *wireRtrn = wire; |
1962 | return 1; |
1963 | } |
1964 | |
1965 | static int |
1966 | CheckVirtualModMap(XkbDescPtr xkb, |
1967 | xkbSetMapReq * req, |
1968 | xkbVModMapWireDesc ** wireRtrn, int *errRtrn) |
1969 | { |
1970 | register xkbVModMapWireDesc *wire = *wireRtrn; |
1971 | register unsigned i; |
1972 | int first, last; |
1973 | |
1974 | if (((req->present & XkbVirtualModMapMask(1<<7)) == 0) || (req->nVModMapKeys < 1)) { |
1975 | req->present &= ~XkbVirtualModMapMask(1<<7); |
1976 | req->nVModMapKeys = 0; |
1977 | return 1; |
1978 | } |
1979 | first = req->firstVModMapKey; |
1980 | last = first + req->nVModMapKeys - 1; |
1981 | if (first < req->minKeyCode) { |
1982 | *errRtrn = _XkbErrCode3(0x71, first, req->minKeyCode)((XID)((((unsigned int)(0x71))<<24)|(((((unsigned int)( first))<<16)|(req->minKeyCode))&0xffffff))); |
1983 | return 0; |
1984 | } |
1985 | if (last > req->maxKeyCode) { |
1986 | *errRtrn = _XkbErrCode3(0x72, last, req->maxKeyCode)((XID)((((unsigned int)(0x72))<<24)|(((((unsigned int)( last))<<16)|(req->maxKeyCode))&0xffffff))); |
1987 | return 0; |
1988 | } |
1989 | for (i = 0; i < req->totalVModMapKeys; i++, wire++) { |
1990 | if ((wire->key < first) || (wire->key > last)) { |
1991 | *errRtrn = _XkbErrCode4(0x73, first, last, wire->key)((XID)((((unsigned int)(0x73))<<24)|(((((unsigned int)( first))<<16)|(((((unsigned int)(last))<<8)|(wire-> key))))&0xffffff))); |
1992 | return 0; |
1993 | } |
1994 | } |
1995 | *wireRtrn = wire; |
1996 | return 1; |
1997 | } |
1998 | |
1999 | static char * |
2000 | SetKeyTypes(XkbDescPtr xkb, |
2001 | xkbSetMapReq * req, |
2002 | xkbKeyTypeWireDesc * wire, XkbChangesPtr changes) |
2003 | { |
2004 | register unsigned i; |
2005 | unsigned first, last; |
2006 | CARD8 *map; |
2007 | |
2008 | if ((unsigned) (req->firstType + req->nTypes) > xkb->map->size_types) { |
2009 | i = req->firstType + req->nTypes; |
2010 | if (XkbAllocClientMapSrvXkbAllocClientMap(xkb, XkbKeyTypesMask(1<<0), i) != Success0) { |
2011 | return NULL((void*)0); |
2012 | } |
2013 | } |
2014 | if ((unsigned) (req->firstType + req->nTypes) > xkb->map->num_types) |
2015 | xkb->map->num_types = req->firstType + req->nTypes; |
2016 | |
2017 | for (i = 0; i < req->nTypes; i++) { |
2018 | XkbKeyTypePtr pOld; |
2019 | register unsigned n; |
2020 | |
2021 | if (XkbResizeKeyTypeSrvXkbResizeKeyType(xkb, i + req->firstType, wire->nMapEntries, |
2022 | wire->preserve, wire->numLevels) != Success0) { |
2023 | return NULL((void*)0); |
2024 | } |
2025 | pOld = &xkb->map->types[i + req->firstType]; |
2026 | map = (CARD8 *) &wire[1]; |
2027 | |
2028 | pOld->mods.real_mods = wire->realMods; |
2029 | pOld->mods.vmods = wire->virtualMods; |
2030 | pOld->num_levels = wire->numLevels; |
2031 | pOld->map_count = wire->nMapEntries; |
2032 | |
2033 | pOld->mods.mask = pOld->mods.real_mods | |
2034 | XkbMaskForVMask(xkb, pOld->mods.vmods); |
2035 | |
2036 | if (wire->nMapEntries) { |
2037 | xkbKTSetMapEntryWireDesc *mapWire; |
2038 | xkbModsWireDesc *preWire; |
2039 | unsigned tmp; |
2040 | |
2041 | mapWire = (xkbKTSetMapEntryWireDesc *) map; |
2042 | preWire = (xkbModsWireDesc *) &mapWire[wire->nMapEntries]; |
2043 | for (n = 0; n < wire->nMapEntries; n++) { |
2044 | pOld->map[n].active = 1; |
2045 | pOld->map[n].mods.mask = mapWire[n].realMods; |
2046 | pOld->map[n].mods.real_mods = mapWire[n].realMods; |
2047 | pOld->map[n].mods.vmods = mapWire[n].virtualMods; |
2048 | pOld->map[n].level = mapWire[n].level; |
2049 | if (mapWire[n].virtualMods != 0) { |
2050 | tmp = XkbMaskForVMask(xkb, mapWire[n].virtualMods); |
2051 | pOld->map[n].active = (tmp != 0); |
2052 | pOld->map[n].mods.mask |= tmp; |
2053 | } |
2054 | if (wire->preserve) { |
2055 | pOld->preserve[n].real_mods = preWire[n].realMods; |
2056 | pOld->preserve[n].vmods = preWire[n].virtualMods; |
2057 | tmp = XkbMaskForVMask(xkb, preWire[n].virtualMods); |
2058 | pOld->preserve[n].mask = preWire[n].realMods | tmp; |
2059 | } |
2060 | } |
2061 | if (wire->preserve) |
2062 | map = (CARD8 *) &preWire[wire->nMapEntries]; |
2063 | else |
2064 | map = (CARD8 *) &mapWire[wire->nMapEntries]; |
2065 | } |
2066 | else |
2067 | map = (CARD8 *) &wire[1]; |
2068 | wire = (xkbKeyTypeWireDesc *) map; |
2069 | } |
2070 | first = req->firstType; |
2071 | last = first + req->nTypes - 1; /* last changed type */ |
2072 | if (changes->map.changed & XkbKeyTypesMask(1<<0)) { |
2073 | int oldLast; |
2074 | |
2075 | oldLast = changes->map.first_type + changes->map.num_types - 1; |
2076 | if (changes->map.first_type < first) |
2077 | first = changes->map.first_type; |
2078 | if (oldLast > last) |
2079 | last = oldLast; |
2080 | } |
2081 | changes->map.changed |= XkbKeyTypesMask(1<<0); |
2082 | changes->map.first_type = first; |
2083 | changes->map.num_types = (last - first) + 1; |
2084 | return (char *) wire; |
2085 | } |
2086 | |
2087 | static char * |
2088 | SetKeySyms(ClientPtr client, |
2089 | XkbDescPtr xkb, |
2090 | xkbSetMapReq * req, |
2091 | xkbSymMapWireDesc * wire, XkbChangesPtr changes, DeviceIntPtr dev) |
2092 | { |
2093 | register unsigned i, s; |
2094 | XkbSymMapPtr oldMap; |
2095 | KeySym *newSyms; |
2096 | KeySym *pSyms; |
2097 | unsigned first, last; |
2098 | |
2099 | oldMap = &xkb->map->key_sym_map[req->firstKeySym]; |
2100 | for (i = 0; i < req->nKeySyms; i++, oldMap++) { |
2101 | pSyms = (KeySym *) &wire[1]; |
2102 | if (wire->nSyms > 0) { |
2103 | newSyms = XkbResizeKeySymsSrvXkbResizeKeySyms(xkb, i + req->firstKeySym, wire->nSyms); |
2104 | for (s = 0; s < wire->nSyms; s++) { |
2105 | newSyms[s] = pSyms[s]; |
2106 | } |
2107 | if (client->swapped) { |
2108 | for (s = 0; s < wire->nSyms; s++) { |
2109 | swapl(&newSyms[s])do { if (sizeof(*(&newSyms[s])) != 4) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&newSyms[s]) & 3) && ((uintptr_t )(&newSyms[s]) & 3) == 0) *(&newSyms[s]) = lswapl (*(&newSyms[s])); else swap_uint32((uint32_t *)(&newSyms [s])); } while (0); |
2110 | } |
2111 | } |
2112 | } |
2113 | oldMap->kt_index[0] = wire->ktIndex[0]; |
2114 | oldMap->kt_index[1] = wire->ktIndex[1]; |
2115 | oldMap->kt_index[2] = wire->ktIndex[2]; |
2116 | oldMap->kt_index[3] = wire->ktIndex[3]; |
2117 | oldMap->group_info = wire->groupInfo; |
2118 | oldMap->width = wire->width; |
2119 | wire = (xkbSymMapWireDesc *) &pSyms[wire->nSyms]; |
2120 | } |
2121 | first = req->firstKeySym; |
2122 | last = first + req->nKeySyms - 1; |
2123 | if (changes->map.changed & XkbKeySymsMask(1<<1)) { |
2124 | int oldLast = |
2125 | (changes->map.first_key_sym + changes->map.num_key_syms - 1); |
2126 | if (changes->map.first_key_sym < first) |
2127 | first = changes->map.first_key_sym; |
2128 | if (oldLast > last) |
2129 | last = oldLast; |
2130 | } |
2131 | changes->map.changed |= XkbKeySymsMask(1<<1); |
2132 | changes->map.first_key_sym = first; |
2133 | changes->map.num_key_syms = (last - first + 1); |
2134 | |
2135 | s = 0; |
2136 | for (i = xkb->min_key_code; i <= xkb->max_key_code; i++) { |
2137 | if (XkbKeyNumGroups(xkb, i)((((((xkb)->map)->key_sym_map[((i))].group_info)&0x0f ))) > s) |
2138 | s = XkbKeyNumGroups(xkb, i)((((((xkb)->map)->key_sym_map[((i))].group_info)&0x0f ))); |
2139 | } |
2140 | if (s != xkb->ctrls->num_groups) { |
2141 | xkbControlsNotify cn; |
2142 | XkbControlsRec old; |
2143 | |
2144 | cn.keycode = 0; |
2145 | cn.eventType = 0; |
2146 | cn.requestMajor = XkbReqCode; |
2147 | cn.requestMinor = X_kbSetMap9; |
2148 | old = *xkb->ctrls; |
2149 | xkb->ctrls->num_groups = s; |
2150 | if (XkbComputeControlsNotify(dev, &old, xkb->ctrls, &cn, FALSE0)) |
2151 | XkbSendControlsNotify(dev, &cn); |
2152 | } |
2153 | return (char *) wire; |
2154 | } |
2155 | |
2156 | static char * |
2157 | SetKeyActions(XkbDescPtr xkb, |
2158 | xkbSetMapReq * req, CARD8 *wire, XkbChangesPtr changes) |
2159 | { |
2160 | register unsigned i, first, last; |
2161 | CARD8 *nActs = wire; |
2162 | XkbAction *newActs; |
2163 | |
2164 | wire += XkbPaddedSize(req->nKeyActs)((((unsigned int)(req->nKeyActs)+3) >> 2) << 2 ); |
2165 | for (i = 0; i < req->nKeyActs; i++) { |
2166 | if (nActs[i] == 0) |
2167 | xkb->server->key_acts[i + req->firstKeyAct] = 0; |
2168 | else { |
2169 | newActs = XkbResizeKeyActionsSrvXkbResizeKeyActions(xkb, i + req->firstKeyAct, nActs[i]); |
2170 | memcpy((char *) newActs, (char *) wire,__builtin___memcpy_chk ((char *) newActs, (char *) wire, nActs [i] * 8, __builtin_object_size ((char *) newActs, 0)) |
2171 | nActs[i] * SIZEOF(xkbActionWireDesc))__builtin___memcpy_chk ((char *) newActs, (char *) wire, nActs [i] * 8, __builtin_object_size ((char *) newActs, 0)); |
2172 | wire += nActs[i] * SIZEOF(xkbActionWireDesc)8; |
2173 | } |
2174 | } |
2175 | first = req->firstKeyAct; |
2176 | last = (first + req->nKeyActs - 1); |
2177 | if (changes->map.changed & XkbKeyActionsMask(1<<4)) { |
2178 | int oldLast; |
2179 | |
2180 | oldLast = changes->map.first_key_act + changes->map.num_key_acts - 1; |
2181 | if (changes->map.first_key_act < first) |
2182 | first = changes->map.first_key_act; |
2183 | if (oldLast > last) |
2184 | last = oldLast; |
2185 | } |
2186 | changes->map.changed |= XkbKeyActionsMask(1<<4); |
2187 | changes->map.first_key_act = first; |
2188 | changes->map.num_key_acts = (last - first + 1); |
2189 | return (char *) wire; |
2190 | } |
2191 | |
2192 | static char * |
2193 | SetKeyBehaviors(XkbSrvInfoPtr xkbi, |
2194 | xkbSetMapReq * req, |
2195 | xkbBehaviorWireDesc * wire, XkbChangesPtr changes) |
2196 | { |
2197 | register unsigned i; |
2198 | int maxRG = -1; |
2199 | XkbDescPtr xkb = xkbi->desc; |
2200 | XkbServerMapPtr server = xkb->server; |
2201 | unsigned first, last; |
2202 | |
2203 | first = req->firstKeyBehavior; |
2204 | last = req->firstKeyBehavior + req->nKeyBehaviors - 1; |
2205 | memset(&server->behaviors[first], 0,__builtin___memset_chk (&server->behaviors[first], 0, req ->nKeyBehaviors * sizeof(XkbBehavior), __builtin_object_size (&server->behaviors[first], 0)) |
2206 | req->nKeyBehaviors * sizeof(XkbBehavior))__builtin___memset_chk (&server->behaviors[first], 0, req ->nKeyBehaviors * sizeof(XkbBehavior), __builtin_object_size (&server->behaviors[first], 0)); |
2207 | for (i = 0; i < req->totalKeyBehaviors; i++) { |
2208 | if ((server->behaviors[wire->key].type & XkbKB_Permanent0x80) == 0) { |
2209 | server->behaviors[wire->key].type = wire->type; |
2210 | server->behaviors[wire->key].data = wire->data; |
2211 | if ((wire->type == XkbKB_RadioGroup0x02) && |
2212 | (((int) wire->data) > maxRG)) |
2213 | maxRG = wire->data + 1; |
2214 | } |
2215 | wire++; |
2216 | } |
2217 | |
2218 | if (maxRG > (int) xkbi->nRadioGroups) { |
2219 | int sz = maxRG * sizeof(XkbRadioGroupRec); |
2220 | |
2221 | if (xkbi->radioGroups) |
2222 | xkbi->radioGroups = realloc(xkbi->radioGroups, sz); |
2223 | else |
2224 | xkbi->radioGroups = calloc(1, sz); |
2225 | if (xkbi->radioGroups) { |
2226 | if (xkbi->nRadioGroups) |
2227 | memset(&xkbi->radioGroups[xkbi->nRadioGroups], 0,__builtin___memset_chk (&xkbi->radioGroups[xkbi->nRadioGroups ], 0, (maxRG - xkbi->nRadioGroups) * sizeof(XkbRadioGroupRec ), __builtin_object_size (&xkbi->radioGroups[xkbi-> nRadioGroups], 0)) |
2228 | (maxRG - xkbi->nRadioGroups) * sizeof(XkbRadioGroupRec))__builtin___memset_chk (&xkbi->radioGroups[xkbi->nRadioGroups ], 0, (maxRG - xkbi->nRadioGroups) * sizeof(XkbRadioGroupRec ), __builtin_object_size (&xkbi->radioGroups[xkbi-> nRadioGroups], 0)); |
2229 | xkbi->nRadioGroups = maxRG; |
2230 | } |
2231 | else |
2232 | xkbi->nRadioGroups = 0; |
2233 | /* should compute members here */ |
2234 | } |
2235 | if (changes->map.changed & XkbKeyBehaviorsMask(1<<5)) { |
2236 | unsigned oldLast; |
2237 | |
2238 | oldLast = changes->map.first_key_behavior + |
2239 | changes->map.num_key_behaviors - 1; |
2240 | if (changes->map.first_key_behavior < req->firstKeyBehavior) |
2241 | first = changes->map.first_key_behavior; |
2242 | if (oldLast > last) |
2243 | last = oldLast; |
2244 | } |
2245 | changes->map.changed |= XkbKeyBehaviorsMask(1<<5); |
2246 | changes->map.first_key_behavior = first; |
2247 | changes->map.num_key_behaviors = (last - first + 1); |
2248 | return (char *) wire; |
2249 | } |
2250 | |
2251 | static char * |
2252 | SetVirtualMods(XkbSrvInfoPtr xkbi, xkbSetMapReq * req, CARD8 *wire, |
2253 | XkbChangesPtr changes) |
2254 | { |
2255 | register int i, bit, nMods; |
2256 | XkbServerMapPtr srv = xkbi->desc->server; |
2257 | |
2258 | if (((req->present & XkbVirtualModsMask(1<<6)) == 0) || (req->virtualMods == 0)) |
2259 | return (char *) wire; |
2260 | for (i = nMods = 0, bit = 1; i < XkbNumVirtualMods16; i++, bit <<= 1) { |
2261 | if (req->virtualMods & bit) { |
2262 | if (srv->vmods[i] != wire[nMods]) { |
2263 | changes->map.changed |= XkbVirtualModsMask(1<<6); |
2264 | changes->map.vmods |= bit; |
2265 | srv->vmods[i] = wire[nMods]; |
2266 | } |
2267 | nMods++; |
2268 | } |
2269 | } |
2270 | return (char *) (wire + XkbPaddedSize(nMods)((((unsigned int)(nMods)+3) >> 2) << 2)); |
2271 | } |
2272 | |
2273 | static char * |
2274 | SetKeyExplicit(XkbSrvInfoPtr xkbi, xkbSetMapReq * req, CARD8 *wire, |
2275 | XkbChangesPtr changes) |
2276 | { |
2277 | register unsigned i, first, last; |
2278 | XkbServerMapPtr xkb = xkbi->desc->server; |
2279 | CARD8 *start; |
2280 | |
2281 | start = wire; |
2282 | first = req->firstKeyExplicit; |
2283 | last = req->firstKeyExplicit + req->nKeyExplicit - 1; |
2284 | memset(&xkb->explicit[first], 0, req->nKeyExplicit)__builtin___memset_chk (&xkb->explicit[first], 0, req-> nKeyExplicit, __builtin_object_size (&xkb->explicit[first ], 0)); |
2285 | for (i = 0; i < req->totalKeyExplicit; i++, wire += 2) { |
2286 | xkb->explicit[wire[0]] = wire[1]; |
2287 | } |
2288 | if (first > 0) { |
2289 | if (changes->map.changed & XkbExplicitComponentsMask(1<<3)) { |
2290 | int oldLast; |
2291 | |
2292 | oldLast = changes->map.first_key_explicit + |
2293 | changes->map.num_key_explicit - 1; |
2294 | if (changes->map.first_key_explicit < first) |
2295 | first = changes->map.first_key_explicit; |
2296 | if (oldLast > last) |
2297 | last = oldLast; |
2298 | } |
2299 | changes->map.first_key_explicit = first; |
2300 | changes->map.num_key_explicit = (last - first) + 1; |
2301 | } |
2302 | wire += XkbPaddedSize(wire - start)((((unsigned int)(wire - start)+3) >> 2) << 2) - (wire - start); |
2303 | return (char *) wire; |
2304 | } |
2305 | |
2306 | static char * |
2307 | SetModifierMap(XkbSrvInfoPtr xkbi, |
2308 | xkbSetMapReq * req, CARD8 *wire, XkbChangesPtr changes) |
2309 | { |
2310 | register unsigned i, first, last; |
2311 | XkbClientMapPtr xkb = xkbi->desc->map; |
2312 | CARD8 *start; |
2313 | |
2314 | start = wire; |
2315 | first = req->firstModMapKey; |
2316 | last = req->firstModMapKey + req->nModMapKeys - 1; |
2317 | memset(&xkb->modmap[first], 0, req->nModMapKeys)__builtin___memset_chk (&xkb->modmap[first], 0, req-> nModMapKeys, __builtin_object_size (&xkb->modmap[first ], 0)); |
2318 | for (i = 0; i < req->totalModMapKeys; i++, wire += 2) { |
2319 | xkb->modmap[wire[0]] = wire[1]; |
2320 | } |
2321 | if (first > 0) { |
2322 | if (changes->map.changed & XkbModifierMapMask(1<<2)) { |
2323 | int oldLast; |
2324 | |
2325 | oldLast = changes->map.first_modmap_key + |
2326 | changes->map.num_modmap_keys - 1; |
2327 | if (changes->map.first_modmap_key < first) |
2328 | first = changes->map.first_modmap_key; |
2329 | if (oldLast > last) |
2330 | last = oldLast; |
2331 | } |
2332 | changes->map.first_modmap_key = first; |
2333 | changes->map.num_modmap_keys = (last - first) + 1; |
2334 | } |
2335 | wire += XkbPaddedSize(wire - start)((((unsigned int)(wire - start)+3) >> 2) << 2) - (wire - start); |
2336 | return (char *) wire; |
2337 | } |
2338 | |
2339 | static char * |
2340 | SetVirtualModMap(XkbSrvInfoPtr xkbi, |
2341 | xkbSetMapReq * req, |
2342 | xkbVModMapWireDesc * wire, XkbChangesPtr changes) |
2343 | { |
2344 | register unsigned i, first, last; |
2345 | XkbServerMapPtr srv = xkbi->desc->server; |
2346 | |
2347 | first = req->firstVModMapKey; |
2348 | last = req->firstVModMapKey + req->nVModMapKeys - 1; |
2349 | memset(&srv->vmodmap[first], 0, req->nVModMapKeys * sizeof(unsigned short))__builtin___memset_chk (&srv->vmodmap[first], 0, req-> nVModMapKeys * sizeof(unsigned short), __builtin_object_size ( &srv->vmodmap[first], 0)); |
2350 | for (i = 0; i < req->totalVModMapKeys; i++, wire++) { |
2351 | srv->vmodmap[wire->key] = wire->vmods; |
2352 | } |
2353 | if (first > 0) { |
2354 | if (changes->map.changed & XkbVirtualModMapMask(1<<7)) { |
2355 | int oldLast; |
2356 | |
2357 | oldLast = changes->map.first_vmodmap_key + |
2358 | changes->map.num_vmodmap_keys - 1; |
2359 | if (changes->map.first_vmodmap_key < first) |
2360 | first = changes->map.first_vmodmap_key; |
2361 | if (oldLast > last) |
2362 | last = oldLast; |
2363 | } |
2364 | changes->map.first_vmodmap_key = first; |
2365 | changes->map.num_vmodmap_keys = (last - first) + 1; |
2366 | } |
2367 | return (char *) wire; |
2368 | } |
2369 | |
2370 | /** |
2371 | * Check if the given request can be applied to the given device but don't |
2372 | * actually do anything.. |
2373 | */ |
2374 | static int |
2375 | _XkbSetMapChecks(ClientPtr client, DeviceIntPtr dev, xkbSetMapReq * req, |
2376 | char *values) |
2377 | { |
2378 | XkbSrvInfoPtr xkbi; |
2379 | XkbDescPtr xkb; |
2380 | int error; |
2381 | int nTypes = 0, nActions; |
2382 | CARD8 mapWidths[XkbMaxLegalKeyCode255 + 1] = { 0 }; |
2383 | CARD16 symsPerKey[XkbMaxLegalKeyCode255 + 1] = { 0 }; |
2384 | XkbSymMapPtr map; |
2385 | int i; |
2386 | |
2387 | xkbi = dev->key->xkbInfo; |
2388 | xkb = xkbi->desc; |
2389 | |
2390 | if ((xkb->min_key_code != req->minKeyCode) || |
2391 | (xkb->max_key_code != req->maxKeyCode)) { |
2392 | if (client->vMajor != 1) { /* pre 1.0 versions of Xlib have a bug */ |
2393 | req->minKeyCode = xkb->min_key_code; |
2394 | req->maxKeyCode = xkb->max_key_code; |
2395 | } |
2396 | else { |
2397 | if (!XkbIsLegalKeycode(req->minKeyCode)((req->minKeyCode)>=8)) { |
2398 | client->errorValue = |
2399 | _XkbErrCode3(2, req->minKeyCode, req->maxKeyCode)((XID)((((unsigned int)(2))<<24)|(((((unsigned int)(req ->minKeyCode))<<16)|(req->maxKeyCode))&0xffffff ))); |
2400 | return BadValue2; |
2401 | } |
2402 | if (req->minKeyCode > req->maxKeyCode) { |
2403 | client->errorValue = |
2404 | _XkbErrCode3(3, req->minKeyCode, req->maxKeyCode)((XID)((((unsigned int)(3))<<24)|(((((unsigned int)(req ->minKeyCode))<<16)|(req->maxKeyCode))&0xffffff ))); |
2405 | return BadMatch8; |
2406 | } |
2407 | } |
2408 | } |
2409 | |
2410 | if ((req->present & XkbKeyTypesMask(1<<0)) && |
2411 | (!CheckKeyTypes(client, xkb, req, (xkbKeyTypeWireDesc **) &values, |
2412 | &nTypes, mapWidths))) { |
2413 | client->errorValue = nTypes; |
2414 | return BadValue2; |
2415 | } |
2416 | |
2417 | /* symsPerKey/mapWidths must be filled regardless of client-side flags */ |
2418 | map = &xkb->map->key_sym_map[xkb->min_key_code]; |
2419 | for (i = xkb->min_key_code; i < xkb->max_key_code; i++, map++) { |
2420 | register int g, ng, w; |
2421 | |
2422 | ng = XkbNumGroups(map->group_info)((map->group_info)&0x0f); |
2423 | for (w = g = 0; g < ng; g++) { |
2424 | if (map->kt_index[g] >= (unsigned) nTypes) { |
2425 | client->errorValue = _XkbErrCode4(0x13, i, g, map->kt_index[g])((XID)((((unsigned int)(0x13))<<24)|(((((unsigned int)( i))<<16)|(((((unsigned int)(g))<<8)|(map->kt_index [g]))))&0xffffff))); |
2426 | return 0; |
2427 | } |
2428 | if (mapWidths[map->kt_index[g]] > w) |
2429 | w = mapWidths[map->kt_index[g]]; |
2430 | } |
2431 | symsPerKey[i] = w * ng; |
2432 | } |
2433 | |
2434 | if ((req->present & XkbKeySymsMask(1<<1)) && |
2435 | (!CheckKeySyms(client, xkb, req, nTypes, mapWidths, symsPerKey, |
2436 | (xkbSymMapWireDesc **) &values, &error))) { |
2437 | client->errorValue = error; |
2438 | return BadValue2; |
2439 | } |
2440 | |
2441 | if ((req->present & XkbKeyActionsMask(1<<4)) && |
2442 | (!CheckKeyActions(xkb, req, nTypes, mapWidths, symsPerKey, |
2443 | (CARD8 **) &values, &nActions))) { |
2444 | client->errorValue = nActions; |
2445 | return BadValue2; |
2446 | } |
2447 | |
2448 | if ((req->present & XkbKeyBehaviorsMask(1<<5)) && |
2449 | (!CheckKeyBehaviors |
2450 | (xkb, req, (xkbBehaviorWireDesc **) &values, &error))) { |
2451 | client->errorValue = error; |
2452 | return BadValue2; |
2453 | } |
2454 | |
2455 | if ((req->present & XkbVirtualModsMask(1<<6)) && |
2456 | (!CheckVirtualMods(xkb, req, (CARD8 **) &values, &error))) { |
2457 | client->errorValue = error; |
2458 | return BadValue2; |
2459 | } |
2460 | if ((req->present & XkbExplicitComponentsMask(1<<3)) && |
2461 | (!CheckKeyExplicit(xkb, req, (CARD8 **) &values, &error))) { |
2462 | client->errorValue = error; |
2463 | return BadValue2; |
2464 | } |
2465 | if ((req->present & XkbModifierMapMask(1<<2)) && |
2466 | (!CheckModifierMap(xkb, req, (CARD8 **) &values, &error))) { |
2467 | client->errorValue = error; |
2468 | return BadValue2; |
2469 | } |
2470 | if ((req->present & XkbVirtualModMapMask(1<<7)) && |
2471 | (!CheckVirtualModMap |
2472 | (xkb, req, (xkbVModMapWireDesc **) &values, &error))) { |
2473 | client->errorValue = error; |
2474 | return BadValue2; |
2475 | } |
2476 | |
2477 | if (((values - ((char *) req)) / 4) != req->length) { |
2478 | ErrorF("[xkb] Internal error! Bad length in XkbSetMap (after check)\n"); |
2479 | client->errorValue = values - ((char *) &req[1]); |
2480 | return BadLength16; |
2481 | } |
2482 | |
2483 | return Success0; |
2484 | } |
2485 | |
2486 | /** |
2487 | * Apply the given request on the given device. |
2488 | */ |
2489 | static int |
2490 | _XkbSetMap(ClientPtr client, DeviceIntPtr dev, xkbSetMapReq * req, char *values) |
2491 | { |
2492 | XkbEventCauseRec cause; |
2493 | XkbChangesRec change; |
2494 | Bool sentNKN; |
2495 | XkbSrvInfoPtr xkbi; |
2496 | XkbDescPtr xkb; |
2497 | |
2498 | xkbi = dev->key->xkbInfo; |
2499 | xkb = xkbi->desc; |
2500 | |
2501 | XkbSetCauseXkbReq(&cause, X_kbSetMap, client){ (&cause)->kc= (&cause)->event= 0, (&cause )->mjr= (XkbReqCode),(&cause)->mnr= (9); (&cause )->client= (client); }; |
2502 | memset(&change, 0, sizeof(change))__builtin___memset_chk (&change, 0, sizeof(change), __builtin_object_size (&change, 0)); |
2503 | sentNKN = FALSE0; |
2504 | if ((xkb->min_key_code != req->minKeyCode) || |
2505 | (xkb->max_key_code != req->maxKeyCode)) { |
2506 | Statusint status; |
2507 | xkbNewKeyboardNotify nkn; |
2508 | |
2509 | nkn.deviceID = nkn.oldDeviceID = dev->id; |
2510 | nkn.oldMinKeyCode = xkb->min_key_code; |
2511 | nkn.oldMaxKeyCode = xkb->max_key_code; |
2512 | status = XkbChangeKeycodeRangeSrvXkbChangeKeycodeRange(xkb, req->minKeyCode, |
2513 | req->maxKeyCode, &change); |
2514 | if (status != Success0) |
2515 | return status; /* oh-oh. what about the other keyboards? */ |
2516 | nkn.minKeyCode = xkb->min_key_code; |
2517 | nkn.maxKeyCode = xkb->max_key_code; |
2518 | nkn.requestMajor = XkbReqCode; |
2519 | nkn.requestMinor = X_kbSetMap9; |
2520 | nkn.changed = XkbNKN_KeycodesMask(1L << 0); |
2521 | XkbSendNewKeyboardNotify(dev, &nkn); |
2522 | sentNKN = TRUE1; |
2523 | } |
2524 | |
2525 | if (req->present & XkbKeyTypesMask(1<<0)) { |
2526 | values = SetKeyTypes(xkb, req, (xkbKeyTypeWireDesc *) values, &change); |
2527 | if (!values) |
2528 | goto allocFailure; |
2529 | } |
2530 | if (req->present & XkbKeySymsMask(1<<1)) { |
2531 | values = |
2532 | SetKeySyms(client, xkb, req, (xkbSymMapWireDesc *) values, &change, |
2533 | dev); |
2534 | if (!values) |
2535 | goto allocFailure; |
2536 | } |
2537 | if (req->present & XkbKeyActionsMask(1<<4)) { |
2538 | values = SetKeyActions(xkb, req, (CARD8 *) values, &change); |
2539 | if (!values) |
2540 | goto allocFailure; |
2541 | } |
2542 | if (req->present & XkbKeyBehaviorsMask(1<<5)) { |
2543 | values = |
2544 | SetKeyBehaviors(xkbi, req, (xkbBehaviorWireDesc *) values, &change); |
2545 | if (!values) |
2546 | goto allocFailure; |
2547 | } |
2548 | if (req->present & XkbVirtualModsMask(1<<6)) |
2549 | values = SetVirtualMods(xkbi, req, (CARD8 *) values, &change); |
2550 | if (req->present & XkbExplicitComponentsMask(1<<3)) |
2551 | values = SetKeyExplicit(xkbi, req, (CARD8 *) values, &change); |
2552 | if (req->present & XkbModifierMapMask(1<<2)) |
2553 | values = SetModifierMap(xkbi, req, (CARD8 *) values, &change); |
2554 | if (req->present & XkbVirtualModMapMask(1<<7)) |
2555 | values = |
2556 | SetVirtualModMap(xkbi, req, (xkbVModMapWireDesc *) values, &change); |
2557 | if (((values - ((char *) req)) / 4) != req->length) { |
2558 | ErrorF("[xkb] Internal error! Bad length in XkbSetMap (after set)\n"); |
2559 | client->errorValue = values - ((char *) &req[1]); |
2560 | return BadLength16; |
2561 | } |
2562 | if (req->flags & XkbSetMapRecomputeActions(1L<<1)) { |
2563 | KeyCode first, last, firstMM, lastMM; |
2564 | |
2565 | if (change.map.num_key_syms > 0) { |
2566 | first = change.map.first_key_sym; |
2567 | last = first + change.map.num_key_syms - 1; |
2568 | } |
2569 | else |
2570 | first = last = 0; |
2571 | if (change.map.num_modmap_keys > 0) { |
2572 | firstMM = change.map.first_modmap_key; |
2573 | lastMM = first + change.map.num_modmap_keys - 1; |
2574 | } |
2575 | else |
2576 | firstMM = lastMM = 0; |
2577 | if ((last > 0) && (lastMM > 0)) { |
2578 | if (firstMM < first) |
2579 | first = firstMM; |
2580 | if (lastMM > last) |
2581 | last = lastMM; |
2582 | } |
2583 | else if (lastMM > 0) { |
2584 | first = firstMM; |
2585 | last = lastMM; |
2586 | } |
2587 | if (last > 0) { |
2588 | unsigned check = 0; |
2589 | |
2590 | XkbUpdateActions(dev, first, (last - first + 1), &change, &check, |
2591 | &cause); |
2592 | if (check) |
2593 | XkbCheckSecondaryEffects(xkbi, check, &change, &cause); |
2594 | } |
2595 | } |
2596 | if (!sentNKN) |
2597 | XkbSendNotification(dev, &change, &cause); |
2598 | |
2599 | return Success0; |
2600 | allocFailure: |
2601 | return BadAlloc11; |
2602 | } |
2603 | |
2604 | int |
2605 | ProcXkbSetMap(ClientPtr client) |
2606 | { |
2607 | DeviceIntPtr dev; |
2608 | char *tmp; |
2609 | int rc; |
2610 | |
2611 | REQUEST(xkbSetMapReq)xkbSetMapReq *stuff = (xkbSetMapReq *)client->requestBuffer; |
2612 | REQUEST_AT_LEAST_SIZE(xkbSetMapReq)if ((sizeof(xkbSetMapReq) >> 2) > client->req_len ) return(16); |
2613 | |
2614 | if (!(client->xkbClientFlags & _XkbClientInitialized(1<<15))) |
2615 | return BadAccess10; |
2616 | |
2617 | CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixManageAccess){ int why; int tmprc = _XkbLookupKeyboard(&(dev), stuff-> deviceSpec, client, (1<<25), &why); if (tmprc != 0) { client->errorValue = ((XID)((((unsigned int)(why))<< 24)|((stuff->deviceSpec)&0xffffff))); return tmprc; }}; |
2618 | CHK_MASK_LEGAL(0x01, stuff->present, XkbAllMapComponentsMask){ if ((stuff->present)&(~((((1<<0)|(1<<1)| (1<<2))|((1<<3)|(1<<4)|(1<<5)|(1<< 6)|(1<<7)))))) { (client->errorValue)= ((XID)((((unsigned int)((0x01)))<<24)|((((stuff->present)&(~((((1<< 0)|(1<<1)|(1<<2))|((1<<3)|(1<<4)|(1<< 5)|(1<<6)|(1<<7)))))))&0xffffff))); return 2; }}; |
2619 | |
2620 | tmp = (char *) &stuff[1]; |
2621 | |
2622 | /* Check if we can to the SetMap on the requested device. If this |
2623 | succeeds, do the same thing for all extension devices (if needed). |
2624 | If any of them fails, fail. */ |
2625 | rc = _XkbSetMapChecks(client, dev, stuff, tmp); |
2626 | |
2627 | if (rc != Success0) |
2628 | return rc; |
2629 | |
2630 | if (stuff->deviceSpec == XkbUseCoreKbd0x0100) { |
2631 | DeviceIntPtr other; |
2632 | |
2633 | for (other = inputInfo.devices; other; other = other->next) { |
2634 | if ((other != dev) && other->key && !IsMaster(other) && |
2635 | GetMaster(other, MASTER_KEYBOARD2) == dev) { |
2636 | rc = XaceHook(XACE_DEVICE_ACCESS3, client, other, |
2637 | DixManageAccess(1<<25)); |
2638 | if (rc == Success0) { |
2639 | rc = _XkbSetMapChecks(client, other, stuff, tmp); |
2640 | if (rc != Success0) |
2641 | return rc; |
2642 | } |
2643 | } |
2644 | } |
2645 | } |
2646 | |
2647 | /* We know now that we will succed with the SetMap. In theory anyway. */ |
2648 | rc = _XkbSetMap(client, dev, stuff, tmp); |
2649 | if (rc != Success0) |
2650 | return rc; |
2651 | |
2652 | if (stuff->deviceSpec == XkbUseCoreKbd0x0100) { |
2653 | DeviceIntPtr other; |
2654 | |
2655 | for (other = inputInfo.devices; other; other = other->next) { |
2656 | if ((other != dev) && other->key && !IsMaster(other) && |
2657 | GetMaster(other, MASTER_KEYBOARD2) == dev) { |
2658 | rc = XaceHook(XACE_DEVICE_ACCESS3, client, other, |
2659 | DixManageAccess(1<<25)); |
2660 | if (rc == Success0) |
2661 | _XkbSetMap(client, other, stuff, tmp); |
2662 | /* ignore rc. if the SetMap failed although the check above |
2663 | reported true there isn't much we can do. we still need to |
2664 | set all other devices, hoping that at least they stay in |
2665 | sync. */ |
2666 | } |
2667 | } |
2668 | } |
2669 | |
2670 | return Success0; |
2671 | } |
2672 | |
2673 | /***====================================================================***/ |
2674 | |
2675 | static Statusint |
2676 | XkbComputeGetCompatMapReplySize(XkbCompatMapPtr compat, |
2677 | xkbGetCompatMapReply * rep) |
2678 | { |
2679 | unsigned size, nGroups; |
2680 | |
2681 | nGroups = 0; |
2682 | if (rep->groups != 0) { |
2683 | register int i, bit; |
2684 | |
2685 | for (i = 0, bit = 1; i < XkbNumKbdGroups4; i++, bit <<= 1) { |
2686 | if (rep->groups & bit) |
2687 | nGroups++; |
2688 | } |
2689 | } |
2690 | size = nGroups * SIZEOF(xkbModsWireDesc)4; |
2691 | size += (rep->nSI * SIZEOF(xkbSymInterpretWireDesc)16); |
2692 | rep->length = size / 4; |
2693 | return Success0; |
2694 | } |
2695 | |
2696 | static int |
2697 | XkbSendCompatMap(ClientPtr client, |
2698 | XkbCompatMapPtr compat, xkbGetCompatMapReply * rep) |
2699 | { |
2700 | char *data; |
2701 | int size; |
2702 | |
2703 | size = rep->length * 4; |
2704 | if (size > 0) { |
2705 | data = malloc(size); |
2706 | if (data) { |
2707 | register unsigned i, bit; |
2708 | xkbModsWireDesc *grp; |
2709 | XkbSymInterpretPtr sym = &compat->sym_interpret[rep->firstSI]; |
2710 | xkbSymInterpretWireDesc *wire = (xkbSymInterpretWireDesc *) data; |
2711 | |
2712 | for (i = 0; i < rep->nSI; i++, sym++, wire++) { |
2713 | wire->sym = sym->sym; |
2714 | wire->mods = sym->mods; |
2715 | wire->match = sym->match; |
2716 | wire->virtualMod = sym->virtual_mod; |
2717 | wire->flags = sym->flags; |
2718 | memcpy((char *) &wire->act, (char *) &sym->act,__builtin___memcpy_chk ((char *) &wire->act, (char *) & sym->act, 8, __builtin_object_size ((char *) &wire-> act, 0)) |
2719 | sz_xkbActionWireDesc)__builtin___memcpy_chk ((char *) &wire->act, (char *) & sym->act, 8, __builtin_object_size ((char *) &wire-> act, 0)); |
2720 | if (client->swapped) { |
2721 | swapl(&wire->sym)do { if (sizeof(*(&wire->sym)) != 4) wrong_size(); if ( __builtin_constant_p((uintptr_t)(&wire->sym) & 3) && ((uintptr_t)(&wire->sym) & 3) == 0) *(&wire-> sym) = lswapl(*(&wire->sym)); else swap_uint32((uint32_t *)(&wire->sym)); } while (0); |
2722 | } |
2723 | } |
2724 | if (rep->groups) { |
2725 | grp = (xkbModsWireDesc *) wire; |
2726 | for (i = 0, bit = 1; i < XkbNumKbdGroups4; i++, bit <<= 1) { |
2727 | if (rep->groups & bit) { |
2728 | grp->mask = compat->groups[i].mask; |
2729 | grp->realMods = compat->groups[i].real_mods; |
2730 | grp->virtualMods = compat->groups[i].vmods; |
2731 | if (client->swapped) { |
2732 | swaps(&grp->virtualMods)do { if (sizeof(*(&grp->virtualMods)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&grp->virtualMods ) & 1) && ((uintptr_t)(&grp->virtualMods) & 1) == 0) *(&grp->virtualMods) = lswaps(*(&grp-> virtualMods)); else swap_uint16((uint16_t *)(&grp->virtualMods )); } while (0); |
2733 | } |
2734 | grp++; |
2735 | } |
2736 | } |
2737 | wire = (xkbSymInterpretWireDesc *) grp; |
Value stored to 'wire' is never read | |
2738 | } |
2739 | } |
2740 | else |
2741 | return BadAlloc11; |
2742 | } |
2743 | else |
2744 | data = NULL((void*)0); |
2745 | |
2746 | if (client->swapped) { |
2747 | swaps(&rep->sequenceNumber)do { if (sizeof(*(&rep->sequenceNumber)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&rep->sequenceNumber ) & 1) && ((uintptr_t)(&rep->sequenceNumber ) & 1) == 0) *(&rep->sequenceNumber) = lswaps(*(& rep->sequenceNumber)); else swap_uint16((uint16_t *)(& rep->sequenceNumber)); } while (0); |
2748 | swapl(&rep->length)do { if (sizeof(*(&rep->length)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&rep->length) & 3) && ((uintptr_t)(&rep->length) & 3) == 0 ) *(&rep->length) = lswapl(*(&rep->length)); else swap_uint32((uint32_t *)(&rep->length)); } while (0); |
2749 | swaps(&rep->firstSI)do { if (sizeof(*(&rep->firstSI)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&rep->firstSI) & 1) && ((uintptr_t)(&rep->firstSI) & 1) == 0) *(&rep->firstSI) = lswaps(*(&rep->firstSI)) ; else swap_uint16((uint16_t *)(&rep->firstSI)); } while (0); |
2750 | swaps(&rep->nSI)do { if (sizeof(*(&rep->nSI)) != 2) wrong_size(); if ( __builtin_constant_p((uintptr_t)(&rep->nSI) & 1) && ((uintptr_t)(&rep->nSI) & 1) == 0) *(&rep-> nSI) = lswaps(*(&rep->nSI)); else swap_uint16((uint16_t *)(&rep->nSI)); } while (0); |
2751 | swaps(&rep->nTotalSI)do { if (sizeof(*(&rep->nTotalSI)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&rep->nTotalSI) & 1) && ((uintptr_t)(&rep->nTotalSI) & 1) == 0) *(&rep->nTotalSI) = lswaps(*(&rep->nTotalSI )); else swap_uint16((uint16_t *)(&rep->nTotalSI)); } while (0); |
2752 | } |
2753 | |
2754 | WriteToClient(client, SIZEOF(xkbGetCompatMapReply)32, rep); |
2755 | if (data) { |
2756 | WriteToClient(client, size, data); |
2757 | free((char *) data); |
2758 | } |
2759 | return Success0; |
2760 | } |
2761 | |
2762 | int |
2763 | ProcXkbGetCompatMap(ClientPtr client) |
2764 | { |
2765 | xkbGetCompatMapReply rep; |
2766 | DeviceIntPtr dev; |
2767 | XkbDescPtr xkb; |
2768 | XkbCompatMapPtr compat; |
2769 | |
2770 | REQUEST(xkbGetCompatMapReq)xkbGetCompatMapReq *stuff = (xkbGetCompatMapReq *)client-> requestBuffer; |
2771 | REQUEST_SIZE_MATCH(xkbGetCompatMapReq)if ((sizeof(xkbGetCompatMapReq) >> 2) != client->req_len ) return(16); |
2772 | |
2773 | if (!(client->xkbClientFlags & _XkbClientInitialized(1<<15))) |
2774 | return BadAccess10; |
2775 | |
2776 | CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixGetAttrAccess){ int why; int tmprc = _XkbLookupKeyboard(&(dev), stuff-> deviceSpec, client, (1<<4), &why); if (tmprc != 0) { client->errorValue = ((XID)((((unsigned int)(why))<< 24)|((stuff->deviceSpec)&0xffffff))); return tmprc; }}; |
2777 | |
2778 | xkb = dev->key->xkbInfo->desc; |
2779 | compat = xkb->compat; |
2780 | |
2781 | rep = (xkbGetCompatMapReply) { |
2782 | .type = X_Reply1, |
2783 | .sequenceNumber = client->sequence, |
2784 | .length = 0, |
2785 | .deviceID = dev->id, |
2786 | .firstSI = stuff->firstSI, |
2787 | .nSI = stuff->nSI |
2788 | }; |
2789 | if (stuff->getAllSI) { |
2790 | rep.firstSI = 0; |
2791 | rep.nSI = compat->num_si; |
2792 | } |
2793 | else if ((((unsigned) stuff->nSI) > 0) && |
2794 | ((unsigned) (stuff->firstSI + stuff->nSI - 1) >= compat->num_si)) { |
2795 | client->errorValue = _XkbErrCode2(0x05, compat->num_si)((XID)((((unsigned int)(0x05))<<24)|((compat->num_si )&0xffffff))); |
2796 | return BadValue2; |
2797 | } |
2798 | rep.nTotalSI = compat->num_si; |
2799 | rep.groups = stuff->groups; |
2800 | XkbComputeGetCompatMapReplySize(compat, &rep); |
2801 | return XkbSendCompatMap(client, compat, &rep); |
2802 | } |
2803 | |
2804 | /** |
2805 | * Apply the given request on the given device. |
2806 | * If dryRun is TRUE, then value checks are performed, but the device isn't |
2807 | * modified. |
2808 | */ |
2809 | static int |
2810 | _XkbSetCompatMap(ClientPtr client, DeviceIntPtr dev, |
2811 | xkbSetCompatMapReq * req, char *data, BOOL dryRun) |
2812 | { |
2813 | XkbSrvInfoPtr xkbi; |
2814 | XkbDescPtr xkb; |
2815 | XkbCompatMapPtr compat; |
2816 | int nGroups; |
2817 | unsigned i, bit; |
2818 | |
2819 | xkbi = dev->key->xkbInfo; |
2820 | xkb = xkbi->desc; |
2821 | compat = xkb->compat; |
2822 | |
2823 | if ((req->nSI > 0) || (req->truncateSI)) { |
2824 | xkbSymInterpretWireDesc *wire; |
2825 | |
2826 | if (req->firstSI > compat->num_si) { |
2827 | client->errorValue = _XkbErrCode2(0x02, compat->num_si)((XID)((((unsigned int)(0x02))<<24)|((compat->num_si )&0xffffff))); |
2828 | return BadValue2; |
2829 | } |
2830 | wire = (xkbSymInterpretWireDesc *) data; |
2831 | wire += req->nSI; |
2832 | data = (char *) wire; |
2833 | } |
2834 | |
2835 | nGroups = 0; |
2836 | if (req->groups != 0) { |
2837 | for (i = 0, bit = 1; i < XkbNumKbdGroups4; i++, bit <<= 1) { |
2838 | if (req->groups & bit) |
2839 | nGroups++; |
2840 | } |
2841 | } |
2842 | data += nGroups * SIZEOF(xkbModsWireDesc)4; |
2843 | if (((data - ((char *) req)) / 4) != req->length) { |
2844 | return BadLength16; |
2845 | } |
2846 | |
2847 | /* Done all the checks we can do */ |
2848 | if (dryRun) |
2849 | return Success0; |
2850 | |
2851 | data = (char *) &req[1]; |
2852 | if (req->nSI > 0) { |
2853 | xkbSymInterpretWireDesc *wire = (xkbSymInterpretWireDesc *) data; |
2854 | XkbSymInterpretPtr sym; |
2855 | unsigned int skipped = 0; |
2856 | |
2857 | if ((unsigned) (req->firstSI + req->nSI) > compat->num_si) { |
2858 | compat->num_si = req->firstSI + req->nSI; |
2859 | compat->sym_interpret = realloc(compat->sym_interpret, |
2860 | compat->num_si * |
2861 | sizeof(XkbSymInterpretRec)); |
2862 | if (!compat->sym_interpret) { |
2863 | compat->num_si = 0; |
2864 | return BadAlloc11; |
2865 | } |
2866 | } |
2867 | else if (req->truncateSI) { |
2868 | compat->num_si = req->firstSI + req->nSI; |
2869 | } |
2870 | sym = &compat->sym_interpret[req->firstSI]; |
2871 | for (i = 0; i < req->nSI; i++, wire++) { |
2872 | if (client->swapped) { |
2873 | swapl(&wire->sym)do { if (sizeof(*(&wire->sym)) != 4) wrong_size(); if ( __builtin_constant_p((uintptr_t)(&wire->sym) & 3) && ((uintptr_t)(&wire->sym) & 3) == 0) *(&wire-> sym) = lswapl(*(&wire->sym)); else swap_uint32((uint32_t *)(&wire->sym)); } while (0); |
2874 | } |
2875 | if (wire->sym == NoSymbol0L && wire->match == XkbSI_AnyOfOrNone(1) && |
2876 | (wire->mods & 0xff) == 0xff && |
2877 | wire->act.type == XkbSA_XFree86Private0x86) { |
2878 | ErrorF("XKB: Skipping broken Any+AnyOfOrNone(All) -> Private " |
2879 | "action from client\n"); |
2880 | skipped++; |
2881 | continue; |
2882 | } |
2883 | sym->sym = wire->sym; |
2884 | sym->mods = wire->mods; |
2885 | sym->match = wire->match; |
2886 | sym->flags = wire->flags; |
2887 | sym->virtual_mod = wire->virtualMod; |
2888 | memcpy((char *) &sym->act, (char *) &wire->act,__builtin___memcpy_chk ((char *) &sym->act, (char *) & wire->act, 8, __builtin_object_size ((char *) &sym-> act, 0)) |
2889 | SIZEOF(xkbActionWireDesc))__builtin___memcpy_chk ((char *) &sym->act, (char *) & wire->act, 8, __builtin_object_size ((char *) &sym-> act, 0)); |
2890 | sym++; |
2891 | } |
2892 | if (skipped) { |
2893 | if (req->firstSI + req->nSI < compat->num_si) |
2894 | memmove(sym, sym + skipped,__builtin___memmove_chk (sym, sym + skipped, (compat->num_si - req->firstSI - req->nSI) * sizeof(*sym), __builtin_object_size (sym, 0)) |
2895 | (compat->num_si - req->firstSI - req->nSI) *__builtin___memmove_chk (sym, sym + skipped, (compat->num_si - req->firstSI - req->nSI) * sizeof(*sym), __builtin_object_size (sym, 0)) |
2896 | sizeof(*sym))__builtin___memmove_chk (sym, sym + skipped, (compat->num_si - req->firstSI - req->nSI) * sizeof(*sym), __builtin_object_size (sym, 0)); |
2897 | compat->num_si -= skipped; |
2898 | } |
2899 | data = (char *) wire; |
2900 | } |
2901 | else if (req->truncateSI) { |
2902 | compat->num_si = req->firstSI; |
2903 | } |
2904 | |
2905 | if (req->groups != 0) { |
2906 | xkbModsWireDesc *wire = (xkbModsWireDesc *) data; |
2907 | |
2908 | for (i = 0, bit = 1; i < XkbNumKbdGroups4; i++, bit <<= 1) { |
2909 | if (req->groups & bit) { |
2910 | if (client->swapped) { |
2911 | swaps(&wire->virtualMods)do { if (sizeof(*(&wire->virtualMods)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&wire->virtualMods ) & 1) && ((uintptr_t)(&wire->virtualMods) & 1) == 0) *(&wire->virtualMods) = lswaps(*(& wire->virtualMods)); else swap_uint16((uint16_t *)(&wire ->virtualMods)); } while (0); |
2912 | } |
2913 | compat->groups[i].mask = wire->realMods; |
2914 | compat->groups[i].real_mods = wire->realMods; |
2915 | compat->groups[i].vmods = wire->virtualMods; |
2916 | if (wire->virtualMods != 0) { |
2917 | unsigned tmp; |
2918 | |
2919 | tmp = XkbMaskForVMask(xkb, wire->virtualMods); |
2920 | compat->groups[i].mask |= tmp; |
2921 | } |
2922 | data += SIZEOF(xkbModsWireDesc)4; |
2923 | wire = (xkbModsWireDesc *) data; |
2924 | } |
2925 | } |
2926 | } |
2927 | i = XkbPaddedSize((data - ((char *) req)))((((unsigned int)((data - ((char *) req)))+3) >> 2) << 2); |
2928 | if ((i / 4) != req->length) { |
2929 | ErrorF("[xkb] Internal length error on read in _XkbSetCompatMap\n"); |
2930 | return BadLength16; |
2931 | } |
2932 | |
2933 | if (dev->xkb_interest) { |
2934 | xkbCompatMapNotify ev; |
2935 | |
2936 | ev.deviceID = dev->id; |
2937 | ev.changedGroups = req->groups; |
2938 | ev.firstSI = req->firstSI; |
2939 | ev.nSI = req->nSI; |
2940 | ev.nTotalSI = compat->num_si; |
2941 | XkbSendCompatMapNotify(dev, &ev); |
2942 | } |
2943 | |
2944 | if (req->recomputeActions) { |
2945 | XkbChangesRec change; |
2946 | unsigned check; |
2947 | XkbEventCauseRec cause; |
2948 | |
2949 | XkbSetCauseXkbReq(&cause, X_kbSetCompatMap, client){ (&cause)->kc= (&cause)->event= 0, (&cause )->mjr= (XkbReqCode),(&cause)->mnr= (11); (&cause )->client= (client); }; |
2950 | memset(&change, 0, sizeof(XkbChangesRec))__builtin___memset_chk (&change, 0, sizeof(XkbChangesRec) , __builtin_object_size (&change, 0)); |
2951 | XkbUpdateActions(dev, xkb->min_key_code, XkbNumKeys(xkb)((xkb)->max_key_code-(xkb)->min_key_code+1), &change, |
2952 | &check, &cause); |
2953 | if (check) |
2954 | XkbCheckSecondaryEffects(xkbi, check, &change, &cause); |
2955 | XkbSendNotification(dev, &change, &cause); |
2956 | } |
2957 | return Success0; |
2958 | } |
2959 | |
2960 | int |
2961 | ProcXkbSetCompatMap(ClientPtr client) |
2962 | { |
2963 | DeviceIntPtr dev; |
2964 | char *data; |
2965 | int rc; |
2966 | |
2967 | REQUEST(xkbSetCompatMapReq)xkbSetCompatMapReq *stuff = (xkbSetCompatMapReq *)client-> requestBuffer; |
2968 | REQUEST_AT_LEAST_SIZE(xkbSetCompatMapReq)if ((sizeof(xkbSetCompatMapReq) >> 2) > client->req_len ) return(16); |
2969 | |
2970 | if (!(client->xkbClientFlags & _XkbClientInitialized(1<<15))) |
2971 | return BadAccess10; |
2972 | |
2973 | CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixManageAccess){ int why; int tmprc = _XkbLookupKeyboard(&(dev), stuff-> deviceSpec, client, (1<<25), &why); if (tmprc != 0) { client->errorValue = ((XID)((((unsigned int)(why))<< 24)|((stuff->deviceSpec)&0xffffff))); return tmprc; }}; |
2974 | |
2975 | data = (char *) &stuff[1]; |
2976 | |
2977 | /* check first using a dry-run */ |
2978 | rc = _XkbSetCompatMap(client, dev, stuff, data, TRUE1); |
2979 | if (rc != Success0) |
2980 | return rc; |
2981 | if (stuff->deviceSpec == XkbUseCoreKbd0x0100) { |
2982 | DeviceIntPtr other; |
2983 | |
2984 | for (other = inputInfo.devices; other; other = other->next) { |
2985 | if ((other != dev) && other->key && !IsMaster(other) && |
2986 | GetMaster(other, MASTER_KEYBOARD2) == dev) { |
2987 | rc = XaceHook(XACE_DEVICE_ACCESS3, client, other, |
2988 | DixManageAccess(1<<25)); |
2989 | if (rc == Success0) { |
2990 | /* dry-run */ |
2991 | rc = _XkbSetCompatMap(client, other, stuff, data, TRUE1); |
2992 | if (rc != Success0) |
2993 | return rc; |
2994 | } |
2995 | } |
2996 | } |
2997 | } |
2998 | |
2999 | /* Yay, the dry-runs succeed. Let's apply */ |
3000 | rc = _XkbSetCompatMap(client, dev, stuff, data, FALSE0); |
3001 | if (rc != Success0) |
3002 | return rc; |
3003 | if (stuff->deviceSpec == XkbUseCoreKbd0x0100) { |
3004 | DeviceIntPtr other; |
3005 | |
3006 | for (other = inputInfo.devices; other; other = other->next) { |
3007 | if ((other != dev) && other->key && !IsMaster(other) && |
3008 | GetMaster(other, MASTER_KEYBOARD2) == dev) { |
3009 | rc = XaceHook(XACE_DEVICE_ACCESS3, client, other, |
3010 | DixManageAccess(1<<25)); |
3011 | if (rc == Success0) { |
3012 | rc = _XkbSetCompatMap(client, other, stuff, data, FALSE0); |
3013 | if (rc != Success0) |
3014 | return rc; |
3015 | } |
3016 | } |
3017 | } |
3018 | } |
3019 | |
3020 | return Success0; |
3021 | } |
3022 | |
3023 | /***====================================================================***/ |
3024 | |
3025 | int |
3026 | ProcXkbGetIndicatorState(ClientPtr client) |
3027 | { |
3028 | xkbGetIndicatorStateReply rep; |
3029 | XkbSrvLedInfoPtr sli; |
3030 | DeviceIntPtr dev; |
3031 | |
3032 | REQUEST(xkbGetIndicatorStateReq)xkbGetIndicatorStateReq *stuff = (xkbGetIndicatorStateReq *)client ->requestBuffer; |
3033 | REQUEST_SIZE_MATCH(xkbGetIndicatorStateReq)if ((sizeof(xkbGetIndicatorStateReq) >> 2) != client-> req_len) return(16); |
3034 | |
3035 | if (!(client->xkbClientFlags & _XkbClientInitialized(1<<15))) |
3036 | return BadAccess10; |
3037 | |
3038 | CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixReadAccess){ int why; int tmprc = _XkbLookupKeyboard(&(dev), stuff-> deviceSpec, client, (1<<0), &why); if (tmprc != 0) { client->errorValue = ((XID)((((unsigned int)(why))<< 24)|((stuff->deviceSpec)&0xffffff))); return tmprc; }}; |
3039 | |
3040 | sli = XkbFindSrvLedInfo(dev, XkbDfltXIClass0x0300, XkbDfltXIId0x0400, |
3041 | XkbXI_IndicatorStateMask(1L << 4)); |
3042 | if (!sli) |
3043 | return BadAlloc11; |
3044 | |
3045 | rep = (xkbGetIndicatorStateReply) { |
3046 | .type = X_Reply1, |
3047 | .deviceID = dev->id, |
3048 | .sequenceNumber = client->sequence, |
3049 | .length = 0, |
3050 | .state = sli->effectiveState |
3051 | }; |
3052 | |
3053 | if (client->swapped) { |
3054 | swaps(&rep.sequenceNumber)do { if (sizeof(*(&rep.sequenceNumber)) != 2) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&rep.sequenceNumber ) & 1) && ((uintptr_t)(&rep.sequenceNumber) & 1) == 0) *(&rep.sequenceNumber) = lswaps(*(&rep.sequenceNumber )); else swap_uint16((uint16_t *)(&rep.sequenceNumber)); } while (0); |
3055 | swapl(&rep.state)do { if (sizeof(*(&rep.state)) != 4) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&rep.state) & 3) && ((uintptr_t) (&rep.state) & 3) == 0) *(&rep.state) = lswapl(*( &rep.state)); else swap_uint32((uint32_t *)(&rep.state )); } while (0); |
3056 | } |
3057 | WriteToClient(client, SIZEOF(xkbGetIndicatorStateReply)32, &rep); |
3058 | return Success0; |
3059 | } |
3060 | |
3061 | /***====================================================================***/ |
3062 | |
3063 | static Statusint |
3064 | XkbComputeGetIndicatorMapReplySize(XkbIndicatorPtr indicators, |
3065 | xkbGetIndicatorMapReply * rep) |
3066 | { |
3067 | register int i, bit; |
3068 | int nIndicators; |
3069 | |
3070 | rep->realIndicators = indicators->phys_indicators; |
3071 | for (i = nIndicators = 0, bit = 1; i < XkbNumIndicators32; i++, bit <<= 1) { |
3072 | if (rep->which & bit) |
3073 | nIndicators++; |
3074 | } |
3075 | rep->length = (nIndicators * SIZEOF(xkbIndicatorMapWireDesc)12) / 4; |
3076 | rep->nIndicators = nIndicators; |
3077 | return Success0; |
3078 | } |
3079 | |
3080 | static int |
3081 | XkbSendIndicatorMap(ClientPtr client, |
3082 | XkbIndicatorPtr indicators, xkbGetIndicatorMapReply * rep) |
3083 | { |
3084 | int length; |
3085 | CARD8 *map; |
3086 | register int i; |
3087 | register unsigned bit; |
3088 | |
3089 | length = rep->length * 4; |
3090 | if (length > 0) { |
3091 | CARD8 *to; |
3092 | |
3093 | to = map = malloc(length); |
3094 | if (map) { |
3095 | xkbIndicatorMapWireDesc *wire = (xkbIndicatorMapWireDesc *) to; |
3096 | |
3097 | for (i = 0, bit = 1; i < XkbNumIndicators32; i++, bit <<= 1) { |
3098 | if (rep->which & bit) { |
3099 | wire->flags = indicators->maps[i].flags; |
3100 | wire->whichGroups = indicators->maps[i].which_groups; |
3101 | wire->groups = indicators->maps[i].groups; |
3102 | wire->whichMods = indicators->maps[i].which_mods; |
3103 | wire->mods = indicators->maps[i].mods.mask; |
3104 | wire->realMods = indicators->maps[i].mods.real_mods; |
3105 | wire->virtualMods = indicators->maps[i].mods.vmods; |
3106 | wire->ctrls = indicators->maps[i].ctrls; |
3107 | if (client->swapped) { |
3108 | swaps(&wire->virtualMods)do { if (sizeof(*(&wire->virtualMods)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&wire->virtualMods ) & 1) && ((uintptr_t)(&wire->virtualMods) & 1) == 0) *(&wire->virtualMods) = lswaps(*(& wire->virtualMods)); else swap_uint16((uint16_t *)(&wire ->virtualMods)); } while (0); |
3109 | swapl(&wire->ctrls)do { if (sizeof(*(&wire->ctrls)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&wire->ctrls) & 3) && ((uintptr_t)(&wire->ctrls) & 3) == 0 ) *(&wire->ctrls) = lswapl(*(&wire->ctrls)); else swap_uint32((uint32_t *)(&wire->ctrls)); } while (0); |
3110 | } |
3111 | wire++; |
3112 | } |
3113 | } |
3114 | to = (CARD8 *) wire; |
3115 | if ((to - map) != length) { |
3116 | client->errorValue = _XkbErrCode2(0xff, length)((XID)((((unsigned int)(0xff))<<24)|((length)&0xffffff ))); |
3117 | free(map); |
3118 | return BadLength16; |
3119 | } |
3120 | } |
3121 | else |
3122 | return BadAlloc11; |
3123 | } |
3124 | else |
3125 | map = NULL((void*)0); |
3126 | if (client->swapped) { |
3127 | swaps(&rep->sequenceNumber)do { if (sizeof(*(&rep->sequenceNumber)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&rep->sequenceNumber ) & 1) && ((uintptr_t)(&rep->sequenceNumber ) & 1) == 0) *(&rep->sequenceNumber) = lswaps(*(& rep->sequenceNumber)); else swap_uint16((uint16_t *)(& rep->sequenceNumber)); } while (0); |
3128 | swapl(&rep->length)do { if (sizeof(*(&rep->length)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&rep->length) & 3) && ((uintptr_t)(&rep->length) & 3) == 0 ) *(&rep->length) = lswapl(*(&rep->length)); else swap_uint32((uint32_t *)(&rep->length)); } while (0); |
3129 | swapl(&rep->which)do { if (sizeof(*(&rep->which)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&rep->which) & 3 ) && ((uintptr_t)(&rep->which) & 3) == 0) * (&rep->which) = lswapl(*(&rep->which)); else swap_uint32 ((uint32_t *)(&rep->which)); } while (0); |
3130 | swapl(&rep->realIndicators)do { if (sizeof(*(&rep->realIndicators)) != 4) wrong_size (); if (__builtin_constant_p((uintptr_t)(&rep->realIndicators ) & 3) && ((uintptr_t)(&rep->realIndicators ) & 3) == 0) *(&rep->realIndicators) = lswapl(*(& rep->realIndicators)); else swap_uint32((uint32_t *)(& rep->realIndicators)); } while (0); |
3131 | } |
3132 | WriteToClient(client, SIZEOF(xkbGetIndicatorMapReply)32, rep); |
3133 | if (map) { |
3134 | WriteToClient(client, length, map); |
3135 | free((char *) map); |
3136 | } |
3137 | return Success0; |
3138 | } |
3139 | |
3140 | int |
3141 | ProcXkbGetIndicatorMap(ClientPtr client) |
3142 | { |
3143 | xkbGetIndicatorMapReply rep; |
3144 | DeviceIntPtr dev; |
3145 | XkbDescPtr xkb; |
3146 | XkbIndicatorPtr leds; |
3147 | |
3148 | REQUEST(xkbGetIndicatorMapReq)xkbGetIndicatorMapReq *stuff = (xkbGetIndicatorMapReq *)client ->requestBuffer; |
3149 | REQUEST_SIZE_MATCH(xkbGetIndicatorMapReq)if ((sizeof(xkbGetIndicatorMapReq) >> 2) != client-> req_len) return(16); |
3150 | |
3151 | if (!(client->xkbClientFlags & _XkbClientInitialized(1<<15))) |
3152 | return BadAccess10; |
3153 | |
3154 | CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixGetAttrAccess){ int why; int tmprc = _XkbLookupKeyboard(&(dev), stuff-> deviceSpec, client, (1<<4), &why); if (tmprc != 0) { client->errorValue = ((XID)((((unsigned int)(why))<< 24)|((stuff->deviceSpec)&0xffffff))); return tmprc; }}; |
3155 | |
3156 | xkb = dev->key->xkbInfo->desc; |
3157 | leds = xkb->indicators; |
3158 | |
3159 | rep = (xkbGetIndicatorMapReply) { |
3160 | .type = X_Reply1, |
3161 | .deviceID = dev->id, |
3162 | .sequenceNumber = client->sequence, |
3163 | .length = 0, |
3164 | .which = stuff->which |
3165 | }; |
3166 | XkbComputeGetIndicatorMapReplySize(leds, &rep); |
3167 | return XkbSendIndicatorMap(client, leds, &rep); |
3168 | } |
3169 | |
3170 | /** |
3171 | * Apply the given map to the given device. Which specifies which components |
3172 | * to apply. |
3173 | */ |
3174 | static int |
3175 | _XkbSetIndicatorMap(ClientPtr client, DeviceIntPtr dev, |
3176 | int which, xkbIndicatorMapWireDesc * desc) |
3177 | { |
3178 | XkbSrvInfoPtr xkbi; |
3179 | XkbSrvLedInfoPtr sli; |
3180 | XkbEventCauseRec cause; |
3181 | int i, bit; |
3182 | |
3183 | xkbi = dev->key->xkbInfo; |
3184 | |
3185 | sli = XkbFindSrvLedInfo(dev, XkbDfltXIClass0x0300, XkbDfltXIId0x0400, |
3186 | XkbXI_IndicatorMapsMask(1L << 3)); |
3187 | if (!sli) |
3188 | return BadAlloc11; |
3189 | |
3190 | for (i = 0, bit = 1; i < XkbNumIndicators32; i++, bit <<= 1) { |
3191 | if (which & bit) { |
3192 | sli->maps[i].flags = desc->flags; |
3193 | sli->maps[i].which_groups = desc->whichGroups; |
3194 | sli->maps[i].groups = desc->groups; |
3195 | sli->maps[i].which_mods = desc->whichMods; |
3196 | sli->maps[i].mods.mask = desc->mods; |
3197 | sli->maps[i].mods.real_mods = desc->mods; |
3198 | sli->maps[i].mods.vmods = desc->virtualMods; |
3199 | sli->maps[i].ctrls = desc->ctrls; |
3200 | if (desc->virtualMods != 0) { |
3201 | unsigned tmp; |
3202 | |
3203 | tmp = XkbMaskForVMask(xkbi->desc, desc->virtualMods); |
3204 | sli->maps[i].mods.mask = desc->mods | tmp; |
3205 | } |
3206 | desc++; |
3207 | } |
3208 | } |
3209 | |
3210 | XkbSetCauseXkbReq(&cause, X_kbSetIndicatorMap, client){ (&cause)->kc= (&cause)->event= 0, (&cause )->mjr= (XkbReqCode),(&cause)->mnr= (14); (&cause )->client= (client); }; |
3211 | XkbApplyLedMapChanges(dev, sli, which, NULL((void*)0), NULL((void*)0), &cause); |
3212 | |
3213 | return Success0; |
3214 | } |
3215 | |
3216 | int |
3217 | ProcXkbSetIndicatorMap(ClientPtr client) |
3218 | { |
3219 | int i, bit; |
3220 | int nIndicators; |
3221 | DeviceIntPtr dev; |
3222 | xkbIndicatorMapWireDesc *from; |
3223 | int rc; |
3224 | |
3225 | REQUEST(xkbSetIndicatorMapReq)xkbSetIndicatorMapReq *stuff = (xkbSetIndicatorMapReq *)client ->requestBuffer; |
3226 | REQUEST_AT_LEAST_SIZE(xkbSetIndicatorMapReq)if ((sizeof(xkbSetIndicatorMapReq) >> 2) > client-> req_len ) return(16); |
3227 | |
3228 | if (!(client->xkbClientFlags & _XkbClientInitialized(1<<15))) |
3229 | return BadAccess10; |
3230 | |
3231 | CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixSetAttrAccess){ int why; int tmprc = _XkbLookupKeyboard(&(dev), stuff-> deviceSpec, client, (1<<5), &why); if (tmprc != 0) { client->errorValue = ((XID)((((unsigned int)(why))<< 24)|((stuff->deviceSpec)&0xffffff))); return tmprc; }}; |
3232 | |
3233 | if (stuff->which == 0) |
3234 | return Success0; |
3235 | |
3236 | for (nIndicators = i = 0, bit = 1; i < XkbNumIndicators32; i++, bit <<= 1) { |
3237 | if (stuff->which & bit) |
3238 | nIndicators++; |
3239 | } |
3240 | if (stuff->length != ((SIZEOF(xkbSetIndicatorMapReq)12 + |
3241 | (nIndicators * SIZEOF(xkbIndicatorMapWireDesc)12)) / |
3242 | 4)) { |
3243 | return BadLength16; |
3244 | } |
3245 | |
3246 | from = (xkbIndicatorMapWireDesc *) &stuff[1]; |
3247 | for (i = 0, bit = 1; i < XkbNumIndicators32; i++, bit <<= 1) { |
3248 | if (stuff->which & bit) { |
3249 | if (client->swapped) { |
3250 | swaps(&from->virtualMods)do { if (sizeof(*(&from->virtualMods)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&from->virtualMods ) & 1) && ((uintptr_t)(&from->virtualMods) & 1) == 0) *(&from->virtualMods) = lswaps(*(& from->virtualMods)); else swap_uint16((uint16_t *)(&from ->virtualMods)); } while (0); |
3251 | swapl(&from->ctrls)do { if (sizeof(*(&from->ctrls)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&from->ctrls) & 3) && ((uintptr_t)(&from->ctrls) & 3) == 0 ) *(&from->ctrls) = lswapl(*(&from->ctrls)); else swap_uint32((uint32_t *)(&from->ctrls)); } while (0); |
3252 | } |
3253 | CHK_MASK_LEGAL(i, from->whichGroups, XkbIM_UseAnyGroup){ if ((from->whichGroups)&(~(((1L << 0)|(1L << 1)|(1L << 2) |(1L << 3))))) { (client->errorValue )= ((XID)((((unsigned int)((i)))<<24)|((((from->whichGroups )&(~(((1L << 0)|(1L << 1)|(1L << 2) |(1L << 3))))))&0xffffff))); return 2; }}; |
3254 | CHK_MASK_LEGAL(i, from->whichMods, XkbIM_UseAnyMods){ if ((from->whichMods)&(~((((1L << 0)|(1L << 1)|(1L << 2) |(1L << 3))|(1L << 4))))) { ( client->errorValue)= ((XID)((((unsigned int)((i)))<< 24)|((((from->whichMods)&(~((((1L << 0)|(1L << 1)|(1L << 2) |(1L << 3))|(1L << 4))))))& 0xffffff))); return 2; }}; |
3255 | from++; |
3256 | } |
3257 | } |
3258 | |
3259 | from = (xkbIndicatorMapWireDesc *) &stuff[1]; |
3260 | rc = _XkbSetIndicatorMap(client, dev, stuff->which, from); |
3261 | if (rc != Success0) |
3262 | return rc; |
3263 | |
3264 | if (stuff->deviceSpec == XkbUseCoreKbd0x0100) { |
3265 | DeviceIntPtr other; |
3266 | |
3267 | for (other = inputInfo.devices; other; other = other->next) { |
3268 | if ((other != dev) && other->key && !IsMaster(other) && |
3269 | GetMaster(other, MASTER_KEYBOARD2) == dev) { |
3270 | rc = XaceHook(XACE_DEVICE_ACCESS3, client, other, |
3271 | DixSetAttrAccess(1<<5)); |
3272 | if (rc == Success0) |
3273 | _XkbSetIndicatorMap(client, other, stuff->which, from); |
3274 | } |
3275 | } |
3276 | } |
3277 | |
3278 | return Success0; |
3279 | } |
3280 | |
3281 | /***====================================================================***/ |
3282 | |
3283 | int |
3284 | ProcXkbGetNamedIndicator(ClientPtr client) |
3285 | { |
3286 | DeviceIntPtr dev; |
3287 | xkbGetNamedIndicatorReply rep; |
3288 | register int i = 0; |
3289 | XkbSrvLedInfoPtr sli; |
3290 | XkbIndicatorMapPtr map = NULL((void*)0); |
3291 | |
3292 | REQUEST(xkbGetNamedIndicatorReq)xkbGetNamedIndicatorReq *stuff = (xkbGetNamedIndicatorReq *)client ->requestBuffer; |
3293 | REQUEST_SIZE_MATCH(xkbGetNamedIndicatorReq)if ((sizeof(xkbGetNamedIndicatorReq) >> 2) != client-> req_len) return(16); |
3294 | |
3295 | if (!(client->xkbClientFlags & _XkbClientInitialized(1<<15))) |
3296 | return BadAccess10; |
3297 | |
3298 | CHK_LED_DEVICE(dev, stuff->deviceSpec, client, DixReadAccess){ int why; int tmprc = _XkbLookupLedDevice(&(dev), stuff-> deviceSpec, client, (1<<0), &why); if (tmprc != 0) { client->errorValue = ((XID)((((unsigned int)(why))<< 24)|((stuff->deviceSpec)&0xffffff))); return tmprc; }}; |
3299 | CHK_ATOM_ONLY(stuff->indicator){ if (((stuff->indicator)==0L)||(!ValidAtom((stuff->indicator )))) { (client->errorValue)= (XID)(stuff->indicator); return 5; }}; |
3300 | |
3301 | sli = XkbFindSrvLedInfo(dev, stuff->ledClass, stuff->ledID, 0); |
3302 | if (!sli) |
3303 | return BadAlloc11; |
3304 | |
3305 | i = 0; |
3306 | map = NULL((void*)0); |
3307 | if ((sli->names) && (sli->maps)) { |
3308 | for (i = 0; i < XkbNumIndicators32; i++) { |
3309 | if (stuff->indicator == sli->names[i]) { |
3310 | map = &sli->maps[i]; |
3311 | break; |
3312 | } |
3313 | } |
3314 | } |
3315 | |
3316 | rep = (xkbGetNamedIndicatorReply) { |
3317 | .type = X_Reply1, |
3318 | .sequenceNumber = client->sequence, |
3319 | .length = 0, |
3320 | .deviceID = dev->id, |
3321 | .indicator = stuff->indicator |
3322 | }; |
3323 | if (map != NULL((void*)0)) { |
3324 | rep.found = TRUE1; |
3325 | rep.on = ((sli->effectiveState & (1 << i)) != 0); |
3326 | rep.realIndicator = ((sli->physIndicators & (1 << i)) != 0); |
3327 | rep.ndx = i; |
3328 | rep.flags = map->flags; |
3329 | rep.whichGroups = map->which_groups; |
3330 | rep.groups = map->groups; |
3331 | rep.whichMods = map->which_mods; |
3332 | rep.mods = map->mods.mask; |
3333 | rep.realMods = map->mods.real_mods; |
3334 | rep.virtualMods = map->mods.vmods; |
3335 | rep.ctrls = map->ctrls; |
3336 | rep.supported = TRUE1; |
3337 | } |
3338 | else { |
3339 | rep.found = FALSE0; |
3340 | rep.on = FALSE0; |
3341 | rep.realIndicator = FALSE0; |
3342 | rep.ndx = XkbNoIndicator0xff; |
3343 | rep.flags = 0; |
3344 | rep.whichGroups = 0; |
3345 | rep.groups = 0; |
3346 | rep.whichMods = 0; |
3347 | rep.mods = 0; |
3348 | rep.realMods = 0; |
3349 | rep.virtualMods = 0; |
3350 | rep.ctrls = 0; |
3351 | rep.supported = TRUE1; |
3352 | } |
3353 | if (client->swapped) { |
3354 | swapl(&rep.length)do { if (sizeof(*(&rep.length)) != 4) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&rep.length) & 3) && ((uintptr_t )(&rep.length) & 3) == 0) *(&rep.length) = lswapl (*(&rep.length)); else swap_uint32((uint32_t *)(&rep. length)); } while (0); |
3355 | swaps(&rep.sequenceNumber)do { if (sizeof(*(&rep.sequenceNumber)) != 2) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&rep.sequenceNumber ) & 1) && ((uintptr_t)(&rep.sequenceNumber) & 1) == 0) *(&rep.sequenceNumber) = lswaps(*(&rep.sequenceNumber )); else swap_uint16((uint16_t *)(&rep.sequenceNumber)); } while (0); |
3356 | swapl(&rep.indicator)do { if (sizeof(*(&rep.indicator)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&rep.indicator) & 3 ) && ((uintptr_t)(&rep.indicator) & 3) == 0) * (&rep.indicator) = lswapl(*(&rep.indicator)); else swap_uint32 ((uint32_t *)(&rep.indicator)); } while (0); |
3357 | swaps(&rep.virtualMods)do { if (sizeof(*(&rep.virtualMods)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&rep.virtualMods) & 1) && ((uintptr_t)(&rep.virtualMods) & 1) == 0) *(&rep.virtualMods) = lswaps(*(&rep.virtualMods)) ; else swap_uint16((uint16_t *)(&rep.virtualMods)); } while (0); |
3358 | swapl(&rep.ctrls)do { if (sizeof(*(&rep.ctrls)) != 4) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&rep.ctrls) & 3) && ((uintptr_t) (&rep.ctrls) & 3) == 0) *(&rep.ctrls) = lswapl(*( &rep.ctrls)); else swap_uint32((uint32_t *)(&rep.ctrls )); } while (0); |
3359 | } |
3360 | |
3361 | WriteToClient(client, SIZEOF(xkbGetNamedIndicatorReply)32, &rep); |
3362 | return Success0; |
3363 | } |
3364 | |
3365 | /** |
3366 | * Find the IM on the device. |
3367 | * Returns the map, or NULL if the map doesn't exist. |
3368 | * If the return value is NULL, led_return is undefined. Otherwise, led_return |
3369 | * is set to the led index of the map. |
3370 | */ |
3371 | static XkbIndicatorMapPtr |
3372 | _XkbFindNamedIndicatorMap(XkbSrvLedInfoPtr sli, Atom indicator, int *led_return) |
3373 | { |
3374 | XkbIndicatorMapPtr map; |
3375 | |
3376 | /* search for the right indicator */ |
3377 | map = NULL((void*)0); |
3378 | if (sli->names && sli->maps) { |
3379 | int led; |
3380 | |
3381 | for (led = 0; (led < XkbNumIndicators32) && (map == NULL((void*)0)); led++) { |
3382 | if (sli->names[led] == indicator) { |
3383 | map = &sli->maps[led]; |
3384 | *led_return = led; |
3385 | break; |
3386 | } |
3387 | } |
3388 | } |
3389 | |
3390 | return map; |
3391 | } |
3392 | |
3393 | /** |
3394 | * Creates an indicator map on the device. If dryRun is TRUE, it only checks |
3395 | * if creation is possible, but doesn't actually create it. |
3396 | */ |
3397 | static int |
3398 | _XkbCreateIndicatorMap(DeviceIntPtr dev, Atom indicator, |
3399 | int ledClass, int ledID, |
3400 | XkbIndicatorMapPtr * map_return, int *led_return, |
3401 | Bool dryRun) |
3402 | { |
3403 | XkbSrvLedInfoPtr sli; |
3404 | XkbIndicatorMapPtr map; |
3405 | int led; |
3406 | |
3407 | sli = XkbFindSrvLedInfo(dev, ledClass, ledID, XkbXI_IndicatorsMask(0x001c)); |
3408 | if (!sli) |
3409 | return BadAlloc11; |
3410 | |
3411 | map = _XkbFindNamedIndicatorMap(sli, indicator, &led); |
3412 | |
3413 | if (!map) { |
3414 | /* find first unused indicator maps and assign the name to it */ |
3415 | for (led = 0, map = NULL((void*)0); (led < XkbNumIndicators32) && (map == NULL((void*)0)); |
3416 | led++) { |
3417 | if ((sli->names) && (sli->maps) && (sli->names[led] == None0L) && |
3418 | (!XkbIM_InUse(&sli->maps[led])((&sli->maps[led])->flags || (&sli->maps[led ])->which_groups || (&sli->maps[led])->which_mods || (&sli->maps[led])->ctrls))) { |
3419 | map = &sli->maps[led]; |
3420 | if (!dryRun) |
3421 | sli->names[led] = indicator; |
3422 | break; |
3423 | } |
3424 | } |
3425 | } |
3426 | |
3427 | if (!map) |
3428 | return BadAlloc11; |
3429 | |
3430 | *led_return = led; |
3431 | *map_return = map; |
3432 | return Success0; |
3433 | } |
3434 | |
3435 | static int |
3436 | _XkbSetNamedIndicator(ClientPtr client, DeviceIntPtr dev, |
3437 | xkbSetNamedIndicatorReq * stuff) |
3438 | { |
3439 | unsigned int extDevReason; |
3440 | unsigned int statec, namec, mapc; |
3441 | XkbSrvLedInfoPtr sli; |
3442 | int led = 0; |
3443 | XkbIndicatorMapPtr map; |
3444 | DeviceIntPtr kbd; |
3445 | XkbEventCauseRec cause; |
3446 | xkbExtensionDeviceNotify ed; |
3447 | XkbChangesRec changes; |
3448 | int rc; |
3449 | |
3450 | rc = _XkbCreateIndicatorMap(dev, stuff->indicator, stuff->ledClass, |
3451 | stuff->ledID, &map, &led, FALSE0); |
3452 | if (rc != Success0 || !map) /* oh-oh */ |
3453 | return rc; |
3454 | |
3455 | sli = XkbFindSrvLedInfo(dev, stuff->ledClass, stuff->ledID, |
3456 | XkbXI_IndicatorsMask(0x001c)); |
3457 | if (!sli) |
3458 | return BadAlloc11; |
3459 | |
3460 | namec = mapc = statec = 0; |
3461 | extDevReason = 0; |
3462 | |
3463 | namec |= (1 << led); |
3464 | sli->namesPresent |= ((stuff->indicator != None0L) ? (1 << led) : 0); |
3465 | extDevReason |= XkbXI_IndicatorNamesMask(1L << 2); |
3466 | |
3467 | if (stuff->setMap) { |
3468 | map->flags = stuff->flags; |
3469 | map->which_groups = stuff->whichGroups; |
3470 | map->groups = stuff->groups; |
3471 | map->which_mods = stuff->whichMods; |
3472 | map->mods.mask = stuff->realMods; |
3473 | map->mods.real_mods = stuff->realMods; |
3474 | map->mods.vmods = stuff->virtualMods; |
3475 | map->ctrls = stuff->ctrls; |
3476 | mapc |= (1 << led); |
3477 | } |
3478 | |
3479 | if ((stuff->setState) && ((map->flags & XkbIM_NoExplicit(1L << 7)) == 0)) { |
3480 | if (stuff->on) |
3481 | sli->explicitState |= (1 << led); |
3482 | else |
3483 | sli->explicitState &= ~(1 << led); |
3484 | statec |= ((sli->effectiveState ^ sli->explicitState) & (1 << led)); |
3485 | } |
3486 | |
3487 | memset((char *) &ed, 0, sizeof(xkbExtensionDeviceNotify))__builtin___memset_chk ((char *) &ed, 0, sizeof(xkbExtensionDeviceNotify ), __builtin_object_size ((char *) &ed, 0)); |
3488 | memset((char *) &changes, 0, sizeof(XkbChangesRec))__builtin___memset_chk ((char *) &changes, 0, sizeof(XkbChangesRec ), __builtin_object_size ((char *) &changes, 0)); |
3489 | XkbSetCauseXkbReq(&cause, X_kbSetNamedIndicator, client){ (&cause)->kc= (&cause)->event= 0, (&cause )->mjr= (XkbReqCode),(&cause)->mnr= (16); (&cause )->client= (client); }; |
3490 | if (namec) |
3491 | XkbApplyLedNameChanges(dev, sli, namec, &ed, &changes, &cause); |
3492 | if (mapc) |
3493 | XkbApplyLedMapChanges(dev, sli, mapc, &ed, &changes, &cause); |
3494 | if (statec) |
3495 | XkbApplyLedStateChanges(dev, sli, statec, &ed, &changes, &cause); |
3496 | |
3497 | kbd = dev; |
3498 | if ((sli->flags & XkbSLI_HasOwnState(1L<<1)) == 0) |
3499 | kbd = inputInfo.keyboard; |
3500 | XkbFlushLedEvents(dev, kbd, sli, &ed, &changes, &cause); |
3501 | |
3502 | return Success0; |
3503 | } |
3504 | |
3505 | int |
3506 | ProcXkbSetNamedIndicator(ClientPtr client) |
3507 | { |
3508 | int rc; |
3509 | DeviceIntPtr dev; |
3510 | int led = 0; |
3511 | XkbIndicatorMapPtr map; |
3512 | |
3513 | REQUEST(xkbSetNamedIndicatorReq)xkbSetNamedIndicatorReq *stuff = (xkbSetNamedIndicatorReq *)client ->requestBuffer; |
3514 | REQUEST_SIZE_MATCH(xkbSetNamedIndicatorReq)if ((sizeof(xkbSetNamedIndicatorReq) >> 2) != client-> req_len) return(16); |
3515 | |
3516 | if (!(client->xkbClientFlags & _XkbClientInitialized(1<<15))) |
3517 | return BadAccess10; |
3518 | |
3519 | CHK_LED_DEVICE(dev, stuff->deviceSpec, client, DixSetAttrAccess){ int why; int tmprc = _XkbLookupLedDevice(&(dev), stuff-> deviceSpec, client, (1<<5), &why); if (tmprc != 0) { client->errorValue = ((XID)((((unsigned int)(why))<< 24)|((stuff->deviceSpec)&0xffffff))); return tmprc; }}; |
3520 | CHK_ATOM_ONLY(stuff->indicator){ if (((stuff->indicator)==0L)||(!ValidAtom((stuff->indicator )))) { (client->errorValue)= (XID)(stuff->indicator); return 5; }}; |
3521 | CHK_MASK_LEGAL(0x10, stuff->whichGroups, XkbIM_UseAnyGroup){ if ((stuff->whichGroups)&(~(((1L << 0)|(1L << 1)|(1L << 2) |(1L << 3))))) { (client->errorValue )= ((XID)((((unsigned int)((0x10)))<<24)|((((stuff-> whichGroups)&(~(((1L << 0)|(1L << 1)|(1L << 2) |(1L << 3))))))&0xffffff))); return 2; }}; |
3522 | CHK_MASK_LEGAL(0x11, stuff->whichMods, XkbIM_UseAnyMods){ if ((stuff->whichMods)&(~((((1L << 0)|(1L << 1)|(1L << 2) |(1L << 3))|(1L << 4))))) { ( client->errorValue)= ((XID)((((unsigned int)((0x11)))<< 24)|((((stuff->whichMods)&(~((((1L << 0)|(1L << 1)|(1L << 2) |(1L << 3))|(1L << 4))))))& 0xffffff))); return 2; }}; |
3523 | |
3524 | /* Dry-run for checks */ |
3525 | rc = _XkbCreateIndicatorMap(dev, stuff->indicator, |
3526 | stuff->ledClass, stuff->ledID, |
3527 | &map, &led, TRUE1); |
3528 | if (rc != Success0 || !map) /* couldn't be created or didn't exist */ |
3529 | return rc; |
3530 | |
3531 | if (stuff->deviceSpec == XkbUseCoreKbd0x0100 || |
3532 | stuff->deviceSpec == XkbUseCorePtr0x0200) { |
3533 | DeviceIntPtr other; |
3534 | |
3535 | for (other = inputInfo.devices; other; other = other->next) { |
3536 | if ((other != dev) && !IsMaster(other) && |
3537 | GetMaster(other, MASTER_KEYBOARD2) == dev && (other->kbdfeed || |
3538 | other->leds) && |
3539 | (XaceHook(XACE_DEVICE_ACCESS3, client, other, DixSetAttrAccess(1<<5)) |
3540 | == Success0)) { |
3541 | rc = _XkbCreateIndicatorMap(other, stuff->indicator, |
3542 | stuff->ledClass, stuff->ledID, &map, |
3543 | &led, TRUE1); |
3544 | if (rc != Success0 || !map) |
3545 | return rc; |
3546 | } |
3547 | } |
3548 | } |
3549 | |
3550 | /* All checks passed, let's do it */ |
3551 | rc = _XkbSetNamedIndicator(client, dev, stuff); |
3552 | if (rc != Success0) |
3553 | return rc; |
3554 | |
3555 | if (stuff->deviceSpec == XkbUseCoreKbd0x0100 || |
3556 | stuff->deviceSpec == XkbUseCorePtr0x0200) { |
3557 | DeviceIntPtr other; |
3558 | |
3559 | for (other = inputInfo.devices; other; other = other->next) { |
3560 | if ((other != dev) && !IsMaster(other) && |
3561 | GetMaster(other, MASTER_KEYBOARD2) == dev && (other->kbdfeed || |
3562 | other->leds) && |
3563 | (XaceHook(XACE_DEVICE_ACCESS3, client, other, DixSetAttrAccess(1<<5)) |
3564 | == Success0)) { |
3565 | _XkbSetNamedIndicator(client, other, stuff); |
3566 | } |
3567 | } |
3568 | } |
3569 | |
3570 | return Success0; |
3571 | } |
3572 | |
3573 | /***====================================================================***/ |
3574 | |
3575 | static CARD32 |
3576 | _XkbCountAtoms(Atom *atoms, int maxAtoms, int *count) |
3577 | { |
3578 | register unsigned int i, bit, nAtoms; |
3579 | register CARD32 atomsPresent; |
3580 | |
3581 | for (i = nAtoms = atomsPresent = 0, bit = 1; i < maxAtoms; i++, bit <<= 1) { |
3582 | if (atoms[i] != None0L) { |
3583 | atomsPresent |= bit; |
3584 | nAtoms++; |
3585 | } |
3586 | } |
3587 | if (count) |
3588 | *count = nAtoms; |
3589 | return atomsPresent; |
3590 | } |
3591 | |
3592 | static char * |
3593 | _XkbWriteAtoms(char *wire, Atom *atoms, int maxAtoms, int swap) |
3594 | { |
3595 | register unsigned int i; |
3596 | Atom *atm; |
3597 | |
3598 | atm = (Atom *) wire; |
3599 | for (i = 0; i < maxAtoms; i++) { |
3600 | if (atoms[i] != None0L) { |
3601 | *atm = atoms[i]; |
3602 | if (swap) { |
3603 | swapl(atm)do { if (sizeof(*(atm)) != 4) wrong_size(); if (__builtin_constant_p ((uintptr_t)(atm) & 3) && ((uintptr_t)(atm) & 3) == 0) *(atm) = lswapl(*(atm)); else swap_uint32((uint32_t *)(atm)); } while (0); |
3604 | } |
3605 | atm++; |
3606 | } |
3607 | } |
3608 | return (char *) atm; |
3609 | } |
3610 | |
3611 | static Statusint |
3612 | XkbComputeGetNamesReplySize(XkbDescPtr xkb, xkbGetNamesReply * rep) |
3613 | { |
3614 | register unsigned which, length; |
3615 | register int i; |
3616 | |
3617 | rep->minKeyCode = xkb->min_key_code; |
3618 | rep->maxKeyCode = xkb->max_key_code; |
3619 | which = rep->which; |
3620 | length = 0; |
3621 | if (xkb->names != NULL((void*)0)) { |
3622 | if (which & XkbKeycodesNameMask(1<<0)) |
3623 | length++; |
3624 | if (which & XkbGeometryNameMask(1<<1)) |
3625 | length++; |
3626 | if (which & XkbSymbolsNameMask(1<<2)) |
3627 | length++; |
3628 | if (which & XkbPhysSymbolsNameMask(1<<3)) |
3629 | length++; |
3630 | if (which & XkbTypesNameMask(1<<4)) |
3631 | length++; |
3632 | if (which & XkbCompatNameMask(1<<5)) |
3633 | length++; |
3634 | } |
3635 | else |
3636 | which &= ~XkbComponentNamesMask(0x3f); |
3637 | |
3638 | if (xkb->map != NULL((void*)0)) { |
3639 | if (which & XkbKeyTypeNamesMask(1<<6)) |
3640 | length += xkb->map->num_types; |
3641 | rep->nTypes = xkb->map->num_types; |
3642 | if (which & XkbKTLevelNamesMask(1<<7)) { |
3643 | XkbKeyTypePtr pType = xkb->map->types; |
3644 | int nKTLevels = 0; |
3645 | |
3646 | length += XkbPaddedSize(xkb->map->num_types)((((unsigned int)(xkb->map->num_types)+3) >> 2) << 2) / 4; |
3647 | for (i = 0; i < xkb->map->num_types; i++, pType++) { |
3648 | if (pType->level_names != NULL((void*)0)) |
3649 | nKTLevels += pType->num_levels; |
3650 | } |
3651 | rep->nKTLevels = nKTLevels; |
3652 | length += nKTLevels; |
3653 | } |
3654 | } |
3655 | else { |
3656 | rep->nTypes = 0; |
3657 | rep->nKTLevels = 0; |
3658 | which &= ~(XkbKeyTypeNamesMask(1<<6) | XkbKTLevelNamesMask(1<<7)); |
3659 | } |
3660 | |
3661 | rep->minKeyCode = xkb->min_key_code; |
3662 | rep->maxKeyCode = xkb->max_key_code; |
3663 | rep->indicators = 0; |
3664 | rep->virtualMods = 0; |
3665 | rep->groupNames = 0; |
3666 | if (xkb->names != NULL((void*)0)) { |
3667 | if (which & XkbIndicatorNamesMask(1<<8)) { |
3668 | int nLeds; |
3669 | |
3670 | rep->indicators = |
3671 | _XkbCountAtoms(xkb->names->indicators, XkbNumIndicators32, |
3672 | &nLeds); |
3673 | length += nLeds; |
3674 | if (nLeds == 0) |
3675 | which &= ~XkbIndicatorNamesMask(1<<8); |
3676 | } |
3677 | |
3678 | if (which & XkbVirtualModNamesMask(1<<11)) { |
3679 | int nVMods; |
3680 | |
3681 | rep->virtualMods = |
3682 | _XkbCountAtoms(xkb->names->vmods, XkbNumVirtualMods16, &nVMods); |
3683 | length += nVMods; |
3684 | if (nVMods == 0) |
3685 | which &= ~XkbVirtualModNamesMask(1<<11); |
3686 | } |
3687 | |
3688 | if (which & XkbGroupNamesMask(1<<12)) { |
3689 | int nGroups; |
3690 | |
3691 | rep->groupNames = |
3692 | _XkbCountAtoms(xkb->names->groups, XkbNumKbdGroups4, &nGroups); |
3693 | length += nGroups; |
3694 | if (nGroups == 0) |
3695 | which &= ~XkbGroupNamesMask(1<<12); |
3696 | } |
3697 | |
3698 | if ((which & XkbKeyNamesMask(1<<9)) && (xkb->names->keys)) |
3699 | length += rep->nKeys; |
3700 | else |
3701 | which &= ~XkbKeyNamesMask(1<<9); |
3702 | |
3703 | if ((which & XkbKeyAliasesMask(1<<10)) && |
3704 | (xkb->names->key_aliases) && (xkb->names->num_key_aliases > 0)) { |
3705 | rep->nKeyAliases = xkb->names->num_key_aliases; |
3706 | length += rep->nKeyAliases * 2; |
3707 | } |
3708 | else { |
3709 | which &= ~XkbKeyAliasesMask(1<<10); |
3710 | rep->nKeyAliases = 0; |
3711 | } |
3712 | |
3713 | if ((which & XkbRGNamesMask(1<<13)) && (xkb->names->num_rg > 0)) |
3714 | length += xkb->names->num_rg; |
3715 | else |
3716 | which &= ~XkbRGNamesMask(1<<13); |
3717 | } |
3718 | else { |
3719 | which &= ~(XkbIndicatorNamesMask(1<<8) | XkbVirtualModNamesMask(1<<11)); |
3720 | which &= ~(XkbGroupNamesMask(1<<12) | XkbKeyNamesMask(1<<9) | XkbKeyAliasesMask(1<<10)); |
3721 | which &= ~XkbRGNamesMask(1<<13); |
3722 | } |
3723 | |
3724 | rep->length = length; |
3725 | rep->which = which; |
3726 | return Success0; |
3727 | } |
3728 | |
3729 | static int |
3730 | XkbSendNames(ClientPtr client, XkbDescPtr xkb, xkbGetNamesReply * rep) |
3731 | { |
3732 | register unsigned i, length, which; |
3733 | char *start; |
3734 | char *desc; |
3735 | |
3736 | length = rep->length * 4; |
3737 | which = rep->which; |
3738 | if (client->swapped) { |
3739 | swaps(&rep->sequenceNumber)do { if (sizeof(*(&rep->sequenceNumber)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&rep->sequenceNumber ) & 1) && ((uintptr_t)(&rep->sequenceNumber ) & 1) == 0) *(&rep->sequenceNumber) = lswaps(*(& rep->sequenceNumber)); else swap_uint16((uint16_t *)(& rep->sequenceNumber)); } while (0); |
3740 | swapl(&rep->length)do { if (sizeof(*(&rep->length)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&rep->length) & 3) && ((uintptr_t)(&rep->length) & 3) == 0 ) *(&rep->length) = lswapl(*(&rep->length)); else swap_uint32((uint32_t *)(&rep->length)); } while (0); |
3741 | swapl(&rep->which)do { if (sizeof(*(&rep->which)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&rep->which) & 3 ) && ((uintptr_t)(&rep->which) & 3) == 0) * (&rep->which) = lswapl(*(&rep->which)); else swap_uint32 ((uint32_t *)(&rep->which)); } while (0); |
3742 | swaps(&rep->virtualMods)do { if (sizeof(*(&rep->virtualMods)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&rep->virtualMods ) & 1) && ((uintptr_t)(&rep->virtualMods) & 1) == 0) *(&rep->virtualMods) = lswaps(*(&rep-> virtualMods)); else swap_uint16((uint16_t *)(&rep->virtualMods )); } while (0); |
3743 | swapl(&rep->indicators)do { if (sizeof(*(&rep->indicators)) != 4) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&rep->indicators ) & 3) && ((uintptr_t)(&rep->indicators) & 3) == 0) *(&rep->indicators) = lswapl(*(&rep-> indicators)); else swap_uint32((uint32_t *)(&rep->indicators )); } while (0); |
3744 | } |
3745 | |
3746 | start = desc = calloc(1, length); |
3747 | if (!start) |
3748 | return BadAlloc11; |
3749 | if (xkb->names) { |
3750 | if (which & XkbKeycodesNameMask(1<<0)) { |
3751 | *((CARD32 *) desc) = xkb->names->keycodes; |
3752 | if (client->swapped) { |
3753 | swapl((int *) desc)do { if (sizeof(*((int *) desc)) != 4) wrong_size(); if (__builtin_constant_p ((uintptr_t)((int *) desc) & 3) && ((uintptr_t)(( int *) desc) & 3) == 0) *((int *) desc) = lswapl(*((int * ) desc)); else swap_uint32((uint32_t *)((int *) desc)); } while (0); |
3754 | } |
3755 | desc += 4; |
3756 | } |
3757 | if (which & XkbGeometryNameMask(1<<1)) { |
3758 | *((CARD32 *) desc) = xkb->names->geometry; |
3759 | if (client->swapped) { |
3760 | swapl((int *) desc)do { if (sizeof(*((int *) desc)) != 4) wrong_size(); if (__builtin_constant_p ((uintptr_t)((int *) desc) & 3) && ((uintptr_t)(( int *) desc) & 3) == 0) *((int *) desc) = lswapl(*((int * ) desc)); else swap_uint32((uint32_t *)((int *) desc)); } while (0); |
3761 | } |
3762 | desc += 4; |
3763 | } |
3764 | if (which & XkbSymbolsNameMask(1<<2)) { |
3765 | *((CARD32 *) desc) = xkb->names->symbols; |
3766 | if (client->swapped) { |
3767 | swapl((int *) desc)do { if (sizeof(*((int *) desc)) != 4) wrong_size(); if (__builtin_constant_p ((uintptr_t)((int *) desc) & 3) && ((uintptr_t)(( int *) desc) & 3) == 0) *((int *) desc) = lswapl(*((int * ) desc)); else swap_uint32((uint32_t *)((int *) desc)); } while (0); |
3768 | } |
3769 | desc += 4; |
3770 | } |
3771 | if (which & XkbPhysSymbolsNameMask(1<<3)) { |
3772 | register CARD32 *atm = (CARD32 *) desc; |
3773 | |
3774 | atm[0] = (CARD32) xkb->names->phys_symbols; |
3775 | if (client->swapped) { |
3776 | swapl(&atm[0])do { if (sizeof(*(&atm[0])) != 4) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&atm[0]) & 3) && ((uintptr_t)(& atm[0]) & 3) == 0) *(&atm[0]) = lswapl(*(&atm[0]) ); else swap_uint32((uint32_t *)(&atm[0])); } while (0); |
3777 | } |
3778 | desc += 4; |
3779 | } |
3780 | if (which & XkbTypesNameMask(1<<4)) { |
3781 | *((CARD32 *) desc) = (CARD32) xkb->names->types; |
3782 | if (client->swapped) { |
3783 | swapl((int *) desc)do { if (sizeof(*((int *) desc)) != 4) wrong_size(); if (__builtin_constant_p ((uintptr_t)((int *) desc) & 3) && ((uintptr_t)(( int *) desc) & 3) == 0) *((int *) desc) = lswapl(*((int * ) desc)); else swap_uint32((uint32_t *)((int *) desc)); } while (0); |
3784 | } |
3785 | desc += 4; |
3786 | } |
3787 | if (which & XkbCompatNameMask(1<<5)) { |
3788 | *((CARD32 *) desc) = (CARD32) xkb->names->compat; |
3789 | if (client->swapped) { |
3790 | swapl((int *) desc)do { if (sizeof(*((int *) desc)) != 4) wrong_size(); if (__builtin_constant_p ((uintptr_t)((int *) desc) & 3) && ((uintptr_t)(( int *) desc) & 3) == 0) *((int *) desc) = lswapl(*((int * ) desc)); else swap_uint32((uint32_t *)((int *) desc)); } while (0); |
3791 | } |
3792 | desc += 4; |
3793 | } |
3794 | if (which & XkbKeyTypeNamesMask(1<<6)) { |
3795 | register CARD32 *atm = (CARD32 *) desc; |
3796 | register XkbKeyTypePtr type = xkb->map->types; |
3797 | |
3798 | for (i = 0; i < xkb->map->num_types; i++, atm++, type++) { |
3799 | *atm = (CARD32) type->name; |
3800 | if (client->swapped) { |
3801 | swapl(atm)do { if (sizeof(*(atm)) != 4) wrong_size(); if (__builtin_constant_p ((uintptr_t)(atm) & 3) && ((uintptr_t)(atm) & 3) == 0) *(atm) = lswapl(*(atm)); else swap_uint32((uint32_t *)(atm)); } while (0); |
3802 | } |
3803 | } |
3804 | desc = (char *) atm; |
3805 | } |
3806 | if (which & XkbKTLevelNamesMask(1<<7) && xkb->map) { |
3807 | XkbKeyTypePtr type = xkb->map->types; |
3808 | register CARD32 *atm; |
3809 | |
3810 | for (i = 0; i < rep->nTypes; i++, type++) { |
3811 | *desc++ = type->num_levels; |
3812 | } |
3813 | desc += XkbPaddedSize(rep->nTypes)((((unsigned int)(rep->nTypes)+3) >> 2) << 2) - rep->nTypes; |
3814 | |
3815 | atm = (CARD32 *) desc; |
3816 | type = xkb->map->types; |
3817 | for (i = 0; i < xkb->map->num_types; i++, type++) { |
3818 | register unsigned l; |
3819 | |
3820 | if (type->level_names) { |
3821 | for (l = 0; l < type->num_levels; l++, atm++) { |
3822 | *atm = type->level_names[l]; |
3823 | if (client->swapped) { |
3824 | swapl(atm)do { if (sizeof(*(atm)) != 4) wrong_size(); if (__builtin_constant_p ((uintptr_t)(atm) & 3) && ((uintptr_t)(atm) & 3) == 0) *(atm) = lswapl(*(atm)); else swap_uint32((uint32_t *)(atm)); } while (0); |
3825 | } |
3826 | } |
3827 | desc += type->num_levels * 4; |
3828 | } |
3829 | } |
3830 | } |
3831 | if (which & XkbIndicatorNamesMask(1<<8)) { |
3832 | desc = |
3833 | _XkbWriteAtoms(desc, xkb->names->indicators, XkbNumIndicators32, |
3834 | client->swapped); |
3835 | } |
3836 | if (which & XkbVirtualModNamesMask(1<<11)) { |
3837 | desc = _XkbWriteAtoms(desc, xkb->names->vmods, XkbNumVirtualMods16, |
3838 | client->swapped); |
3839 | } |
3840 | if (which & XkbGroupNamesMask(1<<12)) { |
3841 | desc = _XkbWriteAtoms(desc, xkb->names->groups, XkbNumKbdGroups4, |
3842 | client->swapped); |
3843 | } |
3844 | if (which & XkbKeyNamesMask(1<<9)) { |
3845 | for (i = 0; i < rep->nKeys; i++, desc += sizeof(XkbKeyNameRec)) { |
3846 | *((XkbKeyNamePtr) desc) = xkb->names->keys[i + rep->firstKey]; |
3847 | } |
3848 | } |
3849 | if (which & XkbKeyAliasesMask(1<<10)) { |
3850 | XkbKeyAliasPtr pAl; |
3851 | |
3852 | pAl = xkb->names->key_aliases; |
3853 | for (i = 0; i < rep->nKeyAliases; |
3854 | i++, pAl++, desc += 2 * XkbKeyNameLength4) { |
3855 | *((XkbKeyAliasPtr) desc) = *pAl; |
3856 | } |
3857 | } |
3858 | if ((which & XkbRGNamesMask(1<<13)) && (rep->nRadioGroups > 0)) { |
3859 | register CARD32 *atm = (CARD32 *) desc; |
3860 | |
3861 | for (i = 0; i < rep->nRadioGroups; i++, atm++) { |
3862 | *atm = (CARD32) xkb->names->radio_groups[i]; |
3863 | if (client->swapped) { |
3864 | swapl(atm)do { if (sizeof(*(atm)) != 4) wrong_size(); if (__builtin_constant_p ((uintptr_t)(atm) & 3) && ((uintptr_t)(atm) & 3) == 0) *(atm) = lswapl(*(atm)); else swap_uint32((uint32_t *)(atm)); } while (0); |
3865 | } |
3866 | } |
3867 | desc += rep->nRadioGroups * 4; |
3868 | } |
3869 | } |
3870 | |
3871 | if ((desc - start) != (length)) { |
3872 | ErrorF("[xkb] BOGUS LENGTH in write names, expected %d, got %ld\n", |
3873 | length, (unsigned long) (desc - start)); |
3874 | } |
3875 | WriteToClient(client, SIZEOF(xkbGetNamesReply)32, rep); |
3876 | WriteToClient(client, length, start); |
3877 | free((char *) start); |
3878 | return Success0; |
3879 | } |
3880 | |
3881 | int |
3882 | ProcXkbGetNames(ClientPtr client) |
3883 | { |
3884 | DeviceIntPtr dev; |
3885 | XkbDescPtr xkb; |
3886 | xkbGetNamesReply rep; |
3887 | |
3888 | REQUEST(xkbGetNamesReq)xkbGetNamesReq *stuff = (xkbGetNamesReq *)client->requestBuffer; |
3889 | REQUEST_SIZE_MATCH(xkbGetNamesReq)if ((sizeof(xkbGetNamesReq) >> 2) != client->req_len ) return(16); |
3890 | |
3891 | if (!(client->xkbClientFlags & _XkbClientInitialized(1<<15))) |
3892 | return BadAccess10; |
3893 | |
3894 | CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixGetAttrAccess){ int why; int tmprc = _XkbLookupKeyboard(&(dev), stuff-> deviceSpec, client, (1<<4), &why); if (tmprc != 0) { client->errorValue = ((XID)((((unsigned int)(why))<< 24)|((stuff->deviceSpec)&0xffffff))); return tmprc; }}; |
3895 | CHK_MASK_LEGAL(0x01, stuff->which, XkbAllNamesMask){ if ((stuff->which)&(~((0x3fff)))) { (client->errorValue )= ((XID)((((unsigned int)((0x01)))<<24)|((((stuff-> which)&(~((0x3fff)))))&0xffffff))); return 2; }}; |
3896 | |
3897 | xkb = dev->key->xkbInfo->desc; |
3898 | rep = (xkbGetNamesReply) { |
3899 | .type = X_Reply1, |
3900 | .deviceID = dev->id, |
3901 | .sequenceNumber = client->sequence, |
3902 | .length = 0, |
3903 | .which = stuff->which, |
3904 | .nTypes = xkb->map->num_types, |
3905 | .firstKey = xkb->min_key_code, |
3906 | .nKeys = XkbNumKeys(xkb)((xkb)->max_key_code-(xkb)->min_key_code+1), |
3907 | .nKeyAliases = xkb->names ? xkb->names->num_key_aliases : 0, |
3908 | .nRadioGroups = xkb->names ? xkb->names->num_rg : 0 |
3909 | }; |
3910 | XkbComputeGetNamesReplySize(xkb, &rep); |
3911 | return XkbSendNames(client, xkb, &rep); |
3912 | } |
3913 | |
3914 | /***====================================================================***/ |
3915 | |
3916 | static CARD32 * |
3917 | _XkbCheckAtoms(CARD32 *wire, int nAtoms, int swapped, Atom *pError) |
3918 | { |
3919 | register int i; |
3920 | |
3921 | for (i = 0; i < nAtoms; i++, wire++) { |
3922 | if (swapped) { |
3923 | swapl(wire)do { if (sizeof(*(wire)) != 4) wrong_size(); if (__builtin_constant_p ((uintptr_t)(wire) & 3) && ((uintptr_t)(wire) & 3) == 0) *(wire) = lswapl(*(wire)); else swap_uint32((uint32_t *)(wire)); } while (0); |
3924 | } |
3925 | if ((((Atom) *wire) != None0L) && (!ValidAtom((Atom) *wire))) { |
3926 | *pError = ((Atom) *wire); |
3927 | return NULL((void*)0); |
3928 | } |
3929 | } |
3930 | return wire; |
3931 | } |
3932 | |
3933 | static CARD32 * |
3934 | _XkbCheckMaskedAtoms(CARD32 *wire, int nAtoms, CARD32 present, int swapped, |
3935 | Atom *pError) |
3936 | { |
3937 | register unsigned i, bit; |
3938 | |
3939 | for (i = 0, bit = 1; (i < nAtoms) && (present); i++, bit <<= 1) { |
3940 | if ((present & bit) == 0) |
3941 | continue; |
3942 | if (swapped) { |
3943 | swapl(wire)do { if (sizeof(*(wire)) != 4) wrong_size(); if (__builtin_constant_p ((uintptr_t)(wire) & 3) && ((uintptr_t)(wire) & 3) == 0) *(wire) = lswapl(*(wire)); else swap_uint32((uint32_t *)(wire)); } while (0); |
3944 | } |
3945 | if ((((Atom) *wire) != None0L) && (!ValidAtom(((Atom) *wire)))) { |
3946 | *pError = (Atom) *wire; |
3947 | return NULL((void*)0); |
3948 | } |
3949 | wire++; |
3950 | } |
3951 | return wire; |
3952 | } |
3953 | |
3954 | static Atom * |
3955 | _XkbCopyMaskedAtoms(Atom *wire, Atom *dest, int nAtoms, CARD32 present) |
3956 | { |
3957 | register int i, bit; |
3958 | |
3959 | for (i = 0, bit = 1; (i < nAtoms) && (present); i++, bit <<= 1) { |
3960 | if ((present & bit) == 0) |
3961 | continue; |
3962 | dest[i] = *wire++; |
3963 | } |
3964 | return wire; |
3965 | } |
3966 | |
3967 | static Bool |
3968 | _XkbCheckTypeName(Atom name, int typeNdx) |
3969 | { |
3970 | const char *str; |
3971 | |
3972 | str = NameForAtom(name); |
3973 | if ((strcmp(str, "ONE_LEVEL") == 0) || (strcmp(str, "TWO_LEVEL") == 0) || |
3974 | (strcmp(str, "ALPHABETIC") == 0) || (strcmp(str, "KEYPAD") == 0)) |
3975 | return FALSE0; |
3976 | return TRUE1; |
3977 | } |
3978 | |
3979 | /** |
3980 | * Check the device-dependent data in the request against the device. Returns |
3981 | * Success, or the appropriate error code. |
3982 | */ |
3983 | static int |
3984 | _XkbSetNamesCheck(ClientPtr client, DeviceIntPtr dev, |
3985 | xkbSetNamesReq * stuff, CARD32 *data) |
3986 | { |
3987 | XkbDescRec *xkb; |
3988 | CARD32 *tmp; |
3989 | Atom bad = None0L; |
3990 | |
3991 | tmp = data; |
3992 | xkb = dev->key->xkbInfo->desc; |
3993 | |
3994 | if (stuff->which & XkbKeyTypeNamesMask(1<<6)) { |
3995 | int i; |
3996 | CARD32 *old; |
3997 | |
3998 | if (stuff->nTypes < 1) { |
3999 | client->errorValue = _XkbErrCode2(0x02, stuff->nTypes)((XID)((((unsigned int)(0x02))<<24)|((stuff->nTypes) &0xffffff))); |
4000 | return BadValue2; |
4001 | } |
4002 | if ((unsigned) (stuff->firstType + stuff->nTypes - 1) >= |
4003 | xkb->map->num_types) { |
4004 | client->errorValue = |
4005 | _XkbErrCode4(0x03, stuff->firstType, stuff->nTypes,((XID)((((unsigned int)(0x03))<<24)|(((((unsigned int)( stuff->firstType))<<16)|(((((unsigned int)(stuff-> nTypes))<<8)|(xkb->map->num_types))))&0xffffff ))) |
4006 | xkb->map->num_types)((XID)((((unsigned int)(0x03))<<24)|(((((unsigned int)( stuff->firstType))<<16)|(((((unsigned int)(stuff-> nTypes))<<8)|(xkb->map->num_types))))&0xffffff ))); |
4007 | return BadValue2; |
4008 | } |
4009 | if (((unsigned) stuff->firstType) <= XkbLastRequiredType3) { |
4010 | client->errorValue = _XkbErrCode2(0x04, stuff->firstType)((XID)((((unsigned int)(0x04))<<24)|((stuff->firstType )&0xffffff))); |
4011 | return BadAccess10; |
4012 | } |
4013 | old = tmp; |
4014 | tmp = _XkbCheckAtoms(tmp, stuff->nTypes, client->swapped, &bad); |
4015 | if (!tmp) { |
4016 | client->errorValue = bad; |
4017 | return BadAtom5; |
4018 | } |
4019 | for (i = 0; i < stuff->nTypes; i++, old++) { |
4020 | if (!_XkbCheckTypeName((Atom) *old, stuff->firstType + i)) |
4021 | client->errorValue = _XkbErrCode2(0x05, i)((XID)((((unsigned int)(0x05))<<24)|((i)&0xffffff)) ); |
4022 | } |
4023 | } |
4024 | if (stuff->which & XkbKTLevelNamesMask(1<<7)) { |
4025 | unsigned i; |
4026 | XkbKeyTypePtr type; |
4027 | CARD8 *width; |
4028 | |
4029 | if (stuff->nKTLevels < 1) { |
4030 | client->errorValue = _XkbErrCode2(0x05, stuff->nKTLevels)((XID)((((unsigned int)(0x05))<<24)|((stuff->nKTLevels )&0xffffff))); |
4031 | return BadValue2; |
4032 | } |
4033 | if ((unsigned) (stuff->firstKTLevel + stuff->nKTLevels - 1) >= |
4034 | xkb->map->num_types) { |
4035 | client->errorValue = _XkbErrCode4(0x06, stuff->firstKTLevel,((XID)((((unsigned int)(0x06))<<24)|(((((unsigned int)( stuff->firstKTLevel))<<16)|(((((unsigned int)(stuff-> nKTLevels))<<8)|(xkb->map->num_types))))&0xffffff ))) |
4036 | stuff->nKTLevels,((XID)((((unsigned int)(0x06))<<24)|(((((unsigned int)( stuff->firstKTLevel))<<16)|(((((unsigned int)(stuff-> nKTLevels))<<8)|(xkb->map->num_types))))&0xffffff ))) |
4037 | xkb->map->num_types)((XID)((((unsigned int)(0x06))<<24)|(((((unsigned int)( stuff->firstKTLevel))<<16)|(((((unsigned int)(stuff-> nKTLevels))<<8)|(xkb->map->num_types))))&0xffffff ))); |
4038 | return BadValue2; |
4039 | } |
4040 | width = (CARD8 *) tmp; |
4041 | tmp = (CARD32 *) (((char *) tmp) + XkbPaddedSize(stuff->nKTLevels)((((unsigned int)(stuff->nKTLevels)+3) >> 2) << 2)); |
4042 | type = &xkb->map->types[stuff->firstKTLevel]; |
4043 | for (i = 0; i < stuff->nKTLevels; i++, type++) { |
4044 | if (width[i] == 0) |
4045 | continue; |
4046 | else if (width[i] != type->num_levels) { |
4047 | client->errorValue = _XkbErrCode4(0x07, i + stuff->firstKTLevel,((XID)((((unsigned int)(0x07))<<24)|(((((unsigned int)( i + stuff->firstKTLevel))<<16)|(((((unsigned int)(type ->num_levels))<<8)|(width[i]))))&0xffffff))) |
4048 | type->num_levels, width[i])((XID)((((unsigned int)(0x07))<<24)|(((((unsigned int)( i + stuff->firstKTLevel))<<16)|(((((unsigned int)(type ->num_levels))<<8)|(width[i]))))&0xffffff))); |
4049 | return BadMatch8; |
4050 | } |
4051 | tmp = _XkbCheckAtoms(tmp, width[i], client->swapped, &bad); |
4052 | if (!tmp) { |
4053 | client->errorValue = bad; |
4054 | return BadAtom5; |
4055 | } |
4056 | } |
4057 | } |
4058 | if (stuff->which & XkbIndicatorNamesMask(1<<8)) { |
4059 | if (stuff->indicators == 0) { |
4060 | client->errorValue = 0x08; |
4061 | return BadMatch8; |
4062 | } |
4063 | tmp = _XkbCheckMaskedAtoms(tmp, XkbNumIndicators32, stuff->indicators, |
4064 | client->swapped, &bad); |
4065 | if (!tmp) { |
4066 | client->errorValue = bad; |
4067 | return BadAtom5; |
4068 | } |
4069 | } |
4070 | if (stuff->which & XkbVirtualModNamesMask(1<<11)) { |
4071 | if (stuff->virtualMods == 0) { |
4072 | client->errorValue = 0x09; |
4073 | return BadMatch8; |
4074 | } |
4075 | tmp = _XkbCheckMaskedAtoms(tmp, XkbNumVirtualMods16, |
4076 | (CARD32) stuff->virtualMods, |
4077 | client->swapped, &bad); |
4078 | if (!tmp) { |
4079 | client->errorValue = bad; |
4080 | return BadAtom5; |
4081 | } |
4082 | } |
4083 | if (stuff->which & XkbGroupNamesMask(1<<12)) { |
4084 | if (stuff->groupNames == 0) { |
4085 | client->errorValue = 0x0a; |
4086 | return BadMatch8; |
4087 | } |
4088 | tmp = _XkbCheckMaskedAtoms(tmp, XkbNumKbdGroups4, |
4089 | (CARD32) stuff->groupNames, |
4090 | client->swapped, &bad); |
4091 | if (!tmp) { |
4092 | client->errorValue = bad; |
4093 | return BadAtom5; |
4094 | } |
4095 | } |
4096 | if (stuff->which & XkbKeyNamesMask(1<<9)) { |
4097 | if (stuff->firstKey < (unsigned) xkb->min_key_code) { |
4098 | client->errorValue = _XkbErrCode3(0x0b, xkb->min_key_code,((XID)((((unsigned int)(0x0b))<<24)|(((((unsigned int)( xkb->min_key_code))<<16)|(stuff->firstKey))&0xffffff ))) |
4099 | stuff->firstKey)((XID)((((unsigned int)(0x0b))<<24)|(((((unsigned int)( xkb->min_key_code))<<16)|(stuff->firstKey))&0xffffff ))); |
4100 | return BadValue2; |
4101 | } |
4102 | if (((unsigned) (stuff->firstKey + stuff->nKeys - 1) > |
4103 | xkb->max_key_code) || (stuff->nKeys < 1)) { |
4104 | client->errorValue = |
4105 | _XkbErrCode4(0x0c, xkb->max_key_code, stuff->firstKey,((XID)((((unsigned int)(0x0c))<<24)|(((((unsigned int)( xkb->max_key_code))<<16)|(((((unsigned int)(stuff-> firstKey))<<8)|(stuff->nKeys))))&0xffffff))) |
4106 | stuff->nKeys)((XID)((((unsigned int)(0x0c))<<24)|(((((unsigned int)( xkb->max_key_code))<<16)|(((((unsigned int)(stuff-> firstKey))<<8)|(stuff->nKeys))))&0xffffff))); |
4107 | return BadValue2; |
4108 | } |
4109 | tmp += stuff->nKeys; |
4110 | } |
4111 | if ((stuff->which & XkbKeyAliasesMask(1<<10)) && (stuff->nKeyAliases > 0)) { |
4112 | tmp += stuff->nKeyAliases * 2; |
4113 | } |
4114 | if (stuff->which & XkbRGNamesMask(1<<13)) { |
4115 | if (stuff->nRadioGroups < 1) { |
4116 | client->errorValue = _XkbErrCode2(0x0d, stuff->nRadioGroups)((XID)((((unsigned int)(0x0d))<<24)|((stuff->nRadioGroups )&0xffffff))); |
4117 | return BadValue2; |
4118 | } |
4119 | tmp = _XkbCheckAtoms(tmp, stuff->nRadioGroups, client->swapped, &bad); |
4120 | if (!tmp) { |
4121 | client->errorValue = bad; |
4122 | return BadAtom5; |
4123 | } |
4124 | } |
4125 | if ((tmp - ((CARD32 *) stuff)) != stuff->length) { |
4126 | client->errorValue = stuff->length; |
4127 | return BadLength16; |
4128 | } |
4129 | |
4130 | return Success0; |
4131 | } |
4132 | |
4133 | static int |
4134 | _XkbSetNames(ClientPtr client, DeviceIntPtr dev, xkbSetNamesReq * stuff) |
4135 | { |
4136 | XkbDescRec *xkb; |
4137 | XkbNamesRec *names; |
4138 | CARD32 *tmp; |
4139 | xkbNamesNotify nn; |
4140 | |
4141 | tmp = (CARD32 *) &stuff[1]; |
4142 | xkb = dev->key->xkbInfo->desc; |
4143 | names = xkb->names; |
4144 | |
4145 | if (XkbAllocNamesSrvXkbAllocNames(xkb, stuff->which, stuff->nRadioGroups, |
4146 | stuff->nKeyAliases) != Success0) { |
4147 | return BadAlloc11; |
4148 | } |
4149 | |
4150 | memset(&nn, 0, sizeof(xkbNamesNotify))__builtin___memset_chk (&nn, 0, sizeof(xkbNamesNotify), __builtin_object_size (&nn, 0)); |
4151 | nn.changed = stuff->which; |
4152 | tmp = (CARD32 *) &stuff[1]; |
4153 | if (stuff->which & XkbKeycodesNameMask(1<<0)) |
4154 | names->keycodes = *tmp++; |
4155 | if (stuff->which & XkbGeometryNameMask(1<<1)) |
4156 | names->geometry = *tmp++; |
4157 | if (stuff->which & XkbSymbolsNameMask(1<<2)) |
4158 | names->symbols = *tmp++; |
4159 | if (stuff->which & XkbPhysSymbolsNameMask(1<<3)) |
4160 | names->phys_symbols = *tmp++; |
4161 | if (stuff->which & XkbTypesNameMask(1<<4)) |
4162 | names->types = *tmp++; |
4163 | if (stuff->which & XkbCompatNameMask(1<<5)) |
4164 | names->compat = *tmp++; |
4165 | if ((stuff->which & XkbKeyTypeNamesMask(1<<6)) && (stuff->nTypes > 0)) { |
4166 | register unsigned i; |
4167 | register XkbKeyTypePtr type; |
4168 | |
4169 | type = &xkb->map->types[stuff->firstType]; |
4170 | for (i = 0; i < stuff->nTypes; i++, type++) { |
4171 | type->name = *tmp++; |
4172 | } |
4173 | nn.firstType = stuff->firstType; |
4174 | nn.nTypes = stuff->nTypes; |
4175 | } |
4176 | if (stuff->which & XkbKTLevelNamesMask(1<<7)) { |
4177 | register XkbKeyTypePtr type; |
4178 | register unsigned i; |
4179 | CARD8 *width; |
4180 | |
4181 | width = (CARD8 *) tmp; |
4182 | tmp = (CARD32 *) (((char *) tmp) + XkbPaddedSize(stuff->nKTLevels)((((unsigned int)(stuff->nKTLevels)+3) >> 2) << 2)); |
4183 | type = &xkb->map->types[stuff->firstKTLevel]; |
4184 | for (i = 0; i < stuff->nKTLevels; i++, type++) { |
4185 | if (width[i] > 0) { |
4186 | if (type->level_names) { |
4187 | register unsigned n; |
4188 | |
4189 | for (n = 0; n < width[i]; n++) { |
4190 | type->level_names[n] = tmp[n]; |
4191 | } |
4192 | } |
4193 | tmp += width[i]; |
4194 | } |
4195 | } |
4196 | nn.firstLevelName = 0; |
4197 | nn.nLevelNames = stuff->nTypes; |
4198 | } |
4199 | if (stuff->which & XkbIndicatorNamesMask(1<<8)) { |
4200 | tmp = _XkbCopyMaskedAtoms(tmp, names->indicators, XkbNumIndicators32, |
4201 | stuff->indicators); |
4202 | nn.changedIndicators = stuff->indicators; |
4203 | } |
4204 | if (stuff->which & XkbVirtualModNamesMask(1<<11)) { |
4205 | tmp = _XkbCopyMaskedAtoms(tmp, names->vmods, XkbNumVirtualMods16, |
4206 | stuff->virtualMods); |
4207 | nn.changedVirtualMods = stuff->virtualMods; |
4208 | } |
4209 | if (stuff->which & XkbGroupNamesMask(1<<12)) { |
4210 | tmp = _XkbCopyMaskedAtoms(tmp, names->groups, XkbNumKbdGroups4, |
4211 | stuff->groupNames); |
4212 | nn.changedVirtualMods = stuff->groupNames; |
4213 | } |
4214 | if (stuff->which & XkbKeyNamesMask(1<<9)) { |
4215 | memcpy((char *) &names->keys[stuff->firstKey], (char *) tmp,__builtin___memcpy_chk ((char *) &names->keys[stuff-> firstKey], (char *) tmp, stuff->nKeys * 4, __builtin_object_size ((char *) &names->keys[stuff->firstKey], 0)) |
4216 | stuff->nKeys * XkbKeyNameLength)__builtin___memcpy_chk ((char *) &names->keys[stuff-> firstKey], (char *) tmp, stuff->nKeys * 4, __builtin_object_size ((char *) &names->keys[stuff->firstKey], 0)); |
4217 | tmp += stuff->nKeys; |
4218 | nn.firstKey = stuff->firstKey; |
4219 | nn.nKeys = stuff->nKeys; |
4220 | } |
4221 | if (stuff->which & XkbKeyAliasesMask(1<<10)) { |
4222 | if (stuff->nKeyAliases > 0) { |
4223 | register int na = stuff->nKeyAliases; |
4224 | |
4225 | if (XkbAllocNamesSrvXkbAllocNames(xkb, XkbKeyAliasesMask(1<<10), 0, na) != Success0) |
4226 | return BadAlloc11; |
4227 | memcpy((char *) names->key_aliases, (char *) tmp,__builtin___memcpy_chk ((char *) names->key_aliases, (char *) tmp, stuff->nKeyAliases * sizeof(XkbKeyAliasRec), __builtin_object_size ((char *) names->key_aliases, 0)) |
4228 | stuff->nKeyAliases * sizeof(XkbKeyAliasRec))__builtin___memcpy_chk ((char *) names->key_aliases, (char *) tmp, stuff->nKeyAliases * sizeof(XkbKeyAliasRec), __builtin_object_size ((char *) names->key_aliases, 0)); |
4229 | tmp += stuff->nKeyAliases * 2; |
4230 | } |
4231 | else if (names->key_aliases != NULL((void*)0)) { |
4232 | free(names->key_aliases); |
4233 | names->key_aliases = NULL((void*)0); |
4234 | names->num_key_aliases = 0; |
4235 | } |
4236 | nn.nAliases = names->num_key_aliases; |
4237 | } |
4238 | if (stuff->which & XkbRGNamesMask(1<<13)) { |
4239 | if (stuff->nRadioGroups > 0) { |
4240 | register unsigned i, nrg; |
4241 | |
4242 | nrg = stuff->nRadioGroups; |
4243 | if (XkbAllocNamesSrvXkbAllocNames(xkb, XkbRGNamesMask(1<<13), nrg, 0) != Success0) |
4244 | return BadAlloc11; |
4245 | |
4246 | for (i = 0; i < stuff->nRadioGroups; i++) { |
4247 | names->radio_groups[i] = tmp[i]; |
4248 | } |
4249 | tmp += stuff->nRadioGroups; |
4250 | } |
4251 | else if (names->radio_groups) { |
4252 | free(names->radio_groups); |
4253 | names->radio_groups = NULL((void*)0); |
4254 | names->num_rg = 0; |
4255 | } |
4256 | nn.nRadioGroups = names->num_rg; |
4257 | } |
4258 | if (nn.changed) { |
4259 | Bool needExtEvent; |
4260 | |
4261 | needExtEvent = (nn.changed & XkbIndicatorNamesMask(1<<8)) != 0; |
4262 | XkbSendNamesNotify(dev, &nn); |
4263 | if (needExtEvent) { |
4264 | XkbSrvLedInfoPtr sli; |
4265 | xkbExtensionDeviceNotify edev; |
4266 | register int i; |
4267 | register unsigned bit; |
4268 | |
4269 | sli = XkbFindSrvLedInfo(dev, XkbDfltXIClass0x0300, XkbDfltXIId0x0400, |
4270 | XkbXI_IndicatorsMask(0x001c)); |
4271 | sli->namesPresent = 0; |
4272 | for (i = 0, bit = 1; i < XkbNumIndicators32; i++, bit <<= 1) { |
4273 | if (names->indicators[i] != None0L) |
4274 | sli->namesPresent |= bit; |
4275 | } |
4276 | memset(&edev, 0, sizeof(xkbExtensionDeviceNotify))__builtin___memset_chk (&edev, 0, sizeof(xkbExtensionDeviceNotify ), __builtin_object_size (&edev, 0)); |
4277 | edev.reason = XkbXI_IndicatorNamesMask(1L << 2); |
4278 | edev.ledClass = KbdFeedbackClass0; |
4279 | edev.ledID = dev->kbdfeed->ctrl.id; |
4280 | edev.ledsDefined = sli->namesPresent | sli->mapsPresent; |
4281 | edev.ledState = sli->effectiveState; |
4282 | edev.firstBtn = 0; |
4283 | edev.nBtns = 0; |
4284 | edev.supported = XkbXI_AllFeaturesMask(0x001f); |
4285 | edev.unsupported = 0; |
4286 | XkbSendExtensionDeviceNotify(dev, client, &edev); |
4287 | } |
4288 | } |
4289 | return Success0; |
4290 | } |
4291 | |
4292 | int |
4293 | ProcXkbSetNames(ClientPtr client) |
4294 | { |
4295 | DeviceIntPtr dev; |
4296 | CARD32 *tmp; |
4297 | Atom bad; |
4298 | int rc; |
4299 | |
4300 | REQUEST(xkbSetNamesReq)xkbSetNamesReq *stuff = (xkbSetNamesReq *)client->requestBuffer; |
4301 | REQUEST_AT_LEAST_SIZE(xkbSetNamesReq)if ((sizeof(xkbSetNamesReq) >> 2) > client->req_len ) return(16); |
4302 | |
4303 | if (!(client->xkbClientFlags & _XkbClientInitialized(1<<15))) |
4304 | return BadAccess10; |
4305 | |
4306 | CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixManageAccess){ int why; int tmprc = _XkbLookupKeyboard(&(dev), stuff-> deviceSpec, client, (1<<25), &why); if (tmprc != 0) { client->errorValue = ((XID)((((unsigned int)(why))<< 24)|((stuff->deviceSpec)&0xffffff))); return tmprc; }}; |
4307 | CHK_MASK_LEGAL(0x01, stuff->which, XkbAllNamesMask){ if ((stuff->which)&(~((0x3fff)))) { (client->errorValue )= ((XID)((((unsigned int)((0x01)))<<24)|((((stuff-> which)&(~((0x3fff)))))&0xffffff))); return 2; }}; |
4308 | |
4309 | /* check device-independent stuff */ |
4310 | tmp = (CARD32 *) &stuff[1]; |
4311 | |
4312 | if (stuff->which & XkbKeycodesNameMask(1<<0)) { |
4313 | tmp = _XkbCheckAtoms(tmp, 1, client->swapped, &bad); |
4314 | if (!tmp) { |
4315 | client->errorValue = bad; |
4316 | return BadAtom5; |
4317 | } |
4318 | } |
4319 | if (stuff->which & XkbGeometryNameMask(1<<1)) { |
4320 | tmp = _XkbCheckAtoms(tmp, 1, client->swapped, &bad); |
4321 | if (!tmp) { |
4322 | client->errorValue = bad; |
4323 | return BadAtom5; |
4324 | } |
4325 | } |
4326 | if (stuff->which & XkbSymbolsNameMask(1<<2)) { |
4327 | tmp = _XkbCheckAtoms(tmp, 1, client->swapped, &bad); |
4328 | if (!tmp) { |
4329 | client->errorValue = bad; |
4330 | return BadAtom5; |
4331 | } |
4332 | } |
4333 | if (stuff->which & XkbPhysSymbolsNameMask(1<<3)) { |
4334 | tmp = _XkbCheckAtoms(tmp, 1, client->swapped, &bad); |
4335 | if (!tmp) { |
4336 | client->errorValue = bad; |
4337 | return BadAtom5; |
4338 | } |
4339 | } |
4340 | if (stuff->which & XkbTypesNameMask(1<<4)) { |
4341 | tmp = _XkbCheckAtoms(tmp, 1, client->swapped, &bad); |
4342 | if (!tmp) { |
4343 | client->errorValue = bad; |
4344 | return BadAtom5; |
4345 | } |
4346 | } |
4347 | if (stuff->which & XkbCompatNameMask(1<<5)) { |
4348 | tmp = _XkbCheckAtoms(tmp, 1, client->swapped, &bad); |
4349 | if (!tmp) { |
4350 | client->errorValue = bad; |
4351 | return BadAtom5; |
4352 | } |
4353 | } |
4354 | |
4355 | /* start of device-dependent tests */ |
4356 | rc = _XkbSetNamesCheck(client, dev, stuff, tmp); |
4357 | if (rc != Success0) |
4358 | return rc; |
4359 | |
4360 | if (stuff->deviceSpec == XkbUseCoreKbd0x0100) { |
4361 | DeviceIntPtr other; |
4362 | |
4363 | for (other = inputInfo.devices; other; other = other->next) { |
4364 | if ((other != dev) && other->key && !IsMaster(other) && |
4365 | GetMaster(other, MASTER_KEYBOARD2) == dev) { |
4366 | |
4367 | rc = XaceHook(XACE_DEVICE_ACCESS3, client, other, |
4368 | DixManageAccess(1<<25)); |
4369 | if (rc == Success0) { |
4370 | rc = _XkbSetNamesCheck(client, other, stuff, tmp); |
4371 | if (rc != Success0) |
4372 | return rc; |
4373 | } |
4374 | } |
4375 | } |
4376 | } |
4377 | |
4378 | /* everything is okay -- update names */ |
4379 | |
4380 | rc = _XkbSetNames(client, dev, stuff); |
4381 | if (rc != Success0) |
4382 | return rc; |
4383 | |
4384 | if (stuff->deviceSpec == XkbUseCoreKbd0x0100) { |
4385 | DeviceIntPtr other; |
4386 | |
4387 | for (other = inputInfo.devices; other; other = other->next) { |
4388 | if ((other != dev) && other->key && !IsMaster(other) && |
4389 | GetMaster(other, MASTER_KEYBOARD2) == dev) { |
4390 | |
4391 | rc = XaceHook(XACE_DEVICE_ACCESS3, client, other, |
4392 | DixManageAccess(1<<25)); |
4393 | if (rc == Success0) |
4394 | _XkbSetNames(client, other, stuff); |
4395 | } |
4396 | } |
4397 | } |
4398 | |
4399 | /* everything is okay -- update names */ |
4400 | |
4401 | return Success0; |
4402 | } |
4403 | |
4404 | /***====================================================================***/ |
4405 | |
4406 | #include "xkbgeom.h" |
4407 | |
4408 | #define XkbSizeCountedString(s)((s)?((((2+strlen(s))+3)/4)*4):4) ((s)?((((2+strlen(s))+3)/4)*4):4) |
4409 | |
4410 | /** |
4411 | * Write the zero-terminated string str into wire as a pascal string with a |
4412 | * 16-bit length field prefixed before the actual string. |
4413 | * |
4414 | * @param wire The destination array, usually the wire struct |
4415 | * @param str The source string as zero-terminated C string |
4416 | * @param swap If TRUE, the length field is swapped. |
4417 | * |
4418 | * @return The input string in the format <string length><string> with a |
4419 | * (swapped) 16 bit string length, non-zero terminated. |
4420 | */ |
4421 | static char * |
4422 | XkbWriteCountedString(char *wire, const char *str, Bool swap) |
4423 | { |
4424 | CARD16 len, *pLen, paddedLen; |
4425 | |
4426 | if (!str) |
4427 | return wire; |
4428 | |
4429 | len = strlen(str); |
4430 | pLen = (CARD16 *) wire; |
4431 | *pLen = len; |
4432 | if (swap) { |
4433 | swaps(pLen)do { if (sizeof(*(pLen)) != 2) wrong_size(); if (__builtin_constant_p ((uintptr_t)(pLen) & 1) && ((uintptr_t)(pLen) & 1) == 0) *(pLen) = lswaps(*(pLen)); else swap_uint16((uint16_t *)(pLen)); } while (0); |
4434 | } |
4435 | paddedLen = pad_to_int32(sizeof(len) + len) - sizeof(len); |
4436 | strncpy(&wire[sizeof(len)], str, paddedLen)__builtin___strncpy_chk (&wire[sizeof(len)], str, paddedLen , __builtin_object_size (&wire[sizeof(len)], 2 > 1 ? 1 : 0)); |
4437 | wire += sizeof(len) + paddedLen; |
4438 | return wire; |
4439 | } |
4440 | |
4441 | static int |
4442 | XkbSizeGeomProperties(XkbGeometryPtr geom) |
4443 | { |
4444 | register int i, size; |
4445 | XkbPropertyPtr prop; |
4446 | |
4447 | for (size = i = 0, prop = geom->properties; i < geom->num_properties; |
4448 | i++, prop++) { |
4449 | size += XkbSizeCountedString(prop->name)((prop->name)?((((2+strlen(prop->name))+3)/4)*4):4); |
4450 | size += XkbSizeCountedString(prop->value)((prop->value)?((((2+strlen(prop->value))+3)/4)*4):4); |
4451 | } |
4452 | return size; |
4453 | } |
4454 | |
4455 | static char * |
4456 | XkbWriteGeomProperties(char *wire, XkbGeometryPtr geom, Bool swap) |
4457 | { |
4458 | register int i; |
4459 | register XkbPropertyPtr prop; |
4460 | |
4461 | for (i = 0, prop = geom->properties; i < geom->num_properties; i++, prop++) { |
4462 | wire = XkbWriteCountedString(wire, prop->name, swap); |
4463 | wire = XkbWriteCountedString(wire, prop->value, swap); |
4464 | } |
4465 | return wire; |
4466 | } |
4467 | |
4468 | static int |
4469 | XkbSizeGeomKeyAliases(XkbGeometryPtr geom) |
4470 | { |
4471 | return geom->num_key_aliases * (2 * XkbKeyNameLength4); |
4472 | } |
4473 | |
4474 | static char * |
4475 | XkbWriteGeomKeyAliases(char *wire, XkbGeometryPtr geom, Bool swap) |
4476 | { |
4477 | register int sz; |
4478 | |
4479 | sz = geom->num_key_aliases * (XkbKeyNameLength4 * 2); |
4480 | if (sz > 0) { |
4481 | memcpy(wire, (char *) geom->key_aliases, sz)__builtin___memcpy_chk (wire, (char *) geom->key_aliases, sz , __builtin_object_size (wire, 0)); |
4482 | wire += sz; |
4483 | } |
4484 | return wire; |
4485 | } |
4486 | |
4487 | static int |
4488 | XkbSizeGeomColors(XkbGeometryPtr geom) |
4489 | { |
4490 | register int i, size; |
4491 | register XkbColorPtr color; |
4492 | |
4493 | for (i = size = 0, color = geom->colors; i < geom->num_colors; i++, color++) { |
4494 | size += XkbSizeCountedString(color->spec)((color->spec)?((((2+strlen(color->spec))+3)/4)*4):4); |
4495 | } |
4496 | return size; |
4497 | } |
4498 | |
4499 | static char * |
4500 | XkbWriteGeomColors(char *wire, XkbGeometryPtr geom, Bool swap) |
4501 | { |
4502 | register int i; |
4503 | register XkbColorPtr color; |
4504 | |
4505 | for (i = 0, color = geom->colors; i < geom->num_colors; i++, color++) { |
4506 | wire = XkbWriteCountedString(wire, color->spec, swap); |
4507 | } |
4508 | return wire; |
4509 | } |
4510 | |
4511 | static int |
4512 | XkbSizeGeomShapes(XkbGeometryPtr geom) |
4513 | { |
4514 | register int i, size; |
4515 | register XkbShapePtr shape; |
4516 | |
4517 | for (i = size = 0, shape = geom->shapes; i < geom->num_shapes; i++, shape++) { |
4518 | register int n; |
4519 | register XkbOutlinePtr ol; |
4520 | |
4521 | size += SIZEOF(xkbShapeWireDesc)8; |
4522 | for (n = 0, ol = shape->outlines; n < shape->num_outlines; n++, ol++) { |
4523 | size += SIZEOF(xkbOutlineWireDesc)4; |
4524 | size += ol->num_points * SIZEOF(xkbPointWireDesc)4; |
4525 | } |
4526 | } |
4527 | return size; |
4528 | } |
4529 | |
4530 | static char * |
4531 | XkbWriteGeomShapes(char *wire, XkbGeometryPtr geom, Bool swap) |
4532 | { |
4533 | int i; |
4534 | XkbShapePtr shape; |
4535 | xkbShapeWireDesc *shapeWire; |
4536 | |
4537 | for (i = 0, shape = geom->shapes; i < geom->num_shapes; i++, shape++) { |
4538 | register int o; |
4539 | XkbOutlinePtr ol; |
4540 | xkbOutlineWireDesc *olWire; |
4541 | |
4542 | shapeWire = (xkbShapeWireDesc *) wire; |
4543 | shapeWire->name = shape->name; |
4544 | shapeWire->nOutlines = shape->num_outlines; |
4545 | if (shape->primary != NULL((void*)0)) |
4546 | shapeWire->primaryNdx = XkbOutlineIndex(shape, shape->primary)((int)((shape->primary)-&(shape)->outlines[0])); |
4547 | else |
4548 | shapeWire->primaryNdx = XkbNoShape0xff; |
4549 | if (shape->approx != NULL((void*)0)) |
4550 | shapeWire->approxNdx = XkbOutlineIndex(shape, shape->approx)((int)((shape->approx)-&(shape)->outlines[0])); |
4551 | else |
4552 | shapeWire->approxNdx = XkbNoShape0xff; |
4553 | shapeWire->pad = 0; |
4554 | if (swap) { |
4555 | swapl(&shapeWire->name)do { if (sizeof(*(&shapeWire->name)) != 4) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&shapeWire->name ) & 3) && ((uintptr_t)(&shapeWire->name) & 3) == 0) *(&shapeWire->name) = lswapl(*(&shapeWire ->name)); else swap_uint32((uint32_t *)(&shapeWire-> name)); } while (0); |
4556 | } |
4557 | wire = (char *) &shapeWire[1]; |
4558 | for (o = 0, ol = shape->outlines; o < shape->num_outlines; o++, ol++) { |
4559 | register int p; |
4560 | XkbPointPtr pt; |
4561 | xkbPointWireDesc *ptWire; |
4562 | |
4563 | olWire = (xkbOutlineWireDesc *) wire; |
4564 | olWire->nPoints = ol->num_points; |
4565 | olWire->cornerRadius = ol->corner_radius; |
4566 | olWire->pad = 0; |
4567 | wire = (char *) &olWire[1]; |
4568 | ptWire = (xkbPointWireDesc *) wire; |
4569 | for (p = 0, pt = ol->points; p < ol->num_points; p++, pt++) { |
4570 | ptWire[p].x = pt->x; |
4571 | ptWire[p].y = pt->y; |
4572 | if (swap) { |
4573 | swaps(&ptWire[p].x)do { if (sizeof(*(&ptWire[p].x)) != 2) wrong_size(); if ( __builtin_constant_p((uintptr_t)(&ptWire[p].x) & 1) && ((uintptr_t)(&ptWire[p].x) & 1) == 0) *(&ptWire[ p].x) = lswaps(*(&ptWire[p].x)); else swap_uint16((uint16_t *)(&ptWire[p].x)); } while (0); |
4574 | swaps(&ptWire[p].y)do { if (sizeof(*(&ptWire[p].y)) != 2) wrong_size(); if ( __builtin_constant_p((uintptr_t)(&ptWire[p].y) & 1) && ((uintptr_t)(&ptWire[p].y) & 1) == 0) *(&ptWire[ p].y) = lswaps(*(&ptWire[p].y)); else swap_uint16((uint16_t *)(&ptWire[p].y)); } while (0); |
4575 | } |
4576 | } |
4577 | wire = (char *) &ptWire[ol->num_points]; |
4578 | } |
4579 | } |
4580 | return wire; |
4581 | } |
4582 | |
4583 | static int |
4584 | XkbSizeGeomDoodads(int num_doodads, XkbDoodadPtr doodad) |
4585 | { |
4586 | register int i, size; |
4587 | |
4588 | for (i = size = 0; i < num_doodads; i++, doodad++) { |
4589 | size += SIZEOF(xkbAnyDoodadWireDesc)20; |
4590 | if (doodad->any.type == XkbTextDoodad3) { |
4591 | size += XkbSizeCountedString(doodad->text.text)((doodad->text.text)?((((2+strlen(doodad->text.text))+3 )/4)*4):4); |
4592 | size += XkbSizeCountedString(doodad->text.font)((doodad->text.font)?((((2+strlen(doodad->text.font))+3 )/4)*4):4); |
4593 | } |
4594 | else if (doodad->any.type == XkbLogoDoodad5) { |
4595 | size += XkbSizeCountedString(doodad->logo.logo_name)((doodad->logo.logo_name)?((((2+strlen(doodad->logo.logo_name ))+3)/4)*4):4); |
4596 | } |
4597 | } |
4598 | return size; |
4599 | } |
4600 | |
4601 | static char * |
4602 | XkbWriteGeomDoodads(char *wire, int num_doodads, XkbDoodadPtr doodad, Bool swap) |
4603 | { |
4604 | register int i; |
4605 | xkbDoodadWireDesc *doodadWire; |
4606 | |
4607 | for (i = 0; i < num_doodads; i++, doodad++) { |
4608 | doodadWire = (xkbDoodadWireDesc *) wire; |
4609 | wire = (char *) &doodadWire[1]; |
4610 | memset(doodadWire, 0, SIZEOF(xkbDoodadWireDesc))__builtin___memset_chk (doodadWire, 0, 20, __builtin_object_size (doodadWire, 0)); |
4611 | doodadWire->any.name = doodad->any.name; |
4612 | doodadWire->any.type = doodad->any.type; |
4613 | doodadWire->any.priority = doodad->any.priority; |
4614 | doodadWire->any.top = doodad->any.top; |
4615 | doodadWire->any.left = doodad->any.left; |
4616 | if (swap) { |
4617 | swapl(&doodadWire->any.name)do { if (sizeof(*(&doodadWire->any.name)) != 4) wrong_size (); if (__builtin_constant_p((uintptr_t)(&doodadWire-> any.name) & 3) && ((uintptr_t)(&doodadWire-> any.name) & 3) == 0) *(&doodadWire->any.name) = lswapl (*(&doodadWire->any.name)); else swap_uint32((uint32_t *)(&doodadWire->any.name)); } while (0); |
4618 | swaps(&doodadWire->any.top)do { if (sizeof(*(&doodadWire->any.top)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&doodadWire-> any.top) & 1) && ((uintptr_t)(&doodadWire-> any.top) & 1) == 0) *(&doodadWire->any.top) = lswaps (*(&doodadWire->any.top)); else swap_uint16((uint16_t * )(&doodadWire->any.top)); } while (0); |
4619 | swaps(&doodadWire->any.left)do { if (sizeof(*(&doodadWire->any.left)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&doodadWire-> any.left) & 1) && ((uintptr_t)(&doodadWire-> any.left) & 1) == 0) *(&doodadWire->any.left) = lswaps (*(&doodadWire->any.left)); else swap_uint16((uint16_t *)(&doodadWire->any.left)); } while (0); |
4620 | } |
4621 | switch (doodad->any.type) { |
4622 | case XkbOutlineDoodad1: |
4623 | case XkbSolidDoodad2: |
4624 | doodadWire->shape.angle = doodad->shape.angle; |
4625 | doodadWire->shape.colorNdx = doodad->shape.color_ndx; |
4626 | doodadWire->shape.shapeNdx = doodad->shape.shape_ndx; |
4627 | if (swap) { |
4628 | swaps(&doodadWire->shape.angle)do { if (sizeof(*(&doodadWire->shape.angle)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&doodadWire-> shape.angle) & 1) && ((uintptr_t)(&doodadWire ->shape.angle) & 1) == 0) *(&doodadWire->shape. angle) = lswaps(*(&doodadWire->shape.angle)); else swap_uint16 ((uint16_t *)(&doodadWire->shape.angle)); } while (0); |
4629 | } |
4630 | break; |
4631 | case XkbTextDoodad3: |
4632 | doodadWire->text.angle = doodad->text.angle; |
4633 | doodadWire->text.width = doodad->text.width; |
4634 | doodadWire->text.height = doodad->text.height; |
4635 | doodadWire->text.colorNdx = doodad->text.color_ndx; |
4636 | if (swap) { |
4637 | swaps(&doodadWire->text.angle)do { if (sizeof(*(&doodadWire->text.angle)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&doodadWire-> text.angle) & 1) && ((uintptr_t)(&doodadWire-> text.angle) & 1) == 0) *(&doodadWire->text.angle) = lswaps(*(&doodadWire->text.angle)); else swap_uint16( (uint16_t *)(&doodadWire->text.angle)); } while (0); |
4638 | swaps(&doodadWire->text.width)do { if (sizeof(*(&doodadWire->text.width)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&doodadWire-> text.width) & 1) && ((uintptr_t)(&doodadWire-> text.width) & 1) == 0) *(&doodadWire->text.width) = lswaps(*(&doodadWire->text.width)); else swap_uint16( (uint16_t *)(&doodadWire->text.width)); } while (0); |
4639 | swaps(&doodadWire->text.height)do { if (sizeof(*(&doodadWire->text.height)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&doodadWire-> text.height) & 1) && ((uintptr_t)(&doodadWire ->text.height) & 1) == 0) *(&doodadWire->text.height ) = lswaps(*(&doodadWire->text.height)); else swap_uint16 ((uint16_t *)(&doodadWire->text.height)); } while (0); |
4640 | } |
4641 | wire = XkbWriteCountedString(wire, doodad->text.text, swap); |
4642 | wire = XkbWriteCountedString(wire, doodad->text.font, swap); |
4643 | break; |
4644 | case XkbIndicatorDoodad4: |
4645 | doodadWire->indicator.shapeNdx = doodad->indicator.shape_ndx; |
4646 | doodadWire->indicator.onColorNdx = doodad->indicator.on_color_ndx; |
4647 | doodadWire->indicator.offColorNdx = doodad->indicator.off_color_ndx; |
4648 | break; |
4649 | case XkbLogoDoodad5: |
4650 | doodadWire->logo.angle = doodad->logo.angle; |
4651 | doodadWire->logo.colorNdx = doodad->logo.color_ndx; |
4652 | doodadWire->logo.shapeNdx = doodad->logo.shape_ndx; |
4653 | wire = XkbWriteCountedString(wire, doodad->logo.logo_name, swap); |
4654 | break; |
4655 | default: |
4656 | ErrorF("[xkb] Unknown doodad type %d in XkbWriteGeomDoodads\n", |
4657 | doodad->any.type); |
4658 | ErrorF("[xkb] Ignored\n"); |
4659 | break; |
4660 | } |
4661 | } |
4662 | return wire; |
4663 | } |
4664 | |
4665 | static char * |
4666 | XkbWriteGeomOverlay(char *wire, XkbOverlayPtr ol, Bool swap) |
4667 | { |
4668 | register int r; |
4669 | XkbOverlayRowPtr row; |
4670 | xkbOverlayWireDesc *olWire; |
4671 | |
4672 | olWire = (xkbOverlayWireDesc *) wire; |
4673 | olWire->name = ol->name; |
4674 | olWire->nRows = ol->num_rows; |
4675 | olWire->pad1 = 0; |
4676 | olWire->pad2 = 0; |
4677 | if (swap) { |
4678 | swapl(&olWire->name)do { if (sizeof(*(&olWire->name)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&olWire->name) & 3) && ((uintptr_t)(&olWire->name) & 3) == 0) *(&olWire->name) = lswapl(*(&olWire->name)) ; else swap_uint32((uint32_t *)(&olWire->name)); } while (0); |
4679 | } |
4680 | wire = (char *) &olWire[1]; |
4681 | for (r = 0, row = ol->rows; r < ol->num_rows; r++, row++) { |
4682 | unsigned int k; |
4683 | XkbOverlayKeyPtr key; |
4684 | xkbOverlayRowWireDesc *rowWire; |
4685 | |
4686 | rowWire = (xkbOverlayRowWireDesc *) wire; |
4687 | rowWire->rowUnder = row->row_under; |
4688 | rowWire->nKeys = row->num_keys; |
4689 | rowWire->pad1 = 0; |
4690 | wire = (char *) &rowWire[1]; |
4691 | for (k = 0, key = row->keys; k < row->num_keys; k++, key++) { |
4692 | xkbOverlayKeyWireDesc *keyWire; |
4693 | |
4694 | keyWire = (xkbOverlayKeyWireDesc *) wire; |
4695 | memcpy(keyWire->over, key->over.name, XkbKeyNameLength)__builtin___memcpy_chk (keyWire->over, key->over.name, 4 , __builtin_object_size (keyWire->over, 0)); |
4696 | memcpy(keyWire->under, key->under.name, XkbKeyNameLength)__builtin___memcpy_chk (keyWire->under, key->under.name , 4, __builtin_object_size (keyWire->under, 0)); |
4697 | wire = (char *) &keyWire[1]; |
4698 | } |
4699 | } |
4700 | return wire; |
4701 | } |
4702 | |
4703 | static int |
4704 | XkbSizeGeomSections(XkbGeometryPtr geom) |
4705 | { |
4706 | register int i, size; |
4707 | XkbSectionPtr section; |
4708 | |
4709 | for (i = size = 0, section = geom->sections; i < geom->num_sections; |
4710 | i++, section++) { |
4711 | size += SIZEOF(xkbSectionWireDesc)20; |
4712 | if (section->rows) { |
4713 | int r; |
4714 | XkbRowPtr row; |
4715 | |
4716 | for (r = 0, row = section->rows; r < section->num_rows; row++, r++) { |
4717 | size += SIZEOF(xkbRowWireDesc)8; |
4718 | size += row->num_keys * SIZEOF(xkbKeyWireDesc)8; |
4719 | } |
4720 | } |
4721 | if (section->doodads) |
4722 | size += XkbSizeGeomDoodads(section->num_doodads, section->doodads); |
4723 | if (section->overlays) { |
4724 | int o; |
4725 | XkbOverlayPtr ol; |
4726 | |
4727 | for (o = 0, ol = section->overlays; o < section->num_overlays; |
4728 | o++, ol++) { |
4729 | int r; |
4730 | XkbOverlayRowPtr row; |
4731 | |
4732 | size += SIZEOF(xkbOverlayWireDesc)8; |
4733 | for (r = 0, row = ol->rows; r < ol->num_rows; r++, row++) { |
4734 | size += SIZEOF(xkbOverlayRowWireDesc)4; |
4735 | size += row->num_keys * SIZEOF(xkbOverlayKeyWireDesc)8; |
4736 | } |
4737 | } |
4738 | } |
4739 | } |
4740 | return size; |
4741 | } |
4742 | |
4743 | static char * |
4744 | XkbWriteGeomSections(char *wire, XkbGeometryPtr geom, Bool swap) |
4745 | { |
4746 | register int i; |
4747 | XkbSectionPtr section; |
4748 | xkbSectionWireDesc *sectionWire; |
4749 | |
4750 | for (i = 0, section = geom->sections; i < geom->num_sections; |
4751 | i++, section++) { |
4752 | sectionWire = (xkbSectionWireDesc *) wire; |
4753 | sectionWire->name = section->name; |
4754 | sectionWire->top = section->top; |
4755 | sectionWire->left = section->left; |
4756 | sectionWire->width = section->width; |
4757 | sectionWire->height = section->height; |
4758 | sectionWire->angle = section->angle; |
4759 | sectionWire->priority = section->priority; |
4760 | sectionWire->nRows = section->num_rows; |
4761 | sectionWire->nDoodads = section->num_doodads; |
4762 | sectionWire->nOverlays = section->num_overlays; |
4763 | sectionWire->pad = 0; |
4764 | if (swap) { |
4765 | swapl(§ionWire->name)do { if (sizeof(*(§ionWire->name)) != 4) wrong_size (); if (__builtin_constant_p((uintptr_t)(§ionWire-> name) & 3) && ((uintptr_t)(§ionWire->name ) & 3) == 0) *(§ionWire->name) = lswapl(*(& sectionWire->name)); else swap_uint32((uint32_t *)(§ionWire ->name)); } while (0); |
4766 | swaps(§ionWire->top)do { if (sizeof(*(§ionWire->top)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(§ionWire-> top) & 1) && ((uintptr_t)(§ionWire->top ) & 1) == 0) *(§ionWire->top) = lswaps(*(& sectionWire->top)); else swap_uint16((uint16_t *)(§ionWire ->top)); } while (0); |
4767 | swaps(§ionWire->left)do { if (sizeof(*(§ionWire->left)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(§ionWire-> left) & 1) && ((uintptr_t)(§ionWire->left ) & 1) == 0) *(§ionWire->left) = lswaps(*(& sectionWire->left)); else swap_uint16((uint16_t *)(§ionWire ->left)); } while (0); |
4768 | swaps(§ionWire->width)do { if (sizeof(*(§ionWire->width)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(§ionWire-> width) & 1) && ((uintptr_t)(§ionWire-> width) & 1) == 0) *(§ionWire->width) = lswaps( *(§ionWire->width)); else swap_uint16((uint16_t *) (§ionWire->width)); } while (0); |
4769 | swaps(§ionWire->height)do { if (sizeof(*(§ionWire->height)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(§ionWire-> height) & 1) && ((uintptr_t)(§ionWire-> height) & 1) == 0) *(§ionWire->height) = lswaps (*(§ionWire->height)); else swap_uint16((uint16_t * )(§ionWire->height)); } while (0); |
4770 | swaps(§ionWire->angle)do { if (sizeof(*(§ionWire->angle)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(§ionWire-> angle) & 1) && ((uintptr_t)(§ionWire-> angle) & 1) == 0) *(§ionWire->angle) = lswaps( *(§ionWire->angle)); else swap_uint16((uint16_t *) (§ionWire->angle)); } while (0); |
4771 | } |
4772 | wire = (char *) §ionWire[1]; |
4773 | if (section->rows) { |
4774 | int r; |
4775 | XkbRowPtr row; |
4776 | xkbRowWireDesc *rowWire; |
4777 | |
4778 | for (r = 0, row = section->rows; r < section->num_rows; r++, row++) { |
4779 | rowWire = (xkbRowWireDesc *) wire; |
4780 | rowWire->top = row->top; |
4781 | rowWire->left = row->left; |
4782 | rowWire->nKeys = row->num_keys; |
4783 | rowWire->vertical = row->vertical; |
4784 | rowWire->pad = 0; |
4785 | if (swap) { |
4786 | swaps(&rowWire->top)do { if (sizeof(*(&rowWire->top)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&rowWire->top) & 1) && ((uintptr_t)(&rowWire->top) & 1) == 0) *(&rowWire->top) = lswaps(*(&rowWire->top)) ; else swap_uint16((uint16_t *)(&rowWire->top)); } while (0); |
4787 | swaps(&rowWire->left)do { if (sizeof(*(&rowWire->left)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&rowWire->left) & 1) && ((uintptr_t)(&rowWire->left) & 1) == 0) *(&rowWire->left) = lswaps(*(&rowWire->left )); else swap_uint16((uint16_t *)(&rowWire->left)); } while (0); |
4788 | } |
4789 | wire = (char *) &rowWire[1]; |
4790 | if (row->keys) { |
4791 | int k; |
4792 | XkbKeyPtr key; |
4793 | xkbKeyWireDesc *keyWire; |
4794 | |
4795 | keyWire = (xkbKeyWireDesc *) wire; |
4796 | for (k = 0, key = row->keys; k < row->num_keys; k++, key++) { |
4797 | memcpy(keyWire[k].name, key->name.name,__builtin___memcpy_chk (keyWire[k].name, key->name.name, 4 , __builtin_object_size (keyWire[k].name, 0)) |
4798 | XkbKeyNameLength)__builtin___memcpy_chk (keyWire[k].name, key->name.name, 4 , __builtin_object_size (keyWire[k].name, 0)); |
4799 | keyWire[k].gap = key->gap; |
4800 | keyWire[k].shapeNdx = key->shape_ndx; |
4801 | keyWire[k].colorNdx = key->color_ndx; |
4802 | if (swap) { |
4803 | swaps(&keyWire[k].gap)do { if (sizeof(*(&keyWire[k].gap)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&keyWire[k].gap) & 1) && ((uintptr_t)(&keyWire[k].gap) & 1) == 0 ) *(&keyWire[k].gap) = lswaps(*(&keyWire[k].gap)); else swap_uint16((uint16_t *)(&keyWire[k].gap)); } while (0); |
4804 | } |
4805 | } |
4806 | wire = (char *) &keyWire[row->num_keys]; |
4807 | } |
4808 | } |
4809 | } |
4810 | if (section->doodads) { |
4811 | wire = XkbWriteGeomDoodads(wire, |
4812 | section->num_doodads, section->doodads, |
4813 | swap); |
4814 | } |
4815 | if (section->overlays) { |
4816 | register int o; |
4817 | |
4818 | for (o = 0; o < section->num_overlays; o++) { |
4819 | wire = XkbWriteGeomOverlay(wire, §ion->overlays[o], swap); |
4820 | } |
4821 | } |
4822 | } |
4823 | return wire; |
4824 | } |
4825 | |
4826 | static Statusint |
4827 | XkbComputeGetGeometryReplySize(XkbGeometryPtr geom, |
4828 | xkbGetGeometryReply * rep, Atom name) |
4829 | { |
4830 | int len; |
4831 | |
4832 | if (geom != NULL((void*)0)) { |
4833 | len = XkbSizeCountedString(geom->label_font)((geom->label_font)?((((2+strlen(geom->label_font))+3)/ 4)*4):4); |
4834 | len += XkbSizeGeomProperties(geom); |
4835 | len += XkbSizeGeomColors(geom); |
4836 | len += XkbSizeGeomShapes(geom); |
4837 | len += XkbSizeGeomSections(geom); |
4838 | len += XkbSizeGeomDoodads(geom->num_doodads, geom->doodads); |
4839 | len += XkbSizeGeomKeyAliases(geom); |
4840 | rep->length = len / 4; |
4841 | rep->found = TRUE1; |
4842 | rep->name = geom->name; |
4843 | rep->widthMM = geom->width_mm; |
4844 | rep->heightMM = geom->height_mm; |
4845 | rep->nProperties = geom->num_properties; |
4846 | rep->nColors = geom->num_colors; |
4847 | rep->nShapes = geom->num_shapes; |
4848 | rep->nSections = geom->num_sections; |
4849 | rep->nDoodads = geom->num_doodads; |
4850 | rep->nKeyAliases = geom->num_key_aliases; |
4851 | rep->baseColorNdx = XkbGeomColorIndex(geom, geom->base_color)((int)((geom->base_color)-&(geom)->colors[0])); |
4852 | rep->labelColorNdx = XkbGeomColorIndex(geom, geom->label_color)((int)((geom->label_color)-&(geom)->colors[0])); |
4853 | } |
4854 | else { |
4855 | rep->length = 0; |
4856 | rep->found = FALSE0; |
4857 | rep->name = name; |
4858 | rep->widthMM = rep->heightMM = 0; |
4859 | rep->nProperties = rep->nColors = rep->nShapes = 0; |
4860 | rep->nSections = rep->nDoodads = 0; |
4861 | rep->nKeyAliases = 0; |
4862 | rep->labelColorNdx = rep->baseColorNdx = 0; |
4863 | } |
4864 | return Success0; |
4865 | } |
4866 | |
4867 | static int |
4868 | XkbSendGeometry(ClientPtr client, |
4869 | XkbGeometryPtr geom, xkbGetGeometryReply * rep, Bool freeGeom) |
4870 | { |
4871 | char *desc, *start; |
4872 | int len; |
4873 | |
4874 | if (geom != NULL((void*)0)) { |
4875 | len = rep->length * 4; |
4876 | start = desc = malloc(len); |
4877 | if (!start) |
4878 | return BadAlloc11; |
4879 | desc = XkbWriteCountedString(desc, geom->label_font, client->swapped); |
4880 | if (rep->nProperties > 0) |
4881 | desc = XkbWriteGeomProperties(desc, geom, client->swapped); |
4882 | if (rep->nColors > 0) |
4883 | desc = XkbWriteGeomColors(desc, geom, client->swapped); |
4884 | if (rep->nShapes > 0) |
4885 | desc = XkbWriteGeomShapes(desc, geom, client->swapped); |
4886 | if (rep->nSections > 0) |
4887 | desc = XkbWriteGeomSections(desc, geom, client->swapped); |
4888 | if (rep->nDoodads > 0) |
4889 | desc = XkbWriteGeomDoodads(desc, geom->num_doodads, geom->doodads, |
4890 | client->swapped); |
4891 | if (rep->nKeyAliases > 0) |
4892 | desc = XkbWriteGeomKeyAliases(desc, geom, client->swapped); |
4893 | if ((desc - start) != (len)) { |
4894 | ErrorF |
4895 | ("[xkb] BOGUS LENGTH in XkbSendGeometry, expected %d, got %ld\n", |
4896 | len, (unsigned long) (desc - start)); |
4897 | } |
4898 | } |
4899 | else { |
4900 | len = 0; |
4901 | start = NULL((void*)0); |
4902 | } |
4903 | if (client->swapped) { |
4904 | swaps(&rep->sequenceNumber)do { if (sizeof(*(&rep->sequenceNumber)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&rep->sequenceNumber ) & 1) && ((uintptr_t)(&rep->sequenceNumber ) & 1) == 0) *(&rep->sequenceNumber) = lswaps(*(& rep->sequenceNumber)); else swap_uint16((uint16_t *)(& rep->sequenceNumber)); } while (0); |
4905 | swapl(&rep->length)do { if (sizeof(*(&rep->length)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&rep->length) & 3) && ((uintptr_t)(&rep->length) & 3) == 0 ) *(&rep->length) = lswapl(*(&rep->length)); else swap_uint32((uint32_t *)(&rep->length)); } while (0); |
4906 | swapl(&rep->name)do { if (sizeof(*(&rep->name)) != 4) wrong_size(); if ( __builtin_constant_p((uintptr_t)(&rep->name) & 3) && ((uintptr_t)(&rep->name) & 3) == 0) *(&rep-> name) = lswapl(*(&rep->name)); else swap_uint32((uint32_t *)(&rep->name)); } while (0); |
4907 | swaps(&rep->widthMM)do { if (sizeof(*(&rep->widthMM)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&rep->widthMM) & 1) && ((uintptr_t)(&rep->widthMM) & 1) == 0) *(&rep->widthMM) = lswaps(*(&rep->widthMM)) ; else swap_uint16((uint16_t *)(&rep->widthMM)); } while (0); |
4908 | swaps(&rep->heightMM)do { if (sizeof(*(&rep->heightMM)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&rep->heightMM) & 1) && ((uintptr_t)(&rep->heightMM) & 1) == 0) *(&rep->heightMM) = lswaps(*(&rep->heightMM )); else swap_uint16((uint16_t *)(&rep->heightMM)); } while (0); |
4909 | swaps(&rep->nProperties)do { if (sizeof(*(&rep->nProperties)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&rep->nProperties ) & 1) && ((uintptr_t)(&rep->nProperties) & 1) == 0) *(&rep->nProperties) = lswaps(*(&rep-> nProperties)); else swap_uint16((uint16_t *)(&rep->nProperties )); } while (0); |
4910 | swaps(&rep->nColors)do { if (sizeof(*(&rep->nColors)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&rep->nColors) & 1) && ((uintptr_t)(&rep->nColors) & 1) == 0) *(&rep->nColors) = lswaps(*(&rep->nColors)) ; else swap_uint16((uint16_t *)(&rep->nColors)); } while (0); |
4911 | swaps(&rep->nShapes)do { if (sizeof(*(&rep->nShapes)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&rep->nShapes) & 1) && ((uintptr_t)(&rep->nShapes) & 1) == 0) *(&rep->nShapes) = lswaps(*(&rep->nShapes)) ; else swap_uint16((uint16_t *)(&rep->nShapes)); } while (0); |
4912 | swaps(&rep->nSections)do { if (sizeof(*(&rep->nSections)) != 2) wrong_size() ; if (__builtin_constant_p((uintptr_t)(&rep->nSections ) & 1) && ((uintptr_t)(&rep->nSections) & 1) == 0) *(&rep->nSections) = lswaps(*(&rep->nSections )); else swap_uint16((uint16_t *)(&rep->nSections)); } while (0); |
4913 | swaps(&rep->nDoodads)do { if (sizeof(*(&rep->nDoodads)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&rep->nDoodads) & 1) && ((uintptr_t)(&rep->nDoodads) & 1) == 0) *(&rep->nDoodads) = lswaps(*(&rep->nDoodads )); else swap_uint16((uint16_t *)(&rep->nDoodads)); } while (0); |
4914 | swaps(&rep->nKeyAliases)do { if (sizeof(*(&rep->nKeyAliases)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&rep->nKeyAliases ) & 1) && ((uintptr_t)(&rep->nKeyAliases) & 1) == 0) *(&rep->nKeyAliases) = lswaps(*(&rep-> nKeyAliases)); else swap_uint16((uint16_t *)(&rep->nKeyAliases )); } while (0); |
4915 | } |
4916 | WriteToClient(client, SIZEOF(xkbGetGeometryReply)32, rep); |
4917 | if (len > 0) |
4918 | WriteToClient(client, len, start); |
4919 | if (start != NULL((void*)0)) |
4920 | free((char *) start); |
4921 | if (freeGeom) |
4922 | XkbFreeGeometrySrvXkbFreeGeometry(geom, XkbGeomAllMask(0x3f), TRUE1); |
4923 | return Success0; |
4924 | } |
4925 | |
4926 | int |
4927 | ProcXkbGetGeometry(ClientPtr client) |
4928 | { |
4929 | DeviceIntPtr dev; |
4930 | xkbGetGeometryReply rep; |
4931 | XkbGeometryPtr geom; |
4932 | Bool shouldFree; |
4933 | Statusint status; |
4934 | |
4935 | REQUEST(xkbGetGeometryReq)xkbGetGeometryReq *stuff = (xkbGetGeometryReq *)client->requestBuffer; |
4936 | REQUEST_SIZE_MATCH(xkbGetGeometryReq)if ((sizeof(xkbGetGeometryReq) >> 2) != client->req_len ) return(16); |
4937 | |
4938 | if (!(client->xkbClientFlags & _XkbClientInitialized(1<<15))) |
4939 | return BadAccess10; |
4940 | |
4941 | CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixGetAttrAccess){ int why; int tmprc = _XkbLookupKeyboard(&(dev), stuff-> deviceSpec, client, (1<<4), &why); if (tmprc != 0) { client->errorValue = ((XID)((((unsigned int)(why))<< 24)|((stuff->deviceSpec)&0xffffff))); return tmprc; }}; |
4942 | CHK_ATOM_OR_NONE(stuff->name){ if (((stuff->name)!=0L)&&(!ValidAtom((stuff-> name)))) { (client->errorValue)= (XID)(stuff->name); return 5; }}; |
4943 | |
4944 | geom = XkbLookupNamedGeometry(dev, stuff->name, &shouldFree); |
4945 | rep = (xkbGetGeometryReply) { |
4946 | .type = X_Reply1, |
4947 | .deviceID = dev->id, |
4948 | .sequenceNumber = client->sequence, |
4949 | .length = 0 |
4950 | }; |
4951 | status = XkbComputeGetGeometryReplySize(geom, &rep, stuff->name); |
4952 | if (status != Success0) |
4953 | return status; |
4954 | else |
4955 | return XkbSendGeometry(client, geom, &rep, shouldFree); |
4956 | } |
4957 | |
4958 | /***====================================================================***/ |
4959 | |
4960 | static Statusint |
4961 | _GetCountedString(char **wire_inout, ClientPtr client, char **str) |
4962 | { |
4963 | char *wire, *next; |
4964 | CARD16 len; |
4965 | |
4966 | wire = *wire_inout; |
4967 | len = *(CARD16 *) wire; |
4968 | if (client->swapped) { |
4969 | swaps(&len)do { if (sizeof(*(&len)) != 2) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&len) & 1) && ((uintptr_t)(& len) & 1) == 0) *(&len) = lswaps(*(&len)); else swap_uint16 ((uint16_t *)(&len)); } while (0); |
4970 | } |
4971 | next = wire + XkbPaddedSize(len + 2)((((unsigned int)(len + 2)+3) >> 2) << 2); |
4972 | /* Check we're still within the size of the request */ |
4973 | if (client->req_len < |
4974 | bytes_to_int32(next - (char *) client->requestBuffer)) |
4975 | return BadValue2; |
4976 | *str = malloc(len + 1); |
4977 | if (!*str) |
4978 | return BadAlloc11; |
4979 | memcpy(*str, &wire[2], len)__builtin___memcpy_chk (*str, &wire[2], len, __builtin_object_size (*str, 0)); |
4980 | *(*str + len) = '\0'; |
4981 | *wire_inout = next; |
4982 | return Success0; |
4983 | } |
4984 | |
4985 | static Statusint |
4986 | _CheckSetDoodad(char **wire_inout, |
4987 | XkbGeometryPtr geom, XkbSectionPtr section, ClientPtr client) |
4988 | { |
4989 | char *wire; |
4990 | xkbDoodadWireDesc *dWire; |
4991 | xkbAnyDoodadWireDesc any; |
4992 | xkbTextDoodadWireDesc text; |
4993 | XkbDoodadPtr doodad; |
4994 | Statusint status; |
4995 | |
4996 | dWire = (xkbDoodadWireDesc *) (*wire_inout); |
4997 | any = dWire->any; |
4998 | wire = (char *) &dWire[1]; |
4999 | if (client->swapped) { |
5000 | swapl(&any.name)do { if (sizeof(*(&any.name)) != 4) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&any.name) & 3) && ((uintptr_t)( &any.name) & 3) == 0) *(&any.name) = lswapl(*(& any.name)); else swap_uint32((uint32_t *)(&any.name)); } while (0); |
5001 | swaps(&any.top)do { if (sizeof(*(&any.top)) != 2) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&any.top) & 1) && ((uintptr_t)(& any.top) & 1) == 0) *(&any.top) = lswaps(*(&any.top )); else swap_uint16((uint16_t *)(&any.top)); } while (0); |
5002 | swaps(&any.left)do { if (sizeof(*(&any.left)) != 2) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&any.left) & 1) && ((uintptr_t)( &any.left) & 1) == 0) *(&any.left) = lswaps(*(& any.left)); else swap_uint16((uint16_t *)(&any.left)); } while (0); |
5003 | swaps(&any.angle)do { if (sizeof(*(&any.angle)) != 2) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&any.angle) & 1) && ((uintptr_t) (&any.angle) & 1) == 0) *(&any.angle) = lswaps(*( &any.angle)); else swap_uint16((uint16_t *)(&any.angle )); } while (0); |
5004 | } |
5005 | CHK_ATOM_ONLY(dWire->any.name){ if (((dWire->any.name)==0L)||(!ValidAtom((dWire->any. name)))) { (client->errorValue)= (XID)(dWire->any.name) ; return 5; }}; |
5006 | doodad = XkbAddGeomDoodadSrvXkbAddGeomDoodad(geom, section, any.name); |
5007 | if (!doodad) |
5008 | return BadAlloc11; |
5009 | doodad->any.type = dWire->any.type; |
5010 | doodad->any.priority = dWire->any.priority; |
5011 | doodad->any.top = any.top; |
5012 | doodad->any.left = any.left; |
5013 | doodad->any.angle = any.angle; |
5014 | switch (doodad->any.type) { |
5015 | case XkbOutlineDoodad1: |
5016 | case XkbSolidDoodad2: |
5017 | if (dWire->shape.colorNdx >= geom->num_colors) { |
5018 | client->errorValue = _XkbErrCode3(0x40, geom->num_colors,((XID)((((unsigned int)(0x40))<<24)|(((((unsigned int)( geom->num_colors))<<16)|(dWire->shape.colorNdx))& 0xffffff))) |
5019 | dWire->shape.colorNdx)((XID)((((unsigned int)(0x40))<<24)|(((((unsigned int)( geom->num_colors))<<16)|(dWire->shape.colorNdx))& 0xffffff))); |
5020 | return BadMatch8; |
5021 | } |
5022 | if (dWire->shape.shapeNdx >= geom->num_shapes) { |
5023 | client->errorValue = _XkbErrCode3(0x41, geom->num_shapes,((XID)((((unsigned int)(0x41))<<24)|(((((unsigned int)( geom->num_shapes))<<16)|(dWire->shape.shapeNdx))& 0xffffff))) |
5024 | dWire->shape.shapeNdx)((XID)((((unsigned int)(0x41))<<24)|(((((unsigned int)( geom->num_shapes))<<16)|(dWire->shape.shapeNdx))& 0xffffff))); |
5025 | return BadMatch8; |
5026 | } |
5027 | doodad->shape.color_ndx = dWire->shape.colorNdx; |
5028 | doodad->shape.shape_ndx = dWire->shape.shapeNdx; |
5029 | break; |
5030 | case XkbTextDoodad3: |
5031 | if (dWire->text.colorNdx >= geom->num_colors) { |
5032 | client->errorValue = _XkbErrCode3(0x42, geom->num_colors,((XID)((((unsigned int)(0x42))<<24)|(((((unsigned int)( geom->num_colors))<<16)|(dWire->text.colorNdx))& 0xffffff))) |
5033 | dWire->text.colorNdx)((XID)((((unsigned int)(0x42))<<24)|(((((unsigned int)( geom->num_colors))<<16)|(dWire->text.colorNdx))& 0xffffff))); |
5034 | return BadMatch8; |
5035 | } |
5036 | text = dWire->text; |
5037 | if (client->swapped) { |
5038 | swaps(&text.width)do { if (sizeof(*(&text.width)) != 2) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&text.width) & 1) && ((uintptr_t )(&text.width) & 1) == 0) *(&text.width) = lswaps (*(&text.width)); else swap_uint16((uint16_t *)(&text .width)); } while (0); |
5039 | swaps(&text.height)do { if (sizeof(*(&text.height)) != 2) wrong_size(); if ( __builtin_constant_p((uintptr_t)(&text.height) & 1) && ((uintptr_t)(&text.height) & 1) == 0) *(&text.height ) = lswaps(*(&text.height)); else swap_uint16((uint16_t * )(&text.height)); } while (0); |
5040 | } |
5041 | doodad->text.width = text.width; |
5042 | doodad->text.height = text.height; |
5043 | doodad->text.color_ndx = dWire->text.colorNdx; |
5044 | status = _GetCountedString(&wire, client, &doodad->text.text); |
5045 | if (status != Success0) |
5046 | return status; |
5047 | status = _GetCountedString(&wire, client, &doodad->text.font); |
5048 | if (status != Success0) { |
5049 | free (doodad->text.text); |
5050 | return status; |
5051 | } |
5052 | break; |
5053 | case XkbIndicatorDoodad4: |
5054 | if (dWire->indicator.onColorNdx >= geom->num_colors) { |
5055 | client->errorValue = _XkbErrCode3(0x43, geom->num_colors,((XID)((((unsigned int)(0x43))<<24)|(((((unsigned int)( geom->num_colors))<<16)|(dWire->indicator.onColorNdx ))&0xffffff))) |
5056 | dWire->indicator.onColorNdx)((XID)((((unsigned int)(0x43))<<24)|(((((unsigned int)( geom->num_colors))<<16)|(dWire->indicator.onColorNdx ))&0xffffff))); |
5057 | return BadMatch8; |
5058 | } |
5059 | if (dWire->indicator.offColorNdx >= geom->num_colors) { |
5060 | client->errorValue = _XkbErrCode3(0x44, geom->num_colors,((XID)((((unsigned int)(0x44))<<24)|(((((unsigned int)( geom->num_colors))<<16)|(dWire->indicator.offColorNdx ))&0xffffff))) |
5061 | dWire->indicator.offColorNdx)((XID)((((unsigned int)(0x44))<<24)|(((((unsigned int)( geom->num_colors))<<16)|(dWire->indicator.offColorNdx ))&0xffffff))); |
5062 | return BadMatch8; |
5063 | } |
5064 | if (dWire->indicator.shapeNdx >= geom->num_shapes) { |
5065 | client->errorValue = _XkbErrCode3(0x45, geom->num_shapes,((XID)((((unsigned int)(0x45))<<24)|(((((unsigned int)( geom->num_shapes))<<16)|(dWire->indicator.shapeNdx ))&0xffffff))) |
5066 | dWire->indicator.shapeNdx)((XID)((((unsigned int)(0x45))<<24)|(((((unsigned int)( geom->num_shapes))<<16)|(dWire->indicator.shapeNdx ))&0xffffff))); |
5067 | return BadMatch8; |
5068 | } |
5069 | doodad->indicator.shape_ndx = dWire->indicator.shapeNdx; |
5070 | doodad->indicator.on_color_ndx = dWire->indicator.onColorNdx; |
5071 | doodad->indicator.off_color_ndx = dWire->indicator.offColorNdx; |
5072 | break; |
5073 | case XkbLogoDoodad5: |
5074 | if (dWire->logo.colorNdx >= geom->num_colors) { |
5075 | client->errorValue = _XkbErrCode3(0x46, geom->num_colors,((XID)((((unsigned int)(0x46))<<24)|(((((unsigned int)( geom->num_colors))<<16)|(dWire->logo.colorNdx))& 0xffffff))) |
5076 | dWire->logo.colorNdx)((XID)((((unsigned int)(0x46))<<24)|(((((unsigned int)( geom->num_colors))<<16)|(dWire->logo.colorNdx))& 0xffffff))); |
5077 | return BadMatch8; |
5078 | } |
5079 | if (dWire->logo.shapeNdx >= geom->num_shapes) { |
5080 | client->errorValue = _XkbErrCode3(0x47, geom->num_shapes,((XID)((((unsigned int)(0x47))<<24)|(((((unsigned int)( geom->num_shapes))<<16)|(dWire->logo.shapeNdx))& 0xffffff))) |
5081 | dWire->logo.shapeNdx)((XID)((((unsigned int)(0x47))<<24)|(((((unsigned int)( geom->num_shapes))<<16)|(dWire->logo.shapeNdx))& 0xffffff))); |
5082 | return BadMatch8; |
5083 | } |
5084 | doodad->logo.color_ndx = dWire->logo.colorNdx; |
5085 | doodad->logo.shape_ndx = dWire->logo.shapeNdx; |
5086 | status = _GetCountedString(&wire, client, &doodad->logo.logo_name); |
5087 | if (status != Success0) |
5088 | return status; |
5089 | break; |
5090 | default: |
5091 | client->errorValue = _XkbErrCode2(0x4F, dWire->any.type)((XID)((((unsigned int)(0x4F))<<24)|((dWire->any.type )&0xffffff))); |
5092 | return BadValue2; |
5093 | } |
5094 | *wire_inout = wire; |
5095 | return Success0; |
5096 | } |
5097 | |
5098 | static Statusint |
5099 | _CheckSetOverlay(char **wire_inout, |
5100 | XkbGeometryPtr geom, XkbSectionPtr section, ClientPtr client) |
5101 | { |
5102 | register int r; |
5103 | char *wire; |
5104 | XkbOverlayPtr ol; |
5105 | xkbOverlayWireDesc *olWire; |
5106 | xkbOverlayRowWireDesc *rWire; |
5107 | |
5108 | wire = *wire_inout; |
5109 | olWire = (xkbOverlayWireDesc *) wire; |
5110 | if (client->swapped) { |
5111 | swapl(&olWire->name)do { if (sizeof(*(&olWire->name)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&olWire->name) & 3) && ((uintptr_t)(&olWire->name) & 3) == 0) *(&olWire->name) = lswapl(*(&olWire->name)) ; else swap_uint32((uint32_t *)(&olWire->name)); } while (0); |
5112 | } |
5113 | CHK_ATOM_ONLY(olWire->name){ if (((olWire->name)==0L)||(!ValidAtom((olWire->name)) )) { (client->errorValue)= (XID)(olWire->name); return 5 ; }}; |
5114 | ol = XkbAddGeomOverlaySrvXkbAddGeomOverlay(section, olWire->name, olWire->nRows); |
5115 | rWire = (xkbOverlayRowWireDesc *) &olWire[1]; |
5116 | for (r = 0; r < olWire->nRows; r++) { |
5117 | register int k; |
5118 | xkbOverlayKeyWireDesc *kWire; |
5119 | XkbOverlayRowPtr row; |
5120 | |
5121 | if (rWire->rowUnder > section->num_rows) { |
5122 | client->errorValue = _XkbErrCode4(0x20, r, section->num_rows,((XID)((((unsigned int)(0x20))<<24)|(((((unsigned int)( r))<<16)|(((((unsigned int)(section->num_rows))<< 8)|(rWire->rowUnder))))&0xffffff))) |
5123 | rWire->rowUnder)((XID)((((unsigned int)(0x20))<<24)|(((((unsigned int)( r))<<16)|(((((unsigned int)(section->num_rows))<< 8)|(rWire->rowUnder))))&0xffffff))); |
5124 | return BadMatch8; |
5125 | } |
5126 | row = XkbAddGeomOverlayRowSrvXkbAddGeomOverlayRow(ol, rWire->rowUnder, rWire->nKeys); |
5127 | kWire = (xkbOverlayKeyWireDesc *) &rWire[1]; |
5128 | for (k = 0; k < rWire->nKeys; k++, kWire++) { |
5129 | if (XkbAddGeomOverlayKeySrvXkbAddGeomOverlayKey(ol, row, |
5130 | (char *) kWire->over, |
5131 | (char *) kWire->under) == NULL((void*)0)) { |
5132 | client->errorValue = _XkbErrCode3(0x21, r, k)((XID)((((unsigned int)(0x21))<<24)|(((((unsigned int)( r))<<16)|(k))&0xffffff))); |
5133 | return BadMatch8; |
5134 | } |
5135 | } |
5136 | rWire = (xkbOverlayRowWireDesc *) kWire; |
5137 | } |
5138 | olWire = (xkbOverlayWireDesc *) rWire; |
5139 | wire = (char *) olWire; |
5140 | *wire_inout = wire; |
5141 | return Success0; |
5142 | } |
5143 | |
5144 | static Statusint |
5145 | _CheckSetSections(XkbGeometryPtr geom, |
5146 | xkbSetGeometryReq * req, char **wire_inout, ClientPtr client) |
5147 | { |
5148 | Statusint status; |
5149 | register int s; |
5150 | char *wire; |
5151 | xkbSectionWireDesc *sWire; |
5152 | XkbSectionPtr section; |
5153 | |
5154 | wire = *wire_inout; |
5155 | if (req->nSections < 1) |
5156 | return Success0; |
5157 | sWire = (xkbSectionWireDesc *) wire; |
5158 | for (s = 0; s < req->nSections; s++) { |
5159 | register int r; |
5160 | xkbRowWireDesc *rWire; |
5161 | |
5162 | if (client->swapped) { |
5163 | swapl(&sWire->name)do { if (sizeof(*(&sWire->name)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&sWire->name) & 3) && ((uintptr_t)(&sWire->name) & 3) == 0 ) *(&sWire->name) = lswapl(*(&sWire->name)); else swap_uint32((uint32_t *)(&sWire->name)); } while (0); |
5164 | swaps(&sWire->top)do { if (sizeof(*(&sWire->top)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&sWire->top) & 1 ) && ((uintptr_t)(&sWire->top) & 1) == 0) * (&sWire->top) = lswaps(*(&sWire->top)); else swap_uint16 ((uint16_t *)(&sWire->top)); } while (0); |
5165 | swaps(&sWire->left)do { if (sizeof(*(&sWire->left)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&sWire->left) & 1) && ((uintptr_t)(&sWire->left) & 1) == 0 ) *(&sWire->left) = lswaps(*(&sWire->left)); else swap_uint16((uint16_t *)(&sWire->left)); } while (0); |
5166 | swaps(&sWire->width)do { if (sizeof(*(&sWire->width)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&sWire->width) & 1) && ((uintptr_t)(&sWire->width) & 1) == 0) *(&sWire->width) = lswaps(*(&sWire->width)) ; else swap_uint16((uint16_t *)(&sWire->width)); } while (0); |
5167 | swaps(&sWire->height)do { if (sizeof(*(&sWire->height)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&sWire->height) & 1) && ((uintptr_t)(&sWire->height) & 1) == 0) *(&sWire->height) = lswaps(*(&sWire->height )); else swap_uint16((uint16_t *)(&sWire->height)); } while (0); |
5168 | swaps(&sWire->angle)do { if (sizeof(*(&sWire->angle)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&sWire->angle) & 1) && ((uintptr_t)(&sWire->angle) & 1) == 0) *(&sWire->angle) = lswaps(*(&sWire->angle)) ; else swap_uint16((uint16_t *)(&sWire->angle)); } while (0); |
5169 | } |
5170 | CHK_ATOM_ONLY(sWire->name){ if (((sWire->name)==0L)||(!ValidAtom((sWire->name)))) { (client->errorValue)= (XID)(sWire->name); return 5; } }; |
5171 | section = XkbAddGeomSectionSrvXkbAddGeomSection(geom, sWire->name, sWire->nRows, |
5172 | sWire->nDoodads, sWire->nOverlays); |
5173 | if (!section) |
5174 | return BadAlloc11; |
5175 | section->priority = sWire->priority; |
5176 | section->top = sWire->top; |
5177 | section->left = sWire->left; |
5178 | section->width = sWire->width; |
5179 | section->height = sWire->height; |
5180 | section->angle = sWire->angle; |
5181 | rWire = (xkbRowWireDesc *) &sWire[1]; |
5182 | for (r = 0; r < sWire->nRows; r++) { |
5183 | register int k; |
5184 | XkbRowPtr row; |
5185 | xkbKeyWireDesc *kWire; |
5186 | |
5187 | if (client->swapped) { |
5188 | swaps(&rWire->top)do { if (sizeof(*(&rWire->top)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&rWire->top) & 1 ) && ((uintptr_t)(&rWire->top) & 1) == 0) * (&rWire->top) = lswaps(*(&rWire->top)); else swap_uint16 ((uint16_t *)(&rWire->top)); } while (0); |
5189 | swaps(&rWire->left)do { if (sizeof(*(&rWire->left)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&rWire->left) & 1) && ((uintptr_t)(&rWire->left) & 1) == 0 ) *(&rWire->left) = lswaps(*(&rWire->left)); else swap_uint16((uint16_t *)(&rWire->left)); } while (0); |
5190 | } |
5191 | row = XkbAddGeomRowSrvXkbAddGeomRow(section, rWire->nKeys); |
5192 | if (!row) |
5193 | return BadAlloc11; |
5194 | row->top = rWire->top; |
5195 | row->left = rWire->left; |
5196 | row->vertical = rWire->vertical; |
5197 | kWire = (xkbKeyWireDesc *) &rWire[1]; |
5198 | for (k = 0; k < rWire->nKeys; k++) { |
5199 | XkbKeyPtr key; |
5200 | |
5201 | key = XkbAddGeomKeySrvXkbAddGeomKey(row); |
5202 | if (!key) |
5203 | return BadAlloc11; |
5204 | memcpy(key->name.name, kWire[k].name, XkbKeyNameLength)__builtin___memcpy_chk (key->name.name, kWire[k].name, 4, __builtin_object_size (key->name.name, 0)); |
5205 | key->gap = kWire[k].gap; |
5206 | key->shape_ndx = kWire[k].shapeNdx; |
5207 | key->color_ndx = kWire[k].colorNdx; |
5208 | if (key->shape_ndx >= geom->num_shapes) { |
5209 | client->errorValue = _XkbErrCode3(0x10, key->shape_ndx,((XID)((((unsigned int)(0x10))<<24)|(((((unsigned int)( key->shape_ndx))<<16)|(geom->num_shapes))&0xffffff ))) |
5210 | geom->num_shapes)((XID)((((unsigned int)(0x10))<<24)|(((((unsigned int)( key->shape_ndx))<<16)|(geom->num_shapes))&0xffffff ))); |
5211 | return BadMatch8; |
5212 | } |
5213 | if (key->color_ndx >= geom->num_colors) { |
5214 | client->errorValue = _XkbErrCode3(0x11, key->color_ndx,((XID)((((unsigned int)(0x11))<<24)|(((((unsigned int)( key->color_ndx))<<16)|(geom->num_colors))&0xffffff ))) |
5215 | geom->num_colors)((XID)((((unsigned int)(0x11))<<24)|(((((unsigned int)( key->color_ndx))<<16)|(geom->num_colors))&0xffffff ))); |
5216 | return BadMatch8; |
5217 | } |
5218 | } |
5219 | rWire = (xkbRowWireDesc *) &kWire[rWire->nKeys]; |
5220 | } |
5221 | wire = (char *) rWire; |
5222 | if (sWire->nDoodads > 0) { |
5223 | register int d; |
5224 | |
5225 | for (d = 0; d < sWire->nDoodads; d++) { |
5226 | status = _CheckSetDoodad(&wire, geom, section, client); |
5227 | if (status != Success0) |
5228 | return status; |
5229 | } |
5230 | } |
5231 | if (sWire->nOverlays > 0) { |
5232 | register int o; |
5233 | |
5234 | for (o = 0; o < sWire->nOverlays; o++) { |
5235 | status = _CheckSetOverlay(&wire, geom, section, client); |
5236 | if (status != Success0) |
5237 | return status; |
5238 | } |
5239 | } |
5240 | sWire = (xkbSectionWireDesc *) wire; |
5241 | } |
5242 | wire = (char *) sWire; |
5243 | *wire_inout = wire; |
5244 | return Success0; |
5245 | } |
5246 | |
5247 | static Statusint |
5248 | _CheckSetShapes(XkbGeometryPtr geom, |
5249 | xkbSetGeometryReq * req, char **wire_inout, ClientPtr client) |
5250 | { |
5251 | register int i; |
5252 | char *wire; |
5253 | |
5254 | wire = *wire_inout; |
5255 | if (req->nShapes < 1) { |
5256 | client->errorValue = _XkbErrCode2(0x06, req->nShapes)((XID)((((unsigned int)(0x06))<<24)|((req->nShapes)& 0xffffff))); |
5257 | return BadValue2; |
5258 | } |
5259 | else { |
5260 | xkbShapeWireDesc *shapeWire; |
5261 | XkbShapePtr shape; |
5262 | register int o; |
5263 | |
5264 | shapeWire = (xkbShapeWireDesc *) wire; |
5265 | for (i = 0; i < req->nShapes; i++) { |
5266 | xkbOutlineWireDesc *olWire; |
5267 | XkbOutlinePtr ol; |
5268 | |
5269 | shape = |
5270 | XkbAddGeomShapeSrvXkbAddGeomShape(geom, shapeWire->name, shapeWire->nOutlines); |
5271 | if (!shape) |
5272 | return BadAlloc11; |
5273 | olWire = (xkbOutlineWireDesc *) (&shapeWire[1]); |
5274 | for (o = 0; o < shapeWire->nOutlines; o++) { |
5275 | register int p; |
5276 | XkbPointPtr pt; |
5277 | xkbPointWireDesc *ptWire; |
5278 | |
5279 | ol = XkbAddGeomOutlineSrvXkbAddGeomOutline(shape, olWire->nPoints); |
5280 | if (!ol) |
5281 | return BadAlloc11; |
5282 | ol->corner_radius = olWire->cornerRadius; |
5283 | ptWire = (xkbPointWireDesc *) &olWire[1]; |
5284 | for (p = 0, pt = ol->points; p < olWire->nPoints; p++, pt++) { |
5285 | pt->x = ptWire[p].x; |
5286 | pt->y = ptWire[p].y; |
5287 | if (client->swapped) { |
5288 | swaps(&pt->x)do { if (sizeof(*(&pt->x)) != 2) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&pt->x) & 1) && ((uintptr_t)( &pt->x) & 1) == 0) *(&pt->x) = lswaps(*(& pt->x)); else swap_uint16((uint16_t *)(&pt->x)); } while (0); |
5289 | swaps(&pt->y)do { if (sizeof(*(&pt->y)) != 2) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&pt->y) & 1) && ((uintptr_t)( &pt->y) & 1) == 0) *(&pt->y) = lswaps(*(& pt->y)); else swap_uint16((uint16_t *)(&pt->y)); } while (0); |
5290 | } |
5291 | } |
5292 | ol->num_points = olWire->nPoints; |
5293 | olWire = (xkbOutlineWireDesc *) (&ptWire[olWire->nPoints]); |
5294 | } |
5295 | if (shapeWire->primaryNdx != XkbNoShape0xff) |
5296 | shape->primary = &shape->outlines[shapeWire->primaryNdx]; |
5297 | if (shapeWire->approxNdx != XkbNoShape0xff) |
5298 | shape->approx = &shape->outlines[shapeWire->approxNdx]; |
5299 | shapeWire = (xkbShapeWireDesc *) olWire; |
5300 | } |
5301 | wire = (char *) shapeWire; |
5302 | } |
5303 | if (geom->num_shapes != req->nShapes) { |
5304 | client->errorValue = _XkbErrCode3(0x07, geom->num_shapes, req->nShapes)((XID)((((unsigned int)(0x07))<<24)|(((((unsigned int)( geom->num_shapes))<<16)|(req->nShapes))&0xffffff ))); |
5305 | return BadMatch8; |
5306 | } |
5307 | |
5308 | *wire_inout = wire; |
5309 | return Success0; |
5310 | } |
5311 | |
5312 | static Statusint |
5313 | _CheckSetGeom(XkbGeometryPtr geom, xkbSetGeometryReq * req, ClientPtr client) |
5314 | { |
5315 | register int i; |
5316 | Statusint status; |
5317 | char *wire; |
5318 | |
5319 | wire = (char *) &req[1]; |
5320 | status = _GetCountedString(&wire, client, &geom->label_font); |
5321 | if (status != Success0) |
5322 | return status; |
5323 | |
5324 | for (i = 0; i < req->nProperties; i++) { |
5325 | char *name, *val; |
5326 | |
5327 | status = _GetCountedString(&wire, client, &name); |
5328 | if (status != Success0) |
5329 | return status; |
5330 | status = _GetCountedString(&wire, client, &val); |
5331 | if (status != Success0) { |
5332 | free(name); |
5333 | return status; |
5334 | } |
5335 | if (XkbAddGeomPropertySrvXkbAddGeomProperty(geom, name, val) == NULL((void*)0)) { |
5336 | free(name); |
5337 | free(val); |
5338 | return BadAlloc11; |
5339 | } |
5340 | free(name); |
5341 | free(val); |
5342 | } |
5343 | |
5344 | if (req->nColors < 2) { |
5345 | client->errorValue = _XkbErrCode3(0x01, 2, req->nColors)((XID)((((unsigned int)(0x01))<<24)|(((((unsigned int)( 2))<<16)|(req->nColors))&0xffffff))); |
5346 | return BadValue2; |
5347 | } |
5348 | if (req->baseColorNdx > req->nColors) { |
5349 | client->errorValue = |
5350 | _XkbErrCode3(0x03, req->nColors, req->baseColorNdx)((XID)((((unsigned int)(0x03))<<24)|(((((unsigned int)( req->nColors))<<16)|(req->baseColorNdx))&0xffffff ))); |
5351 | return BadMatch8; |
5352 | } |
5353 | if (req->labelColorNdx > req->nColors) { |
5354 | client->errorValue = |
5355 | _XkbErrCode3(0x03, req->nColors, req->labelColorNdx)((XID)((((unsigned int)(0x03))<<24)|(((((unsigned int)( req->nColors))<<16)|(req->labelColorNdx))&0xffffff ))); |
5356 | return BadMatch8; |
5357 | } |
5358 | if (req->labelColorNdx == req->baseColorNdx) { |
5359 | client->errorValue = _XkbErrCode3(0x04, req->baseColorNdx,((XID)((((unsigned int)(0x04))<<24)|(((((unsigned int)( req->baseColorNdx))<<16)|(req->labelColorNdx))& 0xffffff))) |
5360 | req->labelColorNdx)((XID)((((unsigned int)(0x04))<<24)|(((((unsigned int)( req->baseColorNdx))<<16)|(req->labelColorNdx))& 0xffffff))); |
5361 | return BadMatch8; |
5362 | } |
5363 | |
5364 | for (i = 0; i < req->nColors; i++) { |
5365 | char *name; |
5366 | |
5367 | status = _GetCountedString(&wire, client, &name); |
5368 | if (status != Success0) |
5369 | return status; |
5370 | if (!XkbAddGeomColorSrvXkbAddGeomColor(geom, name, geom->num_colors)) { |
5371 | free(name); |
5372 | return BadAlloc11; |
5373 | } |
5374 | free(name); |
5375 | } |
5376 | if (req->nColors != geom->num_colors) { |
5377 | client->errorValue = _XkbErrCode3(0x05, req->nColors, geom->num_colors)((XID)((((unsigned int)(0x05))<<24)|(((((unsigned int)( req->nColors))<<16)|(geom->num_colors))&0xffffff ))); |
5378 | return BadMatch8; |
5379 | } |
5380 | geom->label_color = &geom->colors[req->labelColorNdx]; |
5381 | geom->base_color = &geom->colors[req->baseColorNdx]; |
5382 | |
5383 | if ((status = _CheckSetShapes(geom, req, &wire, client)) != Success0) |
5384 | return status; |
5385 | |
5386 | if ((status = _CheckSetSections(geom, req, &wire, client)) != Success0) |
5387 | return status; |
5388 | |
5389 | for (i = 0; i < req->nDoodads; i++) { |
5390 | status = _CheckSetDoodad(&wire, geom, NULL((void*)0), client); |
5391 | if (status != Success0) |
5392 | return status; |
5393 | } |
5394 | |
5395 | for (i = 0; i < req->nKeyAliases; i++) { |
5396 | if (XkbAddGeomKeyAliasSrvXkbAddGeomKeyAlias(geom, &wire[XkbKeyNameLength4], wire) == NULL((void*)0)) |
5397 | return BadAlloc11; |
5398 | wire += 2 * XkbKeyNameLength4; |
5399 | } |
5400 | return Success0; |
5401 | } |
5402 | |
5403 | static int |
5404 | _XkbSetGeometry(ClientPtr client, DeviceIntPtr dev, xkbSetGeometryReq * stuff) |
5405 | { |
5406 | XkbDescPtr xkb; |
5407 | Bool new_name; |
5408 | xkbNewKeyboardNotify nkn; |
5409 | XkbGeometryPtr geom, old; |
5410 | XkbGeometrySizesRec sizes; |
5411 | Statusint status; |
5412 | |
5413 | xkb = dev->key->xkbInfo->desc; |
5414 | old = xkb->geom; |
5415 | xkb->geom = NULL((void*)0); |
5416 | |
5417 | sizes.which = XkbGeomAllMask(0x3f); |
5418 | sizes.num_properties = stuff->nProperties; |
5419 | sizes.num_colors = stuff->nColors; |
5420 | sizes.num_shapes = stuff->nShapes; |
5421 | sizes.num_sections = stuff->nSections; |
5422 | sizes.num_doodads = stuff->nDoodads; |
5423 | sizes.num_key_aliases = stuff->nKeyAliases; |
5424 | if ((status = XkbAllocGeometrySrvXkbAllocGeometry(xkb, &sizes)) != Success0) { |
5425 | xkb->geom = old; |
5426 | return status; |
5427 | } |
5428 | geom = xkb->geom; |
5429 | geom->name = stuff->name; |
5430 | geom->width_mm = stuff->widthMM; |
5431 | geom->height_mm = stuff->heightMM; |
5432 | if ((status = _CheckSetGeom(geom, stuff, client)) != Success0) { |
5433 | XkbFreeGeometrySrvXkbFreeGeometry(geom, XkbGeomAllMask(0x3f), TRUE1); |
5434 | xkb->geom = old; |
5435 | return status; |
5436 | } |
5437 | new_name = (xkb->names->geometry != geom->name); |
5438 | xkb->names->geometry = geom->name; |
5439 | if (old) |
5440 | XkbFreeGeometrySrvXkbFreeGeometry(old, XkbGeomAllMask(0x3f), TRUE1); |
5441 | if (new_name) { |
5442 | xkbNamesNotify nn; |
5443 | |
5444 | memset(&nn, 0, sizeof(xkbNamesNotify))__builtin___memset_chk (&nn, 0, sizeof(xkbNamesNotify), __builtin_object_size (&nn, 0)); |
5445 | nn.changed = XkbGeometryNameMask(1<<1); |
5446 | XkbSendNamesNotify(dev, &nn); |
5447 | } |
5448 | nkn.deviceID = nkn.oldDeviceID = dev->id; |
5449 | nkn.minKeyCode = nkn.oldMinKeyCode = xkb->min_key_code; |
5450 | nkn.maxKeyCode = nkn.oldMaxKeyCode = xkb->max_key_code; |
5451 | nkn.requestMajor = XkbReqCode; |
5452 | nkn.requestMinor = X_kbSetGeometry20; |
5453 | nkn.changed = XkbNKN_GeometryMask(1L << 1); |
5454 | XkbSendNewKeyboardNotify(dev, &nkn); |
5455 | return Success0; |
5456 | } |
5457 | |
5458 | int |
5459 | ProcXkbSetGeometry(ClientPtr client) |
5460 | { |
5461 | DeviceIntPtr dev; |
5462 | int rc; |
5463 | |
5464 | REQUEST(xkbSetGeometryReq)xkbSetGeometryReq *stuff = (xkbSetGeometryReq *)client->requestBuffer; |
5465 | REQUEST_AT_LEAST_SIZE(xkbSetGeometryReq)if ((sizeof(xkbSetGeometryReq) >> 2) > client->req_len ) return(16); |
5466 | |
5467 | if (!(client->xkbClientFlags & _XkbClientInitialized(1<<15))) |
5468 | return BadAccess10; |
5469 | |
5470 | CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixManageAccess){ int why; int tmprc = _XkbLookupKeyboard(&(dev), stuff-> deviceSpec, client, (1<<25), &why); if (tmprc != 0) { client->errorValue = ((XID)((((unsigned int)(why))<< 24)|((stuff->deviceSpec)&0xffffff))); return tmprc; }}; |
5471 | CHK_ATOM_OR_NONE(stuff->name){ if (((stuff->name)!=0L)&&(!ValidAtom((stuff-> name)))) { (client->errorValue)= (XID)(stuff->name); return 5; }}; |
5472 | |
5473 | rc = _XkbSetGeometry(client, dev, stuff); |
5474 | if (rc != Success0) |
5475 | return rc; |
5476 | |
5477 | if (stuff->deviceSpec == XkbUseCoreKbd0x0100) { |
5478 | DeviceIntPtr other; |
5479 | |
5480 | for (other = inputInfo.devices; other; other = other->next) { |
5481 | if ((other != dev) && other->key && !IsMaster(other) && |
5482 | GetMaster(other, MASTER_KEYBOARD2) == dev) { |
5483 | rc = XaceHook(XACE_DEVICE_ACCESS3, client, other, |
5484 | DixManageAccess(1<<25)); |
5485 | if (rc == Success0) |
5486 | _XkbSetGeometry(client, other, stuff); |
5487 | } |
5488 | } |
5489 | } |
5490 | |
5491 | return Success0; |
5492 | } |
5493 | |
5494 | /***====================================================================***/ |
5495 | |
5496 | int |
5497 | ProcXkbPerClientFlags(ClientPtr client) |
5498 | { |
5499 | DeviceIntPtr dev; |
5500 | xkbPerClientFlagsReply rep; |
5501 | XkbInterestPtr interest; |
5502 | Mask access_mode = DixGetAttrAccess(1<<4) | DixSetAttrAccess(1<<5); |
5503 | |
5504 | REQUEST(xkbPerClientFlagsReq)xkbPerClientFlagsReq *stuff = (xkbPerClientFlagsReq *)client-> requestBuffer; |
5505 | REQUEST_SIZE_MATCH(xkbPerClientFlagsReq)if ((sizeof(xkbPerClientFlagsReq) >> 2) != client->req_len ) return(16); |
5506 | |
5507 | if (!(client->xkbClientFlags & _XkbClientInitialized(1<<15))) |
5508 | return BadAccess10; |
5509 | |
5510 | CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, access_mode){ int why; int tmprc = _XkbLookupKeyboard(&(dev), stuff-> deviceSpec, client, access_mode, &why); if (tmprc != 0) { client->errorValue = ((XID)((((unsigned int)(why))<< 24)|((stuff->deviceSpec)&0xffffff))); return tmprc; }}; |
5511 | CHK_MASK_LEGAL(0x01, stuff->change, XkbPCF_AllFlagsMask){ if ((stuff->change)&(~((0x1F)))) { (client->errorValue )= ((XID)((((unsigned int)((0x01)))<<24)|((((stuff-> change)&(~((0x1F)))))&0xffffff))); return 2; }}; |
5512 | CHK_MASK_MATCH(0x02, stuff->change, stuff->value){ if ((stuff->value)&(~(stuff->change))) { client-> errorValue= ((XID)((((unsigned int)((0x02)))<<24)|((((stuff ->value)&(~(stuff->change))))&0xffffff))); return 8; }}; |
5513 | |
5514 | interest = XkbFindClientResource((DevicePtr) dev, client); |
5515 | if (stuff->change) { |
5516 | client->xkbClientFlags &= ~stuff->change; |
5517 | client->xkbClientFlags |= stuff->value; |
5518 | } |
5519 | if (stuff->change & XkbPCF_AutoResetControlsMask(1L << 2)) { |
5520 | Bool want; |
5521 | |
5522 | want = stuff->value & XkbPCF_AutoResetControlsMask(1L << 2); |
5523 | if (interest && !want) { |
5524 | interest->autoCtrls = interest->autoCtrlValues = 0; |
5525 | } |
5526 | else if (want && (!interest)) { |
5527 | XID id = FakeClientID(client->index); |
5528 | |
5529 | if (!AddResourceDarwin_X_AddResource(id, RT_XKBCLIENT, dev)) |
5530 | return BadAlloc11; |
5531 | interest = XkbAddClientResource((DevicePtr) dev, client, id); |
5532 | if (!interest) |
5533 | return BadAlloc11; |
5534 | } |
5535 | if (interest && want) { |
5536 | register unsigned affect; |
5537 | |
5538 | affect = stuff->ctrlsToChange; |
5539 | |
5540 | CHK_MASK_LEGAL(0x03, affect, XkbAllBooleanCtrlsMask){ if ((affect)&(~((0x00001FFF)))) { (client->errorValue )= ((XID)((((unsigned int)((0x03)))<<24)|((((affect)& (~((0x00001FFF)))))&0xffffff))); return 2; }}; |
5541 | CHK_MASK_MATCH(0x04, affect, stuff->autoCtrls){ if ((stuff->autoCtrls)&(~(affect))) { client->errorValue = ((XID)((((unsigned int)((0x04)))<<24)|((((stuff->autoCtrls )&(~(affect))))&0xffffff))); return 8; }}; |
5542 | CHK_MASK_MATCH(0x05, stuff->autoCtrls, stuff->autoCtrlValues){ if ((stuff->autoCtrlValues)&(~(stuff->autoCtrls)) ) { client->errorValue= ((XID)((((unsigned int)((0x05)))<< 24)|((((stuff->autoCtrlValues)&(~(stuff->autoCtrls) )))&0xffffff))); return 8; }}; |
5543 | |
5544 | interest->autoCtrls &= ~affect; |
5545 | interest->autoCtrlValues &= ~affect; |
5546 | interest->autoCtrls |= stuff->autoCtrls & affect; |
5547 | interest->autoCtrlValues |= stuff->autoCtrlValues & affect; |
5548 | } |
5549 | } |
5550 | |
5551 | rep = (xkbPerClientFlagsReply) { |
5552 | .type = X_Reply1, |
5553 | .sequenceNumber = client->sequence, |
5554 | .length = 0, |
5555 | .supported = XkbPCF_AllFlagsMask(0x1F), |
5556 | .value = client->xkbClientFlags & XkbPCF_AllFlagsMask(0x1F), |
5557 | .autoCtrls = interest ? interest->autoCtrls : 0, |
5558 | .autoCtrlValues = interest ? interest->autoCtrlValues : 0, |
5559 | }; |
5560 | if (client->swapped) { |
5561 | swaps(&rep.sequenceNumber)do { if (sizeof(*(&rep.sequenceNumber)) != 2) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&rep.sequenceNumber ) & 1) && ((uintptr_t)(&rep.sequenceNumber) & 1) == 0) *(&rep.sequenceNumber) = lswaps(*(&rep.sequenceNumber )); else swap_uint16((uint16_t *)(&rep.sequenceNumber)); } while (0); |
5562 | swapl(&rep.supported)do { if (sizeof(*(&rep.supported)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&rep.supported) & 3 ) && ((uintptr_t)(&rep.supported) & 3) == 0) * (&rep.supported) = lswapl(*(&rep.supported)); else swap_uint32 ((uint32_t *)(&rep.supported)); } while (0); |
5563 | swapl(&rep.value)do { if (sizeof(*(&rep.value)) != 4) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&rep.value) & 3) && ((uintptr_t) (&rep.value) & 3) == 0) *(&rep.value) = lswapl(*( &rep.value)); else swap_uint32((uint32_t *)(&rep.value )); } while (0); |
5564 | swapl(&rep.autoCtrls)do { if (sizeof(*(&rep.autoCtrls)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&rep.autoCtrls) & 3 ) && ((uintptr_t)(&rep.autoCtrls) & 3) == 0) * (&rep.autoCtrls) = lswapl(*(&rep.autoCtrls)); else swap_uint32 ((uint32_t *)(&rep.autoCtrls)); } while (0); |
5565 | swapl(&rep.autoCtrlValues)do { if (sizeof(*(&rep.autoCtrlValues)) != 4) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&rep.autoCtrlValues ) & 3) && ((uintptr_t)(&rep.autoCtrlValues) & 3) == 0) *(&rep.autoCtrlValues) = lswapl(*(&rep.autoCtrlValues )); else swap_uint32((uint32_t *)(&rep.autoCtrlValues)); } while (0); |
5566 | } |
5567 | WriteToClient(client, SIZEOF(xkbPerClientFlagsReply)32, &rep); |
5568 | return Success0; |
5569 | } |
5570 | |
5571 | /***====================================================================***/ |
5572 | |
5573 | /* all latin-1 alphanumerics, plus parens, minus, underscore, slash */ |
5574 | /* and wildcards */ |
5575 | static unsigned char componentSpecLegal[] = { |
5576 | 0x00, 0x00, 0x00, 0x00, 0x00, 0xa7, 0xff, 0x87, |
5577 | 0xfe, 0xff, 0xff, 0x87, 0xfe, 0xff, 0xff, 0x07, |
5578 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
5579 | 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0x7f, 0xff |
5580 | }; |
5581 | |
5582 | /* same as above but accepts percent, plus and bar too */ |
5583 | static unsigned char componentExprLegal[] = { |
5584 | 0x00, 0x00, 0x00, 0x00, 0x20, 0xaf, 0xff, 0x87, |
5585 | 0xfe, 0xff, 0xff, 0x87, 0xfe, 0xff, 0xff, 0x17, |
5586 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
5587 | 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0x7f, 0xff |
5588 | }; |
5589 | |
5590 | static char * |
5591 | GetComponentSpec(unsigned char **pWire, Bool allowExpr, int *errRtrn) |
5592 | { |
5593 | int len; |
5594 | register int i; |
5595 | unsigned char *wire, *str, *tmp, *legal; |
5596 | |
5597 | if (allowExpr) |
5598 | legal = &componentExprLegal[0]; |
5599 | else |
5600 | legal = &componentSpecLegal[0]; |
5601 | |
5602 | wire = *pWire; |
5603 | len = (*(unsigned char *) wire++); |
5604 | if (len > 0) { |
5605 | str = calloc(1, len + 1); |
5606 | if (str) { |
5607 | tmp = str; |
5608 | for (i = 0; i < len; i++) { |
5609 | if (legal[(*wire) / 8] & (1 << ((*wire) % 8))) |
5610 | *tmp++ = *wire++; |
5611 | else |
5612 | wire++; |
5613 | } |
5614 | if (tmp != str) |
5615 | *tmp++ = '\0'; |
5616 | else { |
5617 | free(str); |
5618 | str = NULL((void*)0); |
5619 | } |
5620 | } |
5621 | else { |
5622 | *errRtrn = BadAlloc11; |
5623 | } |
5624 | } |
5625 | else { |
5626 | str = NULL((void*)0); |
5627 | } |
5628 | *pWire = wire; |
5629 | return (char *) str; |
5630 | } |
5631 | |
5632 | /***====================================================================***/ |
5633 | |
5634 | int |
5635 | ProcXkbListComponents(ClientPtr client) |
5636 | { |
5637 | DeviceIntPtr dev; |
5638 | xkbListComponentsReply rep; |
5639 | unsigned len; |
5640 | unsigned char *str; |
5641 | uint8_t size; |
5642 | int i; |
5643 | |
5644 | REQUEST(xkbListComponentsReq)xkbListComponentsReq *stuff = (xkbListComponentsReq *)client-> requestBuffer; |
5645 | REQUEST_AT_LEAST_SIZE(xkbListComponentsReq)if ((sizeof(xkbListComponentsReq) >> 2) > client-> req_len ) return(16); |
5646 | |
5647 | if (!(client->xkbClientFlags & _XkbClientInitialized(1<<15))) |
5648 | return BadAccess10; |
5649 | |
5650 | CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixGetAttrAccess){ int why; int tmprc = _XkbLookupKeyboard(&(dev), stuff-> deviceSpec, client, (1<<4), &why); if (tmprc != 0) { client->errorValue = ((XID)((((unsigned int)(why))<< 24)|((stuff->deviceSpec)&0xffffff))); return tmprc; }}; |
5651 | |
5652 | /* The request is followed by six Pascal strings (i.e. size in characters |
5653 | * followed by a string pattern) describing what the client wants us to |
5654 | * list. We don't care, but might as well check they haven't got the |
5655 | * length wrong. */ |
5656 | str = (unsigned char *) &stuff[1]; |
5657 | for (i = 0; i < 6; i++) { |
5658 | size = *((uint8_t *)str); |
5659 | len = (str + size + 1) - ((unsigned char *) stuff); |
5660 | if ((XkbPaddedSize(len)((((unsigned int)(len)+3) >> 2) << 2) / 4) > stuff->length) |
5661 | return BadLength16; |
5662 | str += (size + 1); |
5663 | } |
5664 | if ((XkbPaddedSize(len)((((unsigned int)(len)+3) >> 2) << 2) / 4) != stuff->length) |
5665 | return BadLength16; |
5666 | rep = (xkbListComponentsReply) { |
5667 | .type = X_Reply1, |
5668 | .deviceID = dev->id, |
5669 | .sequenceNumber = client->sequence, |
5670 | .length = 0, |
5671 | .nKeymaps = 0, |
5672 | .nKeycodes = 0, |
5673 | .nTypes = 0, |
5674 | .nCompatMaps = 0, |
5675 | .nSymbols = 0, |
5676 | .nGeometries = 0, |
5677 | .extra = 0 |
5678 | }; |
5679 | if (client->swapped) { |
5680 | swaps(&rep.sequenceNumber)do { if (sizeof(*(&rep.sequenceNumber)) != 2) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&rep.sequenceNumber ) & 1) && ((uintptr_t)(&rep.sequenceNumber) & 1) == 0) *(&rep.sequenceNumber) = lswaps(*(&rep.sequenceNumber )); else swap_uint16((uint16_t *)(&rep.sequenceNumber)); } while (0); |
5681 | swapl(&rep.length)do { if (sizeof(*(&rep.length)) != 4) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&rep.length) & 3) && ((uintptr_t )(&rep.length) & 3) == 0) *(&rep.length) = lswapl (*(&rep.length)); else swap_uint32((uint32_t *)(&rep. length)); } while (0); |
5682 | swaps(&rep.nKeymaps)do { if (sizeof(*(&rep.nKeymaps)) != 2) wrong_size(); if ( __builtin_constant_p((uintptr_t)(&rep.nKeymaps) & 1) && ((uintptr_t)(&rep.nKeymaps) & 1) == 0) *(&rep.nKeymaps ) = lswaps(*(&rep.nKeymaps)); else swap_uint16((uint16_t * )(&rep.nKeymaps)); } while (0); |
5683 | swaps(&rep.nKeycodes)do { if (sizeof(*(&rep.nKeycodes)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&rep.nKeycodes) & 1 ) && ((uintptr_t)(&rep.nKeycodes) & 1) == 0) * (&rep.nKeycodes) = lswaps(*(&rep.nKeycodes)); else swap_uint16 ((uint16_t *)(&rep.nKeycodes)); } while (0); |
5684 | swaps(&rep.nTypes)do { if (sizeof(*(&rep.nTypes)) != 2) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&rep.nTypes) & 1) && ((uintptr_t )(&rep.nTypes) & 1) == 0) *(&rep.nTypes) = lswaps (*(&rep.nTypes)); else swap_uint16((uint16_t *)(&rep. nTypes)); } while (0); |
5685 | swaps(&rep.nCompatMaps)do { if (sizeof(*(&rep.nCompatMaps)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&rep.nCompatMaps) & 1) && ((uintptr_t)(&rep.nCompatMaps) & 1) == 0) *(&rep.nCompatMaps) = lswaps(*(&rep.nCompatMaps)) ; else swap_uint16((uint16_t *)(&rep.nCompatMaps)); } while (0); |
5686 | swaps(&rep.nSymbols)do { if (sizeof(*(&rep.nSymbols)) != 2) wrong_size(); if ( __builtin_constant_p((uintptr_t)(&rep.nSymbols) & 1) && ((uintptr_t)(&rep.nSymbols) & 1) == 0) *(&rep.nSymbols ) = lswaps(*(&rep.nSymbols)); else swap_uint16((uint16_t * )(&rep.nSymbols)); } while (0); |
5687 | swaps(&rep.nGeometries)do { if (sizeof(*(&rep.nGeometries)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&rep.nGeometries) & 1) && ((uintptr_t)(&rep.nGeometries) & 1) == 0) *(&rep.nGeometries) = lswaps(*(&rep.nGeometries)) ; else swap_uint16((uint16_t *)(&rep.nGeometries)); } while (0); |
5688 | swaps(&rep.extra)do { if (sizeof(*(&rep.extra)) != 2) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&rep.extra) & 1) && ((uintptr_t) (&rep.extra) & 1) == 0) *(&rep.extra) = lswaps(*( &rep.extra)); else swap_uint16((uint16_t *)(&rep.extra )); } while (0); |
5689 | } |
5690 | WriteToClient(client, SIZEOF(xkbListComponentsReply)32, &rep); |
5691 | return Success0; |
5692 | } |
5693 | |
5694 | /***====================================================================***/ |
5695 | |
5696 | int |
5697 | ProcXkbGetKbdByName(ClientPtr client) |
5698 | { |
5699 | DeviceIntPtr dev; |
5700 | DeviceIntPtr tmpd; |
5701 | DeviceIntPtr master; |
5702 | xkbGetKbdByNameReply rep = { 0 }; |
5703 | xkbGetMapReply mrep = { 0 }; |
5704 | xkbGetCompatMapReply crep = { 0 }; |
5705 | xkbGetIndicatorMapReply irep = { 0 }; |
5706 | xkbGetNamesReply nrep = { 0 }; |
5707 | xkbGetGeometryReply grep = { 0 }; |
5708 | XkbComponentNamesRec names = { 0 }; |
5709 | XkbDescPtr xkb, new; |
5710 | unsigned char *str; |
5711 | char mapFile[PATH_MAX1024]; |
5712 | unsigned len; |
5713 | unsigned fwant, fneed, reported; |
5714 | int status; |
5715 | Bool geom_changed; |
5716 | XkbSrvLedInfoPtr old_sli; |
5717 | XkbSrvLedInfoPtr sli; |
5718 | Mask access_mode = DixGetAttrAccess(1<<4) | DixManageAccess(1<<25); |
5719 | |
5720 | REQUEST(xkbGetKbdByNameReq)xkbGetKbdByNameReq *stuff = (xkbGetKbdByNameReq *)client-> requestBuffer; |
5721 | REQUEST_AT_LEAST_SIZE(xkbGetKbdByNameReq)if ((sizeof(xkbGetKbdByNameReq) >> 2) > client->req_len ) return(16); |
5722 | |
5723 | if (!(client->xkbClientFlags & _XkbClientInitialized(1<<15))) |
5724 | return BadAccess10; |
5725 | |
5726 | CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, access_mode){ int why; int tmprc = _XkbLookupKeyboard(&(dev), stuff-> deviceSpec, client, access_mode, &why); if (tmprc != 0) { client->errorValue = ((XID)((((unsigned int)(why))<< 24)|((stuff->deviceSpec)&0xffffff))); return tmprc; }}; |
5727 | master = GetMaster(dev, MASTER_KEYBOARD2); |
5728 | |
5729 | xkb = dev->key->xkbInfo->desc; |
5730 | status = Success0; |
5731 | str = (unsigned char *) &stuff[1]; |
5732 | if (GetComponentSpec(&str, TRUE1, &status)) /* keymap, unsupported */ |
5733 | return BadMatch8; |
5734 | names.keycodes = GetComponentSpec(&str, TRUE1, &status); |
5735 | names.types = GetComponentSpec(&str, TRUE1, &status); |
5736 | names.compat = GetComponentSpec(&str, TRUE1, &status); |
5737 | names.symbols = GetComponentSpec(&str, TRUE1, &status); |
5738 | names.geometry = GetComponentSpec(&str, TRUE1, &status); |
5739 | if (status != Success0) |
5740 | return status; |
5741 | len = str - ((unsigned char *) stuff); |
5742 | if ((XkbPaddedSize(len)((((unsigned int)(len)+3) >> 2) << 2) / 4) != stuff->length) |
5743 | return BadLength16; |
5744 | |
5745 | CHK_MASK_LEGAL(0x01, stuff->want, XkbGBN_AllComponentsMask){ if ((stuff->want)&(~((0xff)))) { (client->errorValue )= ((XID)((((unsigned int)((0x01)))<<24)|((((stuff-> want)&(~((0xff)))))&0xffffff))); return 2; }}; |
5746 | CHK_MASK_LEGAL(0x02, stuff->need, XkbGBN_AllComponentsMask){ if ((stuff->need)&(~((0xff)))) { (client->errorValue )= ((XID)((((unsigned int)((0x02)))<<24)|((((stuff-> need)&(~((0xff)))))&0xffffff))); return 2; }}; |
5747 | |
5748 | if (stuff->load) |
5749 | fwant = XkbGBN_AllComponentsMask(0xff); |
5750 | else |
5751 | fwant = stuff->want | stuff->need; |
5752 | if ((!names.compat) && |
5753 | (fwant & (XkbGBN_CompatMapMask(1L << 1) | XkbGBN_IndicatorMapMask(1L << 4)))) { |
5754 | names.compat = Xstrdup("%"); |
5755 | } |
5756 | if ((!names.types) && (fwant & (XkbGBN_TypesMask(1L << 0)))) { |
5757 | names.types = Xstrdup("%"); |
5758 | } |
5759 | if ((!names.symbols) && (fwant & XkbGBN_SymbolsMask((1L << 2)|(1L << 3)))) { |
5760 | names.symbols = Xstrdup("%"); |
5761 | } |
5762 | geom_changed = ((names.geometry != NULL((void*)0)) && |
5763 | (strcmp(names.geometry, "%") != 0)); |
5764 | if ((!names.geometry) && (fwant & XkbGBN_GeometryMask(1L << 6))) { |
5765 | names.geometry = Xstrdup("%"); |
5766 | geom_changed = FALSE0; |
5767 | } |
5768 | |
5769 | memset(mapFile, 0, PATH_MAX)__builtin___memset_chk (mapFile, 0, 1024, __builtin_object_size (mapFile, 0)); |
5770 | rep.type = X_Reply1; |
5771 | rep.deviceID = dev->id; |
5772 | rep.sequenceNumber = client->sequence; |
5773 | rep.length = 0; |
5774 | rep.minKeyCode = xkb->min_key_code; |
5775 | rep.maxKeyCode = xkb->max_key_code; |
5776 | rep.loaded = FALSE0; |
5777 | fwant = |
5778 | XkbConvertGetByNameComponents(TRUE1, stuff->want) | XkmVirtualModsMask(1<<6); |
5779 | fneed = XkbConvertGetByNameComponents(TRUE1, stuff->need); |
5780 | rep.reported = XkbConvertGetByNameComponents(FALSE0, fwant | fneed); |
5781 | if (stuff->load) { |
5782 | fneed |= XkmKeymapRequired(((1<<1))|((1<<4)|(1<<2)|(1<<0))); |
5783 | fwant |= XkmKeymapLegal((((1<<1))|((1<<4)|(1<<2)|(1<<0)))|(( ((1<<0)|(1<<6)|(1<<3))|((1<<6)|(1<< 5)))&(~(((1<<1))|((1<<4)|(1<<2)|(1<< 0)))))); |
5784 | } |
5785 | if ((fwant | fneed) & XkmSymbolsMask(1<<2)) { |
5786 | fneed |= XkmKeyNamesIndex4 | XkmTypesIndex0; |
5787 | fwant |= XkmIndicatorsIndex3; |
5788 | } |
5789 | |
5790 | /* We pass dev in here so we can get the old names out if needed. */ |
5791 | rep.found = XkbDDXLoadKeymapByNames(dev, &names, fwant, fneed, &new, |
5792 | mapFile, PATH_MAX1024); |
5793 | rep.newKeyboard = FALSE0; |
5794 | rep.pad1 = rep.pad2 = rep.pad3 = rep.pad4 = 0; |
5795 | |
5796 | stuff->want |= stuff->need; |
5797 | if (new == NULL((void*)0)) |
5798 | rep.reported = 0; |
5799 | else { |
5800 | if (stuff->load) |
5801 | rep.loaded = TRUE1; |
5802 | if (stuff->load || |
5803 | ((rep.reported & XkbGBN_SymbolsMask((1L << 2)|(1L << 3))) && (new->compat))) { |
5804 | XkbChangesRec changes; |
5805 | |
5806 | memset(&changes, 0, sizeof(changes))__builtin___memset_chk (&changes, 0, sizeof(changes), __builtin_object_size (&changes, 0)); |
5807 | XkbUpdateDescActions(new, |
5808 | new->min_key_code, XkbNumKeys(new)((new)->max_key_code-(new)->min_key_code+1), &changes); |
5809 | } |
5810 | |
5811 | if (new->map == NULL((void*)0)) |
5812 | rep.reported &= ~(XkbGBN_SymbolsMask((1L << 2)|(1L << 3)) | XkbGBN_TypesMask(1L << 0)); |
5813 | else if (rep.reported & (XkbGBN_SymbolsMask((1L << 2)|(1L << 3)) | XkbGBN_TypesMask(1L << 0))) { |
5814 | mrep.type = X_Reply1; |
5815 | mrep.deviceID = dev->id; |
5816 | mrep.sequenceNumber = client->sequence; |
5817 | mrep.length = |
5818 | ((SIZEOF(xkbGetMapReply)40 - SIZEOF(xGenericReply)32) >> 2); |
5819 | mrep.minKeyCode = new->min_key_code; |
5820 | mrep.maxKeyCode = new->max_key_code; |
5821 | mrep.present = 0; |
5822 | mrep.totalSyms = mrep.totalActs = |
5823 | mrep.totalKeyBehaviors = mrep.totalKeyExplicit = |
5824 | mrep.totalModMapKeys = mrep.totalVModMapKeys = 0; |
5825 | if (rep.reported & (XkbGBN_TypesMask(1L << 0) | XkbGBN_ClientSymbolsMask(1L << 2))) { |
5826 | mrep.present |= XkbKeyTypesMask(1<<0); |
5827 | mrep.firstType = 0; |
5828 | mrep.nTypes = mrep.totalTypes = new->map->num_types; |
5829 | } |
5830 | else { |
5831 | mrep.firstType = mrep.nTypes = 0; |
5832 | mrep.totalTypes = 0; |
5833 | } |
5834 | if (rep.reported & XkbGBN_ClientSymbolsMask(1L << 2)) { |
5835 | mrep.present |= (XkbKeySymsMask(1<<1) | XkbModifierMapMask(1<<2)); |
5836 | mrep.firstKeySym = mrep.firstModMapKey = new->min_key_code; |
5837 | mrep.nKeySyms = mrep.nModMapKeys = XkbNumKeys(new)((new)->max_key_code-(new)->min_key_code+1); |
5838 | } |
5839 | else { |
5840 | mrep.firstKeySym = mrep.firstModMapKey = 0; |
5841 | mrep.nKeySyms = mrep.nModMapKeys = 0; |
5842 | } |
5843 | if (rep.reported & XkbGBN_ServerSymbolsMask(1L << 3)) { |
5844 | mrep.present |= XkbAllServerInfoMask((1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<< 7)); |
5845 | mrep.virtualMods = ~0; |
5846 | mrep.firstKeyAct = mrep.firstKeyBehavior = |
5847 | mrep.firstKeyExplicit = new->min_key_code; |
5848 | mrep.nKeyActs = mrep.nKeyBehaviors = |
5849 | mrep.nKeyExplicit = XkbNumKeys(new)((new)->max_key_code-(new)->min_key_code+1); |
5850 | mrep.firstVModMapKey = new->min_key_code; |
5851 | mrep.nVModMapKeys = XkbNumKeys(new)((new)->max_key_code-(new)->min_key_code+1); |
5852 | } |
5853 | else { |
5854 | mrep.virtualMods = 0; |
5855 | mrep.firstKeyAct = mrep.firstKeyBehavior = |
5856 | mrep.firstKeyExplicit = 0; |
5857 | mrep.nKeyActs = mrep.nKeyBehaviors = mrep.nKeyExplicit = 0; |
5858 | } |
5859 | XkbComputeGetMapReplySize(new, &mrep); |
5860 | rep.length += SIZEOF(xGenericReply)32 / 4 + mrep.length; |
5861 | } |
5862 | if (new->compat == NULL((void*)0)) |
5863 | rep.reported &= ~XkbGBN_CompatMapMask(1L << 1); |
5864 | else if (rep.reported & XkbGBN_CompatMapMask(1L << 1)) { |
5865 | crep.type = X_Reply1; |
5866 | crep.deviceID = dev->id; |
5867 | crep.sequenceNumber = client->sequence; |
5868 | crep.length = 0; |
5869 | crep.groups = XkbAllGroupsMask(0xf); |
5870 | crep.firstSI = 0; |
5871 | crep.nSI = crep.nTotalSI = new->compat->num_si; |
5872 | XkbComputeGetCompatMapReplySize(new->compat, &crep); |
5873 | rep.length += SIZEOF(xGenericReply)32 / 4 + crep.length; |
5874 | } |
5875 | if (new->indicators == NULL((void*)0)) |
5876 | rep.reported &= ~XkbGBN_IndicatorMapMask(1L << 4); |
5877 | else if (rep.reported & XkbGBN_IndicatorMapMask(1L << 4)) { |
5878 | irep.type = X_Reply1; |
5879 | irep.deviceID = dev->id; |
5880 | irep.sequenceNumber = client->sequence; |
5881 | irep.length = 0; |
5882 | irep.which = XkbAllIndicatorsMask(0xffffffff); |
5883 | XkbComputeGetIndicatorMapReplySize(new->indicators, &irep); |
5884 | rep.length += SIZEOF(xGenericReply)32 / 4 + irep.length; |
5885 | } |
5886 | if (new->names == NULL((void*)0)) |
5887 | rep.reported &= ~(XkbGBN_OtherNamesMask(1L << 7) | XkbGBN_KeyNamesMask(1L << 5)); |
5888 | else if (rep.reported & (XkbGBN_OtherNamesMask(1L << 7) | XkbGBN_KeyNamesMask(1L << 5))) { |
5889 | nrep.type = X_Reply1; |
5890 | nrep.deviceID = dev->id; |
5891 | nrep.sequenceNumber = client->sequence; |
5892 | nrep.length = 0; |
5893 | nrep.minKeyCode = new->min_key_code; |
5894 | nrep.maxKeyCode = new->max_key_code; |
5895 | if (rep.reported & XkbGBN_OtherNamesMask(1L << 7)) { |
5896 | nrep.which = XkbAllNamesMask(0x3fff); |
5897 | if (new->map != NULL((void*)0)) |
5898 | nrep.nTypes = new->map->num_types; |
5899 | else |
5900 | nrep.nTypes = 0; |
5901 | nrep.nKTLevels = 0; |
5902 | nrep.groupNames = XkbAllGroupsMask(0xf); |
5903 | nrep.virtualMods = XkbAllVirtualModsMask0xffff; |
5904 | nrep.indicators = XkbAllIndicatorsMask(0xffffffff); |
5905 | nrep.nRadioGroups = new->names->num_rg; |
5906 | } |
5907 | else { |
5908 | nrep.which = 0; |
5909 | nrep.nTypes = 0; |
5910 | nrep.nKTLevels = 0; |
5911 | nrep.groupNames = 0; |
5912 | nrep.virtualMods = 0; |
5913 | nrep.indicators = 0; |
5914 | nrep.nRadioGroups = 0; |
5915 | } |
5916 | if (rep.reported & XkbGBN_KeyNamesMask(1L << 5)) { |
5917 | nrep.which |= XkbKeyNamesMask(1<<9); |
5918 | nrep.firstKey = new->min_key_code; |
5919 | nrep.nKeys = XkbNumKeys(new)((new)->max_key_code-(new)->min_key_code+1); |
5920 | nrep.nKeyAliases = new->names->num_key_aliases; |
5921 | if (nrep.nKeyAliases) |
5922 | nrep.which |= XkbKeyAliasesMask(1<<10); |
5923 | } |
5924 | else { |
5925 | nrep.which &= ~(XkbKeyNamesMask(1<<9) | XkbKeyAliasesMask(1<<10)); |
5926 | nrep.firstKey = nrep.nKeys = 0; |
5927 | nrep.nKeyAliases = 0; |
5928 | } |
5929 | XkbComputeGetNamesReplySize(new, &nrep); |
5930 | rep.length += SIZEOF(xGenericReply)32 / 4 + nrep.length; |
5931 | } |
5932 | if (new->geom == NULL((void*)0)) |
5933 | rep.reported &= ~XkbGBN_GeometryMask(1L << 6); |
5934 | else if (rep.reported & XkbGBN_GeometryMask(1L << 6)) { |
5935 | grep.type = X_Reply1; |
5936 | grep.deviceID = dev->id; |
5937 | grep.sequenceNumber = client->sequence; |
5938 | grep.length = 0; |
5939 | grep.found = TRUE1; |
5940 | grep.pad = 0; |
5941 | grep.widthMM = grep.heightMM = 0; |
5942 | grep.nProperties = grep.nColors = grep.nShapes = 0; |
5943 | grep.nSections = grep.nDoodads = 0; |
5944 | grep.baseColorNdx = grep.labelColorNdx = 0; |
5945 | XkbComputeGetGeometryReplySize(new->geom, &grep, None0L); |
5946 | rep.length += SIZEOF(xGenericReply)32 / 4 + grep.length; |
5947 | } |
5948 | } |
5949 | |
5950 | reported = rep.reported; |
5951 | if (client->swapped) { |
5952 | swaps(&rep.sequenceNumber)do { if (sizeof(*(&rep.sequenceNumber)) != 2) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&rep.sequenceNumber ) & 1) && ((uintptr_t)(&rep.sequenceNumber) & 1) == 0) *(&rep.sequenceNumber) = lswaps(*(&rep.sequenceNumber )); else swap_uint16((uint16_t *)(&rep.sequenceNumber)); } while (0); |
5953 | swapl(&rep.length)do { if (sizeof(*(&rep.length)) != 4) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&rep.length) & 3) && ((uintptr_t )(&rep.length) & 3) == 0) *(&rep.length) = lswapl (*(&rep.length)); else swap_uint32((uint32_t *)(&rep. length)); } while (0); |
5954 | swaps(&rep.found)do { if (sizeof(*(&rep.found)) != 2) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&rep.found) & 1) && ((uintptr_t) (&rep.found) & 1) == 0) *(&rep.found) = lswaps(*( &rep.found)); else swap_uint16((uint16_t *)(&rep.found )); } while (0); |
5955 | swaps(&rep.reported)do { if (sizeof(*(&rep.reported)) != 2) wrong_size(); if ( __builtin_constant_p((uintptr_t)(&rep.reported) & 1) && ((uintptr_t)(&rep.reported) & 1) == 0) *(&rep.reported ) = lswaps(*(&rep.reported)); else swap_uint16((uint16_t * )(&rep.reported)); } while (0); |
5956 | } |
5957 | WriteToClient(client, SIZEOF(xkbGetKbdByNameReply)32, &rep); |
5958 | if (reported & (XkbGBN_SymbolsMask((1L << 2)|(1L << 3)) | XkbGBN_TypesMask(1L << 0))) |
5959 | XkbSendMap(client, new, &mrep); |
5960 | if (reported & XkbGBN_CompatMapMask(1L << 1)) |
5961 | XkbSendCompatMap(client, new->compat, &crep); |
5962 | if (reported & XkbGBN_IndicatorMapMask(1L << 4)) |
5963 | XkbSendIndicatorMap(client, new->indicators, &irep); |
5964 | if (reported & (XkbGBN_KeyNamesMask(1L << 5) | XkbGBN_OtherNamesMask(1L << 7))) |
5965 | XkbSendNames(client, new, &nrep); |
5966 | if (reported & XkbGBN_GeometryMask(1L << 6)) |
5967 | XkbSendGeometry(client, new->geom, &grep, FALSE0); |
5968 | if (rep.loaded) { |
5969 | XkbDescPtr old_xkb; |
5970 | xkbNewKeyboardNotify nkn; |
5971 | |
5972 | old_xkb = xkb; |
5973 | xkb = new; |
5974 | dev->key->xkbInfo->desc = xkb; |
5975 | new = old_xkb; /* so it'll get freed automatically */ |
5976 | |
5977 | XkbCopyControls(xkb, old_xkb); |
5978 | |
5979 | nkn.deviceID = nkn.oldDeviceID = dev->id; |
5980 | nkn.minKeyCode = new->min_key_code; |
5981 | nkn.maxKeyCode = new->max_key_code; |
5982 | nkn.oldMinKeyCode = xkb->min_key_code; |
5983 | nkn.oldMaxKeyCode = xkb->max_key_code; |
5984 | nkn.requestMajor = XkbReqCode; |
5985 | nkn.requestMinor = X_kbGetKbdByName23; |
5986 | nkn.changed = XkbNKN_KeycodesMask(1L << 0); |
5987 | if (geom_changed) |
5988 | nkn.changed |= XkbNKN_GeometryMask(1L << 1); |
5989 | XkbSendNewKeyboardNotify(dev, &nkn); |
5990 | |
5991 | /* Update the map and LED info on the device itself, as well as |
5992 | * any slaves if it's an MD, or its MD if it's an SD and was the |
5993 | * last device used on that MD. */ |
5994 | for (tmpd = inputInfo.devices; tmpd; tmpd = tmpd->next) { |
5995 | if (tmpd != dev && GetMaster(tmpd, MASTER_KEYBOARD2) != dev && |
5996 | (tmpd != master || dev != master->lastSlave)) |
5997 | continue; |
5998 | |
5999 | if (tmpd != dev) |
6000 | XkbDeviceApplyKeymap(tmpd, xkb); |
6001 | |
6002 | if (tmpd->kbdfeed && tmpd->kbdfeed->xkb_sli) { |
6003 | old_sli = tmpd->kbdfeed->xkb_sli; |
6004 | tmpd->kbdfeed->xkb_sli = NULL((void*)0); |
6005 | sli = XkbAllocSrvLedInfo(tmpd, tmpd->kbdfeed, NULL((void*)0), 0); |
6006 | if (sli) { |
6007 | sli->explicitState = old_sli->explicitState; |
6008 | sli->effectiveState = old_sli->effectiveState; |
6009 | } |
6010 | tmpd->kbdfeed->xkb_sli = sli; |
6011 | XkbFreeSrvLedInfo(old_sli); |
6012 | } |
6013 | } |
6014 | } |
6015 | if ((new != NULL((void*)0)) && (new != xkb)) { |
6016 | XkbFreeKeyboardSrvXkbFreeKeyboard(new, XkbAllComponentsMask(0x7f), TRUE1); |
6017 | new = NULL((void*)0); |
6018 | } |
6019 | XkbFreeComponentNames(&names, FALSE0); |
6020 | return Success0; |
6021 | } |
6022 | |
6023 | /***====================================================================***/ |
6024 | |
6025 | static int |
6026 | ComputeDeviceLedInfoSize(DeviceIntPtr dev, |
6027 | unsigned int what, XkbSrvLedInfoPtr sli) |
6028 | { |
6029 | int nNames, nMaps; |
6030 | register unsigned n, bit; |
6031 | |
6032 | if (sli == NULL((void*)0)) |
6033 | return 0; |
6034 | nNames = nMaps = 0; |
6035 | if ((what & XkbXI_IndicatorNamesMask(1L << 2)) == 0) |
6036 | sli->namesPresent = 0; |
6037 | if ((what & XkbXI_IndicatorMapsMask(1L << 3)) == 0) |
6038 | sli->mapsPresent = 0; |
6039 | |
6040 | for (n = 0, bit = 1; n < XkbNumIndicators32; n++, bit <<= 1) { |
6041 | if (sli->names && sli->names[n] != None0L) { |
6042 | sli->namesPresent |= bit; |
6043 | nNames++; |
6044 | } |
6045 | if (sli->maps && XkbIM_InUse(&sli->maps[n])((&sli->maps[n])->flags || (&sli->maps[n])-> which_groups || (&sli->maps[n])->which_mods || (& sli->maps[n])->ctrls)) { |
6046 | sli->mapsPresent |= bit; |
6047 | nMaps++; |
6048 | } |
6049 | } |
6050 | return (nNames * 4) + (nMaps * SIZEOF(xkbIndicatorMapWireDesc)12); |
6051 | } |
6052 | |
6053 | static int |
6054 | CheckDeviceLedFBs(DeviceIntPtr dev, |
6055 | int class, |
6056 | int id, xkbGetDeviceInfoReply * rep, ClientPtr client) |
6057 | { |
6058 | int nFBs = 0; |
6059 | int length = 0; |
6060 | Bool classOk; |
6061 | |
6062 | if (class == XkbDfltXIClass0x0300) { |
6063 | if (dev->kbdfeed) |
6064 | class = KbdFeedbackClass0; |
6065 | else if (dev->leds) |
6066 | class = LedFeedbackClass4; |
6067 | else { |
6068 | client->errorValue = _XkbErrCode2(XkbErr_BadClass, class)((XID)((((unsigned int)(0xfe))<<24)|((class)&0xffffff ))); |
6069 | return XkbKeyboardErrorCode; |
6070 | } |
6071 | } |
6072 | classOk = FALSE0; |
6073 | if ((dev->kbdfeed) && |
6074 | ((class == KbdFeedbackClass0) || (class == XkbAllXIClasses0x0500))) { |
6075 | KbdFeedbackPtr kf; |
6076 | |
6077 | classOk = TRUE1; |
6078 | for (kf = dev->kbdfeed; (kf); kf = kf->next) { |
6079 | if ((id != XkbAllXIIds0x0600) && (id != XkbDfltXIId0x0400) && |
6080 | (id != kf->ctrl.id)) |
6081 | continue; |
6082 | nFBs++; |
6083 | length += SIZEOF(xkbDeviceLedsWireDesc)20; |
6084 | if (!kf->xkb_sli) |
6085 | kf->xkb_sli = XkbAllocSrvLedInfo(dev, kf, NULL((void*)0), 0); |
6086 | length += ComputeDeviceLedInfoSize(dev, rep->present, kf->xkb_sli); |
6087 | if (id != XkbAllXIIds0x0600) |
6088 | break; |
6089 | } |
6090 | } |
6091 | if ((dev->leds) && |
6092 | ((class == LedFeedbackClass4) || (class == XkbAllXIClasses0x0500))) { |
6093 | LedFeedbackPtr lf; |
6094 | |
6095 | classOk = TRUE1; |
6096 | for (lf = dev->leds; (lf); lf = lf->next) { |
6097 | if ((id != XkbAllXIIds0x0600) && (id != XkbDfltXIId0x0400) && |
6098 | (id != lf->ctrl.id)) |
6099 | continue; |
6100 | nFBs++; |
6101 | length += SIZEOF(xkbDeviceLedsWireDesc)20; |
6102 | if (!lf->xkb_sli) |
6103 | lf->xkb_sli = XkbAllocSrvLedInfo(dev, NULL((void*)0), lf, 0); |
6104 | length += ComputeDeviceLedInfoSize(dev, rep->present, lf->xkb_sli); |
6105 | if (id != XkbAllXIIds0x0600) |
6106 | break; |
6107 | } |
6108 | } |
6109 | if (nFBs > 0) { |
6110 | rep->nDeviceLedFBs = nFBs; |
6111 | rep->length += (length / 4); |
6112 | return Success0; |
6113 | } |
6114 | if (classOk) |
6115 | client->errorValue = _XkbErrCode2(XkbErr_BadId, id)((XID)((((unsigned int)(0xfd))<<24)|((id)&0xffffff) )); |
6116 | else |
6117 | client->errorValue = _XkbErrCode2(XkbErr_BadClass, class)((XID)((((unsigned int)(0xfe))<<24)|((class)&0xffffff ))); |
6118 | return XkbKeyboardErrorCode; |
6119 | } |
6120 | |
6121 | static int |
6122 | SendDeviceLedInfo(XkbSrvLedInfoPtr sli, ClientPtr client) |
6123 | { |
6124 | xkbDeviceLedsWireDesc wire; |
6125 | int length; |
6126 | |
6127 | length = 0; |
6128 | wire.ledClass = sli->class; |
6129 | wire.ledID = sli->id; |
6130 | wire.namesPresent = sli->namesPresent; |
6131 | wire.mapsPresent = sli->mapsPresent; |
6132 | wire.physIndicators = sli->physIndicators; |
6133 | wire.state = sli->effectiveState; |
6134 | if (client->swapped) { |
6135 | swaps(&wire.ledClass)do { if (sizeof(*(&wire.ledClass)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&wire.ledClass) & 1 ) && ((uintptr_t)(&wire.ledClass) & 1) == 0) * (&wire.ledClass) = lswaps(*(&wire.ledClass)); else swap_uint16 ((uint16_t *)(&wire.ledClass)); } while (0); |
6136 | swaps(&wire.ledID)do { if (sizeof(*(&wire.ledID)) != 2) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&wire.ledID) & 1) && ((uintptr_t )(&wire.ledID) & 1) == 0) *(&wire.ledID) = lswaps (*(&wire.ledID)); else swap_uint16((uint16_t *)(&wire .ledID)); } while (0); |
6137 | swapl(&wire.namesPresent)do { if (sizeof(*(&wire.namesPresent)) != 4) wrong_size() ; if (__builtin_constant_p((uintptr_t)(&wire.namesPresent ) & 3) && ((uintptr_t)(&wire.namesPresent) & 3) == 0) *(&wire.namesPresent) = lswapl(*(&wire.namesPresent )); else swap_uint32((uint32_t *)(&wire.namesPresent)); } while (0); |
6138 | swapl(&wire.mapsPresent)do { if (sizeof(*(&wire.mapsPresent)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&wire.mapsPresent) & 3) && ((uintptr_t)(&wire.mapsPresent) & 3) == 0) *(&wire.mapsPresent) = lswapl(*(&wire.mapsPresent )); else swap_uint32((uint32_t *)(&wire.mapsPresent)); } while (0); |
6139 | swapl(&wire.physIndicators)do { if (sizeof(*(&wire.physIndicators)) != 4) wrong_size (); if (__builtin_constant_p((uintptr_t)(&wire.physIndicators ) & 3) && ((uintptr_t)(&wire.physIndicators) & 3) == 0) *(&wire.physIndicators) = lswapl(*(&wire.physIndicators )); else swap_uint32((uint32_t *)(&wire.physIndicators)); } while (0); |
6140 | swapl(&wire.state)do { if (sizeof(*(&wire.state)) != 4) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&wire.state) & 3) && ((uintptr_t )(&wire.state) & 3) == 0) *(&wire.state) = lswapl (*(&wire.state)); else swap_uint32((uint32_t *)(&wire .state)); } while (0); |
6141 | } |
6142 | WriteToClient(client, SIZEOF(xkbDeviceLedsWireDesc)20, &wire); |
6143 | length += SIZEOF(xkbDeviceLedsWireDesc)20; |
6144 | if (sli->namesPresent | sli->mapsPresent) { |
6145 | register unsigned i, bit; |
6146 | |
6147 | if (sli->namesPresent) { |
6148 | CARD32 awire; |
6149 | |
6150 | for (i = 0, bit = 1; i < XkbNumIndicators32; i++, bit <<= 1) { |
6151 | if (sli->namesPresent & bit) { |
6152 | awire = (CARD32) sli->names[i]; |
6153 | if (client->swapped) { |
6154 | swapl(&awire)do { if (sizeof(*(&awire)) != 4) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&awire) & 3) && ((uintptr_t)(& awire) & 3) == 0) *(&awire) = lswapl(*(&awire)); else swap_uint32((uint32_t *)(&awire)); } while (0); |
6155 | } |
6156 | WriteToClient(client, 4, &awire); |
6157 | length += 4; |
6158 | } |
6159 | } |
6160 | } |
6161 | if (sli->mapsPresent) { |
6162 | for (i = 0, bit = 1; i < XkbNumIndicators32; i++, bit <<= 1) { |
6163 | xkbIndicatorMapWireDesc iwire; |
6164 | |
6165 | if (sli->mapsPresent & bit) { |
6166 | iwire.flags = sli->maps[i].flags; |
6167 | iwire.whichGroups = sli->maps[i].which_groups; |
6168 | iwire.groups = sli->maps[i].groups; |
6169 | iwire.whichMods = sli->maps[i].which_mods; |
6170 | iwire.mods = sli->maps[i].mods.mask; |
6171 | iwire.realMods = sli->maps[i].mods.real_mods; |
6172 | iwire.virtualMods = sli->maps[i].mods.vmods; |
6173 | iwire.ctrls = sli->maps[i].ctrls; |
6174 | if (client->swapped) { |
6175 | swaps(&iwire.virtualMods)do { if (sizeof(*(&iwire.virtualMods)) != 2) wrong_size() ; if (__builtin_constant_p((uintptr_t)(&iwire.virtualMods ) & 1) && ((uintptr_t)(&iwire.virtualMods) & 1) == 0) *(&iwire.virtualMods) = lswaps(*(&iwire.virtualMods )); else swap_uint16((uint16_t *)(&iwire.virtualMods)); } while (0); |
6176 | swapl(&iwire.ctrls)do { if (sizeof(*(&iwire.ctrls)) != 4) wrong_size(); if ( __builtin_constant_p((uintptr_t)(&iwire.ctrls) & 3) && ((uintptr_t)(&iwire.ctrls) & 3) == 0) *(&iwire.ctrls ) = lswapl(*(&iwire.ctrls)); else swap_uint32((uint32_t * )(&iwire.ctrls)); } while (0); |
6177 | } |
6178 | WriteToClient(client, SIZEOF(xkbIndicatorMapWireDesc)12, |
6179 | &iwire); |
6180 | length += SIZEOF(xkbIndicatorMapWireDesc)12; |
6181 | } |
6182 | } |
6183 | } |
6184 | } |
6185 | return length; |
6186 | } |
6187 | |
6188 | static int |
6189 | SendDeviceLedFBs(DeviceIntPtr dev, |
6190 | int class, int id, unsigned wantLength, ClientPtr client) |
6191 | { |
6192 | int length = 0; |
6193 | |
6194 | if (class == XkbDfltXIClass0x0300) { |
6195 | if (dev->kbdfeed) |
6196 | class = KbdFeedbackClass0; |
6197 | else if (dev->leds) |
6198 | class = LedFeedbackClass4; |
6199 | } |
6200 | if ((dev->kbdfeed) && |
6201 | ((class == KbdFeedbackClass0) || (class == XkbAllXIClasses0x0500))) { |
6202 | KbdFeedbackPtr kf; |
6203 | |
6204 | for (kf = dev->kbdfeed; (kf); kf = kf->next) { |
6205 | if ((id == XkbAllXIIds0x0600) || (id == XkbDfltXIId0x0400) || |
6206 | (id == kf->ctrl.id)) { |
6207 | length += SendDeviceLedInfo(kf->xkb_sli, client); |
6208 | if (id != XkbAllXIIds0x0600) |
6209 | break; |
6210 | } |
6211 | } |
6212 | } |
6213 | if ((dev->leds) && |
6214 | ((class == LedFeedbackClass4) || (class == XkbAllXIClasses0x0500))) { |
6215 | LedFeedbackPtr lf; |
6216 | |
6217 | for (lf = dev->leds; (lf); lf = lf->next) { |
6218 | if ((id == XkbAllXIIds0x0600) || (id == XkbDfltXIId0x0400) || |
6219 | (id == lf->ctrl.id)) { |
6220 | length += SendDeviceLedInfo(lf->xkb_sli, client); |
6221 | if (id != XkbAllXIIds0x0600) |
6222 | break; |
6223 | } |
6224 | } |
6225 | } |
6226 | if (length == wantLength) |
6227 | return Success0; |
6228 | else |
6229 | return BadLength16; |
6230 | } |
6231 | |
6232 | int |
6233 | ProcXkbGetDeviceInfo(ClientPtr client) |
6234 | { |
6235 | DeviceIntPtr dev; |
6236 | xkbGetDeviceInfoReply rep; |
6237 | int status, nDeviceLedFBs; |
6238 | unsigned length, nameLen; |
6239 | CARD16 ledClass, ledID; |
6240 | unsigned wanted; |
6241 | char *str; |
6242 | |
6243 | REQUEST(xkbGetDeviceInfoReq)xkbGetDeviceInfoReq *stuff = (xkbGetDeviceInfoReq *)client-> requestBuffer; |
6244 | REQUEST_SIZE_MATCH(xkbGetDeviceInfoReq)if ((sizeof(xkbGetDeviceInfoReq) >> 2) != client->req_len ) return(16); |
6245 | |
6246 | if (!(client->xkbClientFlags & _XkbClientInitialized(1<<15))) |
6247 | return BadAccess10; |
6248 | |
6249 | wanted = stuff->wanted; |
6250 | |
6251 | CHK_ANY_DEVICE(dev, stuff->deviceSpec, client, DixGetAttrAccess){ int why; int tmprc = _XkbLookupAnyDevice(&(dev), stuff-> deviceSpec, client, (1<<4), &why); if (tmprc != 0) { client->errorValue = ((XID)((((unsigned int)(why))<< 24)|((stuff->deviceSpec)&0xffffff))); return tmprc; }}; |
6252 | CHK_MASK_LEGAL(0x01, wanted, XkbXI_AllDeviceFeaturesMask){ if ((wanted)&(~((0x001e)))) { (client->errorValue)= ( (XID)((((unsigned int)((0x01)))<<24)|((((wanted)&(~ ((0x001e)))))&0xffffff))); return 2; }}; |
6253 | |
6254 | if ((!dev->button) || ((stuff->nBtns < 1) && (!stuff->allBtns))) |
6255 | wanted &= ~XkbXI_ButtonActionsMask(1L << 1); |
6256 | if ((!dev->kbdfeed) && (!dev->leds)) |
6257 | wanted &= ~XkbXI_IndicatorsMask(0x001c); |
6258 | |
6259 | nameLen = XkbSizeCountedString(dev->name)((dev->name)?((((2+strlen(dev->name))+3)/4)*4):4); |
6260 | rep = (xkbGetDeviceInfoReply) { |
6261 | .type = X_Reply1, |
6262 | .deviceID = dev->id, |
6263 | .sequenceNumber = client->sequence, |
6264 | .length = nameLen / 4, |
6265 | .present = wanted, |
6266 | .supported = XkbXI_AllDeviceFeaturesMask(0x001e), |
6267 | .unsupported = 0, |
6268 | .nDeviceLedFBs = 0, |
6269 | .firstBtnWanted = 0, |
6270 | .nBtnsWanted = 0, |
6271 | .firstBtnRtrn = 0, |
6272 | .nBtnsRtrn = 0, |
6273 | .totalBtns = dev->button ? dev->button->numButtons : 0, |
6274 | .hasOwnState = (dev->key && dev->key->xkbInfo), |
6275 | .dfltKbdFB = dev->kbdfeed ? dev->kbdfeed->ctrl.id : XkbXINone0xff00, |
6276 | .dfltLedFB = dev->leds ? dev->leds->ctrl.id : XkbXINone0xff00, |
6277 | .devType = dev->xinput_type |
6278 | }; |
6279 | |
6280 | ledClass = stuff->ledClass; |
6281 | ledID = stuff->ledID; |
6282 | |
6283 | if (wanted & XkbXI_ButtonActionsMask(1L << 1)) { |
6284 | if (stuff->allBtns) { |
6285 | stuff->firstBtn = 0; |
6286 | stuff->nBtns = dev->button->numButtons; |
6287 | } |
6288 | |
6289 | if ((stuff->firstBtn + stuff->nBtns) > dev->button->numButtons) { |
6290 | client->errorValue = _XkbErrCode4(0x02, dev->button->numButtons,((XID)((((unsigned int)(0x02))<<24)|(((((unsigned int)( dev->button->numButtons))<<16)|(((((unsigned int) (stuff->firstBtn))<<8)|(stuff->nBtns))))&0xffffff ))) |
6291 | stuff->firstBtn, stuff->nBtns)((XID)((((unsigned int)(0x02))<<24)|(((((unsigned int)( dev->button->numButtons))<<16)|(((((unsigned int) (stuff->firstBtn))<<8)|(stuff->nBtns))))&0xffffff ))); |
6292 | return BadValue2; |
6293 | } |
6294 | else { |
6295 | rep.firstBtnWanted = stuff->firstBtn; |
6296 | rep.nBtnsWanted = stuff->nBtns; |
6297 | if (dev->button->xkb_acts != NULL((void*)0)) { |
6298 | XkbAction *act; |
6299 | register int i; |
6300 | |
6301 | rep.firstBtnRtrn = stuff->firstBtn; |
6302 | rep.nBtnsRtrn = stuff->nBtns; |
6303 | act = &dev->button->xkb_acts[rep.firstBtnWanted]; |
6304 | for (i = 0; i < rep.nBtnsRtrn; i++, act++) { |
6305 | if (act->type != XkbSA_NoAction0x00) |
6306 | break; |
6307 | } |
6308 | rep.firstBtnRtrn += i; |
6309 | rep.nBtnsRtrn -= i; |
6310 | act = |
6311 | &dev->button->xkb_acts[rep.firstBtnRtrn + rep.nBtnsRtrn - |
6312 | 1]; |
6313 | for (i = 0; i < rep.nBtnsRtrn; i++, act--) { |
6314 | if (act->type != XkbSA_NoAction0x00) |
6315 | break; |
6316 | } |
6317 | rep.nBtnsRtrn -= i; |
6318 | } |
6319 | rep.length += (rep.nBtnsRtrn * SIZEOF(xkbActionWireDesc)8) / 4; |
6320 | } |
6321 | } |
6322 | |
6323 | if (wanted & XkbXI_IndicatorsMask(0x001c)) { |
6324 | status = CheckDeviceLedFBs(dev, ledClass, ledID, &rep, client); |
6325 | if (status != Success0) |
6326 | return status; |
6327 | } |
6328 | length = rep.length * 4; |
6329 | nDeviceLedFBs = rep.nDeviceLedFBs; |
6330 | if (client->swapped) { |
6331 | swaps(&rep.sequenceNumber)do { if (sizeof(*(&rep.sequenceNumber)) != 2) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&rep.sequenceNumber ) & 1) && ((uintptr_t)(&rep.sequenceNumber) & 1) == 0) *(&rep.sequenceNumber) = lswaps(*(&rep.sequenceNumber )); else swap_uint16((uint16_t *)(&rep.sequenceNumber)); } while (0); |
6332 | swapl(&rep.length)do { if (sizeof(*(&rep.length)) != 4) wrong_size(); if (__builtin_constant_p ((uintptr_t)(&rep.length) & 3) && ((uintptr_t )(&rep.length) & 3) == 0) *(&rep.length) = lswapl (*(&rep.length)); else swap_uint32((uint32_t *)(&rep. length)); } while (0); |
6333 | swaps(&rep.present)do { if (sizeof(*(&rep.present)) != 2) wrong_size(); if ( __builtin_constant_p((uintptr_t)(&rep.present) & 1) && ((uintptr_t)(&rep.present) & 1) == 0) *(&rep.present ) = lswaps(*(&rep.present)); else swap_uint16((uint16_t * )(&rep.present)); } while (0); |
6334 | swaps(&rep.supported)do { if (sizeof(*(&rep.supported)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&rep.supported) & 1 ) && ((uintptr_t)(&rep.supported) & 1) == 0) * (&rep.supported) = lswaps(*(&rep.supported)); else swap_uint16 ((uint16_t *)(&rep.supported)); } while (0); |
6335 | swaps(&rep.unsupported)do { if (sizeof(*(&rep.unsupported)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&rep.unsupported) & 1) && ((uintptr_t)(&rep.unsupported) & 1) == 0) *(&rep.unsupported) = lswaps(*(&rep.unsupported)) ; else swap_uint16((uint16_t *)(&rep.unsupported)); } while (0); |
6336 | swaps(&rep.nDeviceLedFBs)do { if (sizeof(*(&rep.nDeviceLedFBs)) != 2) wrong_size() ; if (__builtin_constant_p((uintptr_t)(&rep.nDeviceLedFBs ) & 1) && ((uintptr_t)(&rep.nDeviceLedFBs) & 1) == 0) *(&rep.nDeviceLedFBs) = lswaps(*(&rep.nDeviceLedFBs )); else swap_uint16((uint16_t *)(&rep.nDeviceLedFBs)); } while (0); |
6337 | swaps(&rep.dfltKbdFB)do { if (sizeof(*(&rep.dfltKbdFB)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&rep.dfltKbdFB) & 1 ) && ((uintptr_t)(&rep.dfltKbdFB) & 1) == 0) * (&rep.dfltKbdFB) = lswaps(*(&rep.dfltKbdFB)); else swap_uint16 ((uint16_t *)(&rep.dfltKbdFB)); } while (0); |
6338 | swaps(&rep.dfltLedFB)do { if (sizeof(*(&rep.dfltLedFB)) != 2) wrong_size(); if (__builtin_constant_p((uintptr_t)(&rep.dfltLedFB) & 1 ) && ((uintptr_t)(&rep.dfltLedFB) & 1) == 0) * (&rep.dfltLedFB) = lswaps(*(&rep.dfltLedFB)); else swap_uint16 ((uint16_t *)(&rep.dfltLedFB)); } while (0); |
6339 | swapl(&rep.devType)do { if (sizeof(*(&rep.devType)) != 4) wrong_size(); if ( __builtin_constant_p((uintptr_t)(&rep.devType) & 3) && ((uintptr_t)(&rep.devType) & 3) == 0) *(&rep.devType ) = lswapl(*(&rep.devType)); else swap_uint32((uint32_t * )(&rep.devType)); } while (0); |
6340 | } |
6341 | WriteToClient(client, SIZEOF(xkbGetDeviceInfoReply)32, &rep); |
6342 | |
6343 | str = malloc(nameLen); |
6344 | if (!str) |
6345 | return BadAlloc11; |
6346 | XkbWriteCountedString(str, dev->name, client->swapped); |
6347 | WriteToClient(client, nameLen, str); |
6348 | free(str); |
6349 | length -= nameLen; |
6350 | |
6351 | if (rep.nBtnsRtrn > 0) { |
6352 | int sz; |
6353 | xkbActionWireDesc *awire; |
6354 | |
6355 | sz = rep.nBtnsRtrn * SIZEOF(xkbActionWireDesc)8; |
6356 | awire = (xkbActionWireDesc *) &dev->button->xkb_acts[rep.firstBtnRtrn]; |
6357 | WriteToClient(client, sz, awire); |
6358 | length -= sz; |
6359 | } |
6360 | if (nDeviceLedFBs > 0) { |
6361 | status = SendDeviceLedFBs(dev, ledClass, ledID, length, client); |
6362 | if (status != Success0) |
6363 | return status; |
6364 | } |
6365 | else if (length != 0) { |
6366 | ErrorF("[xkb] Internal Error! BadLength in ProcXkbGetDeviceInfo\n"); |
6367 | ErrorF("[xkb] Wrote %d fewer bytes than expected\n", |
6368 | length); |
6369 | return BadLength16; |
6370 | } |
6371 | return Success0; |
6372 | } |
6373 | |
6374 | static char * |
6375 | CheckSetDeviceIndicators(char *wire, |
6376 | DeviceIntPtr dev, |
6377 | int num, int *status_rtrn, ClientPtr client) |
6378 | { |
6379 | xkbDeviceLedsWireDesc *ledWire; |
6380 | int i; |
6381 | XkbSrvLedInfoPtr sli; |
6382 | |
6383 | ledWire = (xkbDeviceLedsWireDesc *) wire; |
6384 | for (i = 0; i < num; i++) { |
6385 | if (client->swapped) { |
6386 | swaps(&ledWire->ledClass)do { if (sizeof(*(&ledWire->ledClass)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&ledWire->ledClass ) & 1) && ((uintptr_t)(&ledWire->ledClass) & 1) == 0) *(&ledWire->ledClass) = lswaps(*(& ledWire->ledClass)); else swap_uint16((uint16_t *)(&ledWire ->ledClass)); } while (0); |
6387 | swaps(&ledWire->ledID)do { if (sizeof(*(&ledWire->ledID)) != 2) wrong_size() ; if (__builtin_constant_p((uintptr_t)(&ledWire->ledID ) & 1) && ((uintptr_t)(&ledWire->ledID) & 1) == 0) *(&ledWire->ledID) = lswaps(*(&ledWire-> ledID)); else swap_uint16((uint16_t *)(&ledWire->ledID )); } while (0); |
6388 | swapl(&ledWire->namesPresent)do { if (sizeof(*(&ledWire->namesPresent)) != 4) wrong_size (); if (__builtin_constant_p((uintptr_t)(&ledWire->namesPresent ) & 3) && ((uintptr_t)(&ledWire->namesPresent ) & 3) == 0) *(&ledWire->namesPresent) = lswapl(*( &ledWire->namesPresent)); else swap_uint32((uint32_t * )(&ledWire->namesPresent)); } while (0); |
6389 | swapl(&ledWire->mapsPresent)do { if (sizeof(*(&ledWire->mapsPresent)) != 4) wrong_size (); if (__builtin_constant_p((uintptr_t)(&ledWire->mapsPresent ) & 3) && ((uintptr_t)(&ledWire->mapsPresent ) & 3) == 0) *(&ledWire->mapsPresent) = lswapl(*(& ledWire->mapsPresent)); else swap_uint32((uint32_t *)(& ledWire->mapsPresent)); } while (0); |
6390 | swapl(&ledWire->physIndicators)do { if (sizeof(*(&ledWire->physIndicators)) != 4) wrong_size (); if (__builtin_constant_p((uintptr_t)(&ledWire->physIndicators ) & 3) && ((uintptr_t)(&ledWire->physIndicators ) & 3) == 0) *(&ledWire->physIndicators) = lswapl( *(&ledWire->physIndicators)); else swap_uint32((uint32_t *)(&ledWire->physIndicators)); } while (0); |
6391 | } |
6392 | |
6393 | sli = XkbFindSrvLedInfo(dev, ledWire->ledClass, ledWire->ledID, |
6394 | XkbXI_IndicatorsMask(0x001c)); |
6395 | if (sli != NULL((void*)0)) { |
6396 | register int n; |
6397 | register unsigned bit; |
6398 | int nMaps, nNames; |
6399 | CARD32 *atomWire; |
6400 | xkbIndicatorMapWireDesc *mapWire; |
6401 | |
6402 | nMaps = nNames = 0; |
6403 | for (n = 0, bit = 1; n < XkbNumIndicators32; n++, bit <<= 1) { |
6404 | if (ledWire->namesPresent & bit) |
6405 | nNames++; |
6406 | if (ledWire->mapsPresent & bit) |
6407 | nMaps++; |
6408 | } |
6409 | atomWire = (CARD32 *) &ledWire[1]; |
6410 | if (nNames > 0) { |
6411 | for (n = 0; n < nNames; n++) { |
6412 | if (client->swapped) { |
6413 | swapl(atomWire)do { if (sizeof(*(atomWire)) != 4) wrong_size(); if (__builtin_constant_p ((uintptr_t)(atomWire) & 3) && ((uintptr_t)(atomWire ) & 3) == 0) *(atomWire) = lswapl(*(atomWire)); else swap_uint32 ((uint32_t *)(atomWire)); } while (0); |
6414 | } |
6415 | CHK_ATOM_OR_NONE3(((Atom) (*atomWire)), client->errorValue,{ if (((((Atom) (*atomWire)))!=0L)&&(!ValidAtom((((Atom ) (*atomWire)))))) { (client->errorValue)= (XID)(((Atom) ( *atomWire))); (*status_rtrn)= 5; return ((void*)0); }} |
6416 | *status_rtrn, NULL){ if (((((Atom) (*atomWire)))!=0L)&&(!ValidAtom((((Atom ) (*atomWire)))))) { (client->errorValue)= (XID)(((Atom) ( *atomWire))); (*status_rtrn)= 5; return ((void*)0); }}; |
6417 | atomWire++; |
6418 | } |
6419 | } |
6420 | mapWire = (xkbIndicatorMapWireDesc *) atomWire; |
6421 | if (nMaps > 0) { |
6422 | for (n = 0; n < nMaps; n++) { |
6423 | if (client->swapped) { |
6424 | swaps(&mapWire->virtualMods)do { if (sizeof(*(&mapWire->virtualMods)) != 2) wrong_size (); if (__builtin_constant_p((uintptr_t)(&mapWire->virtualMods ) & 1) && ((uintptr_t)(&mapWire->virtualMods ) & 1) == 0) *(&mapWire->virtualMods) = lswaps(*(& mapWire->virtualMods)); else swap_uint16((uint16_t *)(& mapWire->virtualMods)); } while (0); |
6425 | swapl(&mapWire->ctrls)do { if (sizeof(*(&mapWire->ctrls)) != 4) wrong_size() ; if (__builtin_constant_p((uintptr_t)(&mapWire->ctrls ) & 3) && ((uintptr_t)(&mapWire->ctrls) & 3) == 0) *(&mapWire->ctrls) = lswapl(*(&mapWire-> ctrls)); else swap_uint32((uint32_t *)(&mapWire->ctrls )); } while (0); |
6426 | } |
6427 | CHK_MASK_LEGAL3(0x21, mapWire->whichGroups,{ if ((mapWire->whichGroups)&(~(((1L << 0)|(1L << 1)|(1L << 2) |(1L << 3))))) { (client->errorValue )= ((XID)((((unsigned int)((0x21)))<<24)|((((mapWire-> whichGroups)&(~(((1L << 0)|(1L << 1)|(1L << 2) |(1L << 3))))))&0xffffff))); (*status_rtrn)= 2; return ((void*)0); }} |
6428 | XkbIM_UseAnyGroup,{ if ((mapWire->whichGroups)&(~(((1L << 0)|(1L << 1)|(1L << 2) |(1L << 3))))) { (client->errorValue )= ((XID)((((unsigned int)((0x21)))<<24)|((((mapWire-> whichGroups)&(~(((1L << 0)|(1L << 1)|(1L << 2) |(1L << 3))))))&0xffffff))); (*status_rtrn)= 2; return ((void*)0); }} |
6429 | client->errorValue, *status_rtrn, NULL){ if ((mapWire->whichGroups)&(~(((1L << 0)|(1L << 1)|(1L << 2) |(1L << 3))))) { (client->errorValue )= ((XID)((((unsigned int)((0x21)))<<24)|((((mapWire-> whichGroups)&(~(((1L << 0)|(1L << 1)|(1L << 2) |(1L << 3))))))&0xffffff))); (*status_rtrn)= 2; return ((void*)0); }}; |
6430 | CHK_MASK_LEGAL3(0x22, mapWire->whichMods, XkbIM_UseAnyMods,{ if ((mapWire->whichMods)&(~((((1L << 0)|(1L << 1)|(1L << 2) |(1L << 3))|(1L << 4))))) { ( client->errorValue)= ((XID)((((unsigned int)((0x22)))<< 24)|((((mapWire->whichMods)&(~((((1L << 0)|(1L << 1)|(1L << 2) |(1L << 3))|(1L << 4))))))& 0xffffff))); (*status_rtrn)= 2; return ((void*)0); }} |
6431 | client->errorValue, *status_rtrn, NULL){ if ((mapWire->whichMods)&(~((((1L << 0)|(1L << 1)|(1L << 2) |(1L << 3))|(1L << 4))))) { ( client->errorValue)= ((XID)((((unsigned int)((0x22)))<< 24)|((((mapWire->whichMods)&(~((((1L << 0)|(1L << 1)|(1L << 2) |(1L << 3))|(1L << 4))))))& 0xffffff))); (*status_rtrn)= 2; return ((void*)0); }}; |
6432 | mapWire++; |
6433 | } |
6434 | } |
6435 | ledWire = (xkbDeviceLedsWireDesc *) mapWire; |
6436 | } |
6437 | else { |
6438 | /* SHOULD NEVER HAPPEN */ |
6439 | return (char *) ledWire; |
6440 | } |
6441 | } |
6442 | return (char *) ledWire; |
6443 | } |
6444 | |
6445 | static char * |
6446 | SetDeviceIndicators(char *wire, |
6447 | DeviceIntPtr dev, |
6448 | unsigned changed, |
6449 | int num, |
6450 | int *status_rtrn, |
6451 | ClientPtr client, xkbExtensionDeviceNotify * ev) |
6452 | { |
6453 | xkbDeviceLedsWireDesc *ledWire; |
6454 | int i; |
6455 | XkbEventCauseRec cause; |
6456 | unsigned namec, mapc, statec; |
6457 | xkbExtensionDeviceNotify ed; |
6458 | XkbChangesRec changes; |
6459 | DeviceIntPtr kbd; |
6460 | |
6461 | memset((char *) &ed, 0, sizeof(xkbExtensionDeviceNotify))__builtin___memset_chk ((char *) &ed, 0, sizeof(xkbExtensionDeviceNotify ), __builtin_object_size ((char *) &ed, 0)); |
6462 | memset((char *) &changes, 0, sizeof(XkbChangesRec))__builtin___memset_chk ((char *) &changes, 0, sizeof(XkbChangesRec ), __builtin_object_size ((char *) &changes, 0)); |
6463 | XkbSetCauseXkbReq(&cause, X_kbSetDeviceInfo, client){ (&cause)->kc= (&cause)->event= 0, (&cause )->mjr= (XkbReqCode),(&cause)->mnr= (25); (&cause )->client= (client); }; |
6464 | ledWire = (xkbDeviceLedsWireDesc *) wire; |
6465 | for (i = 0; i < num; i++) { |
6466 | register int n; |
6467 | register unsigned bit; |
6468 | CARD32 *atomWire; |
6469 | xkbIndicatorMapWireDesc *mapWire; |
6470 | XkbSrvLedInfoPtr sli; |
6471 | |
6472 | namec = mapc = statec = 0; |
6473 | sli = XkbFindSrvLedInfo(dev, ledWire->ledClass, ledWire->ledID, |
6474 | XkbXI_IndicatorMapsMask(1L << 3)); |
6475 | if (!sli) { |
6476 | /* SHOULD NEVER HAPPEN!! */ |
6477 | return (char *) ledWire; |
6478 | } |
6479 | |
6480 | atomWire = (CARD32 *) &ledWire[1]; |
6481 | if (changed & XkbXI_IndicatorNamesMask(1L << 2)) { |
6482 | namec = sli->namesPresent | ledWire->namesPresent; |
6483 | memset((char *) sli->names, 0, XkbNumIndicators * sizeof(Atom))__builtin___memset_chk ((char *) sli->names, 0, 32 * sizeof (Atom), __builtin_object_size ((char *) sli->names, 0)); |
6484 | } |
6485 | if (ledWire->namesPresent) { |
6486 | sli->namesPresent = ledWire->namesPresent; |
6487 | memset((char *) sli->names, 0, XkbNumIndicators * sizeof(Atom))__builtin___memset_chk ((char *) sli->names, 0, 32 * sizeof (Atom), __builtin_object_size ((char *) sli->names, 0)); |
6488 | for (n = 0, bit = 1; n < XkbNumIndicators32; n++, bit <<= 1) { |
6489 | if (ledWire->namesPresent & bit) { |
6490 | sli->names[n] = (Atom) *atomWire; |
6491 | if (sli->names[n] == None0L) |
6492 | ledWire->namesPresent &= ~bit; |
6493 | atomWire++; |
6494 | } |
6495 | } |
6496 | } |
6497 | mapWire = (xkbIndicatorMapWireDesc *) atomWire; |
6498 | if (changed & XkbXI_IndicatorMapsMask(1L << 3)) { |
6499 | mapc = sli->mapsPresent | ledWire->mapsPresent; |
6500 | sli->mapsPresent = ledWire->mapsPresent; |
6501 | memset((char *) sli->maps, 0,__builtin___memset_chk ((char *) sli->maps, 0, 32 * sizeof (XkbIndicatorMapRec), __builtin_object_size ((char *) sli-> maps, 0)) |
6502 | XkbNumIndicators * sizeof(XkbIndicatorMapRec))__builtin___memset_chk ((char *) sli->maps, 0, 32 * sizeof (XkbIndicatorMapRec), __builtin_object_size ((char *) sli-> maps, 0)); |
6503 | } |
6504 | if (ledWire->mapsPresent) { |
6505 | for (n = 0, bit = 1; n < XkbNumIndicators32; n++, bit <<= 1) { |
6506 | if (ledWire->mapsPresent & bit) { |
6507 | sli->maps[n].flags = mapWire->flags; |
6508 | sli->maps[n].which_groups = mapWire->whichGroups; |
6509 | sli->maps[n].groups = mapWire->groups; |
6510 | sli->maps[n].which_mods = mapWire->whichMods; |
6511 | sli->maps[n].mods.mask = mapWire->mods; |
6512 | sli->maps[n].mods.real_mods = mapWire->realMods; |
6513 | sli->maps[n].mods.vmods = mapWire->virtualMods; |
6514 | sli->maps[n].ctrls = mapWire->ctrls; |
6515 | mapWire++; |
6516 | } |
6517 | } |
6518 | } |
6519 | if (changed & XkbXI_IndicatorStateMask(1L << 4)) { |
6520 | statec = sli->effectiveState ^ ledWire->state; |
6521 | sli->explicitState &= ~statec; |
6522 | sli->explicitState |= (ledWire->state & statec); |
6523 | } |
6524 | if (namec) |
6525 | XkbApplyLedNameChanges(dev, sli, namec, &ed, &changes, &cause); |
6526 | if (mapc) |
6527 | XkbApplyLedMapChanges(dev, sli, mapc, &ed, &changes, &cause); |
6528 | if (statec) |
6529 | XkbApplyLedStateChanges(dev, sli, statec, &ed, &changes, &cause); |
6530 | |
6531 | kbd = dev; |
6532 | if ((sli->flags & XkbSLI_HasOwnState(1L<<1)) == 0) |
6533 | kbd = inputInfo.keyboard; |
6534 | |
6535 | XkbFlushLedEvents(dev, kbd, sli, &ed, &changes, &cause); |
6536 | ledWire = (xkbDeviceLedsWireDesc *) mapWire; |
6537 | } |
6538 | return (char *) ledWire; |
6539 | } |
6540 | |
6541 | static int |
6542 | _XkbSetDeviceInfo(ClientPtr client, DeviceIntPtr dev, |
6543 | xkbSetDeviceInfoReq * stuff) |
6544 | { |
6545 | char *wire; |
6546 | |
6547 | wire = (char *) &stuff[1]; |
6548 | if (stuff->change & XkbXI_ButtonActionsMask(1L << 1)) { |
6549 | if (!dev->button) { |
6550 | client->errorValue = _XkbErrCode2(XkbErr_BadClass, ButtonClass)((XID)((((unsigned int)(0xfe))<<24)|((1)&0xffffff)) ); |
6551 | return XkbKeyboardErrorCode; |
6552 | } |
6553 | if ((stuff->firstBtn + stuff->nBtns) > dev->button->numButtons) { |
6554 | client->errorValue = |
6555 | _XkbErrCode4(0x02, stuff->firstBtn, stuff->nBtns,((XID)((((unsigned int)(0x02))<<24)|(((((unsigned int)( stuff->firstBtn))<<16)|(((((unsigned int)(stuff-> nBtns))<<8)|(dev->button->numButtons))))&0xffffff ))) |
6556 | dev->button->numButtons)((XID)((((unsigned int)(0x02))<<24)|(((((unsigned int)( stuff->firstBtn))<<16)|(((((unsigned int)(stuff-> nBtns))<<8)|(dev->button->numButtons))))&0xffffff ))); |
6557 | return BadMatch8; |
6558 | } |
6559 | wire += (stuff->nBtns * SIZEOF(xkbActionWireDesc)8); |
6560 | } |
6561 | if (stuff->change & XkbXI_IndicatorsMask(0x001c)) { |
6562 | int status = Success0; |
6563 | |
6564 | wire = CheckSetDeviceIndicators(wire, dev, stuff->nDeviceLedFBs, |
6565 | &status, client); |
6566 | if (status != Success0) |
6567 | return status; |
6568 | } |
6569 | if (((wire - ((char *) stuff)) / 4) != stuff->length) |
6570 | return BadLength16; |
6571 | |
6572 | return Success0; |
6573 | } |
6574 | |
6575 | static int |
6576 | _XkbSetDeviceInfoCheck(ClientPtr client, DeviceIntPtr dev, |
6577 | xkbSetDeviceInfoReq * stuff) |
6578 | { |
6579 | char *wire; |
6580 | xkbExtensionDeviceNotify ed; |
6581 | |
6582 | memset((char *) &ed, 0, SIZEOF(xkbExtensionDeviceNotify))__builtin___memset_chk ((char *) &ed, 0, 32, __builtin_object_size ((char *) &ed, 0)); |
6583 | ed.deviceID = dev->id; |
6584 | wire = (char *) &stuff[1]; |
6585 | if (stuff->change & XkbXI_ButtonActionsMask(1L << 1)) { |
6586 | int nBtns, sz, i; |
6587 | XkbAction *acts; |
6588 | DeviceIntPtr kbd; |
6589 | |
6590 | nBtns = dev->button->numButtons; |
6591 | acts = dev->button->xkb_acts; |
6592 | if (acts == NULL((void*)0)) { |
6593 | acts = calloc(nBtns, sizeof(XkbAction)); |
6594 | if (!acts) |
6595 | return BadAlloc11; |
6596 | dev->button->xkb_acts = acts; |
6597 | } |
6598 | sz = stuff->nBtns * SIZEOF(xkbActionWireDesc)8; |
6599 | memcpy((char *) &acts[stuff->firstBtn], (char *) wire, sz)__builtin___memcpy_chk ((char *) &acts[stuff->firstBtn ], (char *) wire, sz, __builtin_object_size ((char *) &acts [stuff->firstBtn], 0)); |
6600 | wire += sz; |
6601 | ed.reason |= XkbXI_ButtonActionsMask(1L << 1); |
6602 | ed.firstBtn = stuff->firstBtn; |
6603 | ed.nBtns = stuff->nBtns; |
6604 | |
6605 | if (dev->key) |
6606 | kbd = dev; |
6607 | else |
6608 | kbd = inputInfo.keyboard; |
6609 | acts = &dev->button->xkb_acts[stuff->firstBtn]; |
6610 | for (i = 0; i < stuff->nBtns; i++, acts++) { |
6611 | if (acts->type != XkbSA_NoAction0x00) |
6612 | XkbSetActionKeyMods(kbd->key->xkbInfo->desc, acts, 0); |
6613 | } |
6614 | } |
6615 | if (stuff->change & XkbXI_IndicatorsMask(0x001c)) { |
6616 | int status = Success0; |
6617 | |
6618 | wire = SetDeviceIndicators(wire, dev, stuff->change, |
6619 | stuff->nDeviceLedFBs, &status, client, &ed); |
6620 | if (status != Success0) |
6621 | return status; |
6622 | } |
6623 | if ((stuff->change) && (ed.reason)) |
6624 | XkbSendExtensionDeviceNotify(dev, client, &ed); |
6625 | return Success0; |
6626 | } |
6627 | |
6628 | int |
6629 | ProcXkbSetDeviceInfo(ClientPtr client) |
6630 | { |
6631 | DeviceIntPtr dev; |
6632 | int rc; |
6633 | |
6634 | REQUEST(xkbSetDeviceInfoReq)xkbSetDeviceInfoReq *stuff = (xkbSetDeviceInfoReq *)client-> requestBuffer; |
6635 | REQUEST_AT_LEAST_SIZE(xkbSetDeviceInfoReq)if ((sizeof(xkbSetDeviceInfoReq) >> 2) > client-> req_len ) return(16); |
6636 | |
6637 | if (!(client->xkbClientFlags & _XkbClientInitialized(1<<15))) |
6638 | return BadAccess10; |
6639 | |
6640 | CHK_ANY_DEVICE(dev, stuff->deviceSpec, client, DixManageAccess){ int why; int tmprc = _XkbLookupAnyDevice(&(dev), stuff-> deviceSpec, client, (1<<25), &why); if (tmprc != 0) { client->errorValue = ((XID)((((unsigned int)(why))<< 24)|((stuff->deviceSpec)&0xffffff))); return tmprc; }}; |
6641 | CHK_MASK_LEGAL(0x01, stuff->change, XkbXI_AllFeaturesMask){ if ((stuff->change)&(~((0x001f)))) { (client->errorValue )= ((XID)((((unsigned int)((0x01)))<<24)|((((stuff-> change)&(~((0x001f)))))&0xffffff))); return 2; }}; |
6642 | |
6643 | rc = _XkbSetDeviceInfoCheck(client, dev, stuff); |
6644 | |
6645 | if (rc != Success0) |
6646 | return rc; |
6647 | |
6648 | if (stuff->deviceSpec == XkbUseCoreKbd0x0100 || |
6649 | stuff->deviceSpec == XkbUseCorePtr0x0200) { |
6650 | DeviceIntPtr other; |
6651 | |
6652 | for (other = inputInfo.devices; other; other = other->next) { |
6653 | if (((other != dev) && !IsMaster(other) && |
6654 | GetMaster(other, MASTER_KEYBOARD2) == dev) && |
6655 | ((stuff->deviceSpec == XkbUseCoreKbd0x0100 && other->key) || |
6656 | (stuff->deviceSpec == XkbUseCorePtr0x0200 && other->button))) { |
6657 | rc = XaceHook(XACE_DEVICE_ACCESS3, client, other, |
6658 | DixManageAccess(1<<25)); |
6659 | if (rc == Success0) { |
6660 | rc = _XkbSetDeviceInfoCheck(client, other, stuff); |
6661 | if (rc != Success0) |
6662 | return rc; |
6663 | } |
6664 | } |
6665 | } |
6666 | } |
6667 | |
6668 | /* checks done, apply */ |
6669 | rc = _XkbSetDeviceInfo(client, dev, stuff); |
6670 | if (rc != Success0) |
6671 | return rc; |
6672 | |
6673 | if (stuff->deviceSpec == XkbUseCoreKbd0x0100 || |
6674 | stuff->deviceSpec == XkbUseCorePtr0x0200) { |
6675 | DeviceIntPtr other; |
6676 | |
6677 | for (other = inputInfo.devices; other; other = other->next) { |
6678 | if (((other != dev) && !IsMaster(other) && |
6679 | GetMaster(other, MASTER_KEYBOARD2) == dev) && |
6680 | ((stuff->deviceSpec == XkbUseCoreKbd0x0100 && other->key) || |
6681 | (stuff->deviceSpec == XkbUseCorePtr0x0200 && other->button))) { |
6682 | rc = XaceHook(XACE_DEVICE_ACCESS3, client, other, |
6683 | DixManageAccess(1<<25)); |
6684 | if (rc == Success0) { |
6685 | rc = _XkbSetDeviceInfo(client, other, stuff); |
6686 | if (rc != Success0) |
6687 | return rc; |
6688 | } |
6689 | } |
6690 | } |
6691 | } |
6692 | |
6693 | return Success0; |
6694 | } |
6695 | |
6696 | /***====================================================================***/ |
6697 | |
6698 | int |
6699 | ProcXkbSetDebuggingFlags(ClientPtr client) |
6700 | { |
6701 | CARD32 newFlags, newCtrls, extraLength; |
6702 | xkbSetDebuggingFlagsReply rep; |
6703 | int rc; |
6704 | |
6705 | REQUEST(xkbSetDebuggingFlagsReq)xkbSetDebuggingFlagsReq *stuff = (xkbSetDebuggingFlagsReq *)client ->requestBuffer; |
6706 | REQUEST_AT_LEAST_SIZE(xkbSetDebuggingFlagsReq)if ((sizeof(xkbSetDebuggingFlagsReq) >> 2) > client-> req_len ) return(16); |
6707 | |
6708 | rc = XaceHook(XACE_SERVER_ACCESS9, client, DixDebugAccess(1<<26)); |
6709 | if (rc != Success0) |
6710 | return rc; |
6711 | |
6712 | newFlags = xkbDebugFlags & (~stuff->affectFlags); |
6713 | newFlags |= (stuff->flags & stuff->affectFlags); |
6714 | newCtrls = xkbDebugCtrls & (~stuff->affectCtrls); |
6715 | newCtrls |= (stuff->ctrls & stuff->affectCtrls); |
6716 | if (xkbDebugFlags || newFlags || stuff->msgLength) { |
6717 | ErrorF("[xkb] XkbDebug: Setting debug flags to 0x%lx\n", |
6718 | (long) newFlags); |
6719 | if (newCtrls != xkbDebugCtrls) |
6720 | ErrorF("[xkb] XkbDebug: Setting debug controls to 0x%lx\n", |
6721 | (long) newCtrls); |
6722 | } |
6723 | extraLength = (stuff->length << 2) - sz_xkbSetDebuggingFlagsReq24; |
6724 | if (stuff->msgLength > 0) { |
6725 | char *msg; |
6726 | |
6727 | if (extraLength < XkbPaddedSize(stuff->msgLength)((((unsigned int)(stuff->msgLength)+3) >> 2) << 2)) { |
6728 | ErrorF |
6729 | ("[xkb] XkbDebug: msgLength= %d, length= %ld (should be %d)\n", |
6730 | stuff->msgLength, (long) extraLength, |
6731 | XkbPaddedSize(stuff->msgLength)((((unsigned int)(stuff->msgLength)+3) >> 2) << 2)); |
6732 | return BadLength16; |
6733 | } |
6734 | msg = (char *) &stuff[1]; |
6735 | if (msg[stuff->msgLength - 1] != '\0') { |
6736 | ErrorF("[xkb] XkbDebug: message not null-terminated\n"); |
6737 | return BadValue2; |
6738 | } |
6739 | ErrorF("[xkb] XkbDebug: %s\n", msg); |
6740 | } |
6741 | xkbDebugFlags = newFlags; |
6742 | xkbDebugCtrls = newCtrls; |
6743 | |
6744 | rep = (xkbSetDebuggingFlagsReply) { |
6745 | .type = X_Reply1, |
6746 | .sequenceNumber = client->sequence, |
6747 | .length = 0, |
6748 | .currentFlags = newFlags, |
6749 | .currentCtrls = newCtrls, |
6750 | .supportedFlags = ~0, |
6751 | .supportedCtrls = ~0 |
6752 | }; |
6753 | if (client->swapped) { |
6754 | swaps(&rep.sequenceNumber)do { if (sizeof(*(&rep.sequenceNumber)) != 2) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&rep.sequenceNumber ) & 1) && ((uintptr_t)(&rep.sequenceNumber) & 1) == 0) *(&rep.sequenceNumber) = lswaps(*(&rep.sequenceNumber )); else swap_uint16((uint16_t *)(&rep.sequenceNumber)); } while (0); |
6755 | swapl(&rep.currentFlags)do { if (sizeof(*(&rep.currentFlags)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&rep.currentFlags) & 3) && ((uintptr_t)(&rep.currentFlags) & 3) == 0) *(&rep.currentFlags) = lswapl(*(&rep.currentFlags )); else swap_uint32((uint32_t *)(&rep.currentFlags)); } while (0); |
6756 | swapl(&rep.currentCtrls)do { if (sizeof(*(&rep.currentCtrls)) != 4) wrong_size(); if (__builtin_constant_p((uintptr_t)(&rep.currentCtrls) & 3) && ((uintptr_t)(&rep.currentCtrls) & 3) == 0) *(&rep.currentCtrls) = lswapl(*(&rep.currentCtrls )); else swap_uint32((uint32_t *)(&rep.currentCtrls)); } while (0); |
6757 | swapl(&rep.supportedFlags)do { if (sizeof(*(&rep.supportedFlags)) != 4) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&rep.supportedFlags ) & 3) && ((uintptr_t)(&rep.supportedFlags) & 3) == 0) *(&rep.supportedFlags) = lswapl(*(&rep.supportedFlags )); else swap_uint32((uint32_t *)(&rep.supportedFlags)); } while (0); |
6758 | swapl(&rep.supportedCtrls)do { if (sizeof(*(&rep.supportedCtrls)) != 4) wrong_size( ); if (__builtin_constant_p((uintptr_t)(&rep.supportedCtrls ) & 3) && ((uintptr_t)(&rep.supportedCtrls) & 3) == 0) *(&rep.supportedCtrls) = lswapl(*(&rep.supportedCtrls )); else swap_uint32((uint32_t *)(&rep.supportedCtrls)); } while (0); |
6759 | } |
6760 | WriteToClient(client, SIZEOF(xkbSetDebuggingFlagsReply)32, &rep); |
6761 | return Success0; |
6762 | } |
6763 | |
6764 | /***====================================================================***/ |
6765 | |
6766 | static int |
6767 | ProcXkbDispatch(ClientPtr client) |
6768 | { |
6769 | REQUEST(xReq)xReq *stuff = (xReq *)client->requestBuffer; |
6770 | switch (stuff->data) { |
6771 | case X_kbUseExtension0: |
6772 | return ProcXkbUseExtension(client); |
6773 | case X_kbSelectEvents1: |
6774 | return ProcXkbSelectEvents(client); |
6775 | case X_kbBell3: |
6776 | return ProcXkbBell(client); |
6777 | case X_kbGetState4: |
6778 | return ProcXkbGetState(client); |
6779 | case X_kbLatchLockState5: |
6780 | return ProcXkbLatchLockState(client); |
6781 | case X_kbGetControls6: |
6782 | return ProcXkbGetControls(client); |
6783 | case X_kbSetControls7: |
6784 | return ProcXkbSetControls(client); |
6785 | case X_kbGetMap8: |
6786 | return ProcXkbGetMap(client); |
6787 | case X_kbSetMap9: |
6788 | return ProcXkbSetMap(client); |
6789 | case X_kbGetCompatMap10: |
6790 | return ProcXkbGetCompatMap(client); |
6791 | case X_kbSetCompatMap11: |
6792 | return ProcXkbSetCompatMap(client); |
6793 | case X_kbGetIndicatorState12: |
6794 | return ProcXkbGetIndicatorState(client); |
6795 | case X_kbGetIndicatorMap13: |
6796 | return ProcXkbGetIndicatorMap(client); |
6797 | case X_kbSetIndicatorMap14: |
6798 | return ProcXkbSetIndicatorMap(client); |
6799 | case X_kbGetNamedIndicator15: |
6800 | return ProcXkbGetNamedIndicator(client); |
6801 | case X_kbSetNamedIndicator16: |
6802 | return ProcXkbSetNamedIndicator(client); |
6803 | case X_kbGetNames17: |
6804 | return ProcXkbGetNames(client); |
6805 | case X_kbSetNames18: |
6806 | return ProcXkbSetNames(client); |
6807 | case X_kbGetGeometry19: |
6808 | return ProcXkbGetGeometry(client); |
6809 | case X_kbSetGeometry20: |
6810 | return ProcXkbSetGeometry(client); |
6811 | case X_kbPerClientFlags21: |
6812 | return ProcXkbPerClientFlags(client); |
6813 | case X_kbListComponents22: |
6814 | return ProcXkbListComponents(client); |
6815 | case X_kbGetKbdByName23: |
6816 | return ProcXkbGetKbdByName(client); |
6817 | case X_kbGetDeviceInfo24: |
6818 | return ProcXkbGetDeviceInfo(client); |
6819 | case X_kbSetDeviceInfo25: |
6820 | return ProcXkbSetDeviceInfo(client); |
6821 | case X_kbSetDebuggingFlags101: |
6822 | return ProcXkbSetDebuggingFlags(client); |
6823 | default: |
6824 | return BadRequest1; |
6825 | } |
6826 | } |
6827 | |
6828 | static int |
6829 | XkbClientGone(void *data, XID id) |
6830 | { |
6831 | DevicePtr pXDev = (DevicePtr) data; |
6832 | |
6833 | if (!XkbRemoveResourceClient(pXDev, id)) { |
6834 | ErrorF |
6835 | ("[xkb] Internal Error! bad RemoveResourceClient in XkbClientGone\n"); |
6836 | } |
6837 | return 1; |
6838 | } |
6839 | |
6840 | void |
6841 | XkbExtensionInit(void) |
6842 | { |
6843 | ExtensionEntry *extEntry; |
6844 | |
6845 | RT_XKBCLIENT = CreateNewResourceType(XkbClientGone, "XkbClient"); |
6846 | if (!RT_XKBCLIENT) |
6847 | return; |
6848 | |
6849 | if (!XkbInitPrivates()) |
6850 | return; |
6851 | |
6852 | if ((extEntry = AddExtension(XkbName"XKEYBOARD", XkbNumberEvents(0 +1), XkbNumberErrors1, |
6853 | ProcXkbDispatch, SProcXkbDispatch, |
6854 | NULL((void*)0), StandardMinorOpcode))) { |
6855 | XkbReqCode = (unsigned char) extEntry->base; |
6856 | XkbEventBase = (unsigned char) extEntry->eventBase; |
6857 | XkbErrorBase = (unsigned char) extEntry->errorBase; |
6858 | XkbKeyboardErrorCode = XkbErrorBase + XkbKeyboard0; |
6859 | } |
6860 | return; |
6861 | } |