| 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 | if (xkbi->radioGroups) |
| 2220 | xkbi->radioGroups = reallocarrayxreallocarray(xkbi->radioGroups, maxRG, |
| 2221 | sizeof(XkbRadioGroupRec)); |
| 2222 | else |
| 2223 | xkbi->radioGroups = calloc(maxRG, sizeof(XkbRadioGroupRec)); |
| 2224 | if (xkbi->radioGroups) { |
| 2225 | if (xkbi->nRadioGroups) |
| 2226 | 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)) |
| 2227 | (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)); |
| 2228 | xkbi->nRadioGroups = maxRG; |
| 2229 | } |
| 2230 | else |
| 2231 | xkbi->nRadioGroups = 0; |
| 2232 | /* should compute members here */ |
| 2233 | } |
| 2234 | if (changes->map.changed & XkbKeyBehaviorsMask(1<<5)) { |
| 2235 | unsigned oldLast; |
| 2236 | |
| 2237 | oldLast = changes->map.first_key_behavior + |
| 2238 | changes->map.num_key_behaviors - 1; |
| 2239 | if (changes->map.first_key_behavior < req->firstKeyBehavior) |
| 2240 | first = changes->map.first_key_behavior; |
| 2241 | if (oldLast > last) |
| 2242 | last = oldLast; |
| 2243 | } |
| 2244 | changes->map.changed |= XkbKeyBehaviorsMask(1<<5); |
| 2245 | changes->map.first_key_behavior = first; |
| 2246 | changes->map.num_key_behaviors = (last - first + 1); |
| 2247 | return (char *) wire; |
| 2248 | } |
| 2249 | |
| 2250 | static char * |
| 2251 | SetVirtualMods(XkbSrvInfoPtr xkbi, xkbSetMapReq * req, CARD8 *wire, |
| 2252 | XkbChangesPtr changes) |
| 2253 | { |
| 2254 | register int i, bit, nMods; |
| 2255 | XkbServerMapPtr srv = xkbi->desc->server; |
| 2256 | |
| 2257 | if (((req->present & XkbVirtualModsMask(1<<6)) == 0) || (req->virtualMods == 0)) |
| 2258 | return (char *) wire; |
| 2259 | for (i = nMods = 0, bit = 1; i < XkbNumVirtualMods16; i++, bit <<= 1) { |
| 2260 | if (req->virtualMods & bit) { |
| 2261 | if (srv->vmods[i] != wire[nMods]) { |
| 2262 | changes->map.changed |= XkbVirtualModsMask(1<<6); |
| 2263 | changes->map.vmods |= bit; |
| 2264 | srv->vmods[i] = wire[nMods]; |
| 2265 | } |
| 2266 | nMods++; |
| 2267 | } |
| 2268 | } |
| 2269 | return (char *) (wire + XkbPaddedSize(nMods)((((unsigned int)(nMods)+3) >> 2) << 2)); |
| 2270 | } |
| 2271 | |
| 2272 | static char * |
| 2273 | SetKeyExplicit(XkbSrvInfoPtr xkbi, xkbSetMapReq * req, CARD8 *wire, |
| 2274 | XkbChangesPtr changes) |
| 2275 | { |
| 2276 | register unsigned i, first, last; |
| 2277 | XkbServerMapPtr xkb = xkbi->desc->server; |
| 2278 | CARD8 *start; |
| 2279 | |
| 2280 | start = wire; |
| 2281 | first = req->firstKeyExplicit; |
| 2282 | last = req->firstKeyExplicit + req->nKeyExplicit - 1; |
| 2283 | memset(&xkb->explicit[first], 0, req->nKeyExplicit)__builtin___memset_chk (&xkb->explicit[first], 0, req-> nKeyExplicit, __builtin_object_size (&xkb->explicit[first ], 0)); |
| 2284 | for (i = 0; i < req->totalKeyExplicit; i++, wire += 2) { |
| 2285 | xkb->explicit[wire[0]] = wire[1]; |
| 2286 | } |
| 2287 | if (first > 0) { |
| 2288 | if (changes->map.changed & XkbExplicitComponentsMask(1<<3)) { |
| 2289 | int oldLast; |
| 2290 | |
| 2291 | oldLast = changes->map.first_key_explicit + |
| 2292 | changes->map.num_key_explicit - 1; |
| 2293 | if (changes->map.first_key_explicit < first) |
| 2294 | first = changes->map.first_key_explicit; |
| 2295 | if (oldLast > last) |
| 2296 | last = oldLast; |
| 2297 | } |
| 2298 | changes->map.first_key_explicit = first; |
| 2299 | changes->map.num_key_explicit = (last - first) + 1; |
| 2300 | } |
| 2301 | wire += XkbPaddedSize(wire - start)((((unsigned int)(wire - start)+3) >> 2) << 2) - (wire - start); |
| 2302 | return (char *) wire; |
| 2303 | } |
| 2304 | |
| 2305 | static char * |
| 2306 | SetModifierMap(XkbSrvInfoPtr xkbi, |
| 2307 | xkbSetMapReq * req, CARD8 *wire, XkbChangesPtr changes) |
| 2308 | { |
| 2309 | register unsigned i, first, last; |
| 2310 | XkbClientMapPtr xkb = xkbi->desc->map; |
| 2311 | CARD8 *start; |
| 2312 | |
| 2313 | start = wire; |
| 2314 | first = req->firstModMapKey; |
| 2315 | last = req->firstModMapKey + req->nModMapKeys - 1; |
| 2316 | memset(&xkb->modmap[first], 0, req->nModMapKeys)__builtin___memset_chk (&xkb->modmap[first], 0, req-> nModMapKeys, __builtin_object_size (&xkb->modmap[first ], 0)); |
| 2317 | for (i = 0; i < req->totalModMapKeys; i++, wire += 2) { |
| 2318 | xkb->modmap[wire[0]] = wire[1]; |
| 2319 | } |
| 2320 | if (first > 0) { |
| 2321 | if (changes->map.changed & XkbModifierMapMask(1<<2)) { |
| 2322 | int oldLast; |
| 2323 | |
| 2324 | oldLast = changes->map.first_modmap_key + |
| 2325 | changes->map.num_modmap_keys - 1; |
| 2326 | if (changes->map.first_modmap_key < first) |
| 2327 | first = changes->map.first_modmap_key; |
| 2328 | if (oldLast > last) |
| 2329 | last = oldLast; |
| 2330 | } |
| 2331 | changes->map.first_modmap_key = first; |
| 2332 | changes->map.num_modmap_keys = (last - first) + 1; |
| 2333 | } |
| 2334 | wire += XkbPaddedSize(wire - start)((((unsigned int)(wire - start)+3) >> 2) << 2) - (wire - start); |
| 2335 | return (char *) wire; |
| 2336 | } |
| 2337 | |
| 2338 | static char * |
| 2339 | SetVirtualModMap(XkbSrvInfoPtr xkbi, |
| 2340 | xkbSetMapReq * req, |
| 2341 | xkbVModMapWireDesc * wire, XkbChangesPtr changes) |
| 2342 | { |
| 2343 | register unsigned i, first, last; |
| 2344 | XkbServerMapPtr srv = xkbi->desc->server; |
| 2345 | |
| 2346 | first = req->firstVModMapKey; |
| 2347 | last = req->firstVModMapKey + req->nVModMapKeys - 1; |
| 2348 | 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)); |
| 2349 | for (i = 0; i < req->totalVModMapKeys; i++, wire++) { |
| 2350 | srv->vmodmap[wire->key] = wire->vmods; |
| 2351 | } |
| 2352 | if (first > 0) { |
| 2353 | if (changes->map.changed & XkbVirtualModMapMask(1<<7)) { |
| 2354 | int oldLast; |
| 2355 | |
| 2356 | oldLast = changes->map.first_vmodmap_key + |
| 2357 | changes->map.num_vmodmap_keys - 1; |
| 2358 | if (changes->map.first_vmodmap_key < first) |
| 2359 | first = changes->map.first_vmodmap_key; |
| 2360 | if (oldLast > last) |
| 2361 | last = oldLast; |
| 2362 | } |
| 2363 | changes->map.first_vmodmap_key = first; |
| 2364 | changes->map.num_vmodmap_keys = (last - first) + 1; |
| 2365 | } |
| 2366 | return (char *) wire; |
| 2367 | } |
| 2368 | |
| 2369 | /** |
| 2370 | * Check if the given request can be applied to the given device but don't |
| 2371 | * actually do anything.. |
| 2372 | */ |
| 2373 | static int |
| 2374 | _XkbSetMapChecks(ClientPtr client, DeviceIntPtr dev, xkbSetMapReq * req, |
| 2375 | char *values) |
| 2376 | { |
| 2377 | XkbSrvInfoPtr xkbi; |
| 2378 | XkbDescPtr xkb; |
| 2379 | int error; |
| 2380 | int nTypes = 0, nActions; |
| 2381 | CARD8 mapWidths[XkbMaxLegalKeyCode255 + 1] = { 0 }; |
| 2382 | CARD16 symsPerKey[XkbMaxLegalKeyCode255 + 1] = { 0 }; |
| 2383 | XkbSymMapPtr map; |
| 2384 | int i; |
| 2385 | |
| 2386 | xkbi = dev->key->xkbInfo; |
| 2387 | xkb = xkbi->desc; |
| 2388 | |
| 2389 | if ((xkb->min_key_code != req->minKeyCode) || |
| 2390 | (xkb->max_key_code != req->maxKeyCode)) { |
| 2391 | if (client->vMajor != 1) { /* pre 1.0 versions of Xlib have a bug */ |
| 2392 | req->minKeyCode = xkb->min_key_code; |
| 2393 | req->maxKeyCode = xkb->max_key_code; |
| 2394 | } |
| 2395 | else { |
| 2396 | if (!XkbIsLegalKeycode(req->minKeyCode)((req->minKeyCode)>=8)) { |
| 2397 | client->errorValue = |
| 2398 | _XkbErrCode3(2, req->minKeyCode, req->maxKeyCode)((XID)((((unsigned int)(2))<<24)|(((((unsigned int)(req ->minKeyCode))<<16)|(req->maxKeyCode))&0xffffff ))); |
| 2399 | return BadValue2; |
| 2400 | } |
| 2401 | if (req->minKeyCode > req->maxKeyCode) { |
| 2402 | client->errorValue = |
| 2403 | _XkbErrCode3(3, req->minKeyCode, req->maxKeyCode)((XID)((((unsigned int)(3))<<24)|(((((unsigned int)(req ->minKeyCode))<<16)|(req->maxKeyCode))&0xffffff ))); |
| 2404 | return BadMatch8; |
| 2405 | } |
| 2406 | } |
| 2407 | } |
| 2408 | |
| 2409 | if ((req->present & XkbKeyTypesMask(1<<0)) && |
| 2410 | (!CheckKeyTypes(client, xkb, req, (xkbKeyTypeWireDesc **) &values, |
| 2411 | &nTypes, mapWidths))) { |
| 2412 | client->errorValue = nTypes; |
| 2413 | return BadValue2; |
| 2414 | } |
| 2415 | |
| 2416 | /* symsPerKey/mapWidths must be filled regardless of client-side flags */ |
| 2417 | map = &xkb->map->key_sym_map[xkb->min_key_code]; |
| 2418 | for (i = xkb->min_key_code; i < xkb->max_key_code; i++, map++) { |
| 2419 | register int g, ng, w; |
| 2420 | |
| 2421 | ng = XkbNumGroups(map->group_info)((map->group_info)&0x0f); |
| 2422 | for (w = g = 0; g < ng; g++) { |
| 2423 | if (map->kt_index[g] >= (unsigned) nTypes) { |
| 2424 | 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))); |
| 2425 | return 0; |
| 2426 | } |
| 2427 | if (mapWidths[map->kt_index[g]] > w) |
| 2428 | w = mapWidths[map->kt_index[g]]; |
| 2429 | } |
| 2430 | symsPerKey[i] = w * ng; |
| 2431 | } |
| 2432 | |
| 2433 | if ((req->present & XkbKeySymsMask(1<<1)) && |
| 2434 | (!CheckKeySyms(client, xkb, req, nTypes, mapWidths, symsPerKey, |
| 2435 | (xkbSymMapWireDesc **) &values, &error))) { |
| 2436 | client->errorValue = error; |
| 2437 | return BadValue2; |
| 2438 | } |
| 2439 | |
| 2440 | if ((req->present & XkbKeyActionsMask(1<<4)) && |
| 2441 | (!CheckKeyActions(xkb, req, nTypes, mapWidths, symsPerKey, |
| 2442 | (CARD8 **) &values, &nActions))) { |
| 2443 | client->errorValue = nActions; |
| 2444 | return BadValue2; |
| 2445 | } |
| 2446 | |
| 2447 | if ((req->present & XkbKeyBehaviorsMask(1<<5)) && |
| 2448 | (!CheckKeyBehaviors |
| 2449 | (xkb, req, (xkbBehaviorWireDesc **) &values, &error))) { |
| 2450 | client->errorValue = error; |
| 2451 | return BadValue2; |
| 2452 | } |
| 2453 | |
| 2454 | if ((req->present & XkbVirtualModsMask(1<<6)) && |
| 2455 | (!CheckVirtualMods(xkb, req, (CARD8 **) &values, &error))) { |
| 2456 | client->errorValue = error; |
| 2457 | return BadValue2; |
| 2458 | } |
| 2459 | if ((req->present & XkbExplicitComponentsMask(1<<3)) && |
| 2460 | (!CheckKeyExplicit(xkb, req, (CARD8 **) &values, &error))) { |
| 2461 | client->errorValue = error; |
| 2462 | return BadValue2; |
| 2463 | } |
| 2464 | if ((req->present & XkbModifierMapMask(1<<2)) && |
| 2465 | (!CheckModifierMap(xkb, req, (CARD8 **) &values, &error))) { |
| 2466 | client->errorValue = error; |
| 2467 | return BadValue2; |
| 2468 | } |
| 2469 | if ((req->present & XkbVirtualModMapMask(1<<7)) && |
| 2470 | (!CheckVirtualModMap |
| 2471 | (xkb, req, (xkbVModMapWireDesc **) &values, &error))) { |
| 2472 | client->errorValue = error; |
| 2473 | return BadValue2; |
| 2474 | } |
| 2475 | |
| 2476 | if (((values - ((char *) req)) / 4) != req->length) { |
| 2477 | ErrorF("[xkb] Internal error! Bad length in XkbSetMap (after check)\n"); |
| 2478 | client->errorValue = values - ((char *) &req[1]); |
| 2479 | return BadLength16; |
| 2480 | } |
| 2481 | |
| 2482 | return Success0; |
| 2483 | } |
| 2484 | |
| 2485 | /** |
| 2486 | * Apply the given request on the given device. |
| 2487 | */ |
| 2488 | static int |
| 2489 | _XkbSetMap(ClientPtr client, DeviceIntPtr dev, xkbSetMapReq * req, char *values) |
| 2490 | { |
| 2491 | XkbEventCauseRec cause; |
| 2492 | XkbChangesRec change; |
| 2493 | Bool sentNKN; |
| 2494 | XkbSrvInfoPtr xkbi; |
| 2495 | XkbDescPtr xkb; |
| 2496 | |
| 2497 | xkbi = dev->key->xkbInfo; |
| 2498 | xkb = xkbi->desc; |
| 2499 | |
| 2500 | XkbSetCauseXkbReq(&cause, X_kbSetMap, client){ (&cause)->kc= (&cause)->event= 0, (&cause )->mjr= (XkbReqCode),(&cause)->mnr= (9); (&cause )->client= (client); }; |
| 2501 | memset(&change, 0, sizeof(change))__builtin___memset_chk (&change, 0, sizeof(change), __builtin_object_size (&change, 0)); |
| 2502 | sentNKN = FALSE0; |
| 2503 | if ((xkb->min_key_code != req->minKeyCode) || |
| 2504 | (xkb->max_key_code != req->maxKeyCode)) { |
| 2505 | Statusint status; |
| 2506 | xkbNewKeyboardNotify nkn; |
| 2507 | |
| 2508 | nkn.deviceID = nkn.oldDeviceID = dev->id; |
| 2509 | nkn.oldMinKeyCode = xkb->min_key_code; |
| 2510 | nkn.oldMaxKeyCode = xkb->max_key_code; |
| 2511 | status = XkbChangeKeycodeRangeSrvXkbChangeKeycodeRange(xkb, req->minKeyCode, |
| 2512 | req->maxKeyCode, &change); |
| 2513 | if (status != Success0) |
| 2514 | return status; /* oh-oh. what about the other keyboards? */ |
| 2515 | nkn.minKeyCode = xkb->min_key_code; |
| 2516 | nkn.maxKeyCode = xkb->max_key_code; |
| 2517 | nkn.requestMajor = XkbReqCode; |
| 2518 | nkn.requestMinor = X_kbSetMap9; |
| 2519 | nkn.changed = XkbNKN_KeycodesMask(1L << 0); |
| 2520 | XkbSendNewKeyboardNotify(dev, &nkn); |
| 2521 | sentNKN = TRUE1; |
| 2522 | } |
| 2523 | |
| 2524 | if (req->present & XkbKeyTypesMask(1<<0)) { |
| 2525 | values = SetKeyTypes(xkb, req, (xkbKeyTypeWireDesc *) values, &change); |
| 2526 | if (!values) |
| 2527 | goto allocFailure; |
| 2528 | } |
| 2529 | if (req->present & XkbKeySymsMask(1<<1)) { |
| 2530 | values = |
| 2531 | SetKeySyms(client, xkb, req, (xkbSymMapWireDesc *) values, &change, |
| 2532 | dev); |
| 2533 | if (!values) |
| 2534 | goto allocFailure; |
| 2535 | } |
| 2536 | if (req->present & XkbKeyActionsMask(1<<4)) { |
| 2537 | values = SetKeyActions(xkb, req, (CARD8 *) values, &change); |
| 2538 | if (!values) |
| 2539 | goto allocFailure; |
| 2540 | } |
| 2541 | if (req->present & XkbKeyBehaviorsMask(1<<5)) { |
| 2542 | values = |
| 2543 | SetKeyBehaviors(xkbi, req, (xkbBehaviorWireDesc *) values, &change); |
| 2544 | if (!values) |
| 2545 | goto allocFailure; |
| 2546 | } |
| 2547 | if (req->present & XkbVirtualModsMask(1<<6)) |
| 2548 | values = SetVirtualMods(xkbi, req, (CARD8 *) values, &change); |
| 2549 | if (req->present & XkbExplicitComponentsMask(1<<3)) |
| 2550 | values = SetKeyExplicit(xkbi, req, (CARD8 *) values, &change); |
| 2551 | if (req->present & XkbModifierMapMask(1<<2)) |
| 2552 | values = SetModifierMap(xkbi, req, (CARD8 *) values, &change); |
| 2553 | if (req->present & XkbVirtualModMapMask(1<<7)) |
| 2554 | values = |
| 2555 | SetVirtualModMap(xkbi, req, (xkbVModMapWireDesc *) values, &change); |
| 2556 | if (((values - ((char *) req)) / 4) != req->length) { |
| 2557 | ErrorF("[xkb] Internal error! Bad length in XkbSetMap (after set)\n"); |
| 2558 | client->errorValue = values - ((char *) &req[1]); |
| 2559 | return BadLength16; |
| 2560 | } |
| 2561 | if (req->flags & XkbSetMapRecomputeActions(1L<<1)) { |
| 2562 | KeyCode first, last, firstMM, lastMM; |
| 2563 | |
| 2564 | if (change.map.num_key_syms > 0) { |
| 2565 | first = change.map.first_key_sym; |
| 2566 | last = first + change.map.num_key_syms - 1; |
| 2567 | } |
| 2568 | else |
| 2569 | first = last = 0; |
| 2570 | if (change.map.num_modmap_keys > 0) { |
| 2571 | firstMM = change.map.first_modmap_key; |
| 2572 | lastMM = first + change.map.num_modmap_keys - 1; |
| 2573 | } |
| 2574 | else |
| 2575 | firstMM = lastMM = 0; |
| 2576 | if ((last > 0) && (lastMM > 0)) { |
| 2577 | if (firstMM < first) |
| 2578 | first = firstMM; |
| 2579 | if (lastMM > last) |
| 2580 | last = lastMM; |
| 2581 | } |
| 2582 | else if (lastMM > 0) { |
| 2583 | first = firstMM; |
| 2584 | last = lastMM; |
| 2585 | } |
| 2586 | if (last > 0) { |
| 2587 | unsigned check = 0; |
| 2588 | |
| 2589 | XkbUpdateActions(dev, first, (last - first + 1), &change, &check, |
| 2590 | &cause); |
| 2591 | if (check) |
| 2592 | XkbCheckSecondaryEffects(xkbi, check, &change, &cause); |
| 2593 | } |
| 2594 | } |
| 2595 | if (!sentNKN) |
| 2596 | XkbSendNotification(dev, &change, &cause); |
| 2597 | |
| 2598 | return Success0; |
| 2599 | allocFailure: |
| 2600 | return BadAlloc11; |
| 2601 | } |
| 2602 | |
| 2603 | int |
| 2604 | ProcXkbSetMap(ClientPtr client) |
| 2605 | { |
| 2606 | DeviceIntPtr dev; |
| 2607 | char *tmp; |
| 2608 | int rc; |
| 2609 | |
| 2610 | REQUEST(xkbSetMapReq)xkbSetMapReq *stuff = (xkbSetMapReq *)client->requestBuffer; |
| 2611 | REQUEST_AT_LEAST_SIZE(xkbSetMapReq)if ((sizeof(xkbSetMapReq) >> 2) > client->req_len ) return(16); |
| 2612 | |
| 2613 | if (!(client->xkbClientFlags & _XkbClientInitialized(1<<15))) |
| 2614 | return BadAccess10; |
| 2615 | |
| 2616 | 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; }}; |
| 2617 | 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; }}; |
| 2618 | |
| 2619 | tmp = (char *) &stuff[1]; |
| 2620 | |
| 2621 | /* Check if we can to the SetMap on the requested device. If this |
| 2622 | succeeds, do the same thing for all extension devices (if needed). |
| 2623 | If any of them fails, fail. */ |
| 2624 | rc = _XkbSetMapChecks(client, dev, stuff, tmp); |
| 2625 | |
| 2626 | if (rc != Success0) |
| 2627 | return rc; |
| 2628 | |
| 2629 | if (stuff->deviceSpec == XkbUseCoreKbd0x0100) { |
| 2630 | DeviceIntPtr other; |
| 2631 | |
| 2632 | for (other = inputInfo.devices; other; other = other->next) { |
| 2633 | if ((other != dev) && other->key && !IsMaster(other) && |
| 2634 | GetMaster(other, MASTER_KEYBOARD2) == dev) { |
| 2635 | rc = XaceHook(XACE_DEVICE_ACCESS3, client, other, |
| 2636 | DixManageAccess(1<<25)); |
| 2637 | if (rc == Success0) { |
| 2638 | rc = _XkbSetMapChecks(client, other, stuff, tmp); |
| 2639 | if (rc != Success0) |
| 2640 | return rc; |
| 2641 | } |
| 2642 | } |
| 2643 | } |
| 2644 | } |
| 2645 | |
| 2646 | /* We know now that we will succed with the SetMap. In theory anyway. */ |
| 2647 | rc = _XkbSetMap(client, dev, stuff, tmp); |
| 2648 | if (rc != Success0) |
| 2649 | return rc; |
| 2650 | |
| 2651 | if (stuff->deviceSpec == XkbUseCoreKbd0x0100) { |
| 2652 | DeviceIntPtr other; |
| 2653 | |
| 2654 | for (other = inputInfo.devices; other; other = other->next) { |
| 2655 | if ((other != dev) && other->key && !IsMaster(other) && |
| 2656 | GetMaster(other, MASTER_KEYBOARD2) == dev) { |
| 2657 | rc = XaceHook(XACE_DEVICE_ACCESS3, client, other, |
| 2658 | DixManageAccess(1<<25)); |
| 2659 | if (rc == Success0) |
| 2660 | _XkbSetMap(client, other, stuff, tmp); |
| 2661 | /* ignore rc. if the SetMap failed although the check above |
| 2662 | reported true there isn't much we can do. we still need to |
| 2663 | set all other devices, hoping that at least they stay in |
| 2664 | sync. */ |
| 2665 | } |
| 2666 | } |
| 2667 | } |
| 2668 | |
| 2669 | return Success0; |
| 2670 | } |
| 2671 | |
| 2672 | /***====================================================================***/ |
| 2673 | |
| 2674 | static Statusint |
| 2675 | XkbComputeGetCompatMapReplySize(XkbCompatMapPtr compat, |
| 2676 | xkbGetCompatMapReply * rep) |
| 2677 | { |
| 2678 | unsigned size, nGroups; |
| 2679 | |
| 2680 | nGroups = 0; |
| 2681 | if (rep->groups != 0) { |
| 2682 | register int i, bit; |
| 2683 | |
| 2684 | for (i = 0, bit = 1; i < XkbNumKbdGroups4; i++, bit <<= 1) { |
| 2685 | if (rep->groups & bit) |
| 2686 | nGroups++; |
| 2687 | } |
| 2688 | } |
| 2689 | size = nGroups * SIZEOF(xkbModsWireDesc)4; |
| 2690 | size += (rep->nSI * SIZEOF(xkbSymInterpretWireDesc)16); |
| 2691 | rep->length = size / 4; |
| 2692 | return Success0; |
| 2693 | } |
| 2694 | |
| 2695 | static int |
| 2696 | XkbSendCompatMap(ClientPtr client, |
| 2697 | XkbCompatMapPtr compat, xkbGetCompatMapReply * rep) |
| 2698 | { |
| 2699 | char *data; |
| 2700 | int size; |
| 2701 | |
| 2702 | if (rep->length > 0) { |
| 2703 | data = xallocarray(rep->length, 4)xreallocarray(((void*)0), (rep->length), (4)); |
| 2704 | if (data) { |
| 2705 | register unsigned i, bit; |
| 2706 | xkbModsWireDesc *grp; |
| 2707 | XkbSymInterpretPtr sym = &compat->sym_interpret[rep->firstSI]; |
| 2708 | xkbSymInterpretWireDesc *wire = (xkbSymInterpretWireDesc *) data; |
| 2709 | |
| 2710 | size = rep->length * 4; |
| 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 = reallocarrayxreallocarray(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 | if (rep->length > 0) { |
| 3090 | CARD8 *to; |
| 3091 | |
| 3092 | to = map = xallocarray(rep->length, 4)xreallocarray(((void*)0), (rep->length), (4)); |
| 3093 | if (map) { |
| 3094 | xkbIndicatorMapWireDesc *wire = (xkbIndicatorMapWireDesc *) to; |
| 3095 | |
| 3096 | length = rep->length * 4; |
| 3097 | |
| 3098 | for (i = 0, bit = 1; i < XkbNumIndicators32; i++, bit <<= 1) { |
| 3099 | if (rep->which & bit) { |
| 3100 | wire->flags = indicators->maps[i].flags; |
| 3101 | wire->whichGroups = indicators->maps[i].which_groups; |
| 3102 | wire->groups = indicators->maps[i].groups; |
| 3103 | wire->whichMods = indicators->maps[i].which_mods; |
| 3104 | wire->mods = indicators->maps[i].mods.mask; |
| 3105 | wire->realMods = indicators->maps[i].mods.real_mods; |
| 3106 | wire->virtualMods = indicators->maps[i].mods.vmods; |
| 3107 | wire->ctrls = indicators->maps[i].ctrls; |
| 3108 | if (client->swapped) { |
| 3109 | 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); |
| 3110 | 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); |
| 3111 | } |
| 3112 | wire++; |
| 3113 | } |
| 3114 | } |
| 3115 | to = (CARD8 *) wire; |
| 3116 | if ((to - map) != length) { |
| 3117 | client->errorValue = _XkbErrCode2(0xff, length)((XID)((((unsigned int)(0xff))<<24)|((length)&0xffffff ))); |
| 3118 | free(map); |
| 3119 | return BadLength16; |
| 3120 | } |
| 3121 | } |
| 3122 | else |
| 3123 | return BadAlloc11; |
| 3124 | } |
| 3125 | else |
| 3126 | map = NULL((void*)0); |
| 3127 | if (client->swapped) { |
| 3128 | 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); |
| 3129 | 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); |
| 3130 | 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); |
| 3131 | 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); |
| 3132 | } |
| 3133 | WriteToClient(client, SIZEOF(xkbGetIndicatorMapReply)32, rep); |
| 3134 | if (map) { |
| 3135 | WriteToClient(client, length, map); |
| 3136 | free((char *) map); |
| 3137 | } |
| 3138 | return Success0; |
| 3139 | } |
| 3140 | |
| 3141 | int |
| 3142 | ProcXkbGetIndicatorMap(ClientPtr client) |
| 3143 | { |
| 3144 | xkbGetIndicatorMapReply rep; |
| 3145 | DeviceIntPtr dev; |
| 3146 | XkbDescPtr xkb; |
| 3147 | XkbIndicatorPtr leds; |
| 3148 | |
| 3149 | REQUEST(xkbGetIndicatorMapReq)xkbGetIndicatorMapReq *stuff = (xkbGetIndicatorMapReq *)client ->requestBuffer; |
| 3150 | REQUEST_SIZE_MATCH(xkbGetIndicatorMapReq)if ((sizeof(xkbGetIndicatorMapReq) >> 2) != client-> req_len) return(16); |
| 3151 | |
| 3152 | if (!(client->xkbClientFlags & _XkbClientInitialized(1<<15))) |
| 3153 | return BadAccess10; |
| 3154 | |
| 3155 | 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; }}; |
| 3156 | |
| 3157 | xkb = dev->key->xkbInfo->desc; |
| 3158 | leds = xkb->indicators; |
| 3159 | |
| 3160 | rep = (xkbGetIndicatorMapReply) { |
| 3161 | .type = X_Reply1, |
| 3162 | .deviceID = dev->id, |
| 3163 | .sequenceNumber = client->sequence, |
| 3164 | .length = 0, |
| 3165 | .which = stuff->which |
| 3166 | }; |
| 3167 | XkbComputeGetIndicatorMapReplySize(leds, &rep); |
| 3168 | return XkbSendIndicatorMap(client, leds, &rep); |
| 3169 | } |
| 3170 | |
| 3171 | /** |
| 3172 | * Apply the given map to the given device. Which specifies which components |
| 3173 | * to apply. |
| 3174 | */ |
| 3175 | static int |
| 3176 | _XkbSetIndicatorMap(ClientPtr client, DeviceIntPtr dev, |
| 3177 | int which, xkbIndicatorMapWireDesc * desc) |
| 3178 | { |
| 3179 | XkbSrvInfoPtr xkbi; |
| 3180 | XkbSrvLedInfoPtr sli; |
| 3181 | XkbEventCauseRec cause; |
| 3182 | int i, bit; |
| 3183 | |
| 3184 | xkbi = dev->key->xkbInfo; |
| 3185 | |
| 3186 | sli = XkbFindSrvLedInfo(dev, XkbDfltXIClass0x0300, XkbDfltXIId0x0400, |
| 3187 | XkbXI_IndicatorMapsMask(1L << 3)); |
| 3188 | if (!sli) |
| 3189 | return BadAlloc11; |
| 3190 | |
| 3191 | for (i = 0, bit = 1; i < XkbNumIndicators32; i++, bit <<= 1) { |
| 3192 | if (which & bit) { |
| 3193 | sli->maps[i].flags = desc->flags; |
| 3194 | sli->maps[i].which_groups = desc->whichGroups; |
| 3195 | sli->maps[i].groups = desc->groups; |
| 3196 | sli->maps[i].which_mods = desc->whichMods; |
| 3197 | sli->maps[i].mods.mask = desc->mods; |
| 3198 | sli->maps[i].mods.real_mods = desc->mods; |
| 3199 | sli->maps[i].mods.vmods = desc->virtualMods; |
| 3200 | sli->maps[i].ctrls = desc->ctrls; |
| 3201 | if (desc->virtualMods != 0) { |
| 3202 | unsigned tmp; |
| 3203 | |
| 3204 | tmp = XkbMaskForVMask(xkbi->desc, desc->virtualMods); |
| 3205 | sli->maps[i].mods.mask = desc->mods | tmp; |
| 3206 | } |
| 3207 | desc++; |
| 3208 | } |
| 3209 | } |
| 3210 | |
| 3211 | XkbSetCauseXkbReq(&cause, X_kbSetIndicatorMap, client){ (&cause)->kc= (&cause)->event= 0, (&cause )->mjr= (XkbReqCode),(&cause)->mnr= (14); (&cause )->client= (client); }; |
| 3212 | XkbApplyLedMapChanges(dev, sli, which, NULL((void*)0), NULL((void*)0), &cause); |
| 3213 | |
| 3214 | return Success0; |
| 3215 | } |
| 3216 | |
| 3217 | int |
| 3218 | ProcXkbSetIndicatorMap(ClientPtr client) |
| 3219 | { |
| 3220 | int i, bit; |
| 3221 | int nIndicators; |
| 3222 | DeviceIntPtr dev; |
| 3223 | xkbIndicatorMapWireDesc *from; |
| 3224 | int rc; |
| 3225 | |
| 3226 | REQUEST(xkbSetIndicatorMapReq)xkbSetIndicatorMapReq *stuff = (xkbSetIndicatorMapReq *)client ->requestBuffer; |
| 3227 | REQUEST_AT_LEAST_SIZE(xkbSetIndicatorMapReq)if ((sizeof(xkbSetIndicatorMapReq) >> 2) > client-> req_len ) return(16); |
| 3228 | |
| 3229 | if (!(client->xkbClientFlags & _XkbClientInitialized(1<<15))) |
| 3230 | return BadAccess10; |
| 3231 | |
| 3232 | 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; }}; |
| 3233 | |
| 3234 | if (stuff->which == 0) |
| 3235 | return Success0; |
| 3236 | |
| 3237 | for (nIndicators = i = 0, bit = 1; i < XkbNumIndicators32; i++, bit <<= 1) { |
| 3238 | if (stuff->which & bit) |
| 3239 | nIndicators++; |
| 3240 | } |
| 3241 | if (stuff->length != ((SIZEOF(xkbSetIndicatorMapReq)12 + |
| 3242 | (nIndicators * SIZEOF(xkbIndicatorMapWireDesc)12)) / |
| 3243 | 4)) { |
| 3244 | return BadLength16; |
| 3245 | } |
| 3246 | |
| 3247 | from = (xkbIndicatorMapWireDesc *) &stuff[1]; |
| 3248 | for (i = 0, bit = 1; i < XkbNumIndicators32; i++, bit <<= 1) { |
| 3249 | if (stuff->which & bit) { |
| 3250 | if (client->swapped) { |
| 3251 | 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); |
| 3252 | 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); |
| 3253 | } |
| 3254 | 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; }}; |
| 3255 | 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; }}; |
| 3256 | from++; |
| 3257 | } |
| 3258 | } |
| 3259 | |
| 3260 | from = (xkbIndicatorMapWireDesc *) &stuff[1]; |
| 3261 | rc = _XkbSetIndicatorMap(client, dev, stuff->which, from); |
| 3262 | if (rc != Success0) |
| 3263 | return rc; |
| 3264 | |
| 3265 | if (stuff->deviceSpec == XkbUseCoreKbd0x0100) { |
| 3266 | DeviceIntPtr other; |
| 3267 | |
| 3268 | for (other = inputInfo.devices; other; other = other->next) { |
| 3269 | if ((other != dev) && other->key && !IsMaster(other) && |
| 3270 | GetMaster(other, MASTER_KEYBOARD2) == dev) { |
| 3271 | rc = XaceHook(XACE_DEVICE_ACCESS3, client, other, |
| 3272 | DixSetAttrAccess(1<<5)); |
| 3273 | if (rc == Success0) |
| 3274 | _XkbSetIndicatorMap(client, other, stuff->which, from); |
| 3275 | } |
| 3276 | } |
| 3277 | } |
| 3278 | |
| 3279 | return Success0; |
| 3280 | } |
| 3281 | |
| 3282 | /***====================================================================***/ |
| 3283 | |
| 3284 | int |
| 3285 | ProcXkbGetNamedIndicator(ClientPtr client) |
| 3286 | { |
| 3287 | DeviceIntPtr dev; |
| 3288 | xkbGetNamedIndicatorReply rep; |
| 3289 | register int i = 0; |
| 3290 | XkbSrvLedInfoPtr sli; |
| 3291 | XkbIndicatorMapPtr map = NULL((void*)0); |
| 3292 | |
| 3293 | REQUEST(xkbGetNamedIndicatorReq)xkbGetNamedIndicatorReq *stuff = (xkbGetNamedIndicatorReq *)client ->requestBuffer; |
| 3294 | REQUEST_SIZE_MATCH(xkbGetNamedIndicatorReq)if ((sizeof(xkbGetNamedIndicatorReq) >> 2) != client-> req_len) return(16); |
| 3295 | |
| 3296 | if (!(client->xkbClientFlags & _XkbClientInitialized(1<<15))) |
| 3297 | return BadAccess10; |
| 3298 | |
| 3299 | 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; }}; |
| 3300 | CHK_ATOM_ONLY(stuff->indicator){ if (((stuff->indicator)==0L)||(!ValidAtom((stuff->indicator )))) { (client->errorValue)= (XID)(stuff->indicator); return 5; }}; |
| 3301 | |
| 3302 | sli = XkbFindSrvLedInfo(dev, stuff->ledClass, stuff->ledID, 0); |
| 3303 | if (!sli) |
| 3304 | return BadAlloc11; |
| 3305 | |
| 3306 | i = 0; |
| 3307 | map = NULL((void*)0); |
| 3308 | if ((sli->names) && (sli->maps)) { |
| 3309 | for (i = 0; i < XkbNumIndicators32; i++) { |
| 3310 | if (stuff->indicator == sli->names[i]) { |
| 3311 | map = &sli->maps[i]; |
| 3312 | break; |
| 3313 | } |
| 3314 | } |
| 3315 | } |
| 3316 | |
| 3317 | rep = (xkbGetNamedIndicatorReply) { |
| 3318 | .type = X_Reply1, |
| 3319 | .sequenceNumber = client->sequence, |
| 3320 | .length = 0, |
| 3321 | .deviceID = dev->id, |
| 3322 | .indicator = stuff->indicator |
| 3323 | }; |
| 3324 | if (map != NULL((void*)0)) { |
| 3325 | rep.found = TRUE1; |
| 3326 | rep.on = ((sli->effectiveState & (1 << i)) != 0); |
| 3327 | rep.realIndicator = ((sli->physIndicators & (1 << i)) != 0); |
| 3328 | rep.ndx = i; |
| 3329 | rep.flags = map->flags; |
| 3330 | rep.whichGroups = map->which_groups; |
| 3331 | rep.groups = map->groups; |
| 3332 | rep.whichMods = map->which_mods; |
| 3333 | rep.mods = map->mods.mask; |
| 3334 | rep.realMods = map->mods.real_mods; |
| 3335 | rep.virtualMods = map->mods.vmods; |
| 3336 | rep.ctrls = map->ctrls; |
| 3337 | rep.supported = TRUE1; |
| 3338 | } |
| 3339 | else { |
| 3340 | rep.found = FALSE0; |
| 3341 | rep.on = FALSE0; |
| 3342 | rep.realIndicator = FALSE0; |
| 3343 | rep.ndx = XkbNoIndicator0xff; |
| 3344 | rep.flags = 0; |
| 3345 | rep.whichGroups = 0; |
| 3346 | rep.groups = 0; |
| 3347 | rep.whichMods = 0; |
| 3348 | rep.mods = 0; |
| 3349 | rep.realMods = 0; |
| 3350 | rep.virtualMods = 0; |
| 3351 | rep.ctrls = 0; |
| 3352 | rep.supported = TRUE1; |
| 3353 | } |
| 3354 | if (client->swapped) { |
| 3355 | 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); |
| 3356 | 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); |
| 3357 | 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); |
| 3358 | 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); |
| 3359 | 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); |
| 3360 | } |
| 3361 | |
| 3362 | WriteToClient(client, SIZEOF(xkbGetNamedIndicatorReply)32, &rep); |
| 3363 | return Success0; |
| 3364 | } |
| 3365 | |
| 3366 | /** |
| 3367 | * Find the IM on the device. |
| 3368 | * Returns the map, or NULL if the map doesn't exist. |
| 3369 | * If the return value is NULL, led_return is undefined. Otherwise, led_return |
| 3370 | * is set to the led index of the map. |
| 3371 | */ |
| 3372 | static XkbIndicatorMapPtr |
| 3373 | _XkbFindNamedIndicatorMap(XkbSrvLedInfoPtr sli, Atom indicator, int *led_return) |
| 3374 | { |
| 3375 | XkbIndicatorMapPtr map; |
| 3376 | |
| 3377 | /* search for the right indicator */ |
| 3378 | map = NULL((void*)0); |
| 3379 | if (sli->names && sli->maps) { |
| 3380 | int led; |
| 3381 | |
| 3382 | for (led = 0; (led < XkbNumIndicators32) && (map == NULL((void*)0)); led++) { |
| 3383 | if (sli->names[led] == indicator) { |
| 3384 | map = &sli->maps[led]; |
| 3385 | *led_return = led; |
| 3386 | break; |
| 3387 | } |
| 3388 | } |
| 3389 | } |
| 3390 | |
| 3391 | return map; |
| 3392 | } |
| 3393 | |
| 3394 | /** |
| 3395 | * Creates an indicator map on the device. If dryRun is TRUE, it only checks |
| 3396 | * if creation is possible, but doesn't actually create it. |
| 3397 | */ |
| 3398 | static int |
| 3399 | _XkbCreateIndicatorMap(DeviceIntPtr dev, Atom indicator, |
| 3400 | int ledClass, int ledID, |
| 3401 | XkbIndicatorMapPtr * map_return, int *led_return, |
| 3402 | Bool dryRun) |
| 3403 | { |
| 3404 | XkbSrvLedInfoPtr sli; |
| 3405 | XkbIndicatorMapPtr map; |
| 3406 | int led; |
| 3407 | |
| 3408 | sli = XkbFindSrvLedInfo(dev, ledClass, ledID, XkbXI_IndicatorsMask(0x001c)); |
| 3409 | if (!sli) |
| 3410 | return BadAlloc11; |
| 3411 | |
| 3412 | map = _XkbFindNamedIndicatorMap(sli, indicator, &led); |
| 3413 | |
| 3414 | if (!map) { |
| 3415 | /* find first unused indicator maps and assign the name to it */ |
| 3416 | for (led = 0, map = NULL((void*)0); (led < XkbNumIndicators32) && (map == NULL((void*)0)); |
| 3417 | led++) { |
| 3418 | if ((sli->names) && (sli->maps) && (sli->names[led] == None0L) && |
| 3419 | (!XkbIM_InUse(&sli->maps[led])((&sli->maps[led])->flags || (&sli->maps[led ])->which_groups || (&sli->maps[led])->which_mods || (&sli->maps[led])->ctrls))) { |
| 3420 | map = &sli->maps[led]; |
| 3421 | if (!dryRun) |
| 3422 | sli->names[led] = indicator; |
| 3423 | break; |
| 3424 | } |
| 3425 | } |
| 3426 | } |
| 3427 | |
| 3428 | if (!map) |
| 3429 | return BadAlloc11; |
| 3430 | |
| 3431 | *led_return = led; |
| 3432 | *map_return = map; |
| 3433 | return Success0; |
| 3434 | } |
| 3435 | |
| 3436 | static int |
| 3437 | _XkbSetNamedIndicator(ClientPtr client, DeviceIntPtr dev, |
| 3438 | xkbSetNamedIndicatorReq * stuff) |
| 3439 | { |
| 3440 | unsigned int extDevReason; |
| 3441 | unsigned int statec, namec, mapc; |
| 3442 | XkbSrvLedInfoPtr sli; |
| 3443 | int led = 0; |
| 3444 | XkbIndicatorMapPtr map; |
| 3445 | DeviceIntPtr kbd; |
| 3446 | XkbEventCauseRec cause; |
| 3447 | xkbExtensionDeviceNotify ed; |
| 3448 | XkbChangesRec changes; |
| 3449 | int rc; |
| 3450 | |
| 3451 | rc = _XkbCreateIndicatorMap(dev, stuff->indicator, stuff->ledClass, |
| 3452 | stuff->ledID, &map, &led, FALSE0); |
| 3453 | if (rc != Success0 || !map) /* oh-oh */ |
| 3454 | return rc; |
| 3455 | |
| 3456 | sli = XkbFindSrvLedInfo(dev, stuff->ledClass, stuff->ledID, |
| 3457 | XkbXI_IndicatorsMask(0x001c)); |
| 3458 | if (!sli) |
| 3459 | return BadAlloc11; |
| 3460 | |
| 3461 | namec = mapc = statec = 0; |
| 3462 | extDevReason = 0; |
| 3463 | |
| 3464 | namec |= (1 << led); |
| 3465 | sli->namesPresent |= ((stuff->indicator != None0L) ? (1 << led) : 0); |
| 3466 | extDevReason |= XkbXI_IndicatorNamesMask(1L << 2); |
| 3467 | |
| 3468 | if (stuff->setMap) { |
| 3469 | map->flags = stuff->flags; |
| 3470 | map->which_groups = stuff->whichGroups; |
| 3471 | map->groups = stuff->groups; |
| 3472 | map->which_mods = stuff->whichMods; |
| 3473 | map->mods.mask = stuff->realMods; |
| 3474 | map->mods.real_mods = stuff->realMods; |
| 3475 | map->mods.vmods = stuff->virtualMods; |
| 3476 | map->ctrls = stuff->ctrls; |
| 3477 | mapc |= (1 << led); |
| 3478 | } |
| 3479 | |
| 3480 | if ((stuff->setState) && ((map->flags & XkbIM_NoExplicit(1L << 7)) == 0)) { |
| 3481 | if (stuff->on) |
| 3482 | sli->explicitState |= (1 << led); |
| 3483 | else |
| 3484 | sli->explicitState &= ~(1 << led); |
| 3485 | statec |= ((sli->effectiveState ^ sli->explicitState) & (1 << led)); |
| 3486 | } |
| 3487 | |
| 3488 | memset((char *) &ed, 0, sizeof(xkbExtensionDeviceNotify))__builtin___memset_chk ((char *) &ed, 0, sizeof(xkbExtensionDeviceNotify ), __builtin_object_size ((char *) &ed, 0)); |
| 3489 | memset((char *) &changes, 0, sizeof(XkbChangesRec))__builtin___memset_chk ((char *) &changes, 0, sizeof(XkbChangesRec ), __builtin_object_size ((char *) &changes, 0)); |
| 3490 | XkbSetCauseXkbReq(&cause, X_kbSetNamedIndicator, client){ (&cause)->kc= (&cause)->event= 0, (&cause )->mjr= (XkbReqCode),(&cause)->mnr= (16); (&cause )->client= (client); }; |
| 3491 | if (namec) |
| 3492 | XkbApplyLedNameChanges(dev, sli, namec, &ed, &changes, &cause); |
| 3493 | if (mapc) |
| 3494 | XkbApplyLedMapChanges(dev, sli, mapc, &ed, &changes, &cause); |
| 3495 | if (statec) |
| 3496 | XkbApplyLedStateChanges(dev, sli, statec, &ed, &changes, &cause); |
| 3497 | |
| 3498 | kbd = dev; |
| 3499 | if ((sli->flags & XkbSLI_HasOwnState(1L<<1)) == 0) |
| 3500 | kbd = inputInfo.keyboard; |
| 3501 | XkbFlushLedEvents(dev, kbd, sli, &ed, &changes, &cause); |
| 3502 | |
| 3503 | return Success0; |
| 3504 | } |
| 3505 | |
| 3506 | int |
| 3507 | ProcXkbSetNamedIndicator(ClientPtr client) |
| 3508 | { |
| 3509 | int rc; |
| 3510 | DeviceIntPtr dev; |
| 3511 | int led = 0; |
| 3512 | XkbIndicatorMapPtr map; |
| 3513 | |
| 3514 | REQUEST(xkbSetNamedIndicatorReq)xkbSetNamedIndicatorReq *stuff = (xkbSetNamedIndicatorReq *)client ->requestBuffer; |
| 3515 | REQUEST_SIZE_MATCH(xkbSetNamedIndicatorReq)if ((sizeof(xkbSetNamedIndicatorReq) >> 2) != client-> req_len) return(16); |
| 3516 | |
| 3517 | if (!(client->xkbClientFlags & _XkbClientInitialized(1<<15))) |
| 3518 | return BadAccess10; |
| 3519 | |
| 3520 | 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; }}; |
| 3521 | CHK_ATOM_ONLY(stuff->indicator){ if (((stuff->indicator)==0L)||(!ValidAtom((stuff->indicator )))) { (client->errorValue)= (XID)(stuff->indicator); return 5; }}; |
| 3522 | 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; }}; |
| 3523 | 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; }}; |
| 3524 | |
| 3525 | /* Dry-run for checks */ |
| 3526 | rc = _XkbCreateIndicatorMap(dev, stuff->indicator, |
| 3527 | stuff->ledClass, stuff->ledID, |
| 3528 | &map, &led, TRUE1); |
| 3529 | if (rc != Success0 || !map) /* couldn't be created or didn't exist */ |
| 3530 | return rc; |
| 3531 | |
| 3532 | if (stuff->deviceSpec == XkbUseCoreKbd0x0100 || |
| 3533 | stuff->deviceSpec == XkbUseCorePtr0x0200) { |
| 3534 | DeviceIntPtr other; |
| 3535 | |
| 3536 | for (other = inputInfo.devices; other; other = other->next) { |
| 3537 | if ((other != dev) && !IsMaster(other) && |
| 3538 | GetMaster(other, MASTER_KEYBOARD2) == dev && (other->kbdfeed || |
| 3539 | other->leds) && |
| 3540 | (XaceHook(XACE_DEVICE_ACCESS3, client, other, DixSetAttrAccess(1<<5)) |
| 3541 | == Success0)) { |
| 3542 | rc = _XkbCreateIndicatorMap(other, stuff->indicator, |
| 3543 | stuff->ledClass, stuff->ledID, &map, |
| 3544 | &led, TRUE1); |
| 3545 | if (rc != Success0 || !map) |
| 3546 | return rc; |
| 3547 | } |
| 3548 | } |
| 3549 | } |
| 3550 | |
| 3551 | /* All checks passed, let's do it */ |
| 3552 | rc = _XkbSetNamedIndicator(client, dev, stuff); |
| 3553 | if (rc != Success0) |
| 3554 | return rc; |
| 3555 | |
| 3556 | if (stuff->deviceSpec == XkbUseCoreKbd0x0100 || |
| 3557 | stuff->deviceSpec == XkbUseCorePtr0x0200) { |
| 3558 | DeviceIntPtr other; |
| 3559 | |
| 3560 | for (other = inputInfo.devices; other; other = other->next) { |
| 3561 | if ((other != dev) && !IsMaster(other) && |
| 3562 | GetMaster(other, MASTER_KEYBOARD2) == dev && (other->kbdfeed || |
| 3563 | other->leds) && |
| 3564 | (XaceHook(XACE_DEVICE_ACCESS3, client, other, DixSetAttrAccess(1<<5)) |
| 3565 | == Success0)) { |
| 3566 | _XkbSetNamedIndicator(client, other, stuff); |
| 3567 | } |
| 3568 | } |
| 3569 | } |
| 3570 | |
| 3571 | return Success0; |
| 3572 | } |
| 3573 | |
| 3574 | /***====================================================================***/ |
| 3575 | |
| 3576 | static CARD32 |
| 3577 | _XkbCountAtoms(Atom *atoms, int maxAtoms, int *count) |
| 3578 | { |
| 3579 | register unsigned int i, bit, nAtoms; |
| 3580 | register CARD32 atomsPresent; |
| 3581 | |
| 3582 | for (i = nAtoms = atomsPresent = 0, bit = 1; i < maxAtoms; i++, bit <<= 1) { |
| 3583 | if (atoms[i] != None0L) { |
| 3584 | atomsPresent |= bit; |
| 3585 | nAtoms++; |
| 3586 | } |
| 3587 | } |
| 3588 | if (count) |
| 3589 | *count = nAtoms; |
| 3590 | return atomsPresent; |
| 3591 | } |
| 3592 | |
| 3593 | static char * |
| 3594 | _XkbWriteAtoms(char *wire, Atom *atoms, int maxAtoms, int swap) |
| 3595 | { |
| 3596 | register unsigned int i; |
| 3597 | Atom *atm; |
| 3598 | |
| 3599 | atm = (Atom *) wire; |
| 3600 | for (i = 0; i < maxAtoms; i++) { |
| 3601 | if (atoms[i] != None0L) { |
| 3602 | *atm = atoms[i]; |
| 3603 | if (swap) { |
| 3604 | 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); |
| 3605 | } |
| 3606 | atm++; |
| 3607 | } |
| 3608 | } |
| 3609 | return (char *) atm; |
| 3610 | } |
| 3611 | |
| 3612 | static Statusint |
| 3613 | XkbComputeGetNamesReplySize(XkbDescPtr xkb, xkbGetNamesReply * rep) |
| 3614 | { |
| 3615 | register unsigned which, length; |
| 3616 | register int i; |
| 3617 | |
| 3618 | rep->minKeyCode = xkb->min_key_code; |
| 3619 | rep->maxKeyCode = xkb->max_key_code; |
| 3620 | which = rep->which; |
| 3621 | length = 0; |
| 3622 | if (xkb->names != NULL((void*)0)) { |
| 3623 | if (which & XkbKeycodesNameMask(1<<0)) |
| 3624 | length++; |
| 3625 | if (which & XkbGeometryNameMask(1<<1)) |
| 3626 | length++; |
| 3627 | if (which & XkbSymbolsNameMask(1<<2)) |
| 3628 | length++; |
| 3629 | if (which & XkbPhysSymbolsNameMask(1<<3)) |
| 3630 | length++; |
| 3631 | if (which & XkbTypesNameMask(1<<4)) |
| 3632 | length++; |
| 3633 | if (which & XkbCompatNameMask(1<<5)) |
| 3634 | length++; |
| 3635 | } |
| 3636 | else |
| 3637 | which &= ~XkbComponentNamesMask(0x3f); |
| 3638 | |
| 3639 | if (xkb->map != NULL((void*)0)) { |
| 3640 | if (which & XkbKeyTypeNamesMask(1<<6)) |
| 3641 | length += xkb->map->num_types; |
| 3642 | rep->nTypes = xkb->map->num_types; |
| 3643 | if (which & XkbKTLevelNamesMask(1<<7)) { |
| 3644 | XkbKeyTypePtr pType = xkb->map->types; |
| 3645 | int nKTLevels = 0; |
| 3646 | |
| 3647 | length += XkbPaddedSize(xkb->map->num_types)((((unsigned int)(xkb->map->num_types)+3) >> 2) << 2) / 4; |
| 3648 | for (i = 0; i < xkb->map->num_types; i++, pType++) { |
| 3649 | if (pType->level_names != NULL((void*)0)) |
| 3650 | nKTLevels += pType->num_levels; |
| 3651 | } |
| 3652 | rep->nKTLevels = nKTLevels; |
| 3653 | length += nKTLevels; |
| 3654 | } |
| 3655 | } |
| 3656 | else { |
| 3657 | rep->nTypes = 0; |
| 3658 | rep->nKTLevels = 0; |
| 3659 | which &= ~(XkbKeyTypeNamesMask(1<<6) | XkbKTLevelNamesMask(1<<7)); |
| 3660 | } |
| 3661 | |
| 3662 | rep->minKeyCode = xkb->min_key_code; |
| 3663 | rep->maxKeyCode = xkb->max_key_code; |
| 3664 | rep->indicators = 0; |
| 3665 | rep->virtualMods = 0; |
| 3666 | rep->groupNames = 0; |
| 3667 | if (xkb->names != NULL((void*)0)) { |
| 3668 | if (which & XkbIndicatorNamesMask(1<<8)) { |
| 3669 | int nLeds; |
| 3670 | |
| 3671 | rep->indicators = |
| 3672 | _XkbCountAtoms(xkb->names->indicators, XkbNumIndicators32, |
| 3673 | &nLeds); |
| 3674 | length += nLeds; |
| 3675 | if (nLeds == 0) |
| 3676 | which &= ~XkbIndicatorNamesMask(1<<8); |
| 3677 | } |
| 3678 | |
| 3679 | if (which & XkbVirtualModNamesMask(1<<11)) { |
| 3680 | int nVMods; |
| 3681 | |
| 3682 | rep->virtualMods = |
| 3683 | _XkbCountAtoms(xkb->names->vmods, XkbNumVirtualMods16, &nVMods); |
| 3684 | length += nVMods; |
| 3685 | if (nVMods == 0) |
| 3686 | which &= ~XkbVirtualModNamesMask(1<<11); |
| 3687 | } |
| 3688 | |
| 3689 | if (which & XkbGroupNamesMask(1<<12)) { |
| 3690 | int nGroups; |
| 3691 | |
| 3692 | rep->groupNames = |
| 3693 | _XkbCountAtoms(xkb->names->groups, XkbNumKbdGroups4, &nGroups); |
| 3694 | length += nGroups; |
| 3695 | if (nGroups == 0) |
| 3696 | which &= ~XkbGroupNamesMask(1<<12); |
| 3697 | } |
| 3698 | |
| 3699 | if ((which & XkbKeyNamesMask(1<<9)) && (xkb->names->keys)) |
| 3700 | length += rep->nKeys; |
| 3701 | else |
| 3702 | which &= ~XkbKeyNamesMask(1<<9); |
| 3703 | |
| 3704 | if ((which & XkbKeyAliasesMask(1<<10)) && |
| 3705 | (xkb->names->key_aliases) && (xkb->names->num_key_aliases > 0)) { |
| 3706 | rep->nKeyAliases = xkb->names->num_key_aliases; |
| 3707 | length += rep->nKeyAliases * 2; |
| 3708 | } |
| 3709 | else { |
| 3710 | which &= ~XkbKeyAliasesMask(1<<10); |
| 3711 | rep->nKeyAliases = 0; |
| 3712 | } |
| 3713 | |
| 3714 | if ((which & XkbRGNamesMask(1<<13)) && (xkb->names->num_rg > 0)) |
| 3715 | length += xkb->names->num_rg; |
| 3716 | else |
| 3717 | which &= ~XkbRGNamesMask(1<<13); |
| 3718 | } |
| 3719 | else { |
| 3720 | which &= ~(XkbIndicatorNamesMask(1<<8) | XkbVirtualModNamesMask(1<<11)); |
| 3721 | which &= ~(XkbGroupNamesMask(1<<12) | XkbKeyNamesMask(1<<9) | XkbKeyAliasesMask(1<<10)); |
| 3722 | which &= ~XkbRGNamesMask(1<<13); |
| 3723 | } |
| 3724 | |
| 3725 | rep->length = length; |
| 3726 | rep->which = which; |
| 3727 | return Success0; |
| 3728 | } |
| 3729 | |
| 3730 | static int |
| 3731 | XkbSendNames(ClientPtr client, XkbDescPtr xkb, xkbGetNamesReply * rep) |
| 3732 | { |
| 3733 | register unsigned i, length, which; |
| 3734 | char *start; |
| 3735 | char *desc; |
| 3736 | |
| 3737 | length = rep->length * 4; |
| 3738 | which = rep->which; |
| 3739 | if (client->swapped) { |
| 3740 | 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); |
| 3741 | 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); |
| 3742 | 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); |
| 3743 | 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); |
| 3744 | 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); |
| 3745 | } |
| 3746 | |
| 3747 | start = desc = calloc(1, length); |
| 3748 | if (!start) |
| 3749 | return BadAlloc11; |
| 3750 | if (xkb->names) { |
| 3751 | if (which & XkbKeycodesNameMask(1<<0)) { |
| 3752 | *((CARD32 *) desc) = xkb->names->keycodes; |
| 3753 | if (client->swapped) { |
| 3754 | 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); |
| 3755 | } |
| 3756 | desc += 4; |
| 3757 | } |
| 3758 | if (which & XkbGeometryNameMask(1<<1)) { |
| 3759 | *((CARD32 *) desc) = xkb->names->geometry; |
| 3760 | if (client->swapped) { |
| 3761 | 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); |
| 3762 | } |
| 3763 | desc += 4; |
| 3764 | } |
| 3765 | if (which & XkbSymbolsNameMask(1<<2)) { |
| 3766 | *((CARD32 *) desc) = xkb->names->symbols; |
| 3767 | if (client->swapped) { |
| 3768 | 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); |
| 3769 | } |
| 3770 | desc += 4; |
| 3771 | } |
| 3772 | if (which & XkbPhysSymbolsNameMask(1<<3)) { |
| 3773 | register CARD32 *atm = (CARD32 *) desc; |
| 3774 | |
| 3775 | atm[0] = (CARD32) xkb->names->phys_symbols; |
| 3776 | if (client->swapped) { |
| 3777 | 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); |
| 3778 | } |
| 3779 | desc += 4; |
| 3780 | } |
| 3781 | if (which & XkbTypesNameMask(1<<4)) { |
| 3782 | *((CARD32 *) desc) = (CARD32) xkb->names->types; |
| 3783 | if (client->swapped) { |
| 3784 | 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); |
| 3785 | } |
| 3786 | desc += 4; |
| 3787 | } |
| 3788 | if (which & XkbCompatNameMask(1<<5)) { |
| 3789 | *((CARD32 *) desc) = (CARD32) xkb->names->compat; |
| 3790 | if (client->swapped) { |
| 3791 | 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); |
| 3792 | } |
| 3793 | desc += 4; |
| 3794 | } |
| 3795 | if (which & XkbKeyTypeNamesMask(1<<6)) { |
| 3796 | register CARD32 *atm = (CARD32 *) desc; |
| 3797 | register XkbKeyTypePtr type = xkb->map->types; |
| 3798 | |
| 3799 | for (i = 0; i < xkb->map->num_types; i++, atm++, type++) { |
| 3800 | *atm = (CARD32) type->name; |
| 3801 | if (client->swapped) { |
| 3802 | 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); |
| 3803 | } |
| 3804 | } |
| 3805 | desc = (char *) atm; |
| 3806 | } |
| 3807 | if (which & XkbKTLevelNamesMask(1<<7) && xkb->map) { |
| 3808 | XkbKeyTypePtr type = xkb->map->types; |
| 3809 | register CARD32 *atm; |
| 3810 | |
| 3811 | for (i = 0; i < rep->nTypes; i++, type++) { |
| 3812 | *desc++ = type->num_levels; |
| 3813 | } |
| 3814 | desc += XkbPaddedSize(rep->nTypes)((((unsigned int)(rep->nTypes)+3) >> 2) << 2) - rep->nTypes; |
| 3815 | |
| 3816 | atm = (CARD32 *) desc; |
| 3817 | type = xkb->map->types; |
| 3818 | for (i = 0; i < xkb->map->num_types; i++, type++) { |
| 3819 | register unsigned l; |
| 3820 | |
| 3821 | if (type->level_names) { |
| 3822 | for (l = 0; l < type->num_levels; l++, atm++) { |
| 3823 | *atm = type->level_names[l]; |
| 3824 | if (client->swapped) { |
| 3825 | 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); |
| 3826 | } |
| 3827 | } |
| 3828 | desc += type->num_levels * 4; |
| 3829 | } |
| 3830 | } |
| 3831 | } |
| 3832 | if (which & XkbIndicatorNamesMask(1<<8)) { |
| 3833 | desc = |
| 3834 | _XkbWriteAtoms(desc, xkb->names->indicators, XkbNumIndicators32, |
| 3835 | client->swapped); |
| 3836 | } |
| 3837 | if (which & XkbVirtualModNamesMask(1<<11)) { |
| 3838 | desc = _XkbWriteAtoms(desc, xkb->names->vmods, XkbNumVirtualMods16, |
| 3839 | client->swapped); |
| 3840 | } |
| 3841 | if (which & XkbGroupNamesMask(1<<12)) { |
| 3842 | desc = _XkbWriteAtoms(desc, xkb->names->groups, XkbNumKbdGroups4, |
| 3843 | client->swapped); |
| 3844 | } |
| 3845 | if (which & XkbKeyNamesMask(1<<9)) { |
| 3846 | for (i = 0; i < rep->nKeys; i++, desc += sizeof(XkbKeyNameRec)) { |
| 3847 | *((XkbKeyNamePtr) desc) = xkb->names->keys[i + rep->firstKey]; |
| 3848 | } |
| 3849 | } |
| 3850 | if (which & XkbKeyAliasesMask(1<<10)) { |
| 3851 | XkbKeyAliasPtr pAl; |
| 3852 | |
| 3853 | pAl = xkb->names->key_aliases; |
| 3854 | for (i = 0; i < rep->nKeyAliases; |
| 3855 | i++, pAl++, desc += 2 * XkbKeyNameLength4) { |
| 3856 | *((XkbKeyAliasPtr) desc) = *pAl; |
| 3857 | } |
| 3858 | } |
| 3859 | if ((which & XkbRGNamesMask(1<<13)) && (rep->nRadioGroups > 0)) { |
| 3860 | register CARD32 *atm = (CARD32 *) desc; |
| 3861 | |
| 3862 | for (i = 0; i < rep->nRadioGroups; i++, atm++) { |
| 3863 | *atm = (CARD32) xkb->names->radio_groups[i]; |
| 3864 | if (client->swapped) { |
| 3865 | 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); |
| 3866 | } |
| 3867 | } |
| 3868 | desc += rep->nRadioGroups * 4; |
| 3869 | } |
| 3870 | } |
| 3871 | |
| 3872 | if ((desc - start) != (length)) { |
| 3873 | ErrorF("[xkb] BOGUS LENGTH in write names, expected %d, got %ld\n", |
| 3874 | length, (unsigned long) (desc - start)); |
| 3875 | } |
| 3876 | WriteToClient(client, SIZEOF(xkbGetNamesReply)32, rep); |
| 3877 | WriteToClient(client, length, start); |
| 3878 | free((char *) start); |
| 3879 | return Success0; |
| 3880 | } |
| 3881 | |
| 3882 | int |
| 3883 | ProcXkbGetNames(ClientPtr client) |
| 3884 | { |
| 3885 | DeviceIntPtr dev; |
| 3886 | XkbDescPtr xkb; |
| 3887 | xkbGetNamesReply rep; |
| 3888 | |
| 3889 | REQUEST(xkbGetNamesReq)xkbGetNamesReq *stuff = (xkbGetNamesReq *)client->requestBuffer; |
| 3890 | REQUEST_SIZE_MATCH(xkbGetNamesReq)if ((sizeof(xkbGetNamesReq) >> 2) != client->req_len ) return(16); |
| 3891 | |
| 3892 | if (!(client->xkbClientFlags & _XkbClientInitialized(1<<15))) |
| 3893 | return BadAccess10; |
| 3894 | |
| 3895 | 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; }}; |
| 3896 | CHK_MASK_LEGAL(0x01, stuff->which, XkbAllNamesMask){ if ((stuff->which)&(~((0x3fff)))) { (client->errorValue )= ((XID)((((unsigned int)((0x01)))<<24)|((((stuff-> which)&(~((0x3fff)))))&0xffffff))); return 2; }}; |
| 3897 | |
| 3898 | xkb = dev->key->xkbInfo->desc; |
| 3899 | rep = (xkbGetNamesReply) { |
| 3900 | .type = X_Reply1, |
| 3901 | .deviceID = dev->id, |
| 3902 | .sequenceNumber = client->sequence, |
| 3903 | .length = 0, |
| 3904 | .which = stuff->which, |
| 3905 | .nTypes = xkb->map->num_types, |
| 3906 | .firstKey = xkb->min_key_code, |
| 3907 | .nKeys = XkbNumKeys(xkb)((xkb)->max_key_code-(xkb)->min_key_code+1), |
| 3908 | .nKeyAliases = xkb->names ? xkb->names->num_key_aliases : 0, |
| 3909 | .nRadioGroups = xkb->names ? xkb->names->num_rg : 0 |
| 3910 | }; |
| 3911 | XkbComputeGetNamesReplySize(xkb, &rep); |
| 3912 | return XkbSendNames(client, xkb, &rep); |
| 3913 | } |
| 3914 | |
| 3915 | /***====================================================================***/ |
| 3916 | |
| 3917 | static CARD32 * |
| 3918 | _XkbCheckAtoms(CARD32 *wire, int nAtoms, int swapped, Atom *pError) |
| 3919 | { |
| 3920 | register int i; |
| 3921 | |
| 3922 | for (i = 0; i < nAtoms; i++, wire++) { |
| 3923 | if (swapped) { |
| 3924 | 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); |
| 3925 | } |
| 3926 | if ((((Atom) *wire) != None0L) && (!ValidAtom((Atom) *wire))) { |
| 3927 | *pError = ((Atom) *wire); |
| 3928 | return NULL((void*)0); |
| 3929 | } |
| 3930 | } |
| 3931 | return wire; |
| 3932 | } |
| 3933 | |
| 3934 | static CARD32 * |
| 3935 | _XkbCheckMaskedAtoms(CARD32 *wire, int nAtoms, CARD32 present, int swapped, |
| 3936 | Atom *pError) |
| 3937 | { |
| 3938 | register unsigned i, bit; |
| 3939 | |
| 3940 | for (i = 0, bit = 1; (i < nAtoms) && (present); i++, bit <<= 1) { |
| 3941 | if ((present & bit) == 0) |
| 3942 | continue; |
| 3943 | if (swapped) { |
| 3944 | 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); |
| 3945 | } |
| 3946 | if ((((Atom) *wire) != None0L) && (!ValidAtom(((Atom) *wire)))) { |
| 3947 | *pError = (Atom) *wire; |
| 3948 | return NULL((void*)0); |
| 3949 | } |
| 3950 | wire++; |
| 3951 | } |
| 3952 | return wire; |
| 3953 | } |
| 3954 | |
| 3955 | static Atom * |
| 3956 | _XkbCopyMaskedAtoms(Atom *wire, Atom *dest, int nAtoms, CARD32 present) |
| 3957 | { |
| 3958 | register int i, bit; |
| 3959 | |
| 3960 | for (i = 0, bit = 1; (i < nAtoms) && (present); i++, bit <<= 1) { |
| 3961 | if ((present & bit) == 0) |
| 3962 | continue; |
| 3963 | dest[i] = *wire++; |
| 3964 | } |
| 3965 | return wire; |
| 3966 | } |
| 3967 | |
| 3968 | static Bool |
| 3969 | _XkbCheckTypeName(Atom name, int typeNdx) |
| 3970 | { |
| 3971 | const char *str; |
| 3972 | |
| 3973 | str = NameForAtom(name); |
| 3974 | if ((strcmp(str, "ONE_LEVEL") == 0) || (strcmp(str, "TWO_LEVEL") == 0) || |
| 3975 | (strcmp(str, "ALPHABETIC") == 0) || (strcmp(str, "KEYPAD") == 0)) |
| 3976 | return FALSE0; |
| 3977 | return TRUE1; |
| 3978 | } |
| 3979 | |
| 3980 | /** |
| 3981 | * Check the device-dependent data in the request against the device. Returns |
| 3982 | * Success, or the appropriate error code. |
| 3983 | */ |
| 3984 | static int |
| 3985 | _XkbSetNamesCheck(ClientPtr client, DeviceIntPtr dev, |
| 3986 | xkbSetNamesReq * stuff, CARD32 *data) |
| 3987 | { |
| 3988 | XkbDescRec *xkb; |
| 3989 | CARD32 *tmp; |
| 3990 | Atom bad = None0L; |
| 3991 | |
| 3992 | tmp = data; |
| 3993 | xkb = dev->key->xkbInfo->desc; |
| 3994 | |
| 3995 | if (stuff->which & XkbKeyTypeNamesMask(1<<6)) { |
| 3996 | int i; |
| 3997 | CARD32 *old; |
| 3998 | |
| 3999 | if (stuff->nTypes < 1) { |
| 4000 | client->errorValue = _XkbErrCode2(0x02, stuff->nTypes)((XID)((((unsigned int)(0x02))<<24)|((stuff->nTypes) &0xffffff))); |
| 4001 | return BadValue2; |
| 4002 | } |
| 4003 | if ((unsigned) (stuff->firstType + stuff->nTypes - 1) >= |
| 4004 | xkb->map->num_types) { |
| 4005 | client->errorValue = |
| 4006 | _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 ))) |
| 4007 | xkb->map->num_types)((XID)((((unsigned int)(0x03))<<24)|(((((unsigned int)( stuff->firstType))<<16)|(((((unsigned int)(stuff-> nTypes))<<8)|(xkb->map->num_types))))&0xffffff ))); |
| 4008 | return BadValue2; |
| 4009 | } |
| 4010 | if (((unsigned) stuff->firstType) <= XkbLastRequiredType3) { |
| 4011 | client->errorValue = _XkbErrCode2(0x04, stuff->firstType)((XID)((((unsigned int)(0x04))<<24)|((stuff->firstType )&0xffffff))); |
| 4012 | return BadAccess10; |
| 4013 | } |
| 4014 | old = tmp; |
| 4015 | tmp = _XkbCheckAtoms(tmp, stuff->nTypes, client->swapped, &bad); |
| 4016 | if (!tmp) { |
| 4017 | client->errorValue = bad; |
| 4018 | return BadAtom5; |
| 4019 | } |
| 4020 | for (i = 0; i < stuff->nTypes; i++, old++) { |
| 4021 | if (!_XkbCheckTypeName((Atom) *old, stuff->firstType + i)) |
| 4022 | client->errorValue = _XkbErrCode2(0x05, i)((XID)((((unsigned int)(0x05))<<24)|((i)&0xffffff)) ); |
| 4023 | } |
| 4024 | } |
| 4025 | if (stuff->which & XkbKTLevelNamesMask(1<<7)) { |
| 4026 | unsigned i; |
| 4027 | XkbKeyTypePtr type; |
| 4028 | CARD8 *width; |
| 4029 | |
| 4030 | if (stuff->nKTLevels < 1) { |
| 4031 | client->errorValue = _XkbErrCode2(0x05, stuff->nKTLevels)((XID)((((unsigned int)(0x05))<<24)|((stuff->nKTLevels )&0xffffff))); |
| 4032 | return BadValue2; |
| 4033 | } |
| 4034 | if ((unsigned) (stuff->firstKTLevel + stuff->nKTLevels - 1) >= |
| 4035 | xkb->map->num_types) { |
| 4036 | 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 ))) |
| 4037 | stuff->nKTLevels,((XID)((((unsigned int)(0x06))<<24)|(((((unsigned int)( stuff->firstKTLevel))<<16)|(((((unsigned int)(stuff-> nKTLevels))<<8)|(xkb->map->num_types))))&0xffffff ))) |
| 4038 | xkb->map->num_types)((XID)((((unsigned int)(0x06))<<24)|(((((unsigned int)( stuff->firstKTLevel))<<16)|(((((unsigned int)(stuff-> nKTLevels))<<8)|(xkb->map->num_types))))&0xffffff ))); |
| 4039 | return BadValue2; |
| 4040 | } |
| 4041 | width = (CARD8 *) tmp; |
| 4042 | tmp = (CARD32 *) (((char *) tmp) + XkbPaddedSize(stuff->nKTLevels)((((unsigned int)(stuff->nKTLevels)+3) >> 2) << 2)); |
| 4043 | type = &xkb->map->types[stuff->firstKTLevel]; |
| 4044 | for (i = 0; i < stuff->nKTLevels; i++, type++) { |
| 4045 | if (width[i] == 0) |
| 4046 | continue; |
| 4047 | else if (width[i] != type->num_levels) { |
| 4048 | 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))) |
| 4049 | 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))); |
| 4050 | return BadMatch8; |
| 4051 | } |
| 4052 | tmp = _XkbCheckAtoms(tmp, width[i], client->swapped, &bad); |
| 4053 | if (!tmp) { |
| 4054 | client->errorValue = bad; |
| 4055 | return BadAtom5; |
| 4056 | } |
| 4057 | } |
| 4058 | } |
| 4059 | if (stuff->which & XkbIndicatorNamesMask(1<<8)) { |
| 4060 | if (stuff->indicators == 0) { |
| 4061 | client->errorValue = 0x08; |
| 4062 | return BadMatch8; |
| 4063 | } |
| 4064 | tmp = _XkbCheckMaskedAtoms(tmp, XkbNumIndicators32, stuff->indicators, |
| 4065 | client->swapped, &bad); |
| 4066 | if (!tmp) { |
| 4067 | client->errorValue = bad; |
| 4068 | return BadAtom5; |
| 4069 | } |
| 4070 | } |
| 4071 | if (stuff->which & XkbVirtualModNamesMask(1<<11)) { |
| 4072 | if (stuff->virtualMods == 0) { |
| 4073 | client->errorValue = 0x09; |
| 4074 | return BadMatch8; |
| 4075 | } |
| 4076 | tmp = _XkbCheckMaskedAtoms(tmp, XkbNumVirtualMods16, |
| 4077 | (CARD32) stuff->virtualMods, |
| 4078 | client->swapped, &bad); |
| 4079 | if (!tmp) { |
| 4080 | client->errorValue = bad; |
| 4081 | return BadAtom5; |
| 4082 | } |
| 4083 | } |
| 4084 | if (stuff->which & XkbGroupNamesMask(1<<12)) { |
| 4085 | if (stuff->groupNames == 0) { |
| 4086 | client->errorValue = 0x0a; |
| 4087 | return BadMatch8; |
| 4088 | } |
| 4089 | tmp = _XkbCheckMaskedAtoms(tmp, XkbNumKbdGroups4, |
| 4090 | (CARD32) stuff->groupNames, |
| 4091 | client->swapped, &bad); |
| 4092 | if (!tmp) { |
| 4093 | client->errorValue = bad; |
| 4094 | return BadAtom5; |
| 4095 | } |
| 4096 | } |
| 4097 | if (stuff->which & XkbKeyNamesMask(1<<9)) { |
| 4098 | if (stuff->firstKey < (unsigned) xkb->min_key_code) { |
| 4099 | client->errorValue = _XkbErrCode3(0x0b, xkb->min_key_code,((XID)((((unsigned int)(0x0b))<<24)|(((((unsigned int)( xkb->min_key_code))<<16)|(stuff->firstKey))&0xffffff ))) |
| 4100 | stuff->firstKey)((XID)((((unsigned int)(0x0b))<<24)|(((((unsigned int)( xkb->min_key_code))<<16)|(stuff->firstKey))&0xffffff ))); |
| 4101 | return BadValue2; |
| 4102 | } |
| 4103 | if (((unsigned) (stuff->firstKey + stuff->nKeys - 1) > |
| 4104 | xkb->max_key_code) || (stuff->nKeys < 1)) { |
| 4105 | client->errorValue = |
| 4106 | _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))) |
| 4107 | stuff->nKeys)((XID)((((unsigned int)(0x0c))<<24)|(((((unsigned int)( xkb->max_key_code))<<16)|(((((unsigned int)(stuff-> firstKey))<<8)|(stuff->nKeys))))&0xffffff))); |
| 4108 | return BadValue2; |
| 4109 | } |
| 4110 | tmp += stuff->nKeys; |
| 4111 | } |
| 4112 | if ((stuff->which & XkbKeyAliasesMask(1<<10)) && (stuff->nKeyAliases > 0)) { |
| 4113 | tmp += stuff->nKeyAliases * 2; |
| 4114 | } |
| 4115 | if (stuff->which & XkbRGNamesMask(1<<13)) { |
| 4116 | if (stuff->nRadioGroups < 1) { |
| 4117 | client->errorValue = _XkbErrCode2(0x0d, stuff->nRadioGroups)((XID)((((unsigned int)(0x0d))<<24)|((stuff->nRadioGroups )&0xffffff))); |
| 4118 | return BadValue2; |
| 4119 | } |
| 4120 | tmp = _XkbCheckAtoms(tmp, stuff->nRadioGroups, client->swapped, &bad); |
| 4121 | if (!tmp) { |
| 4122 | client->errorValue = bad; |
| 4123 | return BadAtom5; |
| 4124 | } |
| 4125 | } |
| 4126 | if ((tmp - ((CARD32 *) stuff)) != stuff->length) { |
| 4127 | client->errorValue = stuff->length; |
| 4128 | return BadLength16; |
| 4129 | } |
| 4130 | |
| 4131 | return Success0; |
| 4132 | } |
| 4133 | |
| 4134 | static int |
| 4135 | _XkbSetNames(ClientPtr client, DeviceIntPtr dev, xkbSetNamesReq * stuff) |
| 4136 | { |
| 4137 | XkbDescRec *xkb; |
| 4138 | XkbNamesRec *names; |
| 4139 | CARD32 *tmp; |
| 4140 | xkbNamesNotify nn; |
| 4141 | |
| 4142 | tmp = (CARD32 *) &stuff[1]; |
| 4143 | xkb = dev->key->xkbInfo->desc; |
| 4144 | names = xkb->names; |
| 4145 | |
| 4146 | if (XkbAllocNamesSrvXkbAllocNames(xkb, stuff->which, stuff->nRadioGroups, |
| 4147 | stuff->nKeyAliases) != Success0) { |
| 4148 | return BadAlloc11; |
| 4149 | } |
| 4150 | |
| 4151 | memset(&nn, 0, sizeof(xkbNamesNotify))__builtin___memset_chk (&nn, 0, sizeof(xkbNamesNotify), __builtin_object_size (&nn, 0)); |
| 4152 | nn.changed = stuff->which; |
| 4153 | tmp = (CARD32 *) &stuff[1]; |
| 4154 | if (stuff->which & XkbKeycodesNameMask(1<<0)) |
| 4155 | names->keycodes = *tmp++; |
| 4156 | if (stuff->which & XkbGeometryNameMask(1<<1)) |
| 4157 | names->geometry = *tmp++; |
| 4158 | if (stuff->which & XkbSymbolsNameMask(1<<2)) |
| 4159 | names->symbols = *tmp++; |
| 4160 | if (stuff->which & XkbPhysSymbolsNameMask(1<<3)) |
| 4161 | names->phys_symbols = *tmp++; |
| 4162 | if (stuff->which & XkbTypesNameMask(1<<4)) |
| 4163 | names->types = *tmp++; |
| 4164 | if (stuff->which & XkbCompatNameMask(1<<5)) |
| 4165 | names->compat = *tmp++; |
| 4166 | if ((stuff->which & XkbKeyTypeNamesMask(1<<6)) && (stuff->nTypes > 0)) { |
| 4167 | register unsigned i; |
| 4168 | register XkbKeyTypePtr type; |
| 4169 | |
| 4170 | type = &xkb->map->types[stuff->firstType]; |
| 4171 | for (i = 0; i < stuff->nTypes; i++, type++) { |
| 4172 | type->name = *tmp++; |
| 4173 | } |
| 4174 | nn.firstType = stuff->firstType; |
| 4175 | nn.nTypes = stuff->nTypes; |
| 4176 | } |
| 4177 | if (stuff->which & XkbKTLevelNamesMask(1<<7)) { |
| 4178 | register XkbKeyTypePtr type; |
| 4179 | register unsigned i; |
| 4180 | CARD8 *width; |
| 4181 | |
| 4182 | width = (CARD8 *) tmp; |
| 4183 | tmp = (CARD32 *) (((char *) tmp) + XkbPaddedSize(stuff->nKTLevels)((((unsigned int)(stuff->nKTLevels)+3) >> 2) << 2)); |
| 4184 | type = &xkb->map->types[stuff->firstKTLevel]; |
| 4185 | for (i = 0; i < stuff->nKTLevels; i++, type++) { |
| 4186 | if (width[i] > 0) { |
| 4187 | if (type->level_names) { |
| 4188 | register unsigned n; |
| 4189 | |
| 4190 | for (n = 0; n < width[i]; n++) { |
| 4191 | type->level_names[n] = tmp[n]; |
| 4192 | } |
| 4193 | } |
| 4194 | tmp += width[i]; |
| 4195 | } |
| 4196 | } |
| 4197 | nn.firstLevelName = 0; |
| 4198 | nn.nLevelNames = stuff->nTypes; |
| 4199 | } |
| 4200 | if (stuff->which & XkbIndicatorNamesMask(1<<8)) { |
| 4201 | tmp = _XkbCopyMaskedAtoms(tmp, names->indicators, XkbNumIndicators32, |
| 4202 | stuff->indicators); |
| 4203 | nn.changedIndicators = stuff->indicators; |
| 4204 | } |
| 4205 | if (stuff->which & XkbVirtualModNamesMask(1<<11)) { |
| 4206 | tmp = _XkbCopyMaskedAtoms(tmp, names->vmods, XkbNumVirtualMods16, |
| 4207 | stuff->virtualMods); |
| 4208 | nn.changedVirtualMods = stuff->virtualMods; |
| 4209 | } |
| 4210 | if (stuff->which & XkbGroupNamesMask(1<<12)) { |
| 4211 | tmp = _XkbCopyMaskedAtoms(tmp, names->groups, XkbNumKbdGroups4, |
| 4212 | stuff->groupNames); |
| 4213 | nn.changedVirtualMods = stuff->groupNames; |
| 4214 | } |
| 4215 | if (stuff->which & XkbKeyNamesMask(1<<9)) { |
| 4216 | 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)) |
| 4217 | 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)); |
| 4218 | tmp += stuff->nKeys; |
| 4219 | nn.firstKey = stuff->firstKey; |
| 4220 | nn.nKeys = stuff->nKeys; |
| 4221 | } |
| 4222 | if (stuff->which & XkbKeyAliasesMask(1<<10)) { |
| 4223 | if (stuff->nKeyAliases > 0) { |
| 4224 | register int na = stuff->nKeyAliases; |
| 4225 | |
| 4226 | if (XkbAllocNamesSrvXkbAllocNames(xkb, XkbKeyAliasesMask(1<<10), 0, na) != Success0) |
| 4227 | return BadAlloc11; |
| 4228 | 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)) |
| 4229 | 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)); |
| 4230 | tmp += stuff->nKeyAliases * 2; |
| 4231 | } |
| 4232 | else if (names->key_aliases != NULL((void*)0)) { |
| 4233 | free(names->key_aliases); |
| 4234 | names->key_aliases = NULL((void*)0); |
| 4235 | names->num_key_aliases = 0; |
| 4236 | } |
| 4237 | nn.nAliases = names->num_key_aliases; |
| 4238 | } |
| 4239 | if (stuff->which & XkbRGNamesMask(1<<13)) { |
| 4240 | if (stuff->nRadioGroups > 0) { |
| 4241 | register unsigned i, nrg; |
| 4242 | |
| 4243 | nrg = stuff->nRadioGroups; |
| 4244 | if (XkbAllocNamesSrvXkbAllocNames(xkb, XkbRGNamesMask(1<<13), nrg, 0) != Success0) |
| 4245 | return BadAlloc11; |
| 4246 | |
| 4247 | for (i = 0; i < stuff->nRadioGroups; i++) { |
| 4248 | names->radio_groups[i] = tmp[i]; |
| 4249 | } |
| 4250 | tmp += stuff->nRadioGroups; |
| 4251 | } |
| 4252 | else if (names->radio_groups) { |
| 4253 | free(names->radio_groups); |
| 4254 | names->radio_groups = NULL((void*)0); |
| 4255 | names->num_rg = 0; |
| 4256 | } |
| 4257 | nn.nRadioGroups = names->num_rg; |
| 4258 | } |
| 4259 | if (nn.changed) { |
| 4260 | Bool needExtEvent; |
| 4261 | |
| 4262 | needExtEvent = (nn.changed & XkbIndicatorNamesMask(1<<8)) != 0; |
| 4263 | XkbSendNamesNotify(dev, &nn); |
| 4264 | if (needExtEvent) { |
| 4265 | XkbSrvLedInfoPtr sli; |
| 4266 | xkbExtensionDeviceNotify edev; |
| 4267 | register int i; |
| 4268 | register unsigned bit; |
| 4269 | |
| 4270 | sli = XkbFindSrvLedInfo(dev, XkbDfltXIClass0x0300, XkbDfltXIId0x0400, |
| 4271 | XkbXI_IndicatorsMask(0x001c)); |
| 4272 | sli->namesPresent = 0; |
| 4273 | for (i = 0, bit = 1; i < XkbNumIndicators32; i++, bit <<= 1) { |
| 4274 | if (names->indicators[i] != None0L) |
| 4275 | sli->namesPresent |= bit; |
| 4276 | } |
| 4277 | memset(&edev, 0, sizeof(xkbExtensionDeviceNotify))__builtin___memset_chk (&edev, 0, sizeof(xkbExtensionDeviceNotify ), __builtin_object_size (&edev, 0)); |
| 4278 | edev.reason = XkbXI_IndicatorNamesMask(1L << 2); |
| 4279 | edev.ledClass = KbdFeedbackClass0; |
| 4280 | edev.ledID = dev->kbdfeed->ctrl.id; |
| 4281 | edev.ledsDefined = sli->namesPresent | sli->mapsPresent; |
| 4282 | edev.ledState = sli->effectiveState; |
| 4283 | edev.firstBtn = 0; |
| 4284 | edev.nBtns = 0; |
| 4285 | edev.supported = XkbXI_AllFeaturesMask(0x001f); |
| 4286 | edev.unsupported = 0; |
| 4287 | XkbSendExtensionDeviceNotify(dev, client, &edev); |
| 4288 | } |
| 4289 | } |
| 4290 | return Success0; |
| 4291 | } |
| 4292 | |
| 4293 | int |
| 4294 | ProcXkbSetNames(ClientPtr client) |
| 4295 | { |
| 4296 | DeviceIntPtr dev; |
| 4297 | CARD32 *tmp; |
| 4298 | Atom bad; |
| 4299 | int rc; |
| 4300 | |
| 4301 | REQUEST(xkbSetNamesReq)xkbSetNamesReq *stuff = (xkbSetNamesReq *)client->requestBuffer; |
| 4302 | REQUEST_AT_LEAST_SIZE(xkbSetNamesReq)if ((sizeof(xkbSetNamesReq) >> 2) > client->req_len ) return(16); |
| 4303 | |
| 4304 | if (!(client->xkbClientFlags & _XkbClientInitialized(1<<15))) |
| 4305 | return BadAccess10; |
| 4306 | |
| 4307 | 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; }}; |
| 4308 | CHK_MASK_LEGAL(0x01, stuff->which, XkbAllNamesMask){ if ((stuff->which)&(~((0x3fff)))) { (client->errorValue )= ((XID)((((unsigned int)((0x01)))<<24)|((((stuff-> which)&(~((0x3fff)))))&0xffffff))); return 2; }}; |
| 4309 | |
| 4310 | /* check device-independent stuff */ |
| 4311 | tmp = (CARD32 *) &stuff[1]; |
| 4312 | |
| 4313 | if (stuff->which & XkbKeycodesNameMask(1<<0)) { |
| 4314 | tmp = _XkbCheckAtoms(tmp, 1, client->swapped, &bad); |
| 4315 | if (!tmp) { |
| 4316 | client->errorValue = bad; |
| 4317 | return BadAtom5; |
| 4318 | } |
| 4319 | } |
| 4320 | if (stuff->which & XkbGeometryNameMask(1<<1)) { |
| 4321 | tmp = _XkbCheckAtoms(tmp, 1, client->swapped, &bad); |
| 4322 | if (!tmp) { |
| 4323 | client->errorValue = bad; |
| 4324 | return BadAtom5; |
| 4325 | } |
| 4326 | } |
| 4327 | if (stuff->which & XkbSymbolsNameMask(1<<2)) { |
| 4328 | tmp = _XkbCheckAtoms(tmp, 1, client->swapped, &bad); |
| 4329 | if (!tmp) { |
| 4330 | client->errorValue = bad; |
| 4331 | return BadAtom5; |
| 4332 | } |
| 4333 | } |
| 4334 | if (stuff->which & XkbPhysSymbolsNameMask(1<<3)) { |
| 4335 | tmp = _XkbCheckAtoms(tmp, 1, client->swapped, &bad); |
| 4336 | if (!tmp) { |
| 4337 | client->errorValue = bad; |
| 4338 | return BadAtom5; |
| 4339 | } |
| 4340 | } |
| 4341 | if (stuff->which & XkbTypesNameMask(1<<4)) { |
| 4342 | tmp = _XkbCheckAtoms(tmp, 1, client->swapped, &bad); |
| 4343 | if (!tmp) { |
| 4344 | client->errorValue = bad; |
| 4345 | return BadAtom5; |
| 4346 | } |
| 4347 | } |
| 4348 | if (stuff->which & XkbCompatNameMask(1<<5)) { |
| 4349 | tmp = _XkbCheckAtoms(tmp, 1, client->swapped, &bad); |
| 4350 | if (!tmp) { |
| 4351 | client->errorValue = bad; |
| 4352 | return BadAtom5; |
| 4353 | } |
| 4354 | } |
| 4355 | |
| 4356 | /* start of device-dependent tests */ |
| 4357 | rc = _XkbSetNamesCheck(client, dev, stuff, tmp); |
| 4358 | if (rc != Success0) |
| 4359 | return rc; |
| 4360 | |
| 4361 | if (stuff->deviceSpec == XkbUseCoreKbd0x0100) { |
| 4362 | DeviceIntPtr other; |
| 4363 | |
| 4364 | for (other = inputInfo.devices; other; other = other->next) { |
| 4365 | if ((other != dev) && other->key && !IsMaster(other) && |
| 4366 | GetMaster(other, MASTER_KEYBOARD2) == dev) { |
| 4367 | |
| 4368 | rc = XaceHook(XACE_DEVICE_ACCESS3, client, other, |
| 4369 | DixManageAccess(1<<25)); |
| 4370 | if (rc == Success0) { |
| 4371 | rc = _XkbSetNamesCheck(client, other, stuff, tmp); |
| 4372 | if (rc != Success0) |
| 4373 | return rc; |
| 4374 | } |
| 4375 | } |
| 4376 | } |
| 4377 | } |
| 4378 | |
| 4379 | /* everything is okay -- update names */ |
| 4380 | |
| 4381 | rc = _XkbSetNames(client, dev, stuff); |
| 4382 | if (rc != Success0) |
| 4383 | return rc; |
| 4384 | |
| 4385 | if (stuff->deviceSpec == XkbUseCoreKbd0x0100) { |
| 4386 | DeviceIntPtr other; |
| 4387 | |
| 4388 | for (other = inputInfo.devices; other; other = other->next) { |
| 4389 | if ((other != dev) && other->key && !IsMaster(other) && |
| 4390 | GetMaster(other, MASTER_KEYBOARD2) == dev) { |
| 4391 | |
| 4392 | rc = XaceHook(XACE_DEVICE_ACCESS3, client, other, |
| 4393 | DixManageAccess(1<<25)); |
| 4394 | if (rc == Success0) |
| 4395 | _XkbSetNames(client, other, stuff); |
| 4396 | } |
| 4397 | } |
| 4398 | } |
| 4399 | |
| 4400 | /* everything is okay -- update names */ |
| 4401 | |
| 4402 | return Success0; |
| 4403 | } |
| 4404 | |
| 4405 | /***====================================================================***/ |
| 4406 | |
| 4407 | #include "xkbgeom.h" |
| 4408 | |
| 4409 | #define XkbSizeCountedString(s)((s)?((((2+strlen(s))+3)/4)*4):4) ((s)?((((2+strlen(s))+3)/4)*4):4) |
| 4410 | |
| 4411 | /** |
| 4412 | * Write the zero-terminated string str into wire as a pascal string with a |
| 4413 | * 16-bit length field prefixed before the actual string. |
| 4414 | * |
| 4415 | * @param wire The destination array, usually the wire struct |
| 4416 | * @param str The source string as zero-terminated C string |
| 4417 | * @param swap If TRUE, the length field is swapped. |
| 4418 | * |
| 4419 | * @return The input string in the format <string length><string> with a |
| 4420 | * (swapped) 16 bit string length, non-zero terminated. |
| 4421 | */ |
| 4422 | static char * |
| 4423 | XkbWriteCountedString(char *wire, const char *str, Bool swap) |
| 4424 | { |
| 4425 | CARD16 len, *pLen, paddedLen; |
| 4426 | |
| 4427 | if (!str) |
| 4428 | return wire; |
| 4429 | |
| 4430 | len = strlen(str); |
| 4431 | pLen = (CARD16 *) wire; |
| 4432 | *pLen = len; |
| 4433 | if (swap) { |
| 4434 | 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); |
| 4435 | } |
| 4436 | paddedLen = pad_to_int32(sizeof(len) + len) - sizeof(len); |
| 4437 | strncpy(&wire[sizeof(len)], str, paddedLen)__builtin___strncpy_chk (&wire[sizeof(len)], str, paddedLen , __builtin_object_size (&wire[sizeof(len)], 2 > 1 ? 1 : 0)); |
| 4438 | wire += sizeof(len) + paddedLen; |
| 4439 | return wire; |
| 4440 | } |
| 4441 | |
| 4442 | static int |
| 4443 | XkbSizeGeomProperties(XkbGeometryPtr geom) |
| 4444 | { |
| 4445 | register int i, size; |
| 4446 | XkbPropertyPtr prop; |
| 4447 | |
| 4448 | for (size = i = 0, prop = geom->properties; i < geom->num_properties; |
| 4449 | i++, prop++) { |
| 4450 | size += XkbSizeCountedString(prop->name)((prop->name)?((((2+strlen(prop->name))+3)/4)*4):4); |
| 4451 | size += XkbSizeCountedString(prop->value)((prop->value)?((((2+strlen(prop->value))+3)/4)*4):4); |
| 4452 | } |
| 4453 | return size; |
| 4454 | } |
| 4455 | |
| 4456 | static char * |
| 4457 | XkbWriteGeomProperties(char *wire, XkbGeometryPtr geom, Bool swap) |
| 4458 | { |
| 4459 | register int i; |
| 4460 | register XkbPropertyPtr prop; |
| 4461 | |
| 4462 | for (i = 0, prop = geom->properties; i < geom->num_properties; i++, prop++) { |
| 4463 | wire = XkbWriteCountedString(wire, prop->name, swap); |
| 4464 | wire = XkbWriteCountedString(wire, prop->value, swap); |
| 4465 | } |
| 4466 | return wire; |
| 4467 | } |
| 4468 | |
| 4469 | static int |
| 4470 | XkbSizeGeomKeyAliases(XkbGeometryPtr geom) |
| 4471 | { |
| 4472 | return geom->num_key_aliases * (2 * XkbKeyNameLength4); |
| 4473 | } |
| 4474 | |
| 4475 | static char * |
| 4476 | XkbWriteGeomKeyAliases(char *wire, XkbGeometryPtr geom, Bool swap) |
| 4477 | { |
| 4478 | register int sz; |
| 4479 | |
| 4480 | sz = geom->num_key_aliases * (XkbKeyNameLength4 * 2); |
| 4481 | if (sz > 0) { |
| 4482 | memcpy(wire, (char *) geom->key_aliases, sz)__builtin___memcpy_chk (wire, (char *) geom->key_aliases, sz , __builtin_object_size (wire, 0)); |
| 4483 | wire += sz; |
| 4484 | } |
| 4485 | return wire; |
| 4486 | } |
| 4487 | |
| 4488 | static int |
| 4489 | XkbSizeGeomColors(XkbGeometryPtr geom) |
| 4490 | { |
| 4491 | register int i, size; |
| 4492 | register XkbColorPtr color; |
| 4493 | |
| 4494 | for (i = size = 0, color = geom->colors; i < geom->num_colors; i++, color++) { |
| 4495 | size += XkbSizeCountedString(color->spec)((color->spec)?((((2+strlen(color->spec))+3)/4)*4):4); |
| 4496 | } |
| 4497 | return size; |
| 4498 | } |
| 4499 | |
| 4500 | static char * |
| 4501 | XkbWriteGeomColors(char *wire, XkbGeometryPtr geom, Bool swap) |
| 4502 | { |
| 4503 | register int i; |
| 4504 | register XkbColorPtr color; |
| 4505 | |
| 4506 | for (i = 0, color = geom->colors; i < geom->num_colors; i++, color++) { |
| 4507 | wire = XkbWriteCountedString(wire, color->spec, swap); |
| 4508 | } |
| 4509 | return wire; |
| 4510 | } |
| 4511 | |
| 4512 | static int |
| 4513 | XkbSizeGeomShapes(XkbGeometryPtr geom) |
| 4514 | { |
| 4515 | register int i, size; |
| 4516 | register XkbShapePtr shape; |
| 4517 | |
| 4518 | for (i = size = 0, shape = geom->shapes; i < geom->num_shapes; i++, shape++) { |
| 4519 | register int n; |
| 4520 | register XkbOutlinePtr ol; |
| 4521 | |
| 4522 | size += SIZEOF(xkbShapeWireDesc)8; |
| 4523 | for (n = 0, ol = shape->outlines; n < shape->num_outlines; n++, ol++) { |
| 4524 | size += SIZEOF(xkbOutlineWireDesc)4; |
| 4525 | size += ol->num_points * SIZEOF(xkbPointWireDesc)4; |
| 4526 | } |
| 4527 | } |
| 4528 | return size; |
| 4529 | } |
| 4530 | |
| 4531 | static char * |
| 4532 | XkbWriteGeomShapes(char *wire, XkbGeometryPtr geom, Bool swap) |
| 4533 | { |
| 4534 | int i; |
| 4535 | XkbShapePtr shape; |
| 4536 | xkbShapeWireDesc *shapeWire; |
| 4537 | |
| 4538 | for (i = 0, shape = geom->shapes; i < geom->num_shapes; i++, shape++) { |
| 4539 | register int o; |
| 4540 | XkbOutlinePtr ol; |
| 4541 | xkbOutlineWireDesc *olWire; |
| 4542 | |
| 4543 | shapeWire = (xkbShapeWireDesc *) wire; |
| 4544 | shapeWire->name = shape->name; |
| 4545 | shapeWire->nOutlines = shape->num_outlines; |
| 4546 | if (shape->primary != NULL((void*)0)) |
| 4547 | shapeWire->primaryNdx = XkbOutlineIndex(shape, shape->primary)((int)((shape->primary)-&(shape)->outlines[0])); |
| 4548 | else |
| 4549 | shapeWire->primaryNdx = XkbNoShape0xff; |
| 4550 | if (shape->approx != NULL((void*)0)) |
| 4551 | shapeWire->approxNdx = XkbOutlineIndex(shape, shape->approx)((int)((shape->approx)-&(shape)->outlines[0])); |
| 4552 | else |
| 4553 | shapeWire->approxNdx = XkbNoShape0xff; |
| 4554 | shapeWire->pad = 0; |
| 4555 | if (swap) { |
| 4556 | 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); |
| 4557 | } |
| 4558 | wire = (char *) &shapeWire[1]; |
| 4559 | for (o = 0, ol = shape->outlines; o < shape->num_outlines; o++, ol++) { |
| 4560 | register int p; |
| 4561 | XkbPointPtr pt; |
| 4562 | xkbPointWireDesc *ptWire; |
| 4563 | |
| 4564 | olWire = (xkbOutlineWireDesc *) wire; |
| 4565 | olWire->nPoints = ol->num_points; |
| 4566 | olWire->cornerRadius = ol->corner_radius; |
| 4567 | olWire->pad = 0; |
| 4568 | wire = (char *) &olWire[1]; |
| 4569 | ptWire = (xkbPointWireDesc *) wire; |
| 4570 | for (p = 0, pt = ol->points; p < ol->num_points; p++, pt++) { |
| 4571 | ptWire[p].x = pt->x; |
| 4572 | ptWire[p].y = pt->y; |
| 4573 | if (swap) { |
| 4574 | 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); |
| 4575 | 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); |
| 4576 | } |
| 4577 | } |
| 4578 | wire = (char *) &ptWire[ol->num_points]; |
| 4579 | } |
| 4580 | } |
| 4581 | return wire; |
| 4582 | } |
| 4583 | |
| 4584 | static int |
| 4585 | XkbSizeGeomDoodads(int num_doodads, XkbDoodadPtr doodad) |
| 4586 | { |
| 4587 | register int i, size; |
| 4588 | |
| 4589 | for (i = size = 0; i < num_doodads; i++, doodad++) { |
| 4590 | size += SIZEOF(xkbAnyDoodadWireDesc)20; |
| 4591 | if (doodad->any.type == XkbTextDoodad3) { |
| 4592 | size += XkbSizeCountedString(doodad->text.text)((doodad->text.text)?((((2+strlen(doodad->text.text))+3 )/4)*4):4); |
| 4593 | size += XkbSizeCountedString(doodad->text.font)((doodad->text.font)?((((2+strlen(doodad->text.font))+3 )/4)*4):4); |
| 4594 | } |
| 4595 | else if (doodad->any.type == XkbLogoDoodad5) { |
| 4596 | size += XkbSizeCountedString(doodad->logo.logo_name)((doodad->logo.logo_name)?((((2+strlen(doodad->logo.logo_name ))+3)/4)*4):4); |
| 4597 | } |
| 4598 | } |
| 4599 | return size; |
| 4600 | } |
| 4601 | |
| 4602 | static char * |
| 4603 | XkbWriteGeomDoodads(char *wire, int num_doodads, XkbDoodadPtr doodad, Bool swap) |
| 4604 | { |
| 4605 | register int i; |
| 4606 | xkbDoodadWireDesc *doodadWire; |
| 4607 | |
| 4608 | for (i = 0; i < num_doodads; i++, doodad++) { |
| 4609 | doodadWire = (xkbDoodadWireDesc *) wire; |
| 4610 | wire = (char *) &doodadWire[1]; |
| 4611 | memset(doodadWire, 0, SIZEOF(xkbDoodadWireDesc))__builtin___memset_chk (doodadWire, 0, 20, __builtin_object_size (doodadWire, 0)); |
| 4612 | doodadWire->any.name = doodad->any.name; |
| 4613 | doodadWire->any.type = doodad->any.type; |
| 4614 | doodadWire->any.priority = doodad->any.priority; |
| 4615 | doodadWire->any.top = doodad->any.top; |
| 4616 | doodadWire->any.left = doodad->any.left; |
| 4617 | if (swap) { |
| 4618 | 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); |
| 4619 | 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); |
| 4620 | 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); |
| 4621 | } |
| 4622 | switch (doodad->any.type) { |
| 4623 | case XkbOutlineDoodad1: |
| 4624 | case XkbSolidDoodad2: |
| 4625 | doodadWire->shape.angle = doodad->shape.angle; |
| 4626 | doodadWire->shape.colorNdx = doodad->shape.color_ndx; |
| 4627 | doodadWire->shape.shapeNdx = doodad->shape.shape_ndx; |
| 4628 | if (swap) { |
| 4629 | 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); |
| 4630 | } |
| 4631 | break; |
| 4632 | case XkbTextDoodad3: |
| 4633 | doodadWire->text.angle = doodad->text.angle; |
| 4634 | doodadWire->text.width = doodad->text.width; |
| 4635 | doodadWire->text.height = doodad->text.height; |
| 4636 | doodadWire->text.colorNdx = doodad->text.color_ndx; |
| 4637 | if (swap) { |
| 4638 | 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); |
| 4639 | 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); |
| 4640 | 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); |
| 4641 | } |
| 4642 | wire = XkbWriteCountedString(wire, doodad->text.text, swap); |
| 4643 | wire = XkbWriteCountedString(wire, doodad->text.font, swap); |
| 4644 | break; |
| 4645 | case XkbIndicatorDoodad4: |
| 4646 | doodadWire->indicator.shapeNdx = doodad->indicator.shape_ndx; |
| 4647 | doodadWire->indicator.onColorNdx = doodad->indicator.on_color_ndx; |
| 4648 | doodadWire->indicator.offColorNdx = doodad->indicator.off_color_ndx; |
| 4649 | break; |
| 4650 | case XkbLogoDoodad5: |
| 4651 | doodadWire->logo.angle = doodad->logo.angle; |
| 4652 | doodadWire->logo.colorNdx = doodad->logo.color_ndx; |
| 4653 | doodadWire->logo.shapeNdx = doodad->logo.shape_ndx; |
| 4654 | wire = XkbWriteCountedString(wire, doodad->logo.logo_name, swap); |
| 4655 | break; |
| 4656 | default: |
| 4657 | ErrorF("[xkb] Unknown doodad type %d in XkbWriteGeomDoodads\n", |
| 4658 | doodad->any.type); |
| 4659 | ErrorF("[xkb] Ignored\n"); |
| 4660 | break; |
| 4661 | } |
| 4662 | } |
| 4663 | return wire; |
| 4664 | } |
| 4665 | |
| 4666 | static char * |
| 4667 | XkbWriteGeomOverlay(char *wire, XkbOverlayPtr ol, Bool swap) |
| 4668 | { |
| 4669 | register int r; |
| 4670 | XkbOverlayRowPtr row; |
| 4671 | xkbOverlayWireDesc *olWire; |
| 4672 | |
| 4673 | olWire = (xkbOverlayWireDesc *) wire; |
| 4674 | olWire->name = ol->name; |
| 4675 | olWire->nRows = ol->num_rows; |
| 4676 | olWire->pad1 = 0; |
| 4677 | olWire->pad2 = 0; |
| 4678 | if (swap) { |
| 4679 | 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); |
| 4680 | } |
| 4681 | wire = (char *) &olWire[1]; |
| 4682 | for (r = 0, row = ol->rows; r < ol->num_rows; r++, row++) { |
| 4683 | unsigned int k; |
| 4684 | XkbOverlayKeyPtr key; |
| 4685 | xkbOverlayRowWireDesc *rowWire; |
| 4686 | |
| 4687 | rowWire = (xkbOverlayRowWireDesc *) wire; |
| 4688 | rowWire->rowUnder = row->row_under; |
| 4689 | rowWire->nKeys = row->num_keys; |
| 4690 | rowWire->pad1 = 0; |
| 4691 | wire = (char *) &rowWire[1]; |
| 4692 | for (k = 0, key = row->keys; k < row->num_keys; k++, key++) { |
| 4693 | xkbOverlayKeyWireDesc *keyWire; |
| 4694 | |
| 4695 | keyWire = (xkbOverlayKeyWireDesc *) wire; |
| 4696 | memcpy(keyWire->over, key->over.name, XkbKeyNameLength)__builtin___memcpy_chk (keyWire->over, key->over.name, 4 , __builtin_object_size (keyWire->over, 0)); |
| 4697 | memcpy(keyWire->under, key->under.name, XkbKeyNameLength)__builtin___memcpy_chk (keyWire->under, key->under.name , 4, __builtin_object_size (keyWire->under, 0)); |
| 4698 | wire = (char *) &keyWire[1]; |
| 4699 | } |
| 4700 | } |
| 4701 | return wire; |
| 4702 | } |
| 4703 | |
| 4704 | static int |
| 4705 | XkbSizeGeomSections(XkbGeometryPtr geom) |
| 4706 | { |
| 4707 | register int i, size; |
| 4708 | XkbSectionPtr section; |
| 4709 | |
| 4710 | for (i = size = 0, section = geom->sections; i < geom->num_sections; |
| 4711 | i++, section++) { |
| 4712 | size += SIZEOF(xkbSectionWireDesc)20; |
| 4713 | if (section->rows) { |
| 4714 | int r; |
| 4715 | XkbRowPtr row; |
| 4716 | |
| 4717 | for (r = 0, row = section->rows; r < section->num_rows; row++, r++) { |
| 4718 | size += SIZEOF(xkbRowWireDesc)8; |
| 4719 | size += row->num_keys * SIZEOF(xkbKeyWireDesc)8; |
| 4720 | } |
| 4721 | } |
| 4722 | if (section->doodads) |
| 4723 | size += XkbSizeGeomDoodads(section->num_doodads, section->doodads); |
| 4724 | if (section->overlays) { |
| 4725 | int o; |
| 4726 | XkbOverlayPtr ol; |
| 4727 | |
| 4728 | for (o = 0, ol = section->overlays; o < section->num_overlays; |
| 4729 | o++, ol++) { |
| 4730 | int r; |
| 4731 | XkbOverlayRowPtr row; |
| 4732 | |
| 4733 | size += SIZEOF(xkbOverlayWireDesc)8; |
| 4734 | for (r = 0, row = ol->rows; r < ol->num_rows; r++, row++) { |
| 4735 | size += SIZEOF(xkbOverlayRowWireDesc)4; |
| 4736 | size += row->num_keys * SIZEOF(xkbOverlayKeyWireDesc)8; |
| 4737 | } |
| 4738 | } |
| 4739 | } |
| 4740 | } |
| 4741 | return size; |
| 4742 | } |
| 4743 | |
| 4744 | static char * |
| 4745 | XkbWriteGeomSections(char *wire, XkbGeometryPtr geom, Bool swap) |
| 4746 | { |
| 4747 | register int i; |
| 4748 | XkbSectionPtr section; |
| 4749 | xkbSectionWireDesc *sectionWire; |
| 4750 | |
| 4751 | for (i = 0, section = geom->sections; i < geom->num_sections; |
| 4752 | i++, section++) { |
| 4753 | sectionWire = (xkbSectionWireDesc *) wire; |
| 4754 | sectionWire->name = section->name; |
| 4755 | sectionWire->top = section->top; |
| 4756 | sectionWire->left = section->left; |
| 4757 | sectionWire->width = section->width; |
| 4758 | sectionWire->height = section->height; |
| 4759 | sectionWire->angle = section->angle; |
| 4760 | sectionWire->priority = section->priority; |
| 4761 | sectionWire->nRows = section->num_rows; |
| 4762 | sectionWire->nDoodads = section->num_doodads; |
| 4763 | sectionWire->nOverlays = section->num_overlays; |
| 4764 | sectionWire->pad = 0; |
| 4765 | if (swap) { |
| 4766 | 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); |
| 4767 | 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); |
| 4768 | 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); |
| 4769 | 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); |
| 4770 | 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); |
| 4771 | 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); |
| 4772 | } |
| 4773 | wire = (char *) §ionWire[1]; |
| 4774 | if (section->rows) { |
| 4775 | int r; |
| 4776 | XkbRowPtr row; |
| 4777 | xkbRowWireDesc *rowWire; |
| 4778 | |
| 4779 | for (r = 0, row = section->rows; r < section->num_rows; r++, row++) { |
| 4780 | rowWire = (xkbRowWireDesc *) wire; |
| 4781 | rowWire->top = row->top; |
| 4782 | rowWire->left = row->left; |
| 4783 | rowWire->nKeys = row->num_keys; |
| 4784 | rowWire->vertical = row->vertical; |
| 4785 | rowWire->pad = 0; |
| 4786 | if (swap) { |
| 4787 | 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); |
| 4788 | 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); |
| 4789 | } |
| 4790 | wire = (char *) &rowWire[1]; |
| 4791 | if (row->keys) { |
| 4792 | int k; |
| 4793 | XkbKeyPtr key; |
| 4794 | xkbKeyWireDesc *keyWire; |
| 4795 | |
| 4796 | keyWire = (xkbKeyWireDesc *) wire; |
| 4797 | for (k = 0, key = row->keys; k < row->num_keys; k++, key++) { |
| 4798 | memcpy(keyWire[k].name, key->name.name,__builtin___memcpy_chk (keyWire[k].name, key->name.name, 4 , __builtin_object_size (keyWire[k].name, 0)) |
| 4799 | XkbKeyNameLength)__builtin___memcpy_chk (keyWire[k].name, key->name.name, 4 , __builtin_object_size (keyWire[k].name, 0)); |
| 4800 | keyWire[k].gap = key->gap; |
| 4801 | keyWire[k].shapeNdx = key->shape_ndx; |
| 4802 | keyWire[k].colorNdx = key->color_ndx; |
| 4803 | if (swap) { |
| 4804 | 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); |
| 4805 | } |
| 4806 | } |
| 4807 | wire = (char *) &keyWire[row->num_keys]; |
| 4808 | } |
| 4809 | } |
| 4810 | } |
| 4811 | if (section->doodads) { |
| 4812 | wire = XkbWriteGeomDoodads(wire, |
| 4813 | section->num_doodads, section->doodads, |
| 4814 | swap); |
| 4815 | } |
| 4816 | if (section->overlays) { |
| 4817 | register int o; |
| 4818 | |
| 4819 | for (o = 0; o < section->num_overlays; o++) { |
| 4820 | wire = XkbWriteGeomOverlay(wire, §ion->overlays[o], swap); |
| 4821 | } |
| 4822 | } |
| 4823 | } |
| 4824 | return wire; |
| 4825 | } |
| 4826 | |
| 4827 | static Statusint |
| 4828 | XkbComputeGetGeometryReplySize(XkbGeometryPtr geom, |
| 4829 | xkbGetGeometryReply * rep, Atom name) |
| 4830 | { |
| 4831 | int len; |
| 4832 | |
| 4833 | if (geom != NULL((void*)0)) { |
| 4834 | len = XkbSizeCountedString(geom->label_font)((geom->label_font)?((((2+strlen(geom->label_font))+3)/ 4)*4):4); |
| 4835 | len += XkbSizeGeomProperties(geom); |
| 4836 | len += XkbSizeGeomColors(geom); |
| 4837 | len += XkbSizeGeomShapes(geom); |
| 4838 | len += XkbSizeGeomSections(geom); |
| 4839 | len += XkbSizeGeomDoodads(geom->num_doodads, geom->doodads); |
| 4840 | len += XkbSizeGeomKeyAliases(geom); |
| 4841 | rep->length = len / 4; |
| 4842 | rep->found = TRUE1; |
| 4843 | rep->name = geom->name; |
| 4844 | rep->widthMM = geom->width_mm; |
| 4845 | rep->heightMM = geom->height_mm; |
| 4846 | rep->nProperties = geom->num_properties; |
| 4847 | rep->nColors = geom->num_colors; |
| 4848 | rep->nShapes = geom->num_shapes; |
| 4849 | rep->nSections = geom->num_sections; |
| 4850 | rep->nDoodads = geom->num_doodads; |
| 4851 | rep->nKeyAliases = geom->num_key_aliases; |
| 4852 | rep->baseColorNdx = XkbGeomColorIndex(geom, geom->base_color)((int)((geom->base_color)-&(geom)->colors[0])); |
| 4853 | rep->labelColorNdx = XkbGeomColorIndex(geom, geom->label_color)((int)((geom->label_color)-&(geom)->colors[0])); |
| 4854 | } |
| 4855 | else { |
| 4856 | rep->length = 0; |
| 4857 | rep->found = FALSE0; |
| 4858 | rep->name = name; |
| 4859 | rep->widthMM = rep->heightMM = 0; |
| 4860 | rep->nProperties = rep->nColors = rep->nShapes = 0; |
| 4861 | rep->nSections = rep->nDoodads = 0; |
| 4862 | rep->nKeyAliases = 0; |
| 4863 | rep->labelColorNdx = rep->baseColorNdx = 0; |
| 4864 | } |
| 4865 | return Success0; |
| 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 | start = desc = xallocarray(rep->length, 4)xreallocarray(((void*)0), (rep->length), (4)); |
| 4876 | if (!start) |
| 4877 | return BadAlloc11; |
| 4878 | len = rep->length * 4; |
| 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 | } |