00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include <stdio.h>
00015 #include <xcb/xcb.h>
00016
00017 #include "log.h"
00018
00019 static const char *labelError[] = {
00020 "Success",
00021 "BadRequest",
00022 "BadValue",
00023 "BadWindow",
00024 "BadPixmap",
00025 "BadAtom",
00026 "BadCursor",
00027 "BadFont",
00028 "BadMatch",
00029 "BadDrawable",
00030 "BadAccess",
00031 "BadAlloc",
00032 "BadColor",
00033 "BadGC",
00034 "BadIDChoice",
00035 "BadName",
00036 "BadLength",
00037 "BadImplementation",
00038 };
00039
00040 static const char *labelRequest[] = {
00041 "no request",
00042 "CreateWindow",
00043 "ChangeWindowAttributes",
00044 "GetWindowAttributes",
00045 "DestroyWindow",
00046 "DestroySubwindows",
00047 "ChangeSaveSet",
00048 "ReparentWindow",
00049 "MapWindow",
00050 "MapSubwindows",
00051 "UnmapWindow",
00052 "UnmapSubwindows",
00053 "ConfigureWindow",
00054 "CirculateWindow",
00055 "GetGeometry",
00056 "QueryTree",
00057 "InternAtom",
00058 "GetAtomName",
00059 "ChangeProperty",
00060 "DeleteProperty",
00061 "GetProperty",
00062 "ListProperties",
00063 "SetSelectionOwner",
00064 "GetSelectionOwner",
00065 "ConvertSelection",
00066 "SendEvent",
00067 "GrabPointer",
00068 "UngrabPointer",
00069 "GrabButton",
00070 "UngrabButton",
00071 "ChangeActivePointerGrab",
00072 "GrabKeyboard",
00073 "UngrabKeyboard",
00074 "GrabKey",
00075 "UngrabKey",
00076 "AllowEvents",
00077 "GrabServer",
00078 "UngrabServer",
00079 "QueryPointer",
00080 "GetMotionEvents",
00081 "TranslateCoords",
00082 "WarpPointer",
00083 "SetInputFocus",
00084 "GetInputFocus",
00085 "QueryKeymap",
00086 "OpenFont",
00087 "CloseFont",
00088 "QueryFont",
00089 "QueryTextExtents",
00090 "ListFonts",
00091 "ListFontsWithInfo",
00092 "SetFontPath",
00093 "GetFontPath",
00094 "CreatePixmap",
00095 "FreePixmap",
00096 "CreateGC",
00097 "ChangeGC",
00098 "CopyGC",
00099 "SetDashes",
00100 "SetClipRectangles",
00101 "FreeGC",
00102 "ClearArea",
00103 "CopyArea",
00104 "CopyPlane",
00105 "PolyPoint",
00106 "PolyLine",
00107 "PolySegment",
00108 "PolyRectangle",
00109 "PolyArc",
00110 "FillPoly",
00111 "PolyFillRectangle",
00112 "PolyFillArc",
00113 "PutImage",
00114 "GetImage",
00115 "PolyText",
00116 "PolyText",
00117 "ImageText",
00118 "ImageText",
00119 "CreateColormap",
00120 "FreeColormap",
00121 "CopyColormapAndFree",
00122 "InstallColormap",
00123 "UninstallColormap",
00124 "ListInstalledColormaps",
00125 "AllocColor",
00126 "AllocNamedColor",
00127 "AllocColorCells",
00128 "AllocColorPlanes",
00129 "FreeColors",
00130 "StoreColors",
00131 "StoreNamedColor",
00132 "QueryColors",
00133 "LookupColor",
00134 "CreateCursor",
00135 "CreateGlyphCursor",
00136 "FreeCursor",
00137 "RecolorCursor",
00138 "QueryBestSize",
00139 "QueryExtension",
00140 "ListExtensions",
00141 "ChangeKeyboardMapping",
00142 "GetKeyboardMapping",
00143 "ChangeKeyboardControl",
00144 "GetKeyboardControl",
00145 "Bell",
00146 "ChangePointerControl",
00147 "GetPointerControl",
00148 "SetScreenSaver",
00149 "GetScreenSaver",
00150 "ChangeHosts",
00151 "ListHosts",
00152 "SetAccessControl",
00153 "SetCloseDownMode",
00154 "KillClient",
00155 "RotateProperties",
00156 "ForceScreenSaver",
00157 "SetPointerMapping",
00158 "GetPointerMapping",
00159 "SetModifierMapping",
00160 "GetModifierMapping",
00161 "major 120",
00162 "major 121",
00163 "major 122",
00164 "major 123",
00165 "major 124",
00166 "major 125",
00167 "major 126",
00168 "NoOperation",
00169 };
00170
00171 static const char *labelEvent[] = {
00172 "error",
00173 "reply",
00174 "KeyPress",
00175 "KeyRelease",
00176 "ButtonPress",
00177 "ButtonRelease",
00178 "MotionNotify",
00179 "EnterNotify",
00180 "LeaveNotify",
00181 "FocusIn",
00182 "FocusOut",
00183 "KeymapNotify",
00184 "Expose",
00185 "GraphicsExpose",
00186 "NoExpose",
00187 "VisibilityNotify",
00188 "CreateNotify",
00189 "DestroyNotify",
00190 "UnmapNotify",
00191 "MapNotify",
00192 "MapRequest",
00193 "ReparentNotify",
00194 "ConfigureNotify",
00195 "ConfigureRequest",
00196 "GravityNotify",
00197 "ResizeRequest",
00198 "CirculateNotify",
00199 "CirculateRequest",
00200 "PropertyNotify",
00201 "SelectionClear",
00202 "SelectionRequest",
00203 "SelectionNotify",
00204 "ColormapNotify",
00205 "ClientMessage",
00206 "MappingNotify",
00207 };
00208
00209 static const char *labelSendEvent[] = {
00210 "",
00211 " (from SendEvent)",
00212 };
00213
00214 int format_event(xcb_generic_event_t *e) {
00215 uint8_t sendEvent;
00216 uint16_t seqnum;
00217
00218 sendEvent = (e->response_type & 0x80) ? 1 : 0;
00219 e->response_type &= ~0x80;
00220 seqnum = *((uint16_t *) e + 1);
00221
00222 switch(e->response_type) {
00223 case 0:
00224 DLOG("Error %s on seqnum %d (%s).\n",
00225 labelError[*((uint8_t *) e + 1)],
00226 seqnum,
00227 labelRequest[*((uint8_t *) e + 10)]);
00228 break;
00229 default:
00230 if (e->response_type > sizeof(labelEvent) / sizeof(char*))
00231 break;
00232 DLOG("Event %s following seqnum %d%s.\n",
00233 labelEvent[e->response_type],
00234 seqnum,
00235 labelSendEvent[sendEvent]);
00236 break;
00237 case XCB_KEYMAP_NOTIFY:
00238 DLOG("Event %s%s.\n",
00239 labelEvent[e->response_type],
00240 labelSendEvent[sendEvent]);
00241 break;
00242 }
00243
00244 fflush(stdout);
00245 return 1;
00246 }
00247
00248 int handle_event(void *ignored, xcb_connection_t *c, xcb_generic_event_t *e) {
00249 return format_event(e);
00250 }