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