xkbgeom.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564
  1. /************************************************************
  2. Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
  3. Permission to use, copy, modify, and distribute this
  4. software and its documentation for any purpose and without
  5. fee is hereby granted, provided that the above copyright
  6. notice appear in all copies and that both that copyright
  7. notice and this permission notice appear in supporting
  8. documentation, and that the name of Silicon Graphics not be
  9. used in advertising or publicity pertaining to distribution
  10. of the software without specific prior written permission.
  11. Silicon Graphics makes no representation about the suitability
  12. of this software for any purpose. It is provided "as is"
  13. without any express or implied warranty.
  14. SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
  15. SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  16. AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
  17. GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
  18. DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  19. DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  20. OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
  21. THE USE OR PERFORMANCE OF THIS SOFTWARE.
  22. ********************************************************/
  23. #ifndef _XKBGEOM_H_
  24. #define _XKBGEOM_H_
  25. #include "xkbstr.h"
  26. #define XkbAddGeomKeyAlias SrvXkbAddGeomKeyAlias
  27. #define XkbAddGeomColor SrvXkbAddGeomColor
  28. #define XkbAddGeomDoodad SrvXkbAddGeomDoodad
  29. #define XkbAddGeomKey SrvXkbAddGeomKey
  30. #define XkbAddGeomOutline SrvXkbAddGeomOutline
  31. #define XkbAddGeomOverlay SrvXkbAddGeomOverlay
  32. #define XkbAddGeomOverlayRow SrvXkbAddGeomOverlayRow
  33. #define XkbAddGeomOverlayKey SrvXkbAddGeomOverlayKey
  34. #define XkbAddGeomProperty SrvXkbAddGeomProperty
  35. #define XkbAddGeomRow SrvXkbAddGeomRow
  36. #define XkbAddGeomSection SrvXkbAddGeomSection
  37. #define XkbAddGeomShape SrvXkbAddGeomShape
  38. #define XkbAllocGeometry SrvXkbAllocGeometry
  39. #define XkbFreeGeomKeyAliases SrvXkbFreeGeomKeyAliases
  40. #define XkbFreeGeomColors SrvXkbFreeGeomColors
  41. #define XkbFreeGeomDoodads SrvXkbFreeGeomDoodads
  42. #define XkbFreeGeomProperties SrvXkbFreeGeomProperties
  43. #define XkbFreeGeomKeys SrvXkbFreeGeomKeys
  44. #define XkbFreeGeomRows SrvXkbFreeGeomRows
  45. #define XkbFreeGeomSections SrvXkbFreeGeomSections
  46. #define XkbFreeGeomPoints SrvXkbFreeGeomPoints
  47. #define XkbFreeGeomOutlines SrvXkbFreeGeomOutlines
  48. #define XkbFreeGeomShapes SrvXkbFreeGeomShapes
  49. #define XkbFreeGeometry SrvXkbFreeGeometry
  50. typedef struct _XkbProperty {
  51. char *name;
  52. char *value;
  53. } XkbPropertyRec, *XkbPropertyPtr;
  54. typedef struct _XkbColor {
  55. unsigned int pixel;
  56. char *spec;
  57. } XkbColorRec, *XkbColorPtr;
  58. typedef struct _XkbPoint {
  59. short x;
  60. short y;
  61. } XkbPointRec, *XkbPointPtr;
  62. typedef struct _XkbBounds {
  63. short x1, y1;
  64. short x2, y2;
  65. } XkbBoundsRec, *XkbBoundsPtr;
  66. #define XkbBoundsWidth(b) (((b)->x2)-((b)->x1))
  67. #define XkbBoundsHeight(b) (((b)->y2)-((b)->y1))
  68. typedef struct _XkbOutline {
  69. unsigned short num_points;
  70. unsigned short sz_points;
  71. unsigned short corner_radius;
  72. XkbPointPtr points;
  73. } XkbOutlineRec, *XkbOutlinePtr;
  74. typedef struct _XkbShape {
  75. Atom name;
  76. unsigned short num_outlines;
  77. unsigned short sz_outlines;
  78. XkbOutlinePtr outlines;
  79. XkbOutlinePtr approx;
  80. XkbOutlinePtr primary;
  81. XkbBoundsRec bounds;
  82. } XkbShapeRec, *XkbShapePtr;
  83. #define XkbOutlineIndex(s,o) ((int)((o)-&(s)->outlines[0]))
  84. typedef struct _XkbShapeDoodad {
  85. Atom name;
  86. unsigned char type;
  87. unsigned char priority;
  88. short top;
  89. short left;
  90. short angle;
  91. unsigned short color_ndx;
  92. unsigned short shape_ndx;
  93. } XkbShapeDoodadRec, *XkbShapeDoodadPtr;
  94. #define XkbShapeDoodadColor(g,d) (&(g)->colors[(d)->color_ndx])
  95. #define XkbShapeDoodadShape(g,d) (&(g)->shapes[(d)->shape_ndx])
  96. #define XkbSetShapeDoodadColor(g,d,c) ((d)->color_ndx= (c)-&(g)->colors[0])
  97. #define XkbSetShapeDoodadShape(g,d,s) ((d)->shape_ndx= (s)-&(g)->shapes[0])
  98. typedef struct _XkbTextDoodad {
  99. Atom name;
  100. unsigned char type;
  101. unsigned char priority;
  102. short top;
  103. short left;
  104. short angle;
  105. short width;
  106. short height;
  107. unsigned short color_ndx;
  108. char *text;
  109. char *font;
  110. } XkbTextDoodadRec, *XkbTextDoodadPtr;
  111. #define XkbTextDoodadColor(g,d) (&(g)->colors[(d)->color_ndx])
  112. #define XkbSetTextDoodadColor(g,d,c) ((d)->color_ndx= (c)-&(g)->colors[0])
  113. typedef struct _XkbIndicatorDoodad {
  114. Atom name;
  115. unsigned char type;
  116. unsigned char priority;
  117. short top;
  118. short left;
  119. short angle;
  120. unsigned short shape_ndx;
  121. unsigned short on_color_ndx;
  122. unsigned short off_color_ndx;
  123. } XkbIndicatorDoodadRec, *XkbIndicatorDoodadPtr;
  124. #define XkbIndicatorDoodadShape(g,d) (&(g)->shapes[(d)->shape_ndx])
  125. #define XkbIndicatorDoodadOnColor(g,d) (&(g)->colors[(d)->on_color_ndx])
  126. #define XkbIndicatorDoodadOffColor(g,d) (&(g)->colors[(d)->off_color_ndx])
  127. #define XkbSetIndicatorDoodadOnColor(g,d,c) \
  128. ((d)->on_color_ndx= (c)-&(g)->colors[0])
  129. #define XkbSetIndicatorDoodadOffColor(g,d,c) \
  130. ((d)->off_color_ndx= (c)-&(g)->colors[0])
  131. #define XkbSetIndicatorDoodadShape(g,d,s) \
  132. ((d)->shape_ndx= (s)-&(g)->shapes[0])
  133. typedef struct _XkbLogoDoodad {
  134. Atom name;
  135. unsigned char type;
  136. unsigned char priority;
  137. short top;
  138. short left;
  139. short angle;
  140. unsigned short color_ndx;
  141. unsigned short shape_ndx;
  142. char *logo_name;
  143. } XkbLogoDoodadRec, *XkbLogoDoodadPtr;
  144. #define XkbLogoDoodadColor(g,d) (&(g)->colors[(d)->color_ndx])
  145. #define XkbLogoDoodadShape(g,d) (&(g)->shapes[(d)->shape_ndx])
  146. #define XkbSetLogoDoodadColor(g,d,c) ((d)->color_ndx= (c)-&(g)->colors[0])
  147. #define XkbSetLogoDoodadShape(g,d,s) ((d)->shape_ndx= (s)-&(g)->shapes[0])
  148. typedef struct _XkbAnyDoodad {
  149. Atom name;
  150. unsigned char type;
  151. unsigned char priority;
  152. short top;
  153. short left;
  154. short angle;
  155. } XkbAnyDoodadRec, *XkbAnyDoodadPtr;
  156. typedef union _XkbDoodad {
  157. XkbAnyDoodadRec any;
  158. XkbShapeDoodadRec shape;
  159. XkbTextDoodadRec text;
  160. XkbIndicatorDoodadRec indicator;
  161. XkbLogoDoodadRec logo;
  162. } XkbDoodadRec, *XkbDoodadPtr;
  163. #define XkbUnknownDoodad 0
  164. #define XkbOutlineDoodad 1
  165. #define XkbSolidDoodad 2
  166. #define XkbTextDoodad 3
  167. #define XkbIndicatorDoodad 4
  168. #define XkbLogoDoodad 5
  169. typedef 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. typedef struct _XkbRow {
  180. short top;
  181. short left;
  182. unsigned short num_keys;
  183. unsigned short sz_keys;
  184. int vertical;
  185. XkbKeyPtr keys;
  186. XkbBoundsRec bounds;
  187. } XkbRowRec, *XkbRowPtr;
  188. typedef struct _XkbSection {
  189. Atom name;
  190. unsigned char priority;
  191. short top;
  192. short left;
  193. unsigned short width;
  194. unsigned short height;
  195. short angle;
  196. unsigned short num_rows;
  197. unsigned short num_doodads;
  198. unsigned short num_overlays;
  199. unsigned short sz_rows;
  200. unsigned short sz_doodads;
  201. unsigned short sz_overlays;
  202. XkbRowPtr rows;
  203. XkbDoodadPtr doodads;
  204. XkbBoundsRec bounds;
  205. struct _XkbOverlay *overlays;
  206. } XkbSectionRec, *XkbSectionPtr;
  207. typedef struct _XkbOverlayKey {
  208. XkbKeyNameRec over;
  209. XkbKeyNameRec under;
  210. } XkbOverlayKeyRec, *XkbOverlayKeyPtr;
  211. typedef struct _XkbOverlayRow {
  212. unsigned short row_under;
  213. unsigned short num_keys;
  214. unsigned short sz_keys;
  215. XkbOverlayKeyPtr keys;
  216. } XkbOverlayRowRec, *XkbOverlayRowPtr;
  217. typedef struct _XkbOverlay {
  218. Atom name;
  219. XkbSectionPtr section_under;
  220. unsigned short num_rows;
  221. unsigned short sz_rows;
  222. XkbOverlayRowPtr rows;
  223. XkbBoundsPtr bounds;
  224. } XkbOverlayRec, *XkbOverlayPtr;
  225. typedef struct _XkbGeometry {
  226. Atom name;
  227. unsigned short width_mm;
  228. unsigned short height_mm;
  229. char *label_font;
  230. XkbColorPtr label_color;
  231. XkbColorPtr base_color;
  232. unsigned short sz_properties;
  233. unsigned short sz_colors;
  234. unsigned short sz_shapes;
  235. unsigned short sz_sections;
  236. unsigned short sz_doodads;
  237. unsigned short sz_key_aliases;
  238. unsigned short num_properties;
  239. unsigned short num_colors;
  240. unsigned short num_shapes;
  241. unsigned short num_sections;
  242. unsigned short num_doodads;
  243. unsigned short num_key_aliases;
  244. XkbPropertyPtr properties;
  245. XkbColorPtr colors;
  246. XkbShapePtr shapes;
  247. XkbSectionPtr sections;
  248. XkbDoodadPtr doodads;
  249. XkbKeyAliasPtr key_aliases;
  250. } XkbGeometryRec;
  251. #define XkbGeomColorIndex(g,c) ((int)((c)-&(g)->colors[0]))
  252. #define XkbGeomPropertiesMask (1<<0)
  253. #define XkbGeomColorsMask (1<<1)
  254. #define XkbGeomShapesMask (1<<2)
  255. #define XkbGeomSectionsMask (1<<3)
  256. #define XkbGeomDoodadsMask (1<<4)
  257. #define XkbGeomKeyAliasesMask (1<<5)
  258. #define XkbGeomAllMask (0x3f)
  259. typedef struct _XkbGeometrySizes {
  260. unsigned int which;
  261. unsigned short num_properties;
  262. unsigned short num_colors;
  263. unsigned short num_shapes;
  264. unsigned short num_sections;
  265. unsigned short num_doodads;
  266. unsigned short num_key_aliases;
  267. } XkbGeometrySizesRec, *XkbGeometrySizesPtr;
  268. /**
  269. * Specifies which items should be cleared in an XKB geometry array
  270. * when the array is reallocated.
  271. */
  272. typedef enum {
  273. XKB_GEOM_CLEAR_NONE, /* Don't clear any items, just reallocate. */
  274. XKB_GEOM_CLEAR_EXCESS, /* Clear new extra items after reallocation. */
  275. XKB_GEOM_CLEAR_ALL /* Clear all items after reallocation. */
  276. } XkbGeomClearance;
  277. extern XkbPropertyPtr XkbAddGeomProperty(XkbGeometryPtr /* geom */ ,
  278. char * /* name */ ,
  279. char * /* value */
  280. );
  281. extern XkbKeyAliasPtr XkbAddGeomKeyAlias(XkbGeometryPtr /* geom */ ,
  282. char * /* alias */ ,
  283. char * /* real */
  284. );
  285. extern XkbColorPtr XkbAddGeomColor(XkbGeometryPtr /* geom */ ,
  286. char * /* spec */ ,
  287. unsigned int /* pixel */
  288. );
  289. extern XkbOutlinePtr XkbAddGeomOutline(XkbShapePtr /* shape */ ,
  290. int /* sz_points */
  291. );
  292. extern XkbShapePtr XkbAddGeomShape(XkbGeometryPtr /* geom */ ,
  293. Atom /* name */ ,
  294. int /* sz_outlines */
  295. );
  296. extern XkbKeyPtr XkbAddGeomKey(XkbRowPtr /* row */
  297. );
  298. extern XkbRowPtr XkbAddGeomRow(XkbSectionPtr /* section */ ,
  299. int /* sz_keys */
  300. );
  301. extern XkbSectionPtr XkbAddGeomSection(XkbGeometryPtr /* geom */ ,
  302. Atom /* name */ ,
  303. int /* sz_rows */ ,
  304. int /* sz_doodads */ ,
  305. int /* sz_overlays */
  306. );
  307. extern XkbOverlayPtr XkbAddGeomOverlay(XkbSectionPtr /* section */ ,
  308. Atom /* name */ ,
  309. int /* sz_rows */
  310. );
  311. extern XkbOverlayRowPtr XkbAddGeomOverlayRow(XkbOverlayPtr /* overlay */ ,
  312. int /* row_under */ ,
  313. int /* sz_keys */
  314. );
  315. extern XkbOverlayKeyPtr XkbAddGeomOverlayKey(XkbOverlayPtr /* overlay */ ,
  316. XkbOverlayRowPtr /* row */ ,
  317. char * /* over */ ,
  318. char * /* under */
  319. );
  320. extern XkbDoodadPtr XkbAddGeomDoodad(XkbGeometryPtr /* geom */ ,
  321. XkbSectionPtr /* section */ ,
  322. Atom /* name */
  323. );
  324. extern void
  325. XkbFreeGeomKeyAliases(XkbGeometryPtr /* geom */ ,
  326. int /* first */ ,
  327. int /* count */ ,
  328. Bool /* freeAll */
  329. );
  330. extern void
  331. XkbFreeGeomColors(XkbGeometryPtr /* geom */ ,
  332. int /* first */ ,
  333. int /* count */ ,
  334. Bool /* freeAll */
  335. );
  336. extern void
  337. XkbFreeGeomDoodads(XkbDoodadPtr /* doodads */ ,
  338. int /* nDoodads */ ,
  339. Bool /* freeAll */
  340. );
  341. extern void
  342. XkbFreeGeomProperties(XkbGeometryPtr /* geom */ ,
  343. int /* first */ ,
  344. int /* count */ ,
  345. Bool /* freeAll */
  346. );
  347. extern void
  348. XkbFreeGeomOverlayKeys(XkbOverlayRowPtr /* row */ ,
  349. int /* first */ ,
  350. int /* count */ ,
  351. Bool /* freeAll */
  352. );
  353. extern void
  354. XkbFreeGeomOverlayRows(XkbOverlayPtr /* overlay */ ,
  355. int /* first */ ,
  356. int /* count */ ,
  357. Bool /* freeAll */
  358. );
  359. extern void
  360. XkbFreeGeomOverlays(XkbSectionPtr /* section */ ,
  361. int /* first */ ,
  362. int /* count */ ,
  363. Bool /* freeAll */
  364. );
  365. extern void
  366. XkbFreeGeomKeys(XkbRowPtr /* row */ ,
  367. int /* first */ ,
  368. int /* count */ ,
  369. Bool /* freeAll */
  370. );
  371. extern void
  372. XkbFreeGeomRows(XkbSectionPtr /* section */ ,
  373. int /* first */ ,
  374. int /* count */ ,
  375. Bool /* freeAll */
  376. );
  377. extern void
  378. XkbFreeGeomSections(XkbGeometryPtr /* geom */ ,
  379. int /* first */ ,
  380. int /* count */ ,
  381. Bool /* freeAll */
  382. );
  383. extern void
  384. XkbFreeGeomPoints(XkbOutlinePtr /* outline */ ,
  385. int /* first */ ,
  386. int /* count */ ,
  387. Bool /* freeAll */
  388. );
  389. extern void
  390. XkbFreeGeomOutlines(XkbShapePtr /* shape */ ,
  391. int /* first */ ,
  392. int /* count */ ,
  393. Bool /* freeAll */
  394. );
  395. extern void
  396. XkbFreeGeomShapes(XkbGeometryPtr /* geom */ ,
  397. int /* first */ ,
  398. int /* count */ ,
  399. Bool /* freeAll */
  400. );
  401. extern void
  402. XkbFreeGeometry(XkbGeometryPtr /* geom */ ,
  403. unsigned int /* which */ ,
  404. Bool /* freeMap */
  405. );
  406. extern Bool
  407. XkbGeomRealloc(void ** /* buffer */ ,
  408. int /* szItems */ ,
  409. int /* nrItems */ ,
  410. int /* itemSize */ ,
  411. XkbGeomClearance /* clearance */
  412. );
  413. extern Status XkbAllocGeomProps(XkbGeometryPtr /* geom */ ,
  414. int /* nProps */
  415. );
  416. extern Status XkbAllocGeomKeyAliases(XkbGeometryPtr /* geom */ ,
  417. int /* nAliases */
  418. );
  419. extern Status XkbAllocGeomColors(XkbGeometryPtr /* geom */ ,
  420. int /* nColors */
  421. );
  422. extern Status XkbAllocGeomShapes(XkbGeometryPtr /* geom */ ,
  423. int /* nShapes */
  424. );
  425. extern Status XkbAllocGeomSections(XkbGeometryPtr /* geom */ ,
  426. int /* nSections */
  427. );
  428. extern Status XkbAllocGeomOverlays(XkbSectionPtr /* section */ ,
  429. int /* num_needed */
  430. );
  431. extern Status XkbAllocGeomOverlayRows(XkbOverlayPtr /* overlay */ ,
  432. int /* num_needed */
  433. );
  434. extern Status XkbAllocGeomOverlayKeys(XkbOverlayRowPtr /* row */ ,
  435. int /* num_needed */
  436. );
  437. extern Status XkbAllocGeomDoodads(XkbGeometryPtr /* geom */ ,
  438. int /* nDoodads */
  439. );
  440. extern Status XkbAllocGeomSectionDoodads(XkbSectionPtr /* section */ ,
  441. int /* nDoodads */
  442. );
  443. extern Status XkbAllocGeomOutlines(XkbShapePtr /* shape */ ,
  444. int /* nOL */
  445. );
  446. extern Status XkbAllocGeomRows(XkbSectionPtr /* section */ ,
  447. int /* nRows */
  448. );
  449. extern Status XkbAllocGeomPoints(XkbOutlinePtr /* ol */ ,
  450. int /* nPts */
  451. );
  452. extern Status XkbAllocGeomKeys(XkbRowPtr /* row */ ,
  453. int /* nKeys */
  454. );
  455. extern Status XkbAllocGeometry(XkbDescPtr /* xkb */ ,
  456. XkbGeometrySizesPtr /* sizes */
  457. );
  458. extern Bool
  459. XkbComputeShapeTop(XkbShapePtr /* shape */ ,
  460. XkbBoundsPtr /* bounds */
  461. );
  462. extern Bool
  463. XkbComputeShapeBounds(XkbShapePtr /* shape */
  464. );
  465. extern Bool
  466. XkbComputeRowBounds(XkbGeometryPtr /* geom */ ,
  467. XkbSectionPtr /* section */ ,
  468. XkbRowPtr /* row */
  469. );
  470. extern Bool
  471. XkbComputeSectionBounds(XkbGeometryPtr /* geom */ ,
  472. XkbSectionPtr /* section */
  473. );
  474. extern char *XkbFindOverlayForKey(XkbGeometryPtr /* geom */ ,
  475. XkbSectionPtr /* wanted */ ,
  476. char * /* under */
  477. );
  478. #endif /* _XKBGEOM_H_ */