Tizen 2.0 Release
[framework/uifw/xorg/xcb/xcb-util.git] / src / event.c
1 /*
2  * Copyright © 2008-2009 Julien Danjou <julien@danjou.info>
3  *
4  * Permission is hereby granted, free of charge, to any person
5  * obtaining a copy of this software and associated documentation
6  * files (the "Software"), to deal in the Software without
7  * restriction, including without limitation the rights to use, copy,
8  * modify, merge, publish, distribute, sublicense, and/or sell copies
9  * of the Software, and to permit persons to whom the Software is
10  * furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be
13  * included in all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
19  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
20  * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22  *
23  * Except as contained in this notice, the names of the authors or
24  * their institutions shall not be used in advertising or otherwise to
25  * promote the sale, use or other dealings in this Software without
26  * prior written authorization from the authors.
27  */
28
29 #include <assert.h>
30 #include <stdlib.h>
31 #include <string.h>
32
33 #include "xcb_event.h"
34
35 #ifdef HAVE_SYS_TYPES_H
36 # include <sys/types.h>
37 #endif
38
39 #define ssizeof(foo)            (ssize_t)sizeof(foo)
40 #define countof(foo)            (ssizeof(foo) / ssizeof(foo[0]))
41
42 static const char *labelError[] =
43 {
44     "Success",
45     "BadRequest",
46     "BadValue",
47     "BadWindow",
48     "BadPixmap",
49     "BadAtom",
50     "BadCursor",
51     "BadFont",
52     "BadMatch",
53     "BadDrawable",
54     "BadAccess",
55     "BadAlloc",
56     "BadColor",
57     "BadGC",
58     "BadIDChoice",
59     "BadName",
60     "BadLength",
61     "BadImplementation",
62 };
63
64 static const char *labelRequest[] =
65 {
66     "no request",
67     "CreateWindow",
68     "ChangeWindowAttributes",
69     "GetWindowAttributes",
70     "DestroyWindow",
71     "DestroySubwindows",
72     "ChangeSaveSet",
73     "ReparentWindow",
74     "MapWindow",
75     "MapSubwindows",
76     "UnmapWindow",
77     "UnmapSubwindows",
78     "ConfigureWindow",
79     "CirculateWindow",
80     "GetGeometry",
81     "QueryTree",
82     "InternAtom",
83     "GetAtomName",
84     "ChangeProperty",
85     "DeleteProperty",
86     "GetProperty",
87     "ListProperties",
88     "SetSelectionOwner",
89     "GetSelectionOwner",
90     "ConvertSelection",
91     "SendEvent",
92     "GrabPointer",
93     "UngrabPointer",
94     "GrabButton",
95     "UngrabButton",
96     "ChangeActivePointerGrab",
97     "GrabKeyboard",
98     "UngrabKeyboard",
99     "GrabKey",
100     "UngrabKey",
101     "AllowEvents",
102     "GrabServer",
103     "UngrabServer",
104     "QueryPointer",
105     "GetMotionEvents",
106     "TranslateCoords",
107     "WarpPointer",
108     "SetInputFocus",
109     "GetInputFocus",
110     "QueryKeymap",
111     "OpenFont",
112     "CloseFont",
113     "QueryFont",
114     "QueryTextExtents",
115     "ListFonts",
116     "ListFontsWithInfo",
117     "SetFontPath",
118     "GetFontPath",
119     "CreatePixmap",
120     "FreePixmap",
121     "CreateGC",
122     "ChangeGC",
123     "CopyGC",
124     "SetDashes",
125     "SetClipRectangles",
126     "FreeGC",
127     "ClearArea",
128     "CopyArea",
129     "CopyPlane",
130     "PolyPoint",
131     "PolyLine",
132     "PolySegment",
133     "PolyRectangle",
134     "PolyArc",
135     "FillPoly",
136     "PolyFillRectangle",
137     "PolyFillArc",
138     "PutImage",
139     "GetImage",
140     "PolyText",
141     "PolyText",
142     "ImageText",
143     "ImageText",
144     "CreateColormap",
145     "FreeColormap",
146     "CopyColormapAndFree",
147     "InstallColormap",
148     "UninstallColormap",
149     "ListInstalledColormaps",
150     "AllocColor",
151     "AllocNamedColor",
152     "AllocColorCells",
153     "AllocColorPlanes",
154     "FreeColors",
155     "StoreColors",
156     "StoreNamedColor",
157     "QueryColors",
158     "LookupColor",
159     "CreateCursor",
160     "CreateGlyphCursor",
161     "FreeCursor",
162     "RecolorCursor",
163     "QueryBestSize",
164     "QueryExtension",
165     "ListExtensions",
166     "ChangeKeyboardMapping",
167     "GetKeyboardMapping",
168     "ChangeKeyboardControl",
169     "GetKeyboardControl",
170     "Bell",
171     "ChangePointerControl",
172     "GetPointerControl",
173     "SetScreenSaver",
174     "GetScreenSaver",
175     "ChangeHosts",
176     "ListHosts",
177     "SetAccessControl",
178     "SetCloseDownMode",
179     "KillClient",
180     "RotateProperties",
181     "ForceScreenSaver",
182     "SetPointerMapping",
183     "GetPointerMapping",
184     "SetModifierMapping",
185     "GetModifierMapping",
186     "major 120",
187     "major 121",
188     "major 122",
189     "major 123",
190     "major 124",
191     "major 125",
192     "major 126",
193     "NoOperation",
194 };
195
196 static const char *labelEvent[] =
197 {
198     "error",
199     "reply",
200     "KeyPress",
201     "KeyRelease",
202     "ButtonPress",
203     "ButtonRelease",
204     "MotionNotify",
205     "EnterNotify",
206     "LeaveNotify",
207     "FocusIn",
208     "FocusOut",
209     "KeymapNotify",
210     "Expose",
211     "GraphicsExpose",
212     "NoExpose",
213     "VisibilityNotify",
214     "CreateNotify",
215     "DestroyNotify",
216     "UnmapNotify",
217     "MapNotify",
218     "MapRequest",
219     "ReparentNotify",
220     "ConfigureNotify",
221     "ConfigureRequest",
222     "GravityNotify",
223     "ResizeRequest",
224     "CirculateNotify",
225     "CirculateRequest",
226     "PropertyNotify",
227     "SelectionClear",
228     "SelectionRequest",
229     "SelectionNotify",
230     "ColormapNotify",
231     "ClientMessage",
232     "MappingNotify",
233 };
234
235 const char *
236 xcb_event_get_label(uint8_t type)
237 {
238     if(type < countof(labelEvent))
239         return labelEvent[type];
240     return NULL;
241 }
242
243 const char *
244 xcb_event_get_error_label(uint8_t type)
245 {
246     if(type < countof(labelError))
247         return labelError[type];
248     return NULL;
249 }
250
251 const char *
252 xcb_event_get_request_label(uint8_t type)
253 {
254     if(type < countof(labelRequest))
255         return labelRequest[type];
256     return NULL;
257 }