1 /************************************************************
2 Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
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.
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.
25 ********************************************************/
27 #ifdef HAVE_DIX_CONFIG_H
28 #include <dix-config.h>
36 #include <X11/Xproto.h>
40 #include <X11/extensions/XKBgeom.h>
43 #define Size_t unsigned int
48 /***====================================================================***/
51 _XkbFreeGeomLeafElems( Bool freeAll
,
54 unsigned short * num_inout
,
55 unsigned short * sz_inout
,
59 if ((freeAll
)||(*elems
==NULL
)) {
60 *num_inout
= *sz_inout
= 0;
68 if ((first
>=(*num_inout
))||(first
<0)||(count
<1))
71 if (first
+count
>=(*num_inout
)) {
72 /* truncating the array is easy */
79 extra
= ((*num_inout
)-(first
+count
))*elem_sz
;
81 memmove(&ptr
[first
*elem_sz
],&ptr
[(first
+count
)*elem_sz
],extra
);
87 typedef void (*ContentsClearFunc
)(
92 _XkbFreeGeomNonLeafElems( Bool freeAll
,
95 unsigned short * num_inout
,
96 unsigned short * sz_inout
,
99 ContentsClearFunc freeFunc
)
108 else if ((first
>=(*num_inout
))||(first
<0)||(count
<1))
110 else if (first
+count
>(*num_inout
))
111 count
= (*num_inout
)-first
;
118 for (i
=0;i
<count
;i
++) {
124 (*num_inout
)= (*sz_inout
)= 0;
130 else if (first
+count
>=(*num_inout
))
133 i
= ((*num_inout
)-(first
+count
))*elem_sz
;
135 memmove(&ptr
[first
*elem_sz
],&ptr
[(first
+count
)*elem_sz
],i
);
136 (*num_inout
)-= count
;
141 /***====================================================================***/
144 _XkbClearProperty(char *prop_in
)
146 XkbPropertyPtr prop
= (XkbPropertyPtr
)prop_in
;
149 _XkbFree(prop
->name
);
153 _XkbFree(prop
->value
);
160 XkbFreeGeomProperties( XkbGeometryPtr geom
,
165 _XkbFreeGeomNonLeafElems(freeAll
,first
,count
,
166 &geom
->num_properties
,&geom
->sz_properties
,
167 (char **)&geom
->properties
,
168 sizeof(XkbPropertyRec
),_XkbClearProperty
);
172 /***====================================================================***/
175 XkbFreeGeomKeyAliases( XkbGeometryPtr geom
,
180 _XkbFreeGeomLeafElems(freeAll
,first
,count
,
181 &geom
->num_key_aliases
,&geom
->sz_key_aliases
,
182 (char **)&geom
->key_aliases
,
183 sizeof(XkbKeyAliasRec
));
187 /***====================================================================***/
190 _XkbClearColor(char *color_in
)
192 XkbColorPtr color
= (XkbColorPtr
)color_in
;
195 _XkbFree(color
->spec
);
200 XkbFreeGeomColors(XkbGeometryPtr geom
,int first
,int count
,Bool freeAll
)
202 _XkbFreeGeomNonLeafElems(freeAll
,first
,count
,
203 &geom
->num_colors
,&geom
->sz_colors
,
204 (char **)&geom
->colors
,
205 sizeof(XkbColorRec
),_XkbClearColor
);
209 /***====================================================================***/
212 XkbFreeGeomPoints(XkbOutlinePtr outline
,int first
,int count
,Bool freeAll
)
214 _XkbFreeGeomLeafElems(freeAll
,first
,count
,
215 &outline
->num_points
,&outline
->sz_points
,
216 (char **)&outline
->points
,
217 sizeof(XkbPointRec
));
221 /***====================================================================***/
224 _XkbClearOutline(char *outline_in
)
226 XkbOutlinePtr outline
= (XkbOutlinePtr
)outline_in
;
228 if (outline
->points
!=NULL
)
229 XkbFreeGeomPoints(outline
,0,outline
->num_points
,True
);
234 XkbFreeGeomOutlines(XkbShapePtr shape
,int first
,int count
,Bool freeAll
)
236 _XkbFreeGeomNonLeafElems(freeAll
,first
,count
,
237 &shape
->num_outlines
,&shape
->sz_outlines
,
238 (char **)&shape
->outlines
,
239 sizeof(XkbOutlineRec
),_XkbClearOutline
);
244 /***====================================================================***/
247 _XkbClearShape(char *shape_in
)
249 XkbShapePtr shape
= (XkbShapePtr
)shape_in
;
252 XkbFreeGeomOutlines(shape
,0,shape
->num_outlines
,True
);
257 XkbFreeGeomShapes(XkbGeometryPtr geom
,int first
,int count
,Bool freeAll
)
259 _XkbFreeGeomNonLeafElems(freeAll
,first
,count
,
260 &geom
->num_shapes
,&geom
->sz_shapes
,
261 (char **)&geom
->shapes
,
262 sizeof(XkbShapeRec
),_XkbClearShape
);
266 /***====================================================================***/
269 XkbFreeGeomOverlayKeys(XkbOverlayRowPtr row
,int first
,int count
,Bool freeAll
)
271 _XkbFreeGeomLeafElems(freeAll
,first
,count
,
272 &row
->num_keys
,&row
->sz_keys
,
274 sizeof(XkbOverlayKeyRec
));
278 /***====================================================================***/
281 _XkbClearOverlayRow(char *row_in
)
283 XkbOverlayRowPtr row
= (XkbOverlayRowPtr
)row_in
;
286 XkbFreeGeomOverlayKeys(row
,0,row
->num_keys
,True
);
291 XkbFreeGeomOverlayRows(XkbOverlayPtr overlay
,int first
,int count
,Bool freeAll
)
293 _XkbFreeGeomNonLeafElems(freeAll
,first
,count
,
294 &overlay
->num_rows
,&overlay
->sz_rows
,
295 (char **)&overlay
->rows
,
296 sizeof(XkbOverlayRowRec
),_XkbClearOverlayRow
);
300 /***====================================================================***/
303 _XkbClearOverlay(char *overlay_in
)
305 XkbOverlayPtr overlay
= (XkbOverlayPtr
)overlay_in
;
307 if (overlay
->rows
!=NULL
)
308 XkbFreeGeomOverlayRows(overlay
,0,overlay
->num_rows
,True
);
313 XkbFreeGeomOverlays(XkbSectionPtr section
,int first
,int count
,Bool freeAll
)
315 _XkbFreeGeomNonLeafElems(freeAll
,first
,count
,
316 §ion
->num_overlays
,§ion
->sz_overlays
,
317 (char **)§ion
->overlays
,
318 sizeof(XkbOverlayRec
),_XkbClearOverlay
);
322 /***====================================================================***/
325 XkbFreeGeomKeys(XkbRowPtr row
,int first
,int count
,Bool freeAll
)
327 _XkbFreeGeomLeafElems(freeAll
,first
,count
,
328 &row
->num_keys
,&row
->sz_keys
,
334 /***====================================================================***/
337 _XkbClearRow(char *row_in
)
339 XkbRowPtr row
= (XkbRowPtr
)row_in
;
342 XkbFreeGeomKeys(row
,0,row
->num_keys
,True
);
347 XkbFreeGeomRows(XkbSectionPtr section
,int first
,int count
,Bool freeAll
)
349 _XkbFreeGeomNonLeafElems(freeAll
,first
,count
,
350 §ion
->num_rows
,§ion
->sz_rows
,
351 (char **)§ion
->rows
,
352 sizeof(XkbRowRec
),_XkbClearRow
);
355 /***====================================================================***/
358 _XkbClearSection(char *section_in
)
360 XkbSectionPtr section
= (XkbSectionPtr
)section_in
;
362 if (section
->rows
!=NULL
)
363 XkbFreeGeomRows(section
,0,section
->num_rows
,True
);
364 if (section
->doodads
!=NULL
) {
365 XkbFreeGeomDoodads(section
->doodads
,section
->num_doodads
,True
);
366 section
->doodads
= NULL
;
372 XkbFreeGeomSections(XkbGeometryPtr geom
,int first
,int count
,Bool freeAll
)
374 _XkbFreeGeomNonLeafElems(freeAll
,first
,count
,
375 &geom
->num_sections
,&geom
->sz_sections
,
376 (char **)&geom
->sections
,
377 sizeof(XkbSectionRec
),_XkbClearSection
);
381 /***====================================================================***/
384 _XkbClearDoodad(char *doodad_in
)
386 XkbDoodadPtr doodad
= (XkbDoodadPtr
)doodad_in
;
388 switch (doodad
->any
.type
) {
391 if (doodad
->text
.text
!=NULL
) {
392 _XkbFree(doodad
->text
.text
);
393 doodad
->text
.text
= NULL
;
395 if (doodad
->text
.font
!=NULL
) {
396 _XkbFree(doodad
->text
.font
);
397 doodad
->text
.font
= NULL
;
403 if (doodad
->logo
.logo_name
!=NULL
) {
404 _XkbFree(doodad
->logo
.logo_name
);
405 doodad
->logo
.logo_name
= NULL
;
414 XkbFreeGeomDoodads(XkbDoodadPtr doodads
,int nDoodads
,Bool freeAll
)
417 register XkbDoodadPtr doodad
;
420 for (i
=0,doodad
= doodads
;i
<nDoodads
;i
++,doodad
++) {
421 _XkbClearDoodad((char *)doodad
);
430 XkbFreeGeometry(XkbGeometryPtr geom
,unsigned which
,Bool freeMap
)
435 which
= XkbGeomAllMask
;
436 if ((which
&XkbGeomPropertiesMask
)&&(geom
->properties
!=NULL
))
437 XkbFreeGeomProperties(geom
,0,geom
->num_properties
,True
);
438 if ((which
&XkbGeomColorsMask
)&&(geom
->colors
!=NULL
))
439 XkbFreeGeomColors(geom
,0,geom
->num_colors
,True
);
440 if ((which
&XkbGeomShapesMask
)&&(geom
->shapes
!=NULL
))
441 XkbFreeGeomShapes(geom
,0,geom
->num_shapes
,True
);
442 if ((which
&XkbGeomSectionsMask
)&&(geom
->sections
!=NULL
))
443 XkbFreeGeomSections(geom
,0,geom
->num_sections
,True
);
444 if ((which
&XkbGeomDoodadsMask
)&&(geom
->doodads
!= NULL
)) {
445 XkbFreeGeomDoodads(geom
->doodads
,geom
->num_doodads
,True
);
447 geom
->num_doodads
= geom
->sz_doodads
= 0;
449 if ((which
&XkbGeomKeyAliasesMask
)&&(geom
->key_aliases
!=NULL
))
450 XkbFreeGeomKeyAliases(geom
,0,geom
->num_key_aliases
,True
);
452 if (geom
->label_font
!=NULL
) {
453 _XkbFree(geom
->label_font
);
454 geom
->label_font
= NULL
;
461 /***====================================================================***/
464 _XkbGeomAlloc( XPointer
* old
,
465 unsigned short * num
,
466 unsigned short * total
,
475 if ((*num
)+num_new
<=(*total
))
478 *total
= (*num
)+num_new
;
480 (*old
)= (XPointer
)_XkbRealloc((*old
),(*total
)*sz_elem
);
481 else (*old
)= (XPointer
)_XkbCalloc((*total
),sz_elem
);
488 char *tmp
= (char *)(*old
);
489 bzero(&tmp
[sz_elem
*(*num
)],(num_new
*sz_elem
));
494 #define _XkbAllocProps(g,n) _XkbGeomAlloc((XPointer *)&(g)->properties,\
495 &(g)->num_properties,&(g)->sz_properties,\
496 (n),sizeof(XkbPropertyRec))
497 #define _XkbAllocColors(g,n) _XkbGeomAlloc((XPointer *)&(g)->colors,\
498 &(g)->num_colors,&(g)->sz_colors,\
499 (n),sizeof(XkbColorRec))
500 #define _XkbAllocShapes(g,n) _XkbGeomAlloc((XPointer *)&(g)->shapes,\
501 &(g)->num_shapes,&(g)->sz_shapes,\
502 (n),sizeof(XkbShapeRec))
503 #define _XkbAllocSections(g,n) _XkbGeomAlloc((XPointer *)&(g)->sections,\
504 &(g)->num_sections,&(g)->sz_sections,\
505 (n),sizeof(XkbSectionRec))
506 #define _XkbAllocDoodads(g,n) _XkbGeomAlloc((XPointer *)&(g)->doodads,\
507 &(g)->num_doodads,&(g)->sz_doodads,\
508 (n),sizeof(XkbDoodadRec))
509 #define _XkbAllocKeyAliases(g,n) _XkbGeomAlloc((XPointer *)&(g)->key_aliases,\
510 &(g)->num_key_aliases,&(g)->sz_key_aliases,\
511 (n),sizeof(XkbKeyAliasRec))
513 #define _XkbAllocOutlines(s,n) _XkbGeomAlloc((XPointer *)&(s)->outlines,\
514 &(s)->num_outlines,&(s)->sz_outlines,\
515 (n),sizeof(XkbOutlineRec))
516 #define _XkbAllocRows(s,n) _XkbGeomAlloc((XPointer *)&(s)->rows,\
517 &(s)->num_rows,&(s)->sz_rows,\
518 (n),sizeof(XkbRowRec))
519 #define _XkbAllocPoints(o,n) _XkbGeomAlloc((XPointer *)&(o)->points,\
520 &(o)->num_points,&(o)->sz_points,\
521 (n),sizeof(XkbPointRec))
522 #define _XkbAllocKeys(r,n) _XkbGeomAlloc((XPointer *)&(r)->keys,\
523 &(r)->num_keys,&(r)->sz_keys,\
524 (n),sizeof(XkbKeyRec))
525 #define _XkbAllocOverlays(s,n) _XkbGeomAlloc((XPointer *)&(s)->overlays,\
526 &(s)->num_overlays,&(s)->sz_overlays,\
527 (n),sizeof(XkbOverlayRec))
528 #define _XkbAllocOverlayRows(o,n) _XkbGeomAlloc((XPointer *)&(o)->rows,\
529 &(o)->num_rows,&(o)->sz_rows,\
530 (n),sizeof(XkbOverlayRowRec))
531 #define _XkbAllocOverlayKeys(r,n) _XkbGeomAlloc((XPointer *)&(r)->keys,\
532 &(r)->num_keys,&(r)->sz_keys,\
533 (n),sizeof(XkbOverlayKeyRec))
536 XkbAllocGeomProps(XkbGeometryPtr geom
,int nProps
)
538 return _XkbAllocProps(geom
,nProps
);
542 XkbAllocGeomColors(XkbGeometryPtr geom
,int nColors
)
544 return _XkbAllocColors(geom
,nColors
);
548 XkbAllocGeomKeyAliases(XkbGeometryPtr geom
,int nKeyAliases
)
550 return _XkbAllocKeyAliases(geom
,nKeyAliases
);
554 XkbAllocGeomShapes(XkbGeometryPtr geom
,int nShapes
)
556 return _XkbAllocShapes(geom
,nShapes
);
560 XkbAllocGeomSections(XkbGeometryPtr geom
,int nSections
)
562 return _XkbAllocSections(geom
,nSections
);
566 XkbAllocGeomOverlays(XkbSectionPtr section
,int nOverlays
)
568 return _XkbAllocOverlays(section
,nOverlays
);
572 XkbAllocGeomOverlayRows(XkbOverlayPtr overlay
,int nRows
)
574 return _XkbAllocOverlayRows(overlay
,nRows
);
578 XkbAllocGeomOverlayKeys(XkbOverlayRowPtr row
,int nKeys
)
580 return _XkbAllocOverlayKeys(row
,nKeys
);
584 XkbAllocGeomDoodads(XkbGeometryPtr geom
,int nDoodads
)
586 return _XkbAllocDoodads(geom
,nDoodads
);
590 XkbAllocGeomSectionDoodads(XkbSectionPtr section
,int nDoodads
)
592 return _XkbAllocDoodads(section
,nDoodads
);
596 XkbAllocGeomOutlines(XkbShapePtr shape
,int nOL
)
598 return _XkbAllocOutlines(shape
,nOL
);
602 XkbAllocGeomRows(XkbSectionPtr section
,int nRows
)
604 return _XkbAllocRows(section
,nRows
);
608 XkbAllocGeomPoints(XkbOutlinePtr ol
,int nPts
)
610 return _XkbAllocPoints(ol
,nPts
);
614 XkbAllocGeomKeys(XkbRowPtr row
,int nKeys
)
616 return _XkbAllocKeys(row
,nKeys
);
620 XkbAllocGeometry(XkbDescPtr xkb
,XkbGeometrySizesPtr sizes
)
625 if (xkb
->geom
==NULL
) {
626 xkb
->geom
= _XkbTypedCalloc(1,XkbGeometryRec
);
631 if ((sizes
->which
&XkbGeomPropertiesMask
)&&
632 ((rtrn
=_XkbAllocProps(geom
,sizes
->num_properties
))!=Success
)) {
635 if ((sizes
->which
&XkbGeomColorsMask
)&&
636 ((rtrn
=_XkbAllocColors(geom
,sizes
->num_colors
))!=Success
)) {
639 if ((sizes
->which
&XkbGeomShapesMask
)&&
640 ((rtrn
=_XkbAllocShapes(geom
,sizes
->num_shapes
))!=Success
)) {
643 if ((sizes
->which
&XkbGeomSectionsMask
)&&
644 ((rtrn
=_XkbAllocSections(geom
,sizes
->num_sections
))!=Success
)) {
647 if ((sizes
->which
&XkbGeomDoodadsMask
)&&
648 ((rtrn
=_XkbAllocDoodads(geom
,sizes
->num_doodads
))!=Success
)) {
651 if ((sizes
->which
&XkbGeomKeyAliasesMask
)&&
652 ((rtrn
=_XkbAllocKeyAliases(geom
,sizes
->num_key_aliases
))!=Success
)) {
657 XkbFreeGeometry(geom
,XkbGeomAllMask
,True
);
662 /***====================================================================***/
665 XkbAddGeomProperty(XkbGeometryPtr geom
,char *name
,char *value
)
668 register XkbPropertyPtr prop
;
670 if ((!geom
)||(!name
)||(!value
))
672 for (i
=0,prop
=geom
->properties
;i
<geom
->num_properties
;i
++,prop
++) {
673 if ((prop
->name
)&&(strcmp(name
,prop
->name
)==0)) {
675 _XkbFree(prop
->value
);
676 prop
->value
= (char *)_XkbAlloc(strlen(value
)+1);
678 strcpy(prop
->value
,value
);
682 if ((geom
->num_properties
>=geom
->sz_properties
)&&
683 (_XkbAllocProps(geom
,1)!=Success
)) {
686 prop
= &geom
->properties
[geom
->num_properties
];
687 prop
->name
= (char *)_XkbAlloc(strlen(name
)+1);
690 strcpy(prop
->name
,name
);
691 prop
->value
= (char *)_XkbAlloc(strlen(value
)+1);
693 _XkbFree(prop
->name
);
697 strcpy(prop
->value
,value
);
698 geom
->num_properties
++;
703 XkbAddGeomKeyAlias(XkbGeometryPtr geom
,char *aliasStr
,char *realStr
)
706 register XkbKeyAliasPtr alias
;
708 if ((!geom
)||(!aliasStr
)||(!realStr
)||(!aliasStr
[0])||(!realStr
[0]))
710 for (i
=0,alias
=geom
->key_aliases
;i
<geom
->num_key_aliases
;i
++,alias
++) {
711 if (strncmp(alias
->alias
,aliasStr
,XkbKeyNameLength
)==0) {
712 bzero(alias
->real
,XkbKeyNameLength
);
713 strncpy(alias
->real
,realStr
,XkbKeyNameLength
);
717 if ((geom
->num_key_aliases
>=geom
->sz_key_aliases
)&&
718 (_XkbAllocKeyAliases(geom
,1)!=Success
)) {
721 alias
= &geom
->key_aliases
[geom
->num_key_aliases
];
722 bzero(alias
,sizeof(XkbKeyAliasRec
));
723 strncpy(alias
->alias
,aliasStr
,XkbKeyNameLength
);
724 strncpy(alias
->real
,realStr
,XkbKeyNameLength
);
725 geom
->num_key_aliases
++;
730 XkbAddGeomColor(XkbGeometryPtr geom
,char *spec
,unsigned int pixel
)
733 register XkbColorPtr color
;
735 if ((!geom
)||(!spec
))
737 for (i
=0,color
=geom
->colors
;i
<geom
->num_colors
;i
++,color
++) {
738 if ((color
->spec
)&&(strcmp(color
->spec
,spec
)==0)) {
743 if ((geom
->num_colors
>=geom
->sz_colors
)&&
744 (_XkbAllocColors(geom
,1)!=Success
)) {
747 color
= &geom
->colors
[geom
->num_colors
];
749 color
->spec
= (char *)_XkbAlloc(strlen(spec
)+1);
752 strcpy(color
->spec
,spec
);
758 XkbAddGeomOutline(XkbShapePtr shape
,int sz_points
)
760 XkbOutlinePtr outline
;
762 if ((!shape
)||(sz_points
<0))
764 if ((shape
->num_outlines
>=shape
->sz_outlines
)&&
765 (_XkbAllocOutlines(shape
,1)!=Success
)) {
768 outline
= &shape
->outlines
[shape
->num_outlines
];
769 bzero(outline
,sizeof(XkbOutlineRec
));
770 if ((sz_points
>0)&&(_XkbAllocPoints(outline
,sz_points
)!=Success
))
772 shape
->num_outlines
++;
777 XkbAddGeomShape(XkbGeometryPtr geom
,Atom name
,int sz_outlines
)
782 if ((!geom
)||(!name
)||(sz_outlines
<0))
784 if (geom
->num_shapes
>0) {
785 for (shape
=geom
->shapes
,i
=0;i
<geom
->num_shapes
;i
++,shape
++) {
786 if (name
==shape
->name
)
790 if ((geom
->num_shapes
>=geom
->sz_shapes
)&&
791 (_XkbAllocShapes(geom
,1)!=Success
))
793 shape
= &geom
->shapes
[geom
->num_shapes
];
794 bzero(shape
,sizeof(XkbShapeRec
));
795 if ((sz_outlines
>0)&&(_XkbAllocOutlines(shape
,sz_outlines
)!=Success
))
798 shape
->primary
= shape
->approx
= NULL
;
804 XkbAddGeomKey(XkbRowPtr row
)
809 if ((row
->num_keys
>=row
->sz_keys
)&&(_XkbAllocKeys(row
,1)!=Success
))
811 key
= &row
->keys
[row
->num_keys
++];
812 bzero(key
,sizeof(XkbKeyRec
));
817 XkbAddGeomRow(XkbSectionPtr section
,int sz_keys
)
821 if ((!section
)||(sz_keys
<0))
823 if ((section
->num_rows
>=section
->sz_rows
)&&
824 (_XkbAllocRows(section
,1)!=Success
))
826 row
= §ion
->rows
[section
->num_rows
];
827 bzero(row
,sizeof(XkbRowRec
));
828 if ((sz_keys
>0)&&(_XkbAllocKeys(row
,sz_keys
)!=Success
))
835 XkbAddGeomSection( XkbGeometryPtr geom
,
842 XkbSectionPtr section
;
844 if ((!geom
)||(name
==None
)||(sz_rows
<0))
846 for (i
=0,section
=geom
->sections
;i
<geom
->num_sections
;i
++,section
++) {
847 if (section
->name
!=name
)
849 if (((sz_rows
>0)&&(_XkbAllocRows(section
,sz_rows
)!=Success
))||
850 ((sz_doodads
>0)&&(_XkbAllocDoodads(section
,sz_doodads
)!=Success
))||
851 ((sz_over
>0)&&(_XkbAllocOverlays(section
,sz_over
)!=Success
)))
855 if ((geom
->num_sections
>=geom
->sz_sections
)&&
856 (_XkbAllocSections(geom
,1)!=Success
))
858 section
= &geom
->sections
[geom
->num_sections
];
859 if ((sz_rows
>0)&&(_XkbAllocRows(section
,sz_rows
)!=Success
))
861 if ((sz_doodads
>0)&&(_XkbAllocDoodads(section
,sz_doodads
)!=Success
)) {
863 _XkbFree(section
->rows
);
865 section
->sz_rows
= section
->num_rows
= 0;
870 geom
->num_sections
++;
875 XkbAddGeomDoodad(XkbGeometryPtr geom
,XkbSectionPtr section
,Atom name
)
877 XkbDoodadPtr old
,doodad
;
878 register int i
,nDoodads
;
880 if ((!geom
)||(name
==None
))
882 if ((section
!=NULL
)&&(section
->num_doodads
>0)) {
883 old
= section
->doodads
;
884 nDoodads
= section
->num_doodads
;
888 nDoodads
= geom
->num_doodads
;
890 for (i
=0,doodad
=old
;i
<nDoodads
;i
++,doodad
++) {
891 if (doodad
->any
.name
==name
)
895 if ((section
->num_doodads
>=geom
->sz_doodads
)&&
896 (_XkbAllocDoodads(section
,1)!=Success
)) {
899 doodad
= §ion
->doodads
[section
->num_doodads
++];
902 if ((geom
->num_doodads
>=geom
->sz_doodads
)&&
903 (_XkbAllocDoodads(geom
,1)!=Success
))
905 doodad
= &geom
->doodads
[geom
->num_doodads
++];
907 bzero(doodad
,sizeof(XkbDoodadRec
));
908 doodad
->any
.name
= name
;
913 XkbAddGeomOverlayKey( XkbOverlayPtr overlay
,
914 XkbOverlayRowPtr row
,
919 XkbOverlayKeyPtr key
;
920 XkbSectionPtr section
;
924 if ((!overlay
)||(!row
)||(!over
)||(!under
))
926 section
= overlay
->section_under
;
927 if (row
->row_under
>=section
->num_rows
)
929 row_under
= §ion
->rows
[row
->row_under
];
930 for (i
=0,found
=False
;i
<row_under
->num_keys
;i
++) {
931 if (strncmp(under
,row_under
->keys
[i
].name
.name
,XkbKeyNameLength
)==0) {
938 if ((row
->num_keys
>=row
->sz_keys
)&&(_XkbAllocOverlayKeys(row
,1)!=Success
))
940 key
= &row
->keys
[row
->num_keys
];
941 strncpy(key
->under
.name
,under
,XkbKeyNameLength
);
942 strncpy(key
->over
.name
,over
,XkbKeyNameLength
);
948 XkbAddGeomOverlayRow(XkbOverlayPtr overlay
,int row_under
,int sz_keys
)
951 XkbOverlayRowPtr row
;
953 if ((!overlay
)||(sz_keys
<0))
955 if (row_under
>=overlay
->section_under
->num_rows
)
957 for (i
=0;i
<overlay
->num_rows
;i
++) {
958 if (overlay
->rows
[i
].row_under
==row_under
) {
959 row
= &overlay
->rows
[i
];
960 if ((row
->sz_keys
<sz_keys
)&&
961 (_XkbAllocOverlayKeys(row
,sz_keys
)!=Success
)) {
964 return &overlay
->rows
[i
];
967 if ((overlay
->num_rows
>=overlay
->sz_rows
)&&
968 (_XkbAllocOverlayRows(overlay
,1)!=Success
))
970 row
= &overlay
->rows
[overlay
->num_rows
];
971 bzero(row
,sizeof(XkbOverlayRowRec
));
972 if ((sz_keys
>0)&&(_XkbAllocOverlayKeys(row
,sz_keys
)!=Success
))
974 row
->row_under
= row_under
;
980 XkbAddGeomOverlay(XkbSectionPtr section
,Atom name
,int sz_rows
)
983 XkbOverlayPtr overlay
;
985 if ((!section
)||(name
==None
)||(sz_rows
==0))
988 for (i
=0,overlay
=section
->overlays
;i
<section
->num_overlays
;i
++,overlay
++) {
989 if (overlay
->name
==name
) {
990 if ((sz_rows
>0)&&(_XkbAllocOverlayRows(overlay
,sz_rows
)!=Success
))
995 if ((section
->num_overlays
>=section
->sz_overlays
)&&
996 (_XkbAllocOverlays(section
,1)!=Success
))
998 overlay
= §ion
->overlays
[section
->num_overlays
];
999 if ((sz_rows
>0)&&(_XkbAllocOverlayRows(overlay
,sz_rows
)!=Success
))
1001 overlay
->name
= name
;
1002 overlay
->section_under
= section
;
1003 section
->num_overlays
++;