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
32#ifdef XKB_IN_SERVER
33#define XkbAddGeomKeyAlias 		SrvXkbAddGeomKeyAlias
34#define XkbAddGeomColor 		SrvXkbAddGeomColor
35#define XkbAddGeomDoodad		SrvXkbAddGeomDoodad
36#define XkbAddGeomKey			SrvXkbAddGeomKey
37#define XkbAddGeomOutline		SrvXkbAddGeomOutline
38#define XkbAddGeomOverlay		SrvXkbAddGeomOverlay
39#define XkbAddGeomOverlayRow		SrvXkbAddGeomOverlayRow
40#define	XkbAddGeomOverlayKey		SrvXkbAddGeomOverlayKey
41#define XkbAddGeomProperty		SrvXkbAddGeomProperty
42#define XkbAddGeomRow			SrvXkbAddGeomRow
43#define XkbAddGeomSection		SrvXkbAddGeomSection
44#define XkbAddGeomShape			SrvXkbAddGeomShape
45#define XkbAllocGeomKeyAliases		SrvXkbAllocGeomKeyAliases
46#define XkbAllocGeomColors		SrvXkbAllocGeomColors
47#define XkbAllocGeomDoodads		SrvXkbAllocGeomDoodads
48#define XkbAllocGeomKeys		SrvXkbAllocGeomKeys
49#define XkbAllocGeomOutlines		SrvXkbAllocGeomOutlines
50#define XkbAllocGeomPoints		SrvXkbAllocGeomPoints
51#define XkbAllocGeomProps		SrvXkbAllocGeomProps
52#define XkbAllocGeomRows		SrvXkbAllocGeomRows
53#define XkbAllocGeomSectionDoodads	SrvXkbAllocGeomSectionDoodads
54#define XkbAllocGeomSections		SrvXkbAllocGeomSections
55#define	XkbAllocGeomOverlays		SrvXkbAllocGeomOverlays
56#define	XkbAllocGeomOverlayRows		SrvXkbAllocGeomOverlayRows
57#define	XkbAllocGeomOverlayKeys		SrvXkbAllocGeomOverlayKeys
58#define XkbAllocGeomShapes		SrvXkbAllocGeomShapes
59#define XkbAllocGeometry		SrvXkbAllocGeometry
60#define XkbFreeGeomKeyAliases		SrvXkbFreeGeomKeyAliases
61#define XkbFreeGeomColors		SrvXkbFreeGeomColors
62#define XkbFreeGeomDoodads		SrvXkbFreeGeomDoodads
63#define XkbFreeGeomProperties		SrvXkbFreeGeomProperties
64#define	XkbFreeGeomOverlayKeys		SrvXkbFreeGeomOverlayKeys
65#define	XkbFreeGeomOverlayRows		SrvXkbFreeGeomOverlayRows
66#define	XkbFreeGeomOverlays		SrvXkbFreeGeomOverlays
67#define	XkbFreeGeomKeys			SrvXkbFreeGeomKeys
68#define	XkbFreeGeomRows			SrvXkbFreeGeomRows
69#define XkbFreeGeomSections		SrvXkbFreeGeomSections
70#define	XkbFreeGeomPoints		SrvXkbFreeGeomPoints
71#define	XkbFreeGeomOutlines		SrvXkbFreeGeomOutlines
72#define XkbFreeGeomShapes		SrvXkbFreeGeomShapes
73#define XkbFreeGeometry			SrvXkbFreeGeometry
74#endif
75
76typedef	struct _XkbProperty {
77	char	*name;
78	char	*value;
79} XkbPropertyRec,*XkbPropertyPtr;
80
81typedef struct _XkbColor {
82	unsigned int 	pixel;
83	char *		spec;
84} XkbColorRec,*XkbColorPtr;
85
86typedef	struct _XkbPoint {
87	short	x;
88	short	y;
89} XkbPointRec, *XkbPointPtr;
90
91typedef struct	_XkbBounds {
92	short	x1,y1;
93	short	x2,y2;
94} XkbBoundsRec, *XkbBoundsPtr;
95#define	XkbBoundsWidth(b)	(((b)->x2)-((b)->x1))
96#define	XkbBoundsHeight(b)	(((b)->y2)-((b)->y1))
97
98/*
99 * In the following structs, this pattern is used for dynamically sized arrays:
100 * foo is an array for which sz_foo entries are allocated & num_foo are used
101 */
102
103typedef struct _XkbOutline {
104	unsigned short	num_points;
105	unsigned short	sz_points;
106	unsigned short	corner_radius;
107	XkbPointPtr	points;
108} XkbOutlineRec, *XkbOutlinePtr;
109
110typedef struct _XkbShape {
111	Atom	 	 name;
112	unsigned short	 num_outlines;
113	unsigned short	 sz_outlines;
114	XkbOutlinePtr	 outlines;
115	XkbOutlinePtr	 approx;
116	XkbOutlinePtr	 primary;
117	XkbBoundsRec	 bounds;
118} XkbShapeRec, *XkbShapePtr;
119#define	XkbOutlineIndex(s,o)	((int)((o)-&(s)->outlines[0]))
120
121typedef struct _XkbShapeDoodad {
122	Atom		 name;
123	unsigned char	 type;
124	unsigned char	 priority;
125	short		 top;
126	short		 left;
127	short	 	 angle;
128	unsigned short	 color_ndx;
129	unsigned short	 shape_ndx;
130} XkbShapeDoodadRec, *XkbShapeDoodadPtr;
131#define	XkbShapeDoodadColor(g,d)	(&(g)->colors[(d)->color_ndx])
132#define	XkbShapeDoodadShape(g,d)	(&(g)->shapes[(d)->shape_ndx])
133#define	XkbSetShapeDoodadColor(g,d,c)	((d)->color_ndx= (c)-&(g)->colors[0])
134#define	XkbSetShapeDoodadShape(g,d,s)	((d)->shape_ndx= (s)-&(g)->shapes[0])
135
136typedef struct _XkbTextDoodad {
137	Atom		 name;
138	unsigned char	 type;
139	unsigned char	 priority;
140	short	 	 top;
141	short	 	 left;
142	short	 	 angle;
143	short	 	 width;
144	short		 height;
145	unsigned short	 color_ndx;
146	char *		 text;
147	char *		 font;
148} XkbTextDoodadRec, *XkbTextDoodadPtr;
149#define	XkbTextDoodadColor(g,d)	(&(g)->colors[(d)->color_ndx])
150#define	XkbSetTextDoodadColor(g,d,c)	((d)->color_ndx= (c)-&(g)->colors[0])
151
152typedef struct _XkbIndicatorDoodad {
153	Atom		 name;
154	unsigned char	 type;
155	unsigned char	 priority;
156	short	 	 top;
157	short	 	 left;
158	short		 angle;
159	unsigned short	 shape_ndx;
160	unsigned short	 on_color_ndx;
161	unsigned short	 off_color_ndx;
162} XkbIndicatorDoodadRec, *XkbIndicatorDoodadPtr;
163#define	XkbIndicatorDoodadShape(g,d)	(&(g)->shapes[(d)->shape_ndx])
164#define	XkbIndicatorDoodadOnColor(g,d)	(&(g)->colors[(d)->on_color_ndx])
165#define	XkbIndicatorDoodadOffColor(g,d)	(&(g)->colors[(d)->off_color_ndx])
166#define	XkbSetIndicatorDoodadOnColor(g,d,c) \
167				((d)->on_color_ndx= (c)-&(g)->colors[0])
168#define	XkbSetIndicatorDoodadOffColor(g,d,c) \
169				((d)->off_color_ndx= (c)-&(g)->colors[0])
170#define	XkbSetIndicatorDoodadShape(g,d,s) \
171				((d)->shape_ndx= (s)-&(g)->shapes[0])
172
173typedef struct _XkbLogoDoodad {
174	Atom		 name;
175	unsigned char	 type;
176	unsigned char	 priority;
177	short		 top;
178	short		 left;
179	short	 	 angle;
180	unsigned short	 color_ndx;
181	unsigned short	 shape_ndx;
182	char *		 logo_name;
183} XkbLogoDoodadRec, *XkbLogoDoodadPtr;
184#define	XkbLogoDoodadColor(g,d)		(&(g)->colors[(d)->color_ndx])
185#define	XkbLogoDoodadShape(g,d)		(&(g)->shapes[(d)->shape_ndx])
186#define	XkbSetLogoDoodadColor(g,d,c)	((d)->color_ndx= (c)-&(g)->colors[0])
187#define	XkbSetLogoDoodadShape(g,d,s)	((d)->shape_ndx= (s)-&(g)->shapes[0])
188
189typedef struct _XkbAnyDoodad {
190	Atom		 name;
191	unsigned char	 type;
192	unsigned char	 priority;
193	short	 	 top;
194	short	 	 left;
195	short		 angle;
196} XkbAnyDoodadRec, *XkbAnyDoodadPtr;
197
198typedef union _XkbDoodad {
199	XkbAnyDoodadRec		any;
200	XkbShapeDoodadRec	shape;
201	XkbTextDoodadRec	text;
202	XkbIndicatorDoodadRec	indicator;
203	XkbLogoDoodadRec	logo;
204} XkbDoodadRec, *XkbDoodadPtr;
205
206#define	XkbUnknownDoodad	0
207#define	XkbOutlineDoodad	1
208#define	XkbSolidDoodad		2
209#define	XkbTextDoodad		3
210#define	XkbIndicatorDoodad	4
211#define	XkbLogoDoodad		5
212
213typedef struct _XkbKey {
214	XkbKeyNameRec	 name;
215	short		 gap;
216	unsigned char	 shape_ndx;
217	unsigned char	 color_ndx;
218} XkbKeyRec, *XkbKeyPtr;
219#define	XkbKeyShape(g,k)	(&(g)->shapes[(k)->shape_ndx])
220#define	XkbKeyColor(g,k)	(&(g)->colors[(k)->color_ndx])
221#define	XkbSetKeyShape(g,k,s)	((k)->shape_ndx= (s)-&(g)->shapes[0])
222#define	XkbSetKeyColor(g,k,c)	((k)->color_ndx= (c)-&(g)->colors[0])
223
224typedef struct _XkbRow {
225	short	 	top;
226	short	 	left;
227	unsigned short	num_keys;
228	unsigned short	sz_keys;
229	int		vertical;
230	XkbKeyPtr	keys;
231	XkbBoundsRec	bounds;
232} XkbRowRec, *XkbRowPtr;
233
234typedef struct _XkbSection {
235	Atom		 name;
236	unsigned char	 priority;
237	short	 	 top;
238	short	 	 left;
239	unsigned short	 width;
240	unsigned short	 height;
241	short	 	 angle;
242	unsigned short	 num_rows;
243	unsigned short	 num_doodads;
244	unsigned short	 num_overlays;
245	unsigned short	 sz_rows;
246	unsigned short	 sz_doodads;
247	unsigned short	 sz_overlays;
248	XkbRowPtr	 rows;
249	XkbDoodadPtr	 doodads;
250	XkbBoundsRec	 bounds;
251	struct _XkbOverlay *overlays;
252} XkbSectionRec, *XkbSectionPtr;
253
254typedef	struct _XkbOverlayKey {
255	XkbKeyNameRec	over;
256	XkbKeyNameRec	under;
257} XkbOverlayKeyRec,*XkbOverlayKeyPtr;
258
259typedef struct _XkbOverlayRow {
260	unsigned short		row_under;
261	unsigned short		num_keys;
262	unsigned short		sz_keys;
263	XkbOverlayKeyPtr	keys;
264} XkbOverlayRowRec,*XkbOverlayRowPtr;
265
266typedef struct _XkbOverlay {
267	Atom			name;
268	XkbSectionPtr		section_under;
269	unsigned short		num_rows;
270	unsigned short		sz_rows;
271	XkbOverlayRowPtr	rows;
272	XkbBoundsPtr		bounds;
273} XkbOverlayRec,*XkbOverlayPtr;
274
275typedef struct _XkbGeometry {
276	Atom		 name;
277	unsigned short	 width_mm;
278	unsigned short	 height_mm;
279	char *		 label_font;
280	XkbColorPtr	 label_color;
281	XkbColorPtr	 base_color;
282	unsigned short	 sz_properties;
283	unsigned short	 sz_colors;
284	unsigned short	 sz_shapes;
285	unsigned short   sz_sections;
286	unsigned short	 sz_doodads;
287	unsigned short	 sz_key_aliases;
288	unsigned short	 num_properties;
289	unsigned short	 num_colors;
290	unsigned short	 num_shapes;
291	unsigned short	 num_sections;
292	unsigned short	 num_doodads;
293	unsigned short	 num_key_aliases;
294	XkbPropertyPtr	 properties;
295	XkbColorPtr	 colors;
296	XkbShapePtr	 shapes;
297	XkbSectionPtr	 sections;
298	XkbDoodadPtr	 doodads;
299	XkbKeyAliasPtr	 key_aliases;
300} XkbGeometryRec;
301#define	XkbGeomColorIndex(g,c)	((int)((c)-&(g)->colors[0]))
302
303#define	XkbGeomPropertiesMask	(1<<0)
304#define	XkbGeomColorsMask	(1<<1)
305#define	XkbGeomShapesMask	(1<<2)
306#define	XkbGeomSectionsMask	(1<<3)
307#define	XkbGeomDoodadsMask	(1<<4)
308#define	XkbGeomKeyAliasesMask	(1<<5)
309#define	XkbGeomAllMask		(0x3f)
310
311typedef struct _XkbGeometrySizes {
312	unsigned int	which;
313	unsigned short	num_properties;
314	unsigned short	num_colors;
315	unsigned short	num_shapes;
316	unsigned short	num_sections;
317	unsigned short	num_doodads;
318	unsigned short	num_key_aliases;
319} XkbGeometrySizesRec,*XkbGeometrySizesPtr;
320
321_XFUNCPROTOBEGIN
322
323extern	XkbPropertyPtr
324XkbAddGeomProperty(
325    XkbGeometryPtr	/* geom */,
326    char *		/* name */,
327    char *		/* value */
328);
329
330extern	XkbKeyAliasPtr
331XkbAddGeomKeyAlias(
332    XkbGeometryPtr	/* geom */,
333    char *		/* alias */,
334    char *		/* real */
335);
336
337extern	XkbColorPtr
338XkbAddGeomColor(
339    XkbGeometryPtr	/* geom */,
340    char *		/* spec */,
341    unsigned int	/* pixel */
342);
343
344extern	XkbOutlinePtr
345XkbAddGeomOutline(
346    XkbShapePtr		/* shape */,
347    int			/* sz_points */
348);
349
350extern XkbShapePtr
351XkbAddGeomShape(
352    XkbGeometryPtr	/* geom */,
353    Atom		/* name */,
354    int			/* sz_outlines */
355);
356
357extern XkbKeyPtr
358XkbAddGeomKey(
359    XkbRowPtr		/* row */
360);
361
362extern XkbRowPtr
363XkbAddGeomRow(
364    XkbSectionPtr	/* section */,
365    int			/* sz_keys */
366);
367
368extern XkbSectionPtr
369XkbAddGeomSection(
370    XkbGeometryPtr	/* geom */,
371    Atom		/* name */,
372    int			/* sz_rows */,
373    int			/* sz_doodads */,
374    int			/* sz_overlays */
375);
376
377extern XkbOverlayPtr
378XkbAddGeomOverlay(
379    XkbSectionPtr	/* section */,
380    Atom		/* name */,
381    int			/* sz_rows */
382);
383
384extern XkbOverlayRowPtr
385XkbAddGeomOverlayRow(
386    XkbOverlayPtr	/* overlay */,
387    int			/* row_under */,
388    int			/* sz_keys */
389);
390
391extern XkbOverlayKeyPtr
392XkbAddGeomOverlayKey(
393    XkbOverlayPtr	/* overlay */,
394    XkbOverlayRowPtr	/* row */,
395    char *		/* over */,
396    char *		/* under */
397);
398
399extern XkbDoodadPtr
400XkbAddGeomDoodad(
401    XkbGeometryPtr	/* geom */,
402    XkbSectionPtr	/* section */,
403    Atom		/* name */
404);
405
406
407extern void
408XkbFreeGeomKeyAliases(
409    XkbGeometryPtr	/* geom */,
410    int			/* first */,
411    int			/* count */,
412    Bool		/* freeAll */
413);
414
415extern void
416XkbFreeGeomColors(
417    XkbGeometryPtr	/* geom */,
418    int			/* first */,
419    int			/* count */,
420    Bool		/* freeAll */
421);
422
423extern void
424XkbFreeGeomDoodads(
425    XkbDoodadPtr	/* doodads */,
426    int			/* nDoodads */,
427    Bool		/* freeAll */
428);
429
430
431extern void
432XkbFreeGeomProperties(
433    XkbGeometryPtr	/* geom */,
434    int			/* first */,
435    int			/* count */,
436    Bool		/* freeAll */
437);
438
439extern void
440XkbFreeGeomOverlayKeys(
441    XkbOverlayRowPtr	/* row */,
442    int			/* first */,
443    int			/* count */,
444    Bool		/* freeAll */
445);
446
447extern void
448XkbFreeGeomOverlayRows(
449    XkbOverlayPtr	/* overlay */,
450    int			/* first */,
451    int			/* count */,
452    Bool		/* freeAll */
453);
454
455extern void
456XkbFreeGeomOverlays(
457    XkbSectionPtr	/* section */,
458    int			/* first */,
459    int			/* count */,
460    Bool		/* freeAll */
461);
462
463extern void
464XkbFreeGeomKeys(
465    XkbRowPtr		/* row */,
466    int			/* first */,
467    int			/* count */,
468    Bool		/* freeAll */
469);
470
471extern void
472XkbFreeGeomRows(
473    XkbSectionPtr	/* section */,
474    int			/* first */,
475    int			/* count */,
476    Bool		/* freeAll */
477);
478
479extern void
480XkbFreeGeomSections(
481    XkbGeometryPtr	/* geom */,
482    int			/* first */,
483    int			/* count */,
484    Bool		/* freeAll */
485);
486
487
488extern void
489XkbFreeGeomPoints(
490    XkbOutlinePtr	/* outline */,
491    int			/* first */,
492    int			/* count */,
493    Bool		/* freeAll */
494);
495
496extern void
497XkbFreeGeomOutlines(
498    XkbShapePtr		/* shape */,
499    int			/* first */,
500    int			/* count */,
501    Bool		/* freeAll */
502);
503
504extern void
505XkbFreeGeomShapes(
506    XkbGeometryPtr	/* geom */,
507    int			/* first */,
508    int			/* count */,
509    Bool		/* freeAll */
510);
511
512extern void
513XkbFreeGeometry(
514    XkbGeometryPtr	/* geom */,
515    unsigned int	/* which */,
516    Bool		/* freeMap */
517);
518
519extern Status
520XkbAllocGeomProps(
521    XkbGeometryPtr	/* geom */,
522    int			/* nProps */
523);
524
525extern Status
526XkbAllocGeomKeyAliases(
527    XkbGeometryPtr	/* geom */,
528    int			/* nAliases */
529);
530
531extern Status
532XkbAllocGeomColors(
533    XkbGeometryPtr	/* geom */,
534    int			/* nColors */
535);
536
537extern Status
538XkbAllocGeomShapes(
539    XkbGeometryPtr	/* geom */,
540    int			/* nShapes */
541);
542
543extern Status
544XkbAllocGeomSections(
545    XkbGeometryPtr	/* geom */,
546    int			/* nSections */
547);
548
549extern Status
550XkbAllocGeomOverlays(
551    XkbSectionPtr	/* section */,
552    int			/* num_needed */
553);
554
555extern Status
556XkbAllocGeomOverlayRows(
557    XkbOverlayPtr	/* overlay */,
558    int			/* num_needed */
559);
560
561extern Status
562XkbAllocGeomOverlayKeys(
563    XkbOverlayRowPtr	/* row */,
564    int			/* num_needed */
565);
566
567extern Status
568XkbAllocGeomDoodads(
569    XkbGeometryPtr	/* geom */,
570    int			/* nDoodads */
571);
572
573extern Status
574XkbAllocGeomSectionDoodads(
575    XkbSectionPtr	/* section */,
576    int			/* nDoodads */
577);
578
579extern Status
580XkbAllocGeomOutlines(
581    XkbShapePtr		/* shape */,
582    int			/* nOL */
583);
584
585extern Status
586XkbAllocGeomRows(
587    XkbSectionPtr	/* section */,
588    int			/* nRows */
589);
590
591extern Status
592XkbAllocGeomPoints(
593    XkbOutlinePtr	/* ol */,
594    int			/* nPts */
595);
596
597extern Status
598XkbAllocGeomKeys(
599    XkbRowPtr		/* row */,
600    int			/* nKeys */
601);
602
603extern	Status
604XkbAllocGeometry(
605	XkbDescPtr		/* xkb */,
606	XkbGeometrySizesPtr	/* sizes */
607);
608
609extern	Status
610XkbSetGeometry(
611	Display *		/* dpy */,
612	unsigned		/* deviceSpec */,
613	XkbGeometryPtr		/* geom */
614);
615
616extern	Bool
617XkbComputeShapeTop(
618	XkbShapePtr		/* shape */,
619	XkbBoundsPtr		/* bounds */
620);
621
622extern	Bool
623XkbComputeShapeBounds(
624	XkbShapePtr		/* shape */
625);
626
627extern	Bool
628XkbComputeRowBounds(
629	XkbGeometryPtr		/* geom */,
630	XkbSectionPtr		/* section */,
631	XkbRowPtr		/* row */
632);
633
634extern	Bool
635XkbComputeSectionBounds(
636	XkbGeometryPtr		/* geom */,
637	XkbSectionPtr		/* section */
638);
639
640extern	char *
641XkbFindOverlayForKey(
642	XkbGeometryPtr		/* geom */,
643	XkbSectionPtr		/* wanted */,
644	char *			/* under */
645);
646
647extern	Status
648XkbGetGeometry(
649    Display *			/* dpy */,
650    XkbDescPtr			/* xkb */
651);
652
653extern	Status
654XkbGetNamedGeometry(
655    Display *			/* dpy */,
656    XkbDescPtr			/* xkb */,
657    Atom			/* name */
658);
659
660_XFUNCPROTOEND
661
662#endif /* _XKBSTR_H_ */
663