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 <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 76 typedef struct _XkbProperty { 77 char *name; 78 char *value; 79 } XkbPropertyRec,*XkbPropertyPtr; 80 81 typedef struct _XkbColor { 82 unsigned int pixel; 83 char * spec; 84 } XkbColorRec,*XkbColorPtr; 85 86 typedef struct _XkbPoint { 87 short x; 88 short y; 89 } XkbPointRec, *XkbPointPtr; 90 91 typedef 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 103 typedef struct _XkbOutline { 104 unsigned short num_points; 105 unsigned short sz_points; 106 unsigned short corner_radius; 107 XkbPointPtr points; 108 } XkbOutlineRec, *XkbOutlinePtr; 109 110 typedef 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 121 typedef 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 136 typedef 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 152 typedef 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 173 typedef 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 189 typedef 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 198 typedef 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 213 typedef 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 224 typedef 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 234 typedef 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 254 typedef struct _XkbOverlayKey { 255 XkbKeyNameRec over; 256 XkbKeyNameRec under; 257 } XkbOverlayKeyRec,*XkbOverlayKeyPtr; 258 259 typedef struct _XkbOverlayRow { 260 unsigned short row_under; 261 unsigned short num_keys; 262 unsigned short sz_keys; 263 XkbOverlayKeyPtr keys; 264 } XkbOverlayRowRec,*XkbOverlayRowPtr; 265 266 typedef 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 275 typedef 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 311 typedef 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 323 extern XkbPropertyPtr 324 XkbAddGeomProperty( 325 XkbGeometryPtr /* geom */, 326 char * /* name */, 327 char * /* value */ 328 ); 329 330 extern XkbKeyAliasPtr 331 XkbAddGeomKeyAlias( 332 XkbGeometryPtr /* geom */, 333 char * /* alias */, 334 char * /* real */ 335 ); 336 337 extern XkbColorPtr 338 XkbAddGeomColor( 339 XkbGeometryPtr /* geom */, 340 char * /* spec */, 341 unsigned int /* pixel */ 342 ); 343 344 extern XkbOutlinePtr 345 XkbAddGeomOutline( 346 XkbShapePtr /* shape */, 347 int /* sz_points */ 348 ); 349 350 extern XkbShapePtr 351 XkbAddGeomShape( 352 XkbGeometryPtr /* geom */, 353 Atom /* name */, 354 int /* sz_outlines */ 355 ); 356 357 extern XkbKeyPtr 358 XkbAddGeomKey( 359 XkbRowPtr /* row */ 360 ); 361 362 extern XkbRowPtr 363 XkbAddGeomRow( 364 XkbSectionPtr /* section */, 365 int /* sz_keys */ 366 ); 367 368 extern XkbSectionPtr 369 XkbAddGeomSection( 370 XkbGeometryPtr /* geom */, 371 Atom /* name */, 372 int /* sz_rows */, 373 int /* sz_doodads */, 374 int /* sz_overlays */ 375 ); 376 377 extern XkbOverlayPtr 378 XkbAddGeomOverlay( 379 XkbSectionPtr /* section */, 380 Atom /* name */, 381 int /* sz_rows */ 382 ); 383 384 extern XkbOverlayRowPtr 385 XkbAddGeomOverlayRow( 386 XkbOverlayPtr /* overlay */, 387 int /* row_under */, 388 int /* sz_keys */ 389 ); 390 391 extern XkbOverlayKeyPtr 392 XkbAddGeomOverlayKey( 393 XkbOverlayPtr /* overlay */, 394 XkbOverlayRowPtr /* row */, 395 char * /* over */, 396 char * /* under */ 397 ); 398 399 extern XkbDoodadPtr 400 XkbAddGeomDoodad( 401 XkbGeometryPtr /* geom */, 402 XkbSectionPtr /* section */, 403 Atom /* name */ 404 ); 405 406 407 extern void 408 XkbFreeGeomKeyAliases( 409 XkbGeometryPtr /* geom */, 410 int /* first */, 411 int /* count */, 412 Bool /* freeAll */ 413 ); 414 415 extern void 416 XkbFreeGeomColors( 417 XkbGeometryPtr /* geom */, 418 int /* first */, 419 int /* count */, 420 Bool /* freeAll */ 421 ); 422 423 extern void 424 XkbFreeGeomDoodads( 425 XkbDoodadPtr /* doodads */, 426 int /* nDoodads */, 427 Bool /* freeAll */ 428 ); 429 430 431 extern void 432 XkbFreeGeomProperties( 433 XkbGeometryPtr /* geom */, 434 int /* first */, 435 int /* count */, 436 Bool /* freeAll */ 437 ); 438 439 extern void 440 XkbFreeGeomOverlayKeys( 441 XkbOverlayRowPtr /* row */, 442 int /* first */, 443 int /* count */, 444 Bool /* freeAll */ 445 ); 446 447 extern void 448 XkbFreeGeomOverlayRows( 449 XkbOverlayPtr /* overlay */, 450 int /* first */, 451 int /* count */, 452 Bool /* freeAll */ 453 ); 454 455 extern void 456 XkbFreeGeomOverlays( 457 XkbSectionPtr /* section */, 458 int /* first */, 459 int /* count */, 460 Bool /* freeAll */ 461 ); 462 463 extern void 464 XkbFreeGeomKeys( 465 XkbRowPtr /* row */, 466 int /* first */, 467 int /* count */, 468 Bool /* freeAll */ 469 ); 470 471 extern void 472 XkbFreeGeomRows( 473 XkbSectionPtr /* section */, 474 int /* first */, 475 int /* count */, 476 Bool /* freeAll */ 477 ); 478 479 extern void 480 XkbFreeGeomSections( 481 XkbGeometryPtr /* geom */, 482 int /* first */, 483 int /* count */, 484 Bool /* freeAll */ 485 ); 486 487 488 extern void 489 XkbFreeGeomPoints( 490 XkbOutlinePtr /* outline */, 491 int /* first */, 492 int /* count */, 493 Bool /* freeAll */ 494 ); 495 496 extern void 497 XkbFreeGeomOutlines( 498 XkbShapePtr /* shape */, 499 int /* first */, 500 int /* count */, 501 Bool /* freeAll */ 502 ); 503 504 extern void 505 XkbFreeGeomShapes( 506 XkbGeometryPtr /* geom */, 507 int /* first */, 508 int /* count */, 509 Bool /* freeAll */ 510 ); 511 512 extern void 513 XkbFreeGeometry( 514 XkbGeometryPtr /* geom */, 515 unsigned int /* which */, 516 Bool /* freeMap */ 517 ); 518 519 extern Status 520 XkbAllocGeomProps( 521 XkbGeometryPtr /* geom */, 522 int /* nProps */ 523 ); 524 525 extern Status 526 XkbAllocGeomKeyAliases( 527 XkbGeometryPtr /* geom */, 528 int /* nAliases */ 529 ); 530 531 extern Status 532 XkbAllocGeomColors( 533 XkbGeometryPtr /* geom */, 534 int /* nColors */ 535 ); 536 537 extern Status 538 XkbAllocGeomShapes( 539 XkbGeometryPtr /* geom */, 540 int /* nShapes */ 541 ); 542 543 extern Status 544 XkbAllocGeomSections( 545 XkbGeometryPtr /* geom */, 546 int /* nSections */ 547 ); 548 549 extern Status 550 XkbAllocGeomOverlays( 551 XkbSectionPtr /* section */, 552 int /* num_needed */ 553 ); 554 555 extern Status 556 XkbAllocGeomOverlayRows( 557 XkbOverlayPtr /* overlay */, 558 int /* num_needed */ 559 ); 560 561 extern Status 562 XkbAllocGeomOverlayKeys( 563 XkbOverlayRowPtr /* row */, 564 int /* num_needed */ 565 ); 566 567 extern Status 568 XkbAllocGeomDoodads( 569 XkbGeometryPtr /* geom */, 570 int /* nDoodads */ 571 ); 572 573 extern Status 574 XkbAllocGeomSectionDoodads( 575 XkbSectionPtr /* section */, 576 int /* nDoodads */ 577 ); 578 579 extern Status 580 XkbAllocGeomOutlines( 581 XkbShapePtr /* shape */, 582 int /* nOL */ 583 ); 584 585 extern Status 586 XkbAllocGeomRows( 587 XkbSectionPtr /* section */, 588 int /* nRows */ 589 ); 590 591 extern Status 592 XkbAllocGeomPoints( 593 XkbOutlinePtr /* ol */, 594 int /* nPts */ 595 ); 596 597 extern Status 598 XkbAllocGeomKeys( 599 XkbRowPtr /* row */, 600 int /* nKeys */ 601 ); 602 603 extern Status 604 XkbAllocGeometry( 605 XkbDescPtr /* xkb */, 606 XkbGeometrySizesPtr /* sizes */ 607 ); 608 609 extern Status 610 XkbSetGeometry( 611 Display * /* dpy */, 612 unsigned /* deviceSpec */, 613 XkbGeometryPtr /* geom */ 614 ); 615 616 extern Bool 617 XkbComputeShapeTop( 618 XkbShapePtr /* shape */, 619 XkbBoundsPtr /* bounds */ 620 ); 621 622 extern Bool 623 XkbComputeShapeBounds( 624 XkbShapePtr /* shape */ 625 ); 626 627 extern Bool 628 XkbComputeRowBounds( 629 XkbGeometryPtr /* geom */, 630 XkbSectionPtr /* section */, 631 XkbRowPtr /* row */ 632 ); 633 634 extern Bool 635 XkbComputeSectionBounds( 636 XkbGeometryPtr /* geom */, 637 XkbSectionPtr /* section */ 638 ); 639 640 extern char * 641 XkbFindOverlayForKey( 642 XkbGeometryPtr /* geom */, 643 XkbSectionPtr /* wanted */, 644 char * /* under */ 645 ); 646 647 extern Status 648 XkbGetGeometry( 649 Display * /* dpy */, 650 XkbDescPtr /* xkb */ 651 ); 652 653 extern Status 654 XkbGetNamedGeometry( 655 Display * /* dpy */, 656 XkbDescPtr /* xkb */, 657 Atom /* name */ 658 ); 659 660 _XFUNCPROTOEND 661 662 #endif /* _XKBSTR_H_ */ 663