XKBcommon.h: Make header self-contained
[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 <stdio.h>
32 #include <X11/Xfuncproto.h>
33 #include <X11/extensions/XKBstrcommon.h>
34 #include <X11/extensions/XKBrulescommon.h>
35
36 /* Action structures used in the server */
37 typedef struct _XkbcModAction {
38     unsigned char   type;
39     unsigned char   flags;
40     unsigned char   mask;
41     unsigned char   real_mods;
42     unsigned int    vmods;
43 } XkbcModAction;
44
45 typedef struct _XkbcISOAction {
46     unsigned char   type;
47     unsigned char   flags;
48     unsigned char   mask;
49     unsigned char   real_mods;
50     /* FIXME: Make this an int. */
51     char            group_XXX;
52     unsigned char   affect;
53     unsigned int    vmods;
54 } XkbcISOAction;
55
56 typedef struct _XkbcPtrAction {
57     unsigned char   type;
58     unsigned char   flags;
59     int             x;
60     int             y;
61 } XkbcPtrAction;
62
63 typedef struct _XkbcCtrlsAction {
64     unsigned char   type;
65     unsigned char   flags;
66     unsigned long   ctrls;
67 } XkbcCtrlsAction;
68
69 typedef struct  _XkbcRedirectKeyAction {
70     unsigned char   type;
71     unsigned char   new_key;
72     unsigned char   mods_mask;
73     unsigned char   mods;
74     unsigned int    vmods_mask;
75     unsigned int    vmods;
76 } XkbcRedirectKeyAction;
77
78 typedef union _XkbcAction {
79     XkbAnyAction            any;
80     XkbcModAction           mods;
81     XkbGroupAction          group;
82     XkbcISOAction           iso;
83     XkbcPtrAction           ptr;
84     XkbPtrBtnAction         btn;
85     XkbPtrDfltAction        dflt;
86     XkbSwitchScreenAction   screen;
87     XkbcCtrlsAction         ctrls;
88     XkbMessageAction        msg;
89     XkbcRedirectKeyAction   redirect;
90     XkbDeviceBtnAction      devbtn;
91     XkbDeviceValuatorAction devval;
92     unsigned char           type;
93 } XkbcAction;
94
95 typedef struct _XkbcServerMapRec {
96     unsigned short      num_acts;
97     unsigned short      size_acts;
98     XkbcAction *        acts;
99
100     XkbBehavior *       behaviors;
101     unsigned short *    key_acts;
102 #if defined(__cplusplus) || defined(c_plusplus)
103     /* explicit is a C++ reserved word */
104     unsigned char *     c_explicit;
105 #else
106     unsigned char *     explicit;
107 #endif
108     unsigned char       vmods[XkbNumVirtualMods];
109     unsigned short *    vmodmap;
110 } XkbcServerMapRec, *XkbcServerMapPtr;
111
112 /* Common keyboard description structure */
113 typedef struct _XkbcDesc {
114     unsigned int        defined;
115     unsigned short      flags;
116     unsigned short      device_spec;
117     KeyCode             min_key_code;
118     KeyCode             max_key_code;
119
120     XkbControlsPtr      ctrls;
121     XkbcServerMapPtr    server;
122     XkbClientMapPtr     map;
123     XkbIndicatorPtr     indicators;
124     XkbNamesPtr         names;
125     XkbCompatMapPtr     compat;
126     XkbGeometryPtr      geom;
127 } XkbcDescRec, *XkbcDescPtr;
128
129 _XFUNCPROTOBEGIN
130
131 extern void
132 XkbcInitAtoms(void);
133
134 extern XkbcDescPtr
135 XkbcCompileKeymapFromRules(const XkbRMLVOSet *rmlvo);
136
137 extern XkbcDescPtr
138 XkbcCompileKeymapFromComponents(const XkbComponentNamesPtr ktcsg);
139
140 extern XkbcDescPtr
141 XkbcCompileKeymapFromFile(FILE *inputFile, const char *mapName);
142
143 extern XkbComponentListPtr
144 XkbcListComponents(XkbComponentNamesPtr ptrns, int *maxMatch);
145
146 /*
147  * Converts a keysym to a string; will return unknown Unicode codepoints
148  * as "Ua1b2", and other unknown keysyms as "0xabcd1234".
149  *
150  * The string returned may become invalidated after the next call to
151  * XkbcKeysymToString: if you need to preserve it, then you must
152  * duplicate it.
153  */
154 extern char *
155 XkbcKeysymToString(KeySym ks);
156
157 /*
158  * See XkbcKeysymToString comments: this function will accept any string
159  * from that function.
160  */
161 extern KeySym
162 XkbcStringToKeysym(const char *s);
163
164 _XFUNCPROTOEND
165
166 #endif /* _XKBCOMMON_H_ */