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