Debian Codegraph @

src/event.c

raw
1 /*
2 * Copyright © 2008-2009 Julien Danjou <[email protected]>
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 #ifdef HAVE_CONFIG_H
30 #include "config.h"
31 #endif
32
33 #include <assert.h>
34 #include <stdlib.h>
35 #include <string.h>
36
37 #include "xcb_event.h"
38
39 #include <sys/types.h>
40
41 #define ssizeof(foo) (ssize_t)sizeof(foo)
42 #define countof(foo) (ssizeof(foo) / ssizeof(foo[0]))
43
44 static const char *labelError[] =
45 {
46 "Success",
47 "BadRequest",
48 "BadValue",
49 "BadWindow",
50 "BadPixmap",
51 "BadAtom",
52 "BadCursor",
53 "BadFont",
54 "BadMatch",
55 "BadDrawable",
56 "BadAccess",
57 "BadAlloc",
58 "BadColor",
59 "BadGC",
60 "BadIDChoice",
61 "BadName",
62 "BadLength",
63 "BadImplementation",
64 };
65
66 static const char *labelRequest[] =
67 {
68 "no request",
69 "CreateWindow",
70 "ChangeWindowAttributes",
71 "GetWindowAttributes",
72 "DestroyWindow",
73 "DestroySubwindows",
74 "ChangeSaveSet",
75 "ReparentWindow",
76 "MapWindow",
77 "MapSubwindows",
78 "UnmapWindow",
79 "UnmapSubwindows",
80 "ConfigureWindow",
81 "CirculateWindow",
82 "GetGeometry",
83 "QueryTree",
84 "InternAtom",
85 "GetAtomName",
86 "ChangeProperty",
87 "DeleteProperty",
88 "GetProperty",
89 "ListProperties",
90 "SetSelectionOwner",
91 "GetSelectionOwner",
92 "ConvertSelection",
93 "SendEvent",
94 "GrabPointer",
95 "UngrabPointer",
96 "GrabButton",
97 "UngrabButton",
98 "ChangeActivePointerGrab",
99 "GrabKeyboard",
100 "UngrabKeyboard",
101 "GrabKey",
102 "UngrabKey",
103 "AllowEvents",
104 "GrabServer",
105 "UngrabServer",
106 "QueryPointer",
107 "GetMotionEvents",
108 "TranslateCoords",
109 "WarpPointer",
110 "SetInputFocus",
111 "GetInputFocus",
112 "QueryKeymap",
113 "OpenFont",
114 "CloseFont",
115 "QueryFont",
116 "QueryTextExtents",
117 "ListFonts",
118 "ListFontsWithInfo",
119 "SetFontPath",
120 "GetFontPath",
121 "CreatePixmap",
122 "FreePixmap",
123 "CreateGC",
124 "ChangeGC",
125 "CopyGC",
126 "SetDashes",
127 "SetClipRectangles",
128 "FreeGC",
129 "ClearArea",
130 "CopyArea",
131 "CopyPlane",
132 "PolyPoint",
133 "PolyLine",
134 "PolySegment",
135 "PolyRectangle",
136 "PolyArc",
137 "FillPoly",
138 "PolyFillRectangle",
139 "PolyFillArc",
140 "PutImage",
141 "GetImage",
142 "PolyText",
143 "PolyText",
144 "ImageText",
145 "ImageText",
146 "CreateColormap",
147 "FreeColormap",
148 "CopyColormapAndFree",
149 "InstallColormap",
150 "UninstallColormap",
151 "ListInstalledColormaps",
152 "AllocColor",
153 "AllocNamedColor",
154 "AllocColorCells",
155 "AllocColorPlanes",
156 "FreeColors",
157 "StoreColors",
158 "StoreNamedColor",
159 "QueryColors",
160 "LookupColor",
161 "CreateCursor",
162 "CreateGlyphCursor",
163 "FreeCursor",
164 "RecolorCursor",
165 "QueryBestSize",
166 "QueryExtension",
167 "ListExtensions",
168 "ChangeKeyboardMapping",
169 "GetKeyboardMapping",
170 "ChangeKeyboardControl",
171 "GetKeyboardControl",
172 "Bell",
173 "ChangePointerControl",
174 "GetPointerControl",
175 "SetScreenSaver",
176 "GetScreenSaver",
177 "ChangeHosts",
178 "ListHosts",
179 "SetAccessControl",
180 "SetCloseDownMode",
181 "KillClient",
182 "RotateProperties",
183 "ForceScreenSaver",
184 "SetPointerMapping",
185 "GetPointerMapping",
186 "SetModifierMapping",
187 "GetModifierMapping",
188 "major 120",
189 "major 121",
190 "major 122",
191 "major 123",
192 "major 124",
193 "major 125",
194 "major 126",
195 "NoOperation",
196 };
197
198 static const char *labelEvent[] =
199 {
200 "error",
201 "reply",
202 "KeyPress",
203 "KeyRelease",
204 "ButtonPress",
205 "ButtonRelease",
206 "MotionNotify",
207 "EnterNotify",
208 "LeaveNotify",
209 "FocusIn",
210 "FocusOut",
211 "KeymapNotify",
212 "Expose",
213 "GraphicsExpose",
214 "NoExpose",
215 "VisibilityNotify",
216 "CreateNotify",
217 "DestroyNotify",
218 "UnmapNotify",
219 "MapNotify",
220 "MapRequest",
221 "ReparentNotify",
222 "ConfigureNotify",
223 "ConfigureRequest",
224 "GravityNotify",
225 "ResizeRequest",
226 "CirculateNotify",
227 "CirculateRequest",
228 "PropertyNotify",
229 "SelectionClear",
230 "SelectionRequest",
231 "SelectionNotify",
232 "ColormapNotify",
233 "ClientMessage",
234 "MappingNotify",
235 };
236
237 const char *
238 xcb_event_get_label(uint8_t type)
239 {
240 if(type < countof(labelEvent))
241 return labelEvent[type];
242 return NULL;
243 }
244
245 const char *
246 xcb_event_get_error_label(uint8_t type)
247 {
248 if(type < countof(labelError))
249 return labelError[type];
250 return NULL;
251 }
252
253 const char *
254 xcb_event_get_request_label(uint8_t type)
255 {
256 if(type < countof(labelRequest))
257 return labelRequest[type];
258 return NULL;
259 }