XKBGetMap.c revision 1ab64890
11ab64890Smrg/* $Xorg: XKBGetMap.c,v 1.4 2000/08/17 19:45:02 cpqbld Exp $ */
21ab64890Smrg/************************************************************
31ab64890SmrgCopyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
41ab64890Smrg
51ab64890SmrgPermission to use, copy, modify, and distribute this
61ab64890Smrgsoftware and its documentation for any purpose and without
71ab64890Smrgfee is hereby granted, provided that the above copyright
81ab64890Smrgnotice appear in all copies and that both that copyright
91ab64890Smrgnotice and this permission notice appear in supporting
101ab64890Smrgdocumentation, and that the name of Silicon Graphics not be
111ab64890Smrgused in advertising or publicity pertaining to distribution
121ab64890Smrgof the software without specific prior written permission.
131ab64890SmrgSilicon Graphics makes no representation about the suitability
141ab64890Smrgof this software for any purpose. It is provided "as is"
151ab64890Smrgwithout any express or implied warranty.
161ab64890Smrg
171ab64890SmrgSILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
181ab64890SmrgSOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
191ab64890SmrgAND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
201ab64890SmrgGRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
211ab64890SmrgDAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
221ab64890SmrgDATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
231ab64890SmrgOR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
241ab64890SmrgTHE USE OR PERFORMANCE OF THIS SOFTWARE.
251ab64890Smrg
261ab64890Smrg********************************************************/
271ab64890Smrg
281ab64890Smrg/* $XFree86: xc/lib/X11/XKBGetMap.c,v 1.9 2003/04/17 02:06:31 dawes Exp $ */
291ab64890Smrg
301ab64890Smrg#define NEED_REPLIES
311ab64890Smrg#define NEED_EVENTS
321ab64890Smrg#define	NEED_MAP_READERS
331ab64890Smrg#ifdef HAVE_CONFIG_H
341ab64890Smrg#include <config.h>
351ab64890Smrg#endif
361ab64890Smrg#include "Xlibint.h"
371ab64890Smrg#include <X11/extensions/XKBproto.h>
381ab64890Smrg#include "XKBlibint.h"
391ab64890Smrg
401ab64890Smrgstatic Status
411ab64890Smrg_XkbReadKeyTypes(XkbReadBufferPtr buf,XkbDescPtr xkb,xkbGetMapReply *rep)
421ab64890Smrg{
431ab64890Smrgint		 i,n,lastMapCount;
441ab64890SmrgXkbKeyTypePtr	type;
451ab64890Smrg
461ab64890Smrg    if ( rep->nTypes>0 ) {
471ab64890Smrg	n = rep->firstType+rep->nTypes;
481ab64890Smrg	if (xkb->map->num_types>=n)
491ab64890Smrg	    n= xkb->map->num_types;
501ab64890Smrg	else if (XkbAllocClientMap(xkb,XkbKeyTypesMask,n)!=Success)
511ab64890Smrg	    return BadAlloc;
521ab64890Smrg
531ab64890Smrg	type = &xkb->map->types[rep->firstType];
541ab64890Smrg	for (i=0;i<(int)rep->nTypes;i++,type++) {
551ab64890Smrg	    xkbKeyTypeWireDesc	*desc;
561ab64890Smrg	    register int ndx;
571ab64890Smrg
581ab64890Smrg	    ndx= i+rep->firstType;
591ab64890Smrg	    if (ndx>=xkb->map->num_types)
601ab64890Smrg		xkb->map->num_types= ndx+1;
611ab64890Smrg
621ab64890Smrg	    desc= (xkbKeyTypeWireDesc *)_XkbGetReadBufferPtr(buf,
631ab64890Smrg						SIZEOF(xkbKeyTypeWireDesc));
641ab64890Smrg	    if (desc==NULL)
651ab64890Smrg		return BadLength;
661ab64890Smrg
671ab64890Smrg	    lastMapCount= type->map_count;
681ab64890Smrg	    if ( desc->nMapEntries>0 ) {
691ab64890Smrg		if ((type->map==NULL)||(desc->nMapEntries>type->map_count)) {
701ab64890Smrg		    XkbKTMapEntryRec *prev_map = type->map;
711ab64890Smrg
721ab64890Smrg		    type->map= _XkbTypedRealloc(type->map,desc->nMapEntries,
731ab64890Smrg							      XkbKTMapEntryRec);
741ab64890Smrg		    if (type->map==NULL) {
751ab64890Smrg			_XkbFree(prev_map);
761ab64890Smrg			return BadAlloc;
771ab64890Smrg		    }
781ab64890Smrg		}
791ab64890Smrg	    }
801ab64890Smrg	    else if (type->map!=NULL) {
811ab64890Smrg		Xfree(type->map);
821ab64890Smrg		type->map_count= 0;
831ab64890Smrg		type->map= NULL;
841ab64890Smrg	    }
851ab64890Smrg
861ab64890Smrg	    if ( desc->preserve && (desc->nMapEntries>0) ) {
871ab64890Smrg		if ((!type->preserve)||
881ab64890Smrg		    (desc->nMapEntries>lastMapCount)) {
891ab64890Smrg		    XkbModsRec *prev_preserve = type->preserve;
901ab64890Smrg
911ab64890Smrg		    type->preserve= _XkbTypedRealloc(type->preserve,
921ab64890Smrg							desc->nMapEntries,
931ab64890Smrg							XkbModsRec);
941ab64890Smrg		    if (type->preserve==NULL) {
951ab64890Smrg			_XkbFree(prev_preserve);
961ab64890Smrg			return BadAlloc;
971ab64890Smrg		    }
981ab64890Smrg		}
991ab64890Smrg	    }
1001ab64890Smrg	    else if (type->preserve!=NULL) {
1011ab64890Smrg		Xfree(type->preserve);
1021ab64890Smrg		type->preserve= NULL;
1031ab64890Smrg	    }
1041ab64890Smrg
1051ab64890Smrg	    type->mods.mask = desc->mask;
1061ab64890Smrg	    type->mods.real_mods = desc->realMods;
1071ab64890Smrg	    type->mods.vmods = desc->virtualMods;
1081ab64890Smrg	    type->num_levels = desc->numLevels;
1091ab64890Smrg	    type->map_count = desc->nMapEntries;
1101ab64890Smrg	    if (desc->nMapEntries>0) {
1111ab64890Smrg		register xkbKTMapEntryWireDesc *wire;
1121ab64890Smrg		register XkbKTMapEntryPtr	entry;
1131ab64890Smrg		register int size;
1141ab64890Smrg
1151ab64890Smrg		size= type->map_count*SIZEOF(xkbKTMapEntryWireDesc);
1161ab64890Smrg		wire= (xkbKTMapEntryWireDesc *)_XkbGetReadBufferPtr(buf,size);
1171ab64890Smrg		if (wire==NULL)
1181ab64890Smrg		    return BadLength;
1191ab64890Smrg		entry= type->map;
1201ab64890Smrg		for (n=0;n<type->map_count;n++,wire++,entry++) {
1211ab64890Smrg		    entry->active= wire->active;
1221ab64890Smrg		    entry->level= wire->level;
1231ab64890Smrg		    entry->mods.mask= wire->mask;
1241ab64890Smrg		    entry->mods.real_mods= wire->realMods;
1251ab64890Smrg		    entry->mods.vmods= wire->virtualMods;
1261ab64890Smrg		}
1271ab64890Smrg
1281ab64890Smrg	 	if (desc->preserve) {
1291ab64890Smrg		    register xkbModsWireDesc *	pwire;
1301ab64890Smrg		    register XkbModsPtr		preserve;
1311ab64890Smrg		    register int sz;
1321ab64890Smrg
1331ab64890Smrg		    sz= desc->nMapEntries*SIZEOF(xkbModsWireDesc);
1341ab64890Smrg		    pwire=(xkbModsWireDesc *)_XkbGetReadBufferPtr(buf,sz);
1351ab64890Smrg		    if (pwire==NULL)
1361ab64890Smrg			return BadLength;
1371ab64890Smrg		    preserve= type->preserve;
1381ab64890Smrg		    for (n=0;n<desc->nMapEntries;n++,pwire++,preserve++) {
1391ab64890Smrg			preserve->mask=  pwire->mask;
1401ab64890Smrg			preserve->vmods=  pwire->virtualMods;
1411ab64890Smrg			preserve->real_mods= pwire->realMods;
1421ab64890Smrg		    }
1431ab64890Smrg		}
1441ab64890Smrg	    }
1451ab64890Smrg	}
1461ab64890Smrg    }
1471ab64890Smrg    return Success;
1481ab64890Smrg}
1491ab64890Smrg
1501ab64890Smrgstatic Status
1511ab64890Smrg_XkbReadKeySyms(XkbReadBufferPtr buf,XkbDescPtr xkb,xkbGetMapReply *rep)
1521ab64890Smrg{
1531ab64890Smrgregister int i;
1541ab64890SmrgXkbClientMapPtr	map;
1551ab64890Smrg
1561ab64890Smrg    map= xkb->map;
1571ab64890Smrg    if (map->key_sym_map==NULL) {
1581ab64890Smrg	register int offset;
1591ab64890Smrg	XkbSymMapPtr	oldMap;
1601ab64890Smrg	xkbSymMapWireDesc *newMap;
1611ab64890Smrg	map->key_sym_map= _XkbTypedCalloc((xkb->max_key_code+1),XkbSymMapRec);
1621ab64890Smrg	if (map->key_sym_map==NULL)
1631ab64890Smrg	    return BadAlloc;
1641ab64890Smrg	if (map->syms==NULL) {
1651ab64890Smrg	    int sz;
1661ab64890Smrg	    sz= (rep->totalSyms*12)/10;
1671ab64890Smrg	    sz= ((sz+(unsigned)128)/128)*128;
1681ab64890Smrg	    map->syms = _XkbTypedCalloc(sz,KeySym);
1691ab64890Smrg	    if (map->syms==NULL)
1701ab64890Smrg		return BadAlloc;
1711ab64890Smrg	    map->size_syms = sz;
1721ab64890Smrg	}
1731ab64890Smrg	offset = 1;
1741ab64890Smrg	oldMap = &map->key_sym_map[rep->firstKeySym];
1751ab64890Smrg	for (i=0;i<(int)rep->nKeySyms;i++,oldMap++) {
1761ab64890Smrg	    newMap= (xkbSymMapWireDesc *)
1771ab64890Smrg			_XkbGetReadBufferPtr(buf,SIZEOF(xkbSymMapWireDesc));
1781ab64890Smrg	    if (newMap==NULL)
1791ab64890Smrg		return BadLength;
1801ab64890Smrg	    oldMap->kt_index[0]= newMap->ktIndex[0];
1811ab64890Smrg	    oldMap->kt_index[1]= newMap->ktIndex[1];
1821ab64890Smrg	    oldMap->kt_index[2]= newMap->ktIndex[2];
1831ab64890Smrg	    oldMap->kt_index[3]= newMap->ktIndex[3];
1841ab64890Smrg	    oldMap->group_info= newMap->groupInfo;
1851ab64890Smrg	    oldMap->width= newMap->width;
1861ab64890Smrg	    oldMap->offset= offset;
1871ab64890Smrg	    if (offset+newMap->nSyms>=map->size_syms) {
1881ab64890Smrg		register int sz;
1891ab64890Smrg		KeySym *prev_syms = map->syms;
1901ab64890Smrg
1911ab64890Smrg		sz= map->size_syms+128;
1921ab64890Smrg		map->syms= _XkbTypedRealloc(map->syms,sz,KeySym);
1931ab64890Smrg		if (map->syms==NULL) {
1941ab64890Smrg		    _XkbFree(prev_syms);
1951ab64890Smrg		    map->size_syms= 0;
1961ab64890Smrg		    return BadAlloc;
1971ab64890Smrg		}
1981ab64890Smrg		map->size_syms= sz;
1991ab64890Smrg	    }
2001ab64890Smrg	    if (newMap->nSyms>0) {
2011ab64890Smrg		_XkbReadBufferCopyKeySyms(buf,(KeySym *)&map->syms[offset],
2021ab64890Smrg							newMap->nSyms);
2031ab64890Smrg		offset+= newMap->nSyms;
2041ab64890Smrg	    }
2051ab64890Smrg	    else {
2061ab64890Smrg		map->syms[offset]= 0;
2071ab64890Smrg	    }
2081ab64890Smrg	}
2091ab64890Smrg	map->num_syms= offset;
2101ab64890Smrg    }
2111ab64890Smrg    else {
2121ab64890Smrg	xkbSymMapWireDesc *	newMap;
2131ab64890Smrg	XkbSymMapPtr		oldMap;
2141ab64890Smrg	KeySym *		newSyms;
2151ab64890Smrg	int			tmp;
2161ab64890Smrg
2171ab64890Smrg	oldMap = &map->key_sym_map[rep->firstKeySym];
2181ab64890Smrg	for (i=0;i<(int)rep->nKeySyms;i++,oldMap++) {
2191ab64890Smrg	    newMap= (xkbSymMapWireDesc *)
2201ab64890Smrg			_XkbGetReadBufferPtr(buf,SIZEOF(xkbSymMapWireDesc));
2211ab64890Smrg	    if (newMap==NULL)
2221ab64890Smrg		return BadLength;
2231ab64890Smrg
2241ab64890Smrg	    if (newMap->nSyms>0)
2251ab64890Smrg		 tmp= newMap->nSyms;
2261ab64890Smrg	    else tmp= 0;
2271ab64890Smrg
2281ab64890Smrg	    newSyms = XkbResizeKeySyms(xkb,i+rep->firstKeySym,tmp);
2291ab64890Smrg	    if (newSyms==NULL)
2301ab64890Smrg		return BadAlloc;
2311ab64890Smrg	    if (newMap->nSyms>0)
2321ab64890Smrg		_XkbReadBufferCopyKeySyms(buf,newSyms,newMap->nSyms);
2331ab64890Smrg	    else newSyms[0]= NoSymbol;
2341ab64890Smrg	    oldMap->kt_index[0] = newMap->ktIndex[0];
2351ab64890Smrg	    oldMap->kt_index[1] = newMap->ktIndex[1];
2361ab64890Smrg	    oldMap->kt_index[2] = newMap->ktIndex[2];
2371ab64890Smrg	    oldMap->kt_index[3] = newMap->ktIndex[3];
2381ab64890Smrg	    oldMap->group_info = newMap->groupInfo;
2391ab64890Smrg	    oldMap->width = newMap->width;
2401ab64890Smrg	}
2411ab64890Smrg    }
2421ab64890Smrg    return Success;
2431ab64890Smrg}
2441ab64890Smrg
2451ab64890Smrgstatic Status
2461ab64890Smrg_XkbReadKeyActions(XkbReadBufferPtr buf,XkbDescPtr info,xkbGetMapReply *rep)
2471ab64890Smrg{
2481ab64890Smrgint		i;
2491ab64890SmrgCARD8		numDescBuf[248];
2501ab64890SmrgCARD8*		numDesc = NULL;
2511ab64890Smrgregister int	nKeyActs;
2521ab64890SmrgStatus		ret = Success;
2531ab64890Smrg
2541ab64890Smrg    if ( (nKeyActs=rep->nKeyActs)>0 ) {
2551ab64890Smrg	XkbSymMapPtr	symMap;
2561ab64890Smrg
2571ab64890Smrg	if (nKeyActs < sizeof numDescBuf) numDesc = numDescBuf;
2581ab64890Smrg	else numDesc = Xmalloc (nKeyActs * sizeof(CARD8));
2591ab64890Smrg
2601ab64890Smrg	if (!_XkbCopyFromReadBuffer(buf, (char *)numDesc, nKeyActs)) {
2611ab64890Smrg	    ret = BadLength;
2621ab64890Smrg	    goto done;
2631ab64890Smrg	}
2641ab64890Smrg	i= XkbPaddedSize(nKeyActs)-nKeyActs;
2651ab64890Smrg	if ((i>0)&&(!_XkbSkipReadBufferData(buf,i))) {
2661ab64890Smrg	    ret = BadLength;
2671ab64890Smrg	    goto done;
2681ab64890Smrg	}
2691ab64890Smrg	symMap = &info->map->key_sym_map[rep->firstKeyAct];
2701ab64890Smrg	for (i=0;i<(int)rep->nKeyActs;i++,symMap++) {
2711ab64890Smrg	    if (numDesc[i]==0) {
2721ab64890Smrg		info->server->key_acts[i+rep->firstKeyAct]= 0;
2731ab64890Smrg	    }
2741ab64890Smrg	    else {
2751ab64890Smrg		XkbAction *newActs;
2761ab64890Smrg		/* 8/16/93 (ef) -- XXX! Verify size here (numdesc must be */
2771ab64890Smrg		/*                 either zero or XkbKeyNumSyms(info,key) */
2781ab64890Smrg		newActs=XkbResizeKeyActions(info,i+rep->firstKeyAct,
2791ab64890Smrg								numDesc[i]);
2801ab64890Smrg		if (newActs==NULL) {
2811ab64890Smrg		    ret = BadAlloc;
2821ab64890Smrg		    goto done;
2831ab64890Smrg		}
2841ab64890Smrg		if (!_XkbCopyFromReadBuffer(buf,(char *)newActs,
2851ab64890Smrg					(int)(numDesc[i]*sizeof(XkbAction)))) {
2861ab64890Smrg		    ret = BadLength;
2871ab64890Smrg		    goto done;
2881ab64890Smrg		}
2891ab64890Smrg	    }
2901ab64890Smrg	}
2911ab64890Smrg    }
2921ab64890Smrgdone:
2931ab64890Smrg    if (numDesc != NULL && numDesc != numDescBuf) Xfree (numDesc);
2941ab64890Smrg    return ret;
2951ab64890Smrg}
2961ab64890Smrg
2971ab64890Smrgstatic Status
2981ab64890Smrg_XkbReadKeyBehaviors(XkbReadBufferPtr buf,XkbDescPtr xkb,xkbGetMapReply *rep)
2991ab64890Smrg{
3001ab64890Smrgregister int i;
3011ab64890SmrgxkbBehaviorWireDesc	*wire;
3021ab64890Smrg
3031ab64890Smrg    if ( rep->totalKeyBehaviors>0 ) {
3041ab64890Smrg	if ( xkb->server->behaviors == NULL ) {
3051ab64890Smrg	    int size = xkb->max_key_code+1;
3061ab64890Smrg	    xkb->server->behaviors = _XkbTypedCalloc(size,XkbBehavior);
3071ab64890Smrg	    if (xkb->server->behaviors==NULL)
3081ab64890Smrg		return BadAlloc;
3091ab64890Smrg	}
3101ab64890Smrg	else {
3111ab64890Smrg	    bzero(&xkb->server->behaviors[rep->firstKeyBehavior],
3121ab64890Smrg	    		(rep->nKeyBehaviors*sizeof(XkbBehavior)));
3131ab64890Smrg	}
3141ab64890Smrg	for (i=0;i<rep->totalKeyBehaviors;i++) {
3151ab64890Smrg	    wire= (xkbBehaviorWireDesc *)_XkbGetReadBufferPtr(buf,
3161ab64890Smrg						SIZEOF(xkbBehaviorWireDesc));
3171ab64890Smrg	    if (wire==NULL)
3181ab64890Smrg		return BadLength;
3191ab64890Smrg	    xkb->server->behaviors[wire->key].type= wire->type;
3201ab64890Smrg	    xkb->server->behaviors[wire->key].data= wire->data;
3211ab64890Smrg	}
3221ab64890Smrg    }
3231ab64890Smrg    return Success;
3241ab64890Smrg}
3251ab64890Smrg
3261ab64890Smrgstatic Status
3271ab64890Smrg_XkbReadVirtualMods(XkbReadBufferPtr buf,XkbDescPtr xkb,xkbGetMapReply *rep)
3281ab64890Smrg{
3291ab64890Smrg    if ( rep->virtualMods ) {
3301ab64890Smrg	register int i,bit,nVMods;
3311ab64890Smrg	register char *data;
3321ab64890Smrg
3331ab64890Smrg	for (i=nVMods=0,bit=1;i<XkbNumVirtualMods;i++,bit<<=1) {
3341ab64890Smrg	    if (rep->virtualMods&bit)
3351ab64890Smrg		nVMods++;
3361ab64890Smrg	}
3371ab64890Smrg	data= _XkbGetReadBufferPtr(buf,XkbPaddedSize(nVMods));
3381ab64890Smrg	if (data==NULL)
3391ab64890Smrg	    return BadLength;
3401ab64890Smrg	for (i=0,bit=1;(i<XkbNumVirtualMods)&&(nVMods>0);i++,bit<<=1) {
3411ab64890Smrg	    if (rep->virtualMods&bit) {
3421ab64890Smrg		xkb->server->vmods[i]= *data++;
3431ab64890Smrg		nVMods--;
3441ab64890Smrg	    }
3451ab64890Smrg	}
3461ab64890Smrg    }
3471ab64890Smrg    return Success;
3481ab64890Smrg}
3491ab64890Smrg
3501ab64890Smrgstatic Status
3511ab64890Smrg_XkbReadExplicitComponents(	XkbReadBufferPtr	buf,
3521ab64890Smrg				XkbDescPtr 		xkb,
3531ab64890Smrg				xkbGetMapReply *	rep)
3541ab64890Smrg{
3551ab64890Smrgregister int i;
3561ab64890Smrgunsigned char *wire;
3571ab64890Smrg
3581ab64890Smrg    if ( rep->totalKeyExplicit>0 ) {
3591ab64890Smrg	if ( xkb->server->explicit == NULL ) {
3601ab64890Smrg	    int size = xkb->max_key_code+1;
3611ab64890Smrg	    xkb->server->explicit = _XkbTypedCalloc(size,unsigned char);
3621ab64890Smrg	    if (xkb->server->explicit==NULL)
3631ab64890Smrg		return BadAlloc;
3641ab64890Smrg	}
3651ab64890Smrg	else {
3661ab64890Smrg	    bzero(&xkb->server->explicit[rep->firstKeyExplicit],
3671ab64890Smrg	    						rep->nKeyExplicit);
3681ab64890Smrg	}
3691ab64890Smrg	i= XkbPaddedSize(2*rep->totalKeyExplicit);
3701ab64890Smrg	wire=(unsigned char *)_XkbGetReadBufferPtr(buf,i);
3711ab64890Smrg	if (!wire)
3721ab64890Smrg	    return BadLength;
3731ab64890Smrg	for (i=0;i<rep->totalKeyExplicit;i++,wire+=2) {
3741ab64890Smrg	    xkb->server->explicit[wire[0]]= wire[1];
3751ab64890Smrg	}
3761ab64890Smrg    }
3771ab64890Smrg    return Success;
3781ab64890Smrg}
3791ab64890Smrg
3801ab64890Smrgstatic Status
3811ab64890Smrg_XkbReadModifierMap(XkbReadBufferPtr buf,XkbDescPtr xkb,xkbGetMapReply *rep)
3821ab64890Smrg{
3831ab64890Smrgregister int i;
3841ab64890Smrgunsigned char *wire;
3851ab64890Smrg
3861ab64890Smrg    if ( rep->totalModMapKeys>0 ) {
3871ab64890Smrg	if ((xkb->map->modmap==NULL)&&
3881ab64890Smrg	    (XkbAllocClientMap(xkb,XkbModifierMapMask,0)!=Success)) {
3891ab64890Smrg	    return BadAlloc;
3901ab64890Smrg	}
3911ab64890Smrg	else {
3921ab64890Smrg	    bzero(&xkb->map->modmap[rep->firstModMapKey],rep->nModMapKeys);
3931ab64890Smrg	}
3941ab64890Smrg	i= XkbPaddedSize(2*rep->totalModMapKeys);
3951ab64890Smrg	wire=(unsigned char *)_XkbGetReadBufferPtr(buf,i);
3961ab64890Smrg	if (!wire)
3971ab64890Smrg	    return BadLength;
3981ab64890Smrg	for (i=0;i<rep->totalModMapKeys;i++,wire+=2) {
3991ab64890Smrg	    xkb->map->modmap[wire[0]]= wire[1];
4001ab64890Smrg	}
4011ab64890Smrg    }
4021ab64890Smrg    return Success;
4031ab64890Smrg}
4041ab64890Smrg
4051ab64890Smrgstatic Status
4061ab64890Smrg_XkbReadVirtualModMap(XkbReadBufferPtr buf,XkbDescPtr xkb,xkbGetMapReply *rep)
4071ab64890Smrg{
4081ab64890Smrgregister int 		i;
4091ab64890SmrgxkbVModMapWireDesc *	wire;
4101ab64890SmrgXkbServerMapPtr		srv;
4111ab64890Smrg
4121ab64890Smrg    if ( rep->totalVModMapKeys>0 ) {
4131ab64890Smrg	if (((xkb->server==NULL)||(xkb->server->vmodmap==NULL))&&
4141ab64890Smrg	    (XkbAllocServerMap(xkb,XkbVirtualModMapMask,0)!=Success)) {
4151ab64890Smrg	    return BadAlloc;
4161ab64890Smrg	}
4171ab64890Smrg	else {
4181ab64890Smrg	    srv= xkb->server;
4191ab64890Smrg	    if (rep->nVModMapKeys > rep->firstVModMapKey)
4201ab64890Smrg		bzero((char *)&srv->vmodmap[rep->firstVModMapKey],
4211ab64890Smrg		      (rep->nVModMapKeys - rep->firstVModMapKey) *
4221ab64890Smrg		      sizeof(unsigned short));
4231ab64890Smrg	}
4241ab64890Smrg	srv= xkb->server;
4251ab64890Smrg	i= rep->totalVModMapKeys*SIZEOF(xkbVModMapWireDesc);
4261ab64890Smrg	wire=(xkbVModMapWireDesc *)_XkbGetReadBufferPtr(buf,i);
4271ab64890Smrg	if (!wire)
4281ab64890Smrg	    return BadLength;
4291ab64890Smrg	for (i=0;i<rep->totalVModMapKeys;i++,wire++) {
4301ab64890Smrg	    if ((wire->key>=xkb->min_key_code)&&(wire->key<=xkb->max_key_code))
4311ab64890Smrg		srv->vmodmap[wire->key]= wire->vmods;
4321ab64890Smrg	}
4331ab64890Smrg    }
4341ab64890Smrg    return Success;
4351ab64890Smrg}
4361ab64890Smrg
4371ab64890Smrgstatic xkbGetMapReq *
4381ab64890Smrg_XkbGetGetMapReq(Display *dpy,XkbDescPtr xkb)
4391ab64890Smrg{
4401ab64890SmrgxkbGetMapReq *req;
4411ab64890Smrg
4421ab64890Smrg    GetReq(kbGetMap, req);
4431ab64890Smrg    req->reqType = dpy->xkb_info->codes->major_opcode;
4441ab64890Smrg    req->xkbReqType = X_kbGetMap;
4451ab64890Smrg    req->deviceSpec = xkb->device_spec;
4461ab64890Smrg    req->full = req->partial = 0;
4471ab64890Smrg    req->firstType = req->nTypes = 0;
4481ab64890Smrg    req->firstKeySym = req->nKeySyms = 0;
4491ab64890Smrg    req->firstKeyAct = req->nKeyActs = 0;
4501ab64890Smrg    req->firstKeyBehavior = req->nKeyBehaviors = 0;
4511ab64890Smrg    req->virtualMods = 0;
4521ab64890Smrg    req->firstKeyExplicit = req->nKeyExplicit = 0;
4531ab64890Smrg    req->firstModMapKey = req->nModMapKeys = 0;
4541ab64890Smrg    req->firstVModMapKey = req->nVModMapKeys = 0;
4551ab64890Smrg    return req;
4561ab64890Smrg}
4571ab64890Smrg
4581ab64890SmrgStatus
4591ab64890Smrg_XkbReadGetMapReply(	Display *	dpy,
4601ab64890Smrg			xkbGetMapReply *rep,
4611ab64890Smrg			XkbDescPtr	xkb,
4621ab64890Smrg			int *		nread_rtrn)
4631ab64890Smrg{
4641ab64890Smrgint		extraData;
4651ab64890Smrgunsigned	mask;
4661ab64890Smrg
4671ab64890Smrg    if ( xkb->device_spec == XkbUseCoreKbd )
4681ab64890Smrg	xkb->device_spec= rep->deviceID;
4691ab64890Smrg    xkb->min_key_code = rep->minKeyCode;
4701ab64890Smrg    xkb->max_key_code = rep->maxKeyCode;
4711ab64890Smrg
4721ab64890Smrg    if (!xkb->map) {
4731ab64890Smrg	mask= rep->present&XkbAllClientInfoMask;
4741ab64890Smrg	if (mask&&(XkbAllocClientMap(xkb,mask,rep->nTypes)!=Success))
4751ab64890Smrg	    return BadAlloc;
4761ab64890Smrg    }
4771ab64890Smrg    if (!xkb->server) {
4781ab64890Smrg	mask= rep->present&XkbAllServerInfoMask;
4791ab64890Smrg	if (mask&&(XkbAllocServerMap(xkb,mask,rep->totalActs)!=Success))
4801ab64890Smrg	    return BadAlloc;
4811ab64890Smrg    }
4821ab64890Smrg    extraData= (int)(rep->length*4);
4831ab64890Smrg    extraData-= (SIZEOF(xkbGetMapReply)-SIZEOF(xGenericReply));
4841ab64890Smrg    if (rep->length) {
4851ab64890Smrg	XkbReadBufferRec	buf;
4861ab64890Smrg	int			left;
4871ab64890Smrg	if (_XkbInitReadBuffer(dpy,&buf,extraData)) {
4881ab64890Smrg	    Status status= Success;
4891ab64890Smrg	    if (nread_rtrn!=NULL)
4901ab64890Smrg		*nread_rtrn= extraData;
4911ab64890Smrg	    if (status==Success)
4921ab64890Smrg		status= _XkbReadKeyTypes(&buf,xkb,rep);
4931ab64890Smrg	    if (status==Success)
4941ab64890Smrg		status= _XkbReadKeySyms(&buf,xkb,rep);
4951ab64890Smrg	    if (status==Success)
4961ab64890Smrg		status= _XkbReadKeyActions(&buf,xkb,rep);
4971ab64890Smrg	    if (status==Success)
4981ab64890Smrg		status= _XkbReadKeyBehaviors(&buf,xkb,rep);
4991ab64890Smrg	    if (status==Success)
5001ab64890Smrg		status= _XkbReadVirtualMods(&buf,xkb,rep);
5011ab64890Smrg	    if (status==Success)
5021ab64890Smrg		status= _XkbReadExplicitComponents(&buf,xkb,rep);
5031ab64890Smrg	    if (status==Success)
5041ab64890Smrg		status= _XkbReadModifierMap(&buf,xkb,rep);
5051ab64890Smrg	    if (status==Success)
5061ab64890Smrg		status= _XkbReadVirtualModMap(&buf,xkb,rep);
5071ab64890Smrg	    left= _XkbFreeReadBuffer(&buf);
5081ab64890Smrg	    if (status!=Success)		return status;
5091ab64890Smrg	    else if ( left || buf.error )	return BadLength;
5101ab64890Smrg	}
5111ab64890Smrg	else return BadAlloc;
5121ab64890Smrg    }
5131ab64890Smrg    return Success;
5141ab64890Smrg}
5151ab64890Smrg
5161ab64890Smrgstatic Status
5171ab64890Smrg_XkbHandleGetMapReply(Display *dpy,XkbDescPtr xkb)
5181ab64890Smrg{
5191ab64890SmrgxkbGetMapReply	rep;
5201ab64890Smrg
5211ab64890Smrg    if (!_XReply(dpy, (xReply *)&rep,
5221ab64890Smrg    		 ( (SIZEOF(xkbGetMapReply)-SIZEOF(xGenericReply)) >> 2 ),
5231ab64890Smrg		 xFalse)) {
5241ab64890Smrg	return BadImplementation;
5251ab64890Smrg    }
5261ab64890Smrg    return _XkbReadGetMapReply(dpy,&rep,xkb,NULL);
5271ab64890Smrg}
5281ab64890Smrg
5291ab64890SmrgStatus
5301ab64890SmrgXkbGetUpdatedMap(Display *dpy,unsigned which,XkbDescPtr xkb)
5311ab64890Smrg{
5321ab64890Smrg    if ((dpy->flags & XlibDisplayNoXkb) ||
5331ab64890Smrg	(!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
5341ab64890Smrg	return BadAccess;
5351ab64890Smrg    if (which) {
5361ab64890Smrg	register xkbGetMapReq *req;
5371ab64890Smrg	Status status;
5381ab64890Smrg
5391ab64890Smrg	LockDisplay(dpy);
5401ab64890Smrg
5411ab64890Smrg	req = _XkbGetGetMapReq(dpy, xkb);
5421ab64890Smrg	req->full = which;
5431ab64890Smrg	status= _XkbHandleGetMapReply(dpy, xkb);
5441ab64890Smrg
5451ab64890Smrg	UnlockDisplay(dpy);
5461ab64890Smrg	SyncHandle();
5471ab64890Smrg	return status;
5481ab64890Smrg    }
5491ab64890Smrg    return Success;
5501ab64890Smrg}
5511ab64890Smrg
5521ab64890SmrgXkbDescPtr
5531ab64890SmrgXkbGetMap(Display *dpy,unsigned which,unsigned deviceSpec)
5541ab64890Smrg{
5551ab64890SmrgXkbDescPtr xkb;
5561ab64890Smrg
5571ab64890Smrg    xkb = _XkbTypedCalloc(1,XkbDescRec);
5581ab64890Smrg    if (xkb) {
5591ab64890Smrg	xkb->device_spec = deviceSpec;
5601ab64890Smrg	xkb->map = _XkbTypedCalloc(1,XkbClientMapRec);
5611ab64890Smrg	if ((xkb->map==NULL)||
5621ab64890Smrg	    ((which)&&(XkbGetUpdatedMap(dpy,which,xkb)!=Success))) {
5631ab64890Smrg	    if (xkb->map) {
5641ab64890Smrg		Xfree(xkb->map);
5651ab64890Smrg		xkb->map= NULL;
5661ab64890Smrg	    }
5671ab64890Smrg	    Xfree(xkb);
5681ab64890Smrg	    return NULL;
5691ab64890Smrg	}
5701ab64890Smrg	xkb->dpy= dpy;
5711ab64890Smrg    }
5721ab64890Smrg    return xkb;
5731ab64890Smrg}
5741ab64890Smrg
5751ab64890SmrgStatus
5761ab64890SmrgXkbGetKeyTypes(Display *dpy,unsigned first,unsigned num,XkbDescPtr xkb)
5771ab64890Smrg{
5781ab64890Smrg    register xkbGetMapReq *req;
5791ab64890Smrg    Status status;
5801ab64890Smrg
5811ab64890Smrg    if ((dpy->flags & XlibDisplayNoXkb) ||
5821ab64890Smrg	(!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
5831ab64890Smrg	return BadAccess;
5841ab64890Smrg    if ((num<1)||(num>XkbMaxKeyTypes))
5851ab64890Smrg	return BadValue;
5861ab64890Smrg
5871ab64890Smrg    LockDisplay(dpy);
5881ab64890Smrg
5891ab64890Smrg    req = _XkbGetGetMapReq(dpy, xkb);
5901ab64890Smrg    req->firstType = first;
5911ab64890Smrg    req->nTypes = num;
5921ab64890Smrg    status= _XkbHandleGetMapReply(dpy, xkb);
5931ab64890Smrg
5941ab64890Smrg    UnlockDisplay(dpy);
5951ab64890Smrg    SyncHandle();
5961ab64890Smrg    return status;
5971ab64890Smrg}
5981ab64890Smrg
5991ab64890SmrgStatus
6001ab64890SmrgXkbGetKeyActions(Display *dpy,unsigned first,unsigned num,XkbDescPtr xkb)
6011ab64890Smrg{
6021ab64890Smrg    register xkbGetMapReq *req;
6031ab64890Smrg    Status status;
6041ab64890Smrg
6051ab64890Smrg    if ((dpy->flags & XlibDisplayNoXkb) ||
6061ab64890Smrg	(!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
6071ab64890Smrg	return BadAccess;
6081ab64890Smrg
6091ab64890Smrg    if ((num<1)||(num>XkbMaxKeyCount))
6101ab64890Smrg	return BadValue;
6111ab64890Smrg
6121ab64890Smrg    LockDisplay(dpy);
6131ab64890Smrg
6141ab64890Smrg    req = _XkbGetGetMapReq(dpy, xkb);
6151ab64890Smrg    req->firstKeyAct = first;
6161ab64890Smrg    req->nKeyActs = num;
6171ab64890Smrg    status= _XkbHandleGetMapReply(dpy, xkb);
6181ab64890Smrg
6191ab64890Smrg    UnlockDisplay(dpy);
6201ab64890Smrg    SyncHandle();
6211ab64890Smrg    return status;
6221ab64890Smrg}
6231ab64890Smrg
6241ab64890SmrgStatus
6251ab64890SmrgXkbGetKeySyms(Display *dpy,unsigned first,unsigned num,XkbDescPtr xkb)
6261ab64890Smrg{
6271ab64890Smrg    register xkbGetMapReq *req;
6281ab64890Smrg    Status status;
6291ab64890Smrg
6301ab64890Smrg    if ((dpy->flags & XlibDisplayNoXkb) ||
6311ab64890Smrg	(!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
6321ab64890Smrg	return BadAccess;
6331ab64890Smrg
6341ab64890Smrg    if ((num<1)||(num>XkbMaxKeyCount))
6351ab64890Smrg	return BadValue;
6361ab64890Smrg
6371ab64890Smrg    LockDisplay(dpy);
6381ab64890Smrg
6391ab64890Smrg    req = _XkbGetGetMapReq(dpy, xkb);
6401ab64890Smrg    req->firstKeySym = first;
6411ab64890Smrg    req->nKeySyms = num;
6421ab64890Smrg    status= _XkbHandleGetMapReply(dpy, xkb);
6431ab64890Smrg
6441ab64890Smrg    UnlockDisplay(dpy);
6451ab64890Smrg    SyncHandle();
6461ab64890Smrg
6471ab64890Smrg    return status;
6481ab64890Smrg}
6491ab64890Smrg
6501ab64890SmrgStatus
6511ab64890SmrgXkbGetKeyBehaviors(Display *dpy,unsigned first,unsigned num,XkbDescPtr xkb)
6521ab64890Smrg{
6531ab64890Smrg    register xkbGetMapReq *req;
6541ab64890Smrg    Status status;
6551ab64890Smrg
6561ab64890Smrg    if ((dpy->flags & XlibDisplayNoXkb) ||
6571ab64890Smrg	(!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
6581ab64890Smrg	return BadAccess;
6591ab64890Smrg
6601ab64890Smrg    if ((num<1)||(num>XkbMaxKeyCount))
6611ab64890Smrg	return BadValue;
6621ab64890Smrg
6631ab64890Smrg    LockDisplay(dpy);
6641ab64890Smrg
6651ab64890Smrg    req = _XkbGetGetMapReq(dpy, xkb);
6661ab64890Smrg    req->firstKeyBehavior = first;
6671ab64890Smrg    req->nKeyBehaviors = num;
6681ab64890Smrg    status= _XkbHandleGetMapReply(dpy, xkb);
6691ab64890Smrg
6701ab64890Smrg    UnlockDisplay(dpy);
6711ab64890Smrg    SyncHandle();
6721ab64890Smrg    return status;
6731ab64890Smrg}
6741ab64890Smrg
6751ab64890SmrgStatus
6761ab64890SmrgXkbGetVirtualMods(Display *dpy,unsigned which,XkbDescPtr xkb)
6771ab64890Smrg{
6781ab64890Smrg    register xkbGetMapReq *req;
6791ab64890Smrg    Status status;
6801ab64890Smrg
6811ab64890Smrg    if ((dpy->flags & XlibDisplayNoXkb) ||
6821ab64890Smrg	(!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
6831ab64890Smrg	return BadAccess;
6841ab64890Smrg
6851ab64890Smrg    LockDisplay(dpy);
6861ab64890Smrg
6871ab64890Smrg    req = _XkbGetGetMapReq(dpy, xkb);
6881ab64890Smrg    req->virtualMods = which;
6891ab64890Smrg    status= _XkbHandleGetMapReply(dpy, xkb);
6901ab64890Smrg
6911ab64890Smrg    UnlockDisplay(dpy);
6921ab64890Smrg    SyncHandle();
6931ab64890Smrg    return status;
6941ab64890Smrg}
6951ab64890Smrg
6961ab64890SmrgStatus
6971ab64890SmrgXkbGetKeyExplicitComponents(	Display *	dpy,
6981ab64890Smrg				unsigned	first,
6991ab64890Smrg				unsigned 	num,
7001ab64890Smrg				XkbDescPtr	xkb)
7011ab64890Smrg{
7021ab64890Smrg    register xkbGetMapReq *req;
7031ab64890Smrg    Status status;
7041ab64890Smrg
7051ab64890Smrg    if ((dpy->flags & XlibDisplayNoXkb) ||
7061ab64890Smrg	(!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
7071ab64890Smrg	return BadAccess;
7081ab64890Smrg
7091ab64890Smrg    if ((num<1)||(num>XkbMaxKeyCount))
7101ab64890Smrg	return BadValue;
7111ab64890Smrg
7121ab64890Smrg    LockDisplay(dpy);
7131ab64890Smrg
7141ab64890Smrg    req = _XkbGetGetMapReq(dpy, xkb);
7151ab64890Smrg    req->firstKeyExplicit = first;
7161ab64890Smrg    req->nKeyExplicit = num;
7171ab64890Smrg    if ((xkb!=NULL) && (xkb->server!=NULL) && (xkb->server->explicit!=NULL)) {
7181ab64890Smrg	if ((num>0)&&(first>=xkb->min_key_code)&&(first+num<=xkb->max_key_code))
7191ab64890Smrg	    bzero(&xkb->server->explicit[first],num);
7201ab64890Smrg    }
7211ab64890Smrg    if (xkb)
7221ab64890Smrg        status= _XkbHandleGetMapReply(dpy, xkb);
7231ab64890Smrg    else
7241ab64890Smrg        status = BadMatch;
7251ab64890Smrg
7261ab64890Smrg    UnlockDisplay(dpy);
7271ab64890Smrg    SyncHandle();
7281ab64890Smrg    return status;
7291ab64890Smrg}
7301ab64890Smrg
7311ab64890SmrgStatus
7321ab64890SmrgXkbGetKeyModifierMap(Display *dpy,unsigned first,unsigned num,XkbDescPtr xkb)
7331ab64890Smrg{
7341ab64890Smrg    register xkbGetMapReq *req;
7351ab64890Smrg    Status status;
7361ab64890Smrg
7371ab64890Smrg    if ((dpy->flags & XlibDisplayNoXkb) ||
7381ab64890Smrg	(!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
7391ab64890Smrg	return BadAccess;
7401ab64890Smrg
7411ab64890Smrg    if ((num<1)||(num>XkbMaxKeyCount))
7421ab64890Smrg	return BadValue;
7431ab64890Smrg
7441ab64890Smrg    LockDisplay(dpy);
7451ab64890Smrg
7461ab64890Smrg    req = _XkbGetGetMapReq(dpy, xkb);
7471ab64890Smrg    req->firstModMapKey = first;
7481ab64890Smrg    req->nModMapKeys = num;
7491ab64890Smrg    if ((xkb!=NULL) && (xkb->map!=NULL) && (xkb->map->modmap!=NULL)) {
7501ab64890Smrg	if ((num>0)&&(first>=xkb->min_key_code)&&(first+num<=xkb->max_key_code))
7511ab64890Smrg	    bzero(&xkb->map->modmap[first],num);
7521ab64890Smrg    }
7531ab64890Smrg    if (xkb)
7541ab64890Smrg        status= _XkbHandleGetMapReply(dpy, xkb);
7551ab64890Smrg    else
7561ab64890Smrg        status = BadMatch;
7571ab64890Smrg
7581ab64890Smrg    UnlockDisplay(dpy);
7591ab64890Smrg    SyncHandle();
7601ab64890Smrg    return status;
7611ab64890Smrg}
7621ab64890Smrg
7631ab64890SmrgStatus
7641ab64890SmrgXkbGetKeyVirtualModMap(Display *dpy,unsigned first,unsigned num,XkbDescPtr xkb)
7651ab64890Smrg{
7661ab64890Smrg    register xkbGetMapReq *req;
7671ab64890Smrg    Status status;
7681ab64890Smrg
7691ab64890Smrg    if ((dpy->flags & XlibDisplayNoXkb) ||
7701ab64890Smrg	(!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
7711ab64890Smrg	return BadAccess;
7721ab64890Smrg
7731ab64890Smrg    if ((num<1)||(num>XkbMaxKeyCount))
7741ab64890Smrg	return BadValue;
7751ab64890Smrg
7761ab64890Smrg    LockDisplay(dpy);
7771ab64890Smrg
7781ab64890Smrg    req = _XkbGetGetMapReq(dpy, xkb);
7791ab64890Smrg    req->firstVModMapKey = first;
7801ab64890Smrg    req->nVModMapKeys = num;
7811ab64890Smrg    if ((xkb!=NULL) && (xkb->map!=NULL) && (xkb->map->modmap!=NULL)) {
7821ab64890Smrg	if ((num>0)&&(first>=xkb->min_key_code)&&(first+num<=xkb->max_key_code))
7831ab64890Smrg	    bzero(&xkb->server->vmodmap[first],num*sizeof(unsigned short));
7841ab64890Smrg    }
7851ab64890Smrg
7861ab64890Smrg    if (xkb)
7871ab64890Smrg        status= _XkbHandleGetMapReply(dpy, xkb);
7881ab64890Smrg    else
7891ab64890Smrg        status = BadMatch;
7901ab64890Smrg
7911ab64890Smrg    UnlockDisplay(dpy);
7921ab64890Smrg    SyncHandle();
7931ab64890Smrg    return status;
7941ab64890Smrg}
7951ab64890Smrg
7961ab64890SmrgStatus
7971ab64890SmrgXkbGetMapChanges(Display *dpy,XkbDescPtr xkb,XkbMapChangesPtr changes)
7981ab64890Smrg{
7991ab64890Smrg    xkbGetMapReq *req;
8001ab64890Smrg
8011ab64890Smrg    if ((dpy->flags & XlibDisplayNoXkb) ||
8021ab64890Smrg	(!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
8031ab64890Smrg	return BadAccess;
8041ab64890Smrg    LockDisplay(dpy);
8051ab64890Smrg    if (changes->changed) {
8061ab64890Smrg	Status status= Success;
8071ab64890Smrg	req = _XkbGetGetMapReq(dpy, xkb);
8081ab64890Smrg	req->full = 0;
8091ab64890Smrg	req->partial = changes->changed;
8101ab64890Smrg	req->firstType = changes->first_type;
8111ab64890Smrg	req->nTypes = changes->num_types;
8121ab64890Smrg	req->firstKeySym = changes->first_key_sym;
8131ab64890Smrg	req->nKeySyms = changes->num_key_syms;
8141ab64890Smrg	req->firstKeyAct = changes->first_key_act;
8151ab64890Smrg	req->nKeyActs = changes->num_key_acts;
8161ab64890Smrg	req->firstKeyBehavior = changes->first_key_behavior;
8171ab64890Smrg	req->nKeyBehaviors = changes->num_key_behaviors;
8181ab64890Smrg	req->virtualMods = changes->vmods;
8191ab64890Smrg	req->firstKeyExplicit = changes->first_key_explicit;
8201ab64890Smrg	req->nKeyExplicit = changes->num_key_explicit;
8211ab64890Smrg	req->firstModMapKey = changes->first_modmap_key;
8221ab64890Smrg	req->nModMapKeys = changes->num_modmap_keys;
8231ab64890Smrg	req->firstVModMapKey = changes->first_vmodmap_key;
8241ab64890Smrg	req->nVModMapKeys = changes->num_vmodmap_keys;
8251ab64890Smrg	status= _XkbHandleGetMapReply(dpy, xkb);
8261ab64890Smrg	UnlockDisplay(dpy);
8271ab64890Smrg	SyncHandle();
8281ab64890Smrg	return status;
8291ab64890Smrg    }
8301ab64890Smrg    UnlockDisplay(dpy);
8311ab64890Smrg    return Success;
8321ab64890Smrg}
8331ab64890Smrg
834