Copy xkbfile IsUpper/IsLower macros
[platform/upstream/libxkbcommon.git] / include / X11 / extensions / XKBcommon.h
1 /*
2 Copyright 1985, 1987, 1990, 1998  The Open Group
3 Copyright 2008  Dan Nicholson
4
5 Permission is hereby granted, free of charge, to any person obtaining a
6 copy of this software and associated documentation files (the "Software"),
7 to deal in the Software without restriction, including without limitation
8 the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 and/or sell copies of the Software, and to permit persons to whom the
10 Software is furnished to do so, subject to the following conditions:
11
12 The above copyright notice and this permission notice shall be included in
13 all copies or substantial portions of the Software.
14
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
22 Except as contained in this notice, the names of the authors or their
23 institutions shall not be used in advertising or otherwise to promote the
24 sale, use or other dealings in this Software without prior written
25 authorization from the authors.
26 */
27
28 #ifndef _XKBCOMMON_H_
29 #define _XKBCOMMON_H_
30
31 #include <X11/X.h>
32 #include <X11/Xdefs.h>
33 #include <X11/Xfuncproto.h>
34 #include <X11/keysym.h>
35 #include <X11/extensions/XKBstrcommon.h>
36 #include <X11/extensions/XKBgeomcommon.h>
37
38 /* Common keyboard description structure */
39 typedef struct _XkbcDesc {
40     unsigned int        defined;
41     unsigned short      flags;
42     unsigned short      device_spec;
43     KeyCode             min_key_code;
44     KeyCode             max_key_code;
45
46     XkbControlsPtr      ctrls;
47     XkbServerMapPtr     server;
48     XkbClientMapPtr     map;
49     XkbIndicatorPtr     indicators;
50     XkbNamesPtr         names;
51     XkbCompatMapPtr     compat;
52     XkbGeometryPtr      geom;
53 } XkbcDescRec, *XkbcDescPtr;
54
55 #define _XkbcKSLower (1 << 0)
56 #define _XkbcKSUpper (1 << 1)
57
58 #define XkbcKSIsLower(k) (_XkbcKSCheckCase(k) & _XkbcKSLower)
59 #define XkbcKSIsUpper(k) (_XkbcKSCheckCase(k) & _XkbcKSUpper)
60 #define XkbcKSIsKeypad(k) \
61     (((k) >= XK_KP_Space) && ((k) <= XK_KP_Equal))
62 #define XkbcKSIsDeadKey(k) \
63     (((k) >= XK_dead_grave) && ((k) <= XK_dead_semivoiced_sound))
64
65 _XFUNCPROTOBEGIN
66
67 extern char *
68 XkbcKeysymToString(KeySym ks);
69
70 extern KeySym
71 XkbcStringToKeysym(const char *s);
72
73 extern int
74 XkbcAllocCompatMap(XkbcDescPtr xkb, unsigned which, unsigned nSI);
75
76 extern void
77 XkbcFreeCompatMap(XkbcDescPtr xkb, unsigned which, Bool freeMap);
78
79 extern int
80 XkbcAllocNames(XkbcDescPtr xkb, unsigned which, int nTotalRG, int nTotalAliases);
81
82 extern void
83 XkbcFreeNames(XkbcDescPtr xkb, unsigned which, Bool freeMap);
84
85 extern int
86 XkbcAllocControls(XkbcDescPtr xkb, unsigned which);
87
88 extern void
89 XkbcFreeControls(XkbcDescPtr xkb, unsigned which, Bool freeMap);
90
91 extern int
92 XkbcAllocIndicatorMaps(XkbcDescPtr xkb);
93
94 extern void
95 XkbcFreeIndicatorMaps(XkbcDescPtr xkb);
96
97 extern XkbcDescRec *
98 XkbcAllocKeyboard(void);
99
100 extern void
101 XkbcFreeKeyboard(XkbcDescPtr xkb, unsigned which, Bool freeAll);
102
103 extern int
104 XkbcAllocClientMap(XkbcDescPtr xkb, unsigned which, unsigned nTotalTypes);
105
106 extern int
107 XkbcAllocServerMap(XkbcDescPtr xkb, unsigned which, unsigned nNewActions);
108
109 extern int
110 XkbcCopyKeyType(XkbKeyTypePtr from, XkbKeyTypePtr into);
111
112 extern int
113 XkbcCopyKeyTypes(XkbKeyTypePtr from, XkbKeyTypePtr into, int num_types);
114
115 extern void
116 XkbcFreeClientMap(XkbcDescPtr xkb, unsigned what, Bool freeMap);
117
118 extern void
119 XkbcFreeServerMap(XkbcDescPtr xkb, unsigned what, Bool freeMap);
120
121 extern void
122 XkbcFreeGeomProperties(XkbGeometryPtr geom, int first, int count, Bool freeAll);
123
124 extern void
125 XkbcFreeGeomKeyAliases(XkbGeometryPtr geom, int first, int count, Bool freeAll);
126
127 extern void
128 XkbcFreeGeomColors(XkbGeometryPtr geom, int first, int count, Bool freeAll);
129
130 extern void
131 XkbcFreeGeomPoints(XkbOutlinePtr outline, int first, int count, Bool freeAll);
132
133 extern void
134 XkbcFreeGeomOutlines(XkbShapePtr shape, int first, int count, Bool freeAll);
135
136 extern void
137 XkbcFreeGeomShapes(XkbGeometryPtr geom, int first, int count, Bool freeAll);
138
139 extern void
140 XkbcFreeGeomOverlayKeys(XkbOverlayRowPtr row, int first, int count,
141                         Bool freeAll);
142
143 extern void
144 XkbcFreeGeomOverlayRows(XkbOverlayPtr overlay, int first, int count,
145                         Bool freeAll);
146
147 extern void
148 XkbcFreeGeomOverlays(XkbSectionPtr section, int first, int count, Bool freeAll);
149
150 extern void
151 XkbcFreeGeomKeys(XkbRowPtr row, int first, int count, Bool freeAll);
152
153 extern void
154 XkbcFreeGeomRows(XkbSectionPtr section, int first, int count, Bool freeAll);
155
156 extern void
157 XkbcFreeGeomSections(XkbGeometryPtr geom, int first, int count, Bool freeAll);
158
159 extern void
160 XkbcFreeGeomDoodads(XkbDoodadPtr doodads, int nDoodads, Bool freeAll);
161
162 extern void
163 XkbcFreeGeometry(XkbGeometryPtr geom, unsigned which, Bool freeMap);
164
165 extern int
166 XkbcAllocGeomProps(XkbGeometryPtr geom, int nProps);
167
168 extern int
169 XkbcAllocGeomColors(XkbGeometryPtr geom, int nColors);
170
171 extern int
172 XkbcAllocGeomKeyAliases(XkbGeometryPtr geom, int nKeyAliases);
173
174 extern int
175 XkbcAllocGeomShapes(XkbGeometryPtr geom, int nShapes);
176
177 extern int
178 XkbcAllocGeomSections(XkbGeometryPtr geom, int nSections);
179
180 extern int
181 XkbcAllocGeomOverlays(XkbSectionPtr section, int nOverlays);
182
183 extern int
184 XkbcAllocGeomOverlayRows(XkbOverlayPtr overlay, int nRows);
185
186 extern int
187 XkbcAllocGeomOverlayKeys(XkbOverlayRowPtr row, int nKeys);
188
189 extern int
190 XkbcAllocGeomDoodads(XkbGeometryPtr geom, int nDoodads);
191
192 extern int
193 XkbcAllocGeomSectionDoodads(XkbSectionPtr section, int nDoodads);
194
195 extern int
196 XkbcAllocGeomOutlines(XkbShapePtr shape, int nOL);
197
198 extern int
199 XkbcAllocGeomRows(XkbSectionPtr section, int nRows);
200
201 extern int
202 XkbcAllocGeomPoints(XkbOutlinePtr ol, int nPts);
203
204 extern int
205 XkbcAllocGeomKeys(XkbRowPtr row, int nKeys);
206
207 extern int
208 XkbcAllocGeometry(XkbcDescPtr xkb, XkbGeometrySizesPtr sizes);
209
210 extern XkbPropertyPtr
211 XkbcAddGeomProperty(XkbGeometryPtr geom, char *name, char *value);
212
213 extern XkbKeyAliasPtr
214 XkbcAddGeomKeyAlias(XkbGeometryPtr geom, char *aliasStr, char *realStr);
215
216 extern XkbColorPtr
217 XkbcAddGeomColor(XkbGeometryPtr geom, char *spec, unsigned int pixel);
218
219 extern XkbOutlinePtr
220 XkbcAddGeomOutline(XkbShapePtr shape, int sz_points);
221
222 extern XkbShapePtr
223 XkbcAddGeomShape(XkbGeometryPtr geom, Atom name, int sz_outlines);
224
225 extern XkbKeyPtr
226 XkbcAddGeomKey(XkbRowPtr row);
227
228 extern XkbRowPtr
229 XkbcAddGeomRow(XkbSectionPtr section, int sz_keys);
230
231 extern XkbSectionPtr
232 XkbcAddGeomSection(XkbGeometryPtr geom, Atom name,
233                    int sz_rows, int sz_doodads, int sz_over);
234
235 extern XkbDoodadPtr
236 XkbcAddGeomDoodad(XkbGeometryPtr geom, XkbSectionPtr section, Atom name);
237
238 extern XkbOverlayKeyPtr
239 XkbcAddGeomOverlayKey(XkbOverlayPtr overlay, XkbOverlayRowPtr row,
240                       char *over, char *under);
241
242 extern XkbOverlayRowPtr
243 XkbcAddGeomOverlayRow(XkbOverlayPtr overlay, int row_under, int sz_keys);
244
245 extern XkbOverlayPtr
246 XkbcAddGeomOverlay(XkbSectionPtr section, Atom name, int sz_rows);
247
248 extern void
249 XkbcInitAtoms(void);
250
251 extern char *
252 XkbcAtomGetString(Atom atom);
253
254 extern Atom
255 XkbcInternAtom(char *name, Bool onlyIfExists);
256
257 extern char *
258 XkbcAtomText(Atom atm);
259
260 extern char *
261 XkbcVModIndexText(XkbcDescPtr xkb, unsigned ndx);
262
263 extern char *
264 XkbcVModMaskText(XkbcDescPtr xkb, unsigned modMask, unsigned mask);
265
266 extern char *
267 XkbcModIndexText(unsigned ndx);
268
269 extern char *
270 XkbcModMaskText(unsigned mask, Bool cFormat);
271
272 extern char *
273 XkbcConfigText(unsigned config);
274
275 extern char *
276 XkbcGeomFPText(int val);
277
278 extern char *
279 XkbcActionTypeText(unsigned type);
280
281 extern char *
282 XkbcKeysymText(KeySym sym);
283
284 extern char *
285 XkbcKeyNameText(char *name);
286
287 extern char *
288 XkbcSIMatchText(unsigned type);
289
290 extern Bool
291 XkbcComputeShapeBounds(XkbShapePtr shape);
292
293 extern Bool
294 XkbcComputeShapeTop(XkbShapePtr shape, XkbBoundsPtr bounds);
295
296 extern Bool
297 XkbcComputeRowBounds(XkbGeometryPtr geom, XkbSectionPtr section, XkbRowPtr row);
298
299 extern Bool
300 XkbcComputeSectionBounds(XkbGeometryPtr geom, XkbSectionPtr section);
301
302 extern int
303 XkbcInitCanonicalKeyTypes(XkbcDescPtr xkb, unsigned which, int keypadVMod);
304
305 extern Bool
306 XkbcVirtualModsToReal(XkbcDescPtr xkb, unsigned virtual_mask,
307                       unsigned *mask_rtrn);
308
309 extern Bool
310 XkbcComputeEffectiveMap(XkbcDescPtr xkb, XkbKeyTypePtr type,
311                         unsigned char *map_rtrn);
312
313 extern void
314 XkbcEnsureSafeMapName(char *name);
315
316 extern unsigned
317 _XkbcKSCheckCase(KeySym  sym);
318
319 _XFUNCPROTOEND
320
321 #endif /* _XKBCOMMON_H_ */