2009-02-14 02:33:31 +01:00
|
|
|
/*
|
|
|
|
* vim:ts=8:expandtab
|
|
|
|
*
|
|
|
|
* i3 - an improved dynamic tiling window manager
|
|
|
|
*
|
2010-03-19 18:48:36 +01:00
|
|
|
* © 2009-2010 Michael Stapelberg and contributors
|
2009-02-14 02:33:31 +01:00
|
|
|
*
|
|
|
|
* See file LICENSE for license information.
|
|
|
|
*
|
2009-02-15 03:07:29 +01:00
|
|
|
* debug.c: Contains debugging functions, especially FormatEvent, which prints unhandled events.
|
|
|
|
* This code is from xcb-util.
|
|
|
|
*
|
2009-02-14 02:33:31 +01:00
|
|
|
*/
|
2009-02-13 19:04:45 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <xcb/xcb.h>
|
|
|
|
|
2010-03-19 18:48:36 +01:00
|
|
|
#include "log.h"
|
|
|
|
|
2009-02-13 19:04:45 +01:00
|
|
|
static const char *labelError[] = {
|
|
|
|
"Success",
|
|
|
|
"BadRequest",
|
|
|
|
"BadValue",
|
|
|
|
"BadWindow",
|
|
|
|
"BadPixmap",
|
|
|
|
"BadAtom",
|
|
|
|
"BadCursor",
|
|
|
|
"BadFont",
|
|
|
|
"BadMatch",
|
|
|
|
"BadDrawable",
|
|
|
|
"BadAccess",
|
|
|
|
"BadAlloc",
|
|
|
|
"BadColor",
|
|
|
|
"BadGC",
|
|
|
|
"BadIDChoice",
|
|
|
|
"BadName",
|
|
|
|
"BadLength",
|
|
|
|
"BadImplementation",
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char *labelRequest[] = {
|
|
|
|
"no request",
|
|
|
|
"CreateWindow",
|
|
|
|
"ChangeWindowAttributes",
|
|
|
|
"GetWindowAttributes",
|
|
|
|
"DestroyWindow",
|
|
|
|
"DestroySubwindows",
|
|
|
|
"ChangeSaveSet",
|
|
|
|
"ReparentWindow",
|
|
|
|
"MapWindow",
|
|
|
|
"MapSubwindows",
|
|
|
|
"UnmapWindow",
|
|
|
|
"UnmapSubwindows",
|
|
|
|
"ConfigureWindow",
|
|
|
|
"CirculateWindow",
|
|
|
|
"GetGeometry",
|
|
|
|
"QueryTree",
|
|
|
|
"InternAtom",
|
|
|
|
"GetAtomName",
|
|
|
|
"ChangeProperty",
|
|
|
|
"DeleteProperty",
|
|
|
|
"GetProperty",
|
|
|
|
"ListProperties",
|
|
|
|
"SetSelectionOwner",
|
|
|
|
"GetSelectionOwner",
|
|
|
|
"ConvertSelection",
|
|
|
|
"SendEvent",
|
|
|
|
"GrabPointer",
|
|
|
|
"UngrabPointer",
|
|
|
|
"GrabButton",
|
|
|
|
"UngrabButton",
|
|
|
|
"ChangeActivePointerGrab",
|
|
|
|
"GrabKeyboard",
|
|
|
|
"UngrabKeyboard",
|
|
|
|
"GrabKey",
|
|
|
|
"UngrabKey",
|
|
|
|
"AllowEvents",
|
|
|
|
"GrabServer",
|
|
|
|
"UngrabServer",
|
|
|
|
"QueryPointer",
|
|
|
|
"GetMotionEvents",
|
|
|
|
"TranslateCoords",
|
|
|
|
"WarpPointer",
|
|
|
|
"SetInputFocus",
|
|
|
|
"GetInputFocus",
|
|
|
|
"QueryKeymap",
|
|
|
|
"OpenFont",
|
|
|
|
"CloseFont",
|
|
|
|
"QueryFont",
|
|
|
|
"QueryTextExtents",
|
|
|
|
"ListFonts",
|
|
|
|
"ListFontsWithInfo",
|
|
|
|
"SetFontPath",
|
|
|
|
"GetFontPath",
|
|
|
|
"CreatePixmap",
|
|
|
|
"FreePixmap",
|
|
|
|
"CreateGC",
|
|
|
|
"ChangeGC",
|
|
|
|
"CopyGC",
|
|
|
|
"SetDashes",
|
|
|
|
"SetClipRectangles",
|
|
|
|
"FreeGC",
|
|
|
|
"ClearArea",
|
|
|
|
"CopyArea",
|
|
|
|
"CopyPlane",
|
|
|
|
"PolyPoint",
|
|
|
|
"PolyLine",
|
|
|
|
"PolySegment",
|
|
|
|
"PolyRectangle",
|
|
|
|
"PolyArc",
|
|
|
|
"FillPoly",
|
|
|
|
"PolyFillRectangle",
|
|
|
|
"PolyFillArc",
|
|
|
|
"PutImage",
|
|
|
|
"GetImage",
|
|
|
|
"PolyText",
|
|
|
|
"PolyText",
|
|
|
|
"ImageText",
|
|
|
|
"ImageText",
|
|
|
|
"CreateColormap",
|
|
|
|
"FreeColormap",
|
|
|
|
"CopyColormapAndFree",
|
|
|
|
"InstallColormap",
|
|
|
|
"UninstallColormap",
|
|
|
|
"ListInstalledColormaps",
|
|
|
|
"AllocColor",
|
|
|
|
"AllocNamedColor",
|
|
|
|
"AllocColorCells",
|
|
|
|
"AllocColorPlanes",
|
|
|
|
"FreeColors",
|
|
|
|
"StoreColors",
|
|
|
|
"StoreNamedColor",
|
|
|
|
"QueryColors",
|
|
|
|
"LookupColor",
|
|
|
|
"CreateCursor",
|
|
|
|
"CreateGlyphCursor",
|
|
|
|
"FreeCursor",
|
|
|
|
"RecolorCursor",
|
|
|
|
"QueryBestSize",
|
|
|
|
"QueryExtension",
|
|
|
|
"ListExtensions",
|
|
|
|
"ChangeKeyboardMapping",
|
|
|
|
"GetKeyboardMapping",
|
|
|
|
"ChangeKeyboardControl",
|
|
|
|
"GetKeyboardControl",
|
|
|
|
"Bell",
|
|
|
|
"ChangePointerControl",
|
|
|
|
"GetPointerControl",
|
|
|
|
"SetScreenSaver",
|
|
|
|
"GetScreenSaver",
|
|
|
|
"ChangeHosts",
|
|
|
|
"ListHosts",
|
|
|
|
"SetAccessControl",
|
|
|
|
"SetCloseDownMode",
|
|
|
|
"KillClient",
|
|
|
|
"RotateProperties",
|
|
|
|
"ForceScreenSaver",
|
|
|
|
"SetPointerMapping",
|
|
|
|
"GetPointerMapping",
|
|
|
|
"SetModifierMapping",
|
|
|
|
"GetModifierMapping",
|
|
|
|
"major 120",
|
|
|
|
"major 121",
|
|
|
|
"major 122",
|
|
|
|
"major 123",
|
|
|
|
"major 124",
|
|
|
|
"major 125",
|
|
|
|
"major 126",
|
|
|
|
"NoOperation",
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char *labelEvent[] = {
|
|
|
|
"error",
|
|
|
|
"reply",
|
|
|
|
"KeyPress",
|
|
|
|
"KeyRelease",
|
|
|
|
"ButtonPress",
|
|
|
|
"ButtonRelease",
|
|
|
|
"MotionNotify",
|
|
|
|
"EnterNotify",
|
|
|
|
"LeaveNotify",
|
|
|
|
"FocusIn",
|
|
|
|
"FocusOut",
|
|
|
|
"KeymapNotify",
|
|
|
|
"Expose",
|
|
|
|
"GraphicsExpose",
|
|
|
|
"NoExpose",
|
|
|
|
"VisibilityNotify",
|
|
|
|
"CreateNotify",
|
|
|
|
"DestroyNotify",
|
|
|
|
"UnmapNotify",
|
|
|
|
"MapNotify",
|
|
|
|
"MapRequest",
|
|
|
|
"ReparentNotify",
|
|
|
|
"ConfigureNotify",
|
|
|
|
"ConfigureRequest",
|
|
|
|
"GravityNotify",
|
|
|
|
"ResizeRequest",
|
|
|
|
"CirculateNotify",
|
|
|
|
"CirculateRequest",
|
|
|
|
"PropertyNotify",
|
|
|
|
"SelectionClear",
|
|
|
|
"SelectionRequest",
|
|
|
|
"SelectionNotify",
|
|
|
|
"ColormapNotify",
|
|
|
|
"ClientMessage",
|
|
|
|
"MappingNotify",
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char *labelSendEvent[] = {
|
|
|
|
"",
|
|
|
|
" (from SendEvent)",
|
|
|
|
};
|
|
|
|
|
|
|
|
int format_event(xcb_generic_event_t *e) {
|
|
|
|
uint8_t sendEvent;
|
|
|
|
uint16_t seqnum;
|
|
|
|
|
|
|
|
sendEvent = (e->response_type & 0x80) ? 1 : 0;
|
|
|
|
e->response_type &= ~0x80;
|
|
|
|
seqnum = *((uint16_t *) e + 1);
|
|
|
|
|
|
|
|
switch(e->response_type) {
|
|
|
|
case 0:
|
2010-03-19 18:48:36 +01:00
|
|
|
DLOG("Error %s on seqnum %d (%s).\n",
|
2009-02-13 19:04:45 +01:00
|
|
|
labelError[*((uint8_t *) e + 1)],
|
|
|
|
seqnum,
|
|
|
|
labelRequest[*((uint8_t *) e + 10)]);
|
|
|
|
break;
|
|
|
|
default:
|
2010-03-02 12:47:21 +01:00
|
|
|
if (e->response_type > sizeof(labelEvent) / sizeof(char*))
|
|
|
|
break;
|
2010-03-19 18:48:36 +01:00
|
|
|
DLOG("Event %s following seqnum %d%s.\n",
|
2009-02-13 19:04:45 +01:00
|
|
|
labelEvent[e->response_type],
|
|
|
|
seqnum,
|
|
|
|
labelSendEvent[sendEvent]);
|
|
|
|
break;
|
|
|
|
case XCB_KEYMAP_NOTIFY:
|
2010-03-19 18:48:36 +01:00
|
|
|
DLOG("Event %s%s.\n",
|
2009-02-13 19:04:45 +01:00
|
|
|
labelEvent[e->response_type],
|
|
|
|
labelSendEvent[sendEvent]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
fflush(stdout);
|
|
|
|
return 1;
|
|
|
|
}
|