1/************************************************************
2Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
3
4Permission to use, copy, modify, and distribute this
5software and its documentation for any purpose and without
6fee is hereby granted, provided that the above copyright
7notice appear in all copies and that both that copyright
8notice and this permission notice appear in supporting
9documentation, and that the name of Silicon Graphics not be
10used in advertising or publicity pertaining to distribution
11of the software without specific prior written permission.
12Silicon Graphics makes no representation about the suitability
13of this software for any purpose. It is provided "as is"
14without any express or implied warranty.
15
16SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
17SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
18AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
19GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
20DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
21DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
22OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
23THE USE OR PERFORMANCE OF THIS SOFTWARE.
24
25********************************************************/
26
27#ifndef _XKBGEOM_H_
28#define	_XKBGEOM_H_
29
30#include <X11/extensions/XKBstr.h>
31
32typedef	struct _XkbProperty {
33	char	*name;
34	char	*value;
35} XkbPropertyRec,*XkbPropertyPtr;
36
37typedef struct _XkbColor {
38	unsigned int 	pixel;
39	char *		spec;
40} XkbColorRec,*XkbColorPtr;
41
42typedef	struct _XkbPoint {
43	short	x;
44	short	y;
45} XkbPointRec, *XkbPointPtr;
46
47typedef struct	_XkbBounds {
48	short	x1,y1;
49	short	x2,y2;
50} XkbBoundsRec, *XkbBoundsPtr;
51#define	XkbBoundsWidth(b)	(((b)->x2)-((b)->x1))
52#define	XkbBoundsHeight(b)	(((b)->y2)-((b)->y1))
53
54/*
55 * In the following structs, this pattern is used for dynamically sized arrays:
56 * foo is an array for which sz_foo entries are allocated & num_foo are used
57 */
58
59typedef struct _XkbOutline {
60	unsigned short	num_points;
61	unsigned short	sz_points;
62	unsigned short	corner_radius;
63	XkbPointPtr	points;
64} XkbOutlineRec, *XkbOutlinePtr;
65
66typedef struct _XkbShape {
67	Atom	 	 name;
68	unsigned short	 num_outlines;
69	unsigned short	 sz_outlines;
70	XkbOutlinePtr	 outlines;
71	XkbOutlinePtr	 approx;
72	XkbOutlinePtr	 primary;
73	XkbBoundsRec	 bounds;
74} XkbShapeRec, *XkbShapePtr;
75#define	XkbOutlineIndex(s,o)	((int)((o)-&(s)->outlines[0]))
76
77typedef struct _XkbShapeDoodad {
78	Atom		 name;
79	unsigned char	 type;
80	unsigned char	 priority;
81	short		 top;
82	short		 left;
83	short	 	 angle;
84	unsigned short	 color_ndx;
85	unsigned short	 shape_ndx;
86} XkbShapeDoodadRec, *XkbShapeDoodadPtr;
87#define	XkbShapeDoodadColor(g,d)	(&(g)->colors[(d)->color_ndx])
88#define	XkbShapeDoodadShape(g,d)	(&(g)->shapes[(d)->shape_ndx])
89#define	XkbSetShapeDoodadColor(g,d,c)	((d)->color_ndx= (c)-&(g)->colors[0])
90#define	XkbSetShapeDoodadShape(g,d,s)	((d)->shape_ndx= (s)-&(g)->shapes[0])
91
92typedef struct _XkbTextDoodad {
93	Atom		 name;
94	unsigned char	 type;
95	unsigned char	 priority;
96	short	 	 top;
97	short	 	 left;
98	short	 	 angle;
99	short	 	 width;
100	short		 height;
101	unsigned short	 color_ndx;
102	char *		 text;
103	char *		 font;
104} XkbTextDoodadRec, *XkbTextDoodadPtr;
105#define	XkbTextDoodadColor(g,d)	(&(g)->colors[(d)->color_ndx])
106#define	XkbSetTextDoodadColor(g,d,c)	((d)->color_ndx= (c)-&(g)->colors[0])
107
108typedef struct _XkbIndicatorDoodad {
109	Atom		 name;
110	unsigned char	 type;
111	unsigned char	 priority;
112	short	 	 top;
113	short	 	 left;
114	short		 angle;
115	unsigned short	 shape_ndx;
116	unsigned short	 on_color_ndx;
117	unsigned short	 off_color_ndx;
118} XkbIndicatorDoodadRec, *XkbIndicatorDoodadPtr;
119#define	XkbIndicatorDoodadShape(g,d)	(&(g)->shapes[(d)->shape_ndx])
120#define	XkbIndicatorDoodadOnColor(g,d)	(&(g)->colors[(d)->on_color_ndx])
121#define	XkbIndicatorDoodadOffColor(g,d)	(&(g)->colors[(d)->off_color_ndx])
122#define	XkbSetIndicatorDoodadOnColor(g,d,c) \
123				((d)->on_color_ndx= (c)-&(g)->colors[0])
124#define	XkbSetIndicatorDoodadOffColor(g,d,c) \
125				((d)->off_color_ndx= (c)-&(g)->colors[0])
126#define	XkbSetIndicatorDoodadShape(g,d,s) \
127				((d)->shape_ndx= (s)-&(g)->shapes[0])
128
129typedef struct _XkbLogoDoodad {
130	Atom		 name;
131	unsigned char	 type;
132	unsigned char	 priority;
133	short		 top;
134	short		 left;
135	short	 	 angle;
136	unsigned short	 color_ndx;
137	unsigned short	 shape_ndx;
138	char *		 logo_name;
139} XkbLogoDoodadRec, *XkbLogoDoodadPtr;
140#define	XkbLogoDoodadColor(g,d)		(&(g)->colors[(d)->color_ndx])
141#define	XkbLogoDoodadShape(g,d)		(&(g)->shapes[(d)->shape_ndx])
142#define	XkbSetLogoDoodadColor(g,d,c)	((d)->color_ndx= (c)-&(g)->colors[0])
143#define	XkbSetLogoDoodadShape(g,d,s)	((d)->shape_ndx= (s)-&(g)->shapes[0])
144
145typedef struct _XkbAnyDoodad {
146	Atom		 name;
147	unsigned char	 type;
148	unsigned char	 priority;
149	short	 	 top;
150	short	 	 left;
151	short		 angle;
152} XkbAnyDoodadRec, *XkbAnyDoodadPtr;
153
154typedef union _XkbDoodad {
155	XkbAnyDoodadRec		any;
156	XkbShapeDoodadRec	shape;
157	XkbTextDoodadRec	text;
158	XkbIndicatorDoodadRec	indicator;
159	XkbLogoDoodadRec	logo;
160} XkbDoodadRec, *XkbDoodadPtr;
161
162#define	XkbUnknownDoodad	0
163#define	XkbOutlineDoodad	1
164#define	XkbSolidDoodad		2
165#define	XkbTextDoodad		3
166#define	XkbIndicatorDoodad	4
167#define	XkbLogoDoodad		5
168
169typedef struct _XkbKey {
170	XkbKeyNameRec	 name;
171	short		 gap;
172	unsigned char	 shape_ndx;
173	unsigned char	 color_ndx;
174} XkbKeyRec, *XkbKeyPtr;
175#define	XkbKeyShape(g,k)	(&(g)->shapes[(k)->shape_ndx])
176#define	XkbKeyColor(g,k)	(&(g)->colors[(k)->color_ndx])
177#define	XkbSetKeyShape(g,k,s)	((k)->shape_ndx= (s)-&(g)->shapes[0])
178#define	XkbSetKeyColor(g,k,c)	((k)->color_ndx= (c)-&(g)->colors[0])
179
180typedef struct _XkbRow {
181	short	 	top;
182	short	 	left;
183	unsigned short	num_keys;
184	unsigned short	sz_keys;
185	int		vertical;
186	XkbKeyPtr	keys;
187	XkbBoundsRec	bounds;
188} XkbRowRec, *XkbRowPtr;
189
190typedef struct _XkbSection {
191	Atom		 name;
192	unsigned char	 priority;
193	short	 	 top;
194	short	 	 left;
195	unsigned short	 width;
196	unsigned short	 height;
197	short	 	 angle;
198	unsigned short	 num_rows;
199	unsigned short	 num_doodads;
200	unsigned short	 num_overlays;
201	unsigned short	 sz_rows;
202	unsigned short	 sz_doodads;
203	unsigned short	 sz_overlays;
204	XkbRowPtr	 rows;
205	XkbDoodadPtr	 doodads;
206	XkbBoundsRec	 bounds;
207	struct _XkbOverlay *overlays;
208} XkbSectionRec, *XkbSectionPtr;
209
210typedef	struct _XkbOverlayKey {
211	XkbKeyNameRec	over;
212	XkbKeyNameRec	under;
213} XkbOverlayKeyRec,*XkbOverlayKeyPtr;
214
215typedef struct _XkbOverlayRow {
216	unsigned short		row_under;
217	unsigned short		num_keys;
218	unsigned short		sz_keys;
219	XkbOverlayKeyPtr	keys;
220} XkbOverlayRowRec,*XkbOverlayRowPtr;
221
222typedef struct _XkbOverlay {
223	Atom			name;
224	XkbSectionPtr		section_under;
225	unsigned short		num_rows;
226	unsigned short		sz_rows;
227	XkbOverlayRowPtr	rows;
228	XkbBoundsPtr		bounds;
229} XkbOverlayRec,*XkbOverlayPtr;
230
231typedef struct _XkbGeometry {
232	Atom		 name;
233	unsigned short	 width_mm;
234	unsigned short	 height_mm;
235	char *		 label_font;
236	XkbColorPtr	 label_color;
237	XkbColorPtr	 base_color;
238	unsigned short	 sz_properties;
239	unsigned short	 sz_colors;
240	unsigned short	 sz_shapes;
241	unsigned short   sz_sections;
242	unsigned short	 sz_doodads;
243	unsigned short	 sz_key_aliases;
244	unsigned short	 num_properties;
245	unsigned short	 num_colors;
246	unsigned short	 num_shapes;
247	unsigned short	 num_sections;
248	unsigned short	 num_doodads;
249	unsigned short	 num_key_aliases;
250	XkbPropertyPtr	 properties;
251	XkbColorPtr	 colors;
252	XkbShapePtr	 shapes;
253	XkbSectionPtr	 sections;
254	XkbDoodadPtr	 doodads;
255	XkbKeyAliasPtr	 key_aliases;
256} XkbGeometryRec;
257#define	XkbGeomColorIndex(g,c)	((int)((c)-&(g)->colors[0]))
258
259#define	XkbGeomPropertiesMask	(1<<0)
260#define	XkbGeomColorsMask	(1<<1)
261#define	XkbGeomShapesMask	(1<<2)
262#define	XkbGeomSectionsMask	(1<<3)
263#define	XkbGeomDoodadsMask	(1<<4)
264#define	XkbGeomKeyAliasesMask	(1<<5)
265#define	XkbGeomAllMask		(0x3f)
266
267typedef struct _XkbGeometrySizes {
268	unsigned int	which;
269	unsigned short	num_properties;
270	unsigned short	num_colors;
271	unsigned short	num_shapes;
272	unsigned short	num_sections;
273	unsigned short	num_doodads;
274	unsigned short	num_key_aliases;
275} XkbGeometrySizesRec,*XkbGeometrySizesPtr;
276
277_XFUNCPROTOBEGIN
278
279extern	XkbPropertyPtr
280XkbAddGeomProperty(
281    XkbGeometryPtr	/* geom */,
282    _Xconst char *	/* name */,
283    _Xconst char *	/* value */
284);
285
286extern	XkbKeyAliasPtr
287XkbAddGeomKeyAlias(
288    XkbGeometryPtr	/* geom */,
289    _Xconst char *	/* alias */,
290    _Xconst char *	/* real */
291);
292
293extern	XkbColorPtr
294XkbAddGeomColor(
295    XkbGeometryPtr	/* geom */,
296    _Xconst char *	/* spec */,
297    unsigned int	/* pixel */
298);
299
300extern	XkbOutlinePtr
301XkbAddGeomOutline(
302    XkbShapePtr		/* shape */,
303    int			/* sz_points */
304);
305
306extern XkbShapePtr
307XkbAddGeomShape(
308    XkbGeometryPtr	/* geom */,
309    Atom		/* name */,
310    int			/* sz_outlines */
311);
312
313extern XkbKeyPtr
314XkbAddGeomKey(
315    XkbRowPtr		/* row */
316);
317
318extern XkbRowPtr
319XkbAddGeomRow(
320    XkbSectionPtr	/* section */,
321    int			/* sz_keys */
322);
323
324extern XkbSectionPtr
325XkbAddGeomSection(
326    XkbGeometryPtr	/* geom */,
327    Atom		/* name */,
328    int			/* sz_rows */,
329    int			/* sz_doodads */,
330    int			/* sz_overlays */
331);
332
333extern XkbOverlayPtr
334XkbAddGeomOverlay(
335    XkbSectionPtr	/* section */,
336    Atom		/* name */,
337    int			/* sz_rows */
338);
339
340extern XkbOverlayRowPtr
341XkbAddGeomOverlayRow(
342    XkbOverlayPtr	/* overlay */,
343    int			/* row_under */,
344    int			/* sz_keys */
345);
346
347extern XkbOverlayKeyPtr
348XkbAddGeomOverlayKey(
349    XkbOverlayPtr	/* overlay */,
350    XkbOverlayRowPtr	/* row */,
351    _Xconst char *	/* over */,
352    _Xconst char *	/* under */
353);
354
355extern XkbDoodadPtr
356XkbAddGeomDoodad(
357    XkbGeometryPtr	/* geom */,
358    XkbSectionPtr	/* section */,
359    Atom		/* name */
360);
361
362
363extern void
364XkbFreeGeomKeyAliases(
365    XkbGeometryPtr	/* geom */,
366    int			/* first */,
367    int			/* count */,
368    Bool		/* freeAll */
369);
370
371extern void
372XkbFreeGeomColors(
373    XkbGeometryPtr	/* geom */,
374    int			/* first */,
375    int			/* count */,
376    Bool		/* freeAll */
377);
378
379extern void
380XkbFreeGeomDoodads(
381    XkbDoodadPtr	/* doodads */,
382    int			/* nDoodads */,
383    Bool		/* freeAll */
384);
385
386
387extern void
388XkbFreeGeomProperties(
389    XkbGeometryPtr	/* geom */,
390    int			/* first */,
391    int			/* count */,
392    Bool		/* freeAll */
393);
394
395extern void
396XkbFreeGeomOverlayKeys(
397    XkbOverlayRowPtr	/* row */,
398    int			/* first */,
399    int			/* count */,
400    Bool		/* freeAll */
401);
402
403extern void
404XkbFreeGeomOverlayRows(
405    XkbOverlayPtr	/* overlay */,
406    int			/* first */,
407    int			/* count */,
408    Bool		/* freeAll */
409);
410
411extern void
412XkbFreeGeomOverlays(
413    XkbSectionPtr	/* section */,
414    int			/* first */,
415    int			/* count */,
416    Bool		/* freeAll */
417);
418
419extern void
420XkbFreeGeomKeys(
421    XkbRowPtr		/* row */,
422    int			/* first */,
423    int			/* count */,
424    Bool		/* freeAll */
425);
426
427extern void
428XkbFreeGeomRows(
429    XkbSectionPtr	/* section */,
430    int			/* first */,
431    int			/* count */,
432    Bool		/* freeAll */
433);
434
435extern void
436XkbFreeGeomSections(
437    XkbGeometryPtr	/* geom */,
438    int			/* first */,
439    int			/* count */,
440    Bool		/* freeAll */
441);
442
443
444extern void
445XkbFreeGeomPoints(
446    XkbOutlinePtr	/* outline */,
447    int			/* first */,
448    int			/* count */,
449    Bool		/* freeAll */
450);
451
452extern void
453XkbFreeGeomOutlines(
454    XkbShapePtr		/* shape */,
455    int			/* first */,
456    int			/* count */,
457    Bool		/* freeAll */
458);
459
460extern void
461XkbFreeGeomShapes(
462    XkbGeometryPtr	/* geom */,
463    int			/* first */,
464    int			/* count */,
465    Bool		/* freeAll */
466);
467
468extern void
469XkbFreeGeometry(
470    XkbGeometryPtr	/* geom */,
471    unsigned int	/* which */,
472    Bool		/* freeMap */
473);
474
475extern Status
476XkbAllocGeomProps(
477    XkbGeometryPtr	/* geom */,
478    int			/* nProps */
479);
480
481extern Status
482XkbAllocGeomKeyAliases(
483    XkbGeometryPtr	/* geom */,
484    int			/* nAliases */
485);
486
487extern Status
488XkbAllocGeomColors(
489    XkbGeometryPtr	/* geom */,
490    int			/* nColors */
491);
492
493extern Status
494XkbAllocGeomShapes(
495    XkbGeometryPtr	/* geom */,
496    int			/* nShapes */
497);
498
499extern Status
500XkbAllocGeomSections(
501    XkbGeometryPtr	/* geom */,
502    int			/* nSections */
503);
504
505extern Status
506XkbAllocGeomOverlays(
507    XkbSectionPtr	/* section */,
508    int			/* num_needed */
509);
510
511extern Status
512XkbAllocGeomOverlayRows(
513    XkbOverlayPtr	/* overlay */,
514    int			/* num_needed */
515);
516
517extern Status
518XkbAllocGeomOverlayKeys(
519    XkbOverlayRowPtr	/* row */,
520    int			/* num_needed */
521);
522
523extern Status
524XkbAllocGeomDoodads(
525    XkbGeometryPtr	/* geom */,
526    int			/* nDoodads */
527);
528
529extern Status
530XkbAllocGeomSectionDoodads(
531    XkbSectionPtr	/* section */,
532    int			/* nDoodads */
533);
534
535extern Status
536XkbAllocGeomOutlines(
537    XkbShapePtr		/* shape */,
538    int			/* nOL */
539);
540
541extern Status
542XkbAllocGeomRows(
543    XkbSectionPtr	/* section */,
544    int			/* nRows */
545);
546
547extern Status
548XkbAllocGeomPoints(
549    XkbOutlinePtr	/* ol */,
550    int			/* nPts */
551);
552
553extern Status
554XkbAllocGeomKeys(
555    XkbRowPtr		/* row */,
556    int			/* nKeys */
557);
558
559extern	Status
560XkbAllocGeometry(
561	XkbDescPtr		/* xkb */,
562	XkbGeometrySizesPtr	/* sizes */
563);
564
565extern	Status
566XkbSetGeometry(
567	Display *		/* dpy */,
568	unsigned		/* deviceSpec */,
569	XkbGeometryPtr		/* geom */
570);
571
572extern	Bool
573XkbComputeShapeTop(
574	XkbShapePtr		/* shape */,
575	XkbBoundsPtr		/* bounds */
576);
577
578extern	Bool
579XkbComputeShapeBounds(
580	XkbShapePtr		/* shape */
581);
582
583extern	Bool
584XkbComputeRowBounds(
585	XkbGeometryPtr		/* geom */,
586	XkbSectionPtr		/* section */,
587	XkbRowPtr		/* row */
588);
589
590extern	Bool
591XkbComputeSectionBounds(
592	XkbGeometryPtr		/* geom */,
593	XkbSectionPtr		/* section */
594);
595
596extern	char *
597XkbFindOverlayForKey(
598	XkbGeometryPtr		/* geom */,
599	XkbSectionPtr		/* wanted */,
600	_Xconst char *		/* under */
601);
602
603extern	Status
604XkbGetGeometry(
605    Display *			/* dpy */,
606    XkbDescPtr			/* xkb */
607);
608
609extern	Status
610XkbGetNamedGeometry(
611    Display *			/* dpy */,
612    XkbDescPtr			/* xkb */,
613    Atom			/* name */
614);
615
616_XFUNCPROTOEND
617
618#endif /* _XKBSTR_H_ */
619