summaryrefslogtreecommitdiff
path: root/src/utils/x11logger.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-09-14 23:05:01 +0300
committerAndrei Karas <akaras@inbox.ru>2017-09-14 23:05:01 +0300
commit6129271291775f6ddd69101c93d2917231142038 (patch)
treecd8053d1d78bf202e6e00cdf77d8852579447a45 /src/utils/x11logger.cpp
parent7057bd0a97f295d9ceb774a36279735d8a4e7310 (diff)
downloadmanaverse-6129271291775f6ddd69101c93d2917231142038.tar.gz
manaverse-6129271291775f6ddd69101c93d2917231142038.tar.bz2
manaverse-6129271291775f6ddd69101c93d2917231142038.tar.xz
manaverse-6129271291775f6ddd69101c93d2917231142038.zip
Improve x11 events logging.
Diffstat (limited to 'src/utils/x11logger.cpp')
-rw-r--r--src/utils/x11logger.cpp178
1 files changed, 145 insertions, 33 deletions
diff --git a/src/utils/x11logger.cpp b/src/utils/x11logger.cpp
index f21541630..5b83886fe 100644
--- a/src/utils/x11logger.cpp
+++ b/src/utils/x11logger.cpp
@@ -30,6 +30,7 @@ PRAGMA48(GCC diagnostic ignored "-Wshadow")
#include <SDL_syswm.h>
PRAGMA48(GCC diagnostic pop)
+#include "utils/cast.h"
#include "utils/stringutils.h"
#include "debug.h"
@@ -46,47 +47,158 @@ bool X11Logger::logEvent(const SDL_Event &event)
std::string typeStr;
#ifdef USE_SDL2
- const int type = event.syswm.msg->msg.x11.event.type;
+ XEvent &xEvent = event.syswm.msg->msg.x11.event;
#else // USE_SDL2
- const int type = event.syswm.msg->event.xevent.type;
+ XEvent &xEvent = event.syswm.msg->event.xevent;
#endif // USE_SDL2
+ const int type = xEvent.type;
+
switch (type)
{
- logType(2, "KeyPress");
- logType(3, "KeyRelease");
- logType(4, "ButtonPress");
- logType(5, "ButtonRelease");
- logType(6, "MotionNotify");
- logType(7, "EnterNotify");
- logType(8, "LeaveNotify");
- logType(9, "FocusIn");
- logType(10, "FocusOut");
- logType(11, "KeymapNotify");
- logType(12, "Expose");
- logType(13, "GraphicsExpose");
- logType(14, "NoExpose");
- logType(15, "VisibilityNotify");
- logType(16, "CreateNotify");
+ logType(2, strprintf("KeyPress: %u,%u %d,%d",
+ xEvent.xkey.keycode,
+ xEvent.xkey.state,
+ xEvent.xkey.x,
+ xEvent.xkey.y));
+ logType(3, strprintf("KeyRelease: %u,%u %d,%d",
+ xEvent.xkey.keycode,
+ xEvent.xkey.state,
+ xEvent.xkey.x,
+ xEvent.xkey.y));
+ logType(4, strprintf("ButtonPress: %u,%u %d,%d",
+ xEvent.xbutton.button,
+ xEvent.xbutton.state,
+ xEvent.xbutton.x,
+ xEvent.xbutton.y));
+ logType(5, strprintf("ButtonRelease: %u,%u %d,%d",
+ xEvent.xbutton.button,
+ xEvent.xbutton.state,
+ xEvent.xbutton.x,
+ xEvent.xbutton.y));
+ logType(6, strprintf("MotionNotify: %d,%u %d,%d",
+ CAST_S32(xEvent.xmotion.is_hint),
+ xEvent.xmotion.state,
+ xEvent.xmotion.x,
+ xEvent.xmotion.y));
+ logType(7, strprintf("EnterNotify: %d,%d,%d,%u, %d,%d",
+ xEvent.xcrossing.mode,
+ xEvent.xcrossing.detail,
+ xEvent.xcrossing.focus ? 1 : 0,
+ xEvent.xcrossing.state,
+ xEvent.xcrossing.x,
+ xEvent.xcrossing.y));
+ logType(8, strprintf("LeaveNotify: %d,%d,%d,%u, %d,%d",
+ xEvent.xcrossing.mode,
+ xEvent.xcrossing.detail,
+ xEvent.xcrossing.focus ? 1 : 0,
+ xEvent.xcrossing.state,
+ xEvent.xcrossing.x,
+ xEvent.xcrossing.y));
+ logType(9, strprintf("FocusIn: %d,%d",
+ xEvent.xfocus.mode,
+ xEvent.xfocus.detail));
+ logType(10, strprintf("FocusOut: %d,%d",
+ xEvent.xfocus.mode,
+ xEvent.xfocus.detail));
+ case 11:
+ typeStr = "KeymapNotify: ";
+ for (int f = 0; f < 32; f ++)
+ {
+ typeStr.append(strprintf("%u ",
+ CAST_U32(xEvent.xkeymap.key_vector[f])));
+ }
+ break;
+ logType(12, strprintf("Expose: %d,%d,%d,%d %d",
+ xEvent.xexpose.x,
+ xEvent.xexpose.y,
+ xEvent.xexpose.width,
+ xEvent.xexpose.height,
+ xEvent.xexpose.count));
+ logType(13, strprintf("GraphicsExpose: %d,%d,%d,%d %d,%d,%d",
+ xEvent.xgraphicsexpose.x,
+ xEvent.xgraphicsexpose.y,
+ xEvent.xgraphicsexpose.width,
+ xEvent.xgraphicsexpose.height,
+ xEvent.xgraphicsexpose.count,
+ xEvent.xgraphicsexpose.major_code,
+ xEvent.xgraphicsexpose.minor_code));
+ logType(14, strprintf("NoExpose: %d,%d",
+ xEvent.xnoexpose.major_code,
+ xEvent.xnoexpose.minor_code));
+ logType(15, strprintf("VisibilityNotify: %d",
+ xEvent.xvisibility.state));
+ logType(16, strprintf("CreateNotify: %d,%d,%d,%d %d,%d",
+ xEvent.xcreatewindow.x,
+ xEvent.xcreatewindow.y,
+ xEvent.xcreatewindow.width,
+ xEvent.xcreatewindow.height,
+ xEvent.xcreatewindow.border_width,
+ xEvent.xcreatewindow.override_redirect ? 1 : 0));
logType(17, "DestroyNotify");
- logType(18, "UnmapNotify");
- logType(19, "MapNotify");
+ logType(18, strprintf("UnmapNotify: %d",
+ xEvent.xunmap.from_configure ? 1: 0));
+ logType(19, strprintf("MapNotify: %d",
+ xEvent.xmap.override_redirect ? 1 : 0));
logType(20, "MapRequest");
- logType(21, "ReparentNotify");
- logType(22, "ConfigureNotify");
- logType(23, "ConfigureRequest");
- logType(24, "GravityNotify");
- logType(25, "ResizeRequest");
- logType(26, "CirculateNotify");
- logType(27, "CirculateRequest");
- logType(28, "PropertyNotify");
- logType(29, "SelectionClear");
- logType(30, "SelectionRequest");
- logType(31, "SelectionNotify");
- logType(32, "ColormapNotify");
- logType(33, "ClientMessage");
- logType(34, "MappingNotify");
+ logType(21, strprintf("ReparentNotify: %d,%d, %d",
+ xEvent.xreparent.x,
+ xEvent.xreparent.y,
+ xEvent.xreparent.override_redirect ? 1 : 0));
+ logType(22, strprintf("ConfigureNotify: %d,%d %d,%d %d,%d",
+ xEvent.xconfigure.x,
+ xEvent.xconfigure.y,
+ xEvent.xconfigure.width,
+ xEvent.xconfigure.height,
+ xEvent.xconfigure.border_width,
+ xEvent.xconfigure.override_redirect ? 1 : 0));
+ logType(23, strprintf("ConfigureRequest: %d,%d %d,%d %d,%d",
+ xEvent.xconfigurerequest.x,
+ xEvent.xconfigurerequest.y,
+ xEvent.xconfigurerequest.width,
+ xEvent.xconfigurerequest.height,
+ xEvent.xconfigurerequest.border_width,
+ xEvent.xconfigurerequest.detail));
+ logType(24, strprintf("GravityNotify: %d,%d",
+ xEvent.xgravity.x,
+ xEvent.xgravity.y));
+ logType(25, strprintf("ResizeRequest: %d,%d",
+ xEvent.xresizerequest.width,
+ xEvent.xresizerequest.height));
+ logType(26, strprintf("CirculateNotify: %d",
+ xEvent.xcirculate.place));
+ logType(27, strprintf("CirculateRequest: %d",
+ xEvent.xcirculaterequest.place));
+ logType(28, strprintf("PropertyNotify: %u, %d",
+ CAST_U32(xEvent.xproperty.atom),
+ xEvent.xproperty.state));
+ logType(29, strprintf("SelectionClear: %u",
+ CAST_U32(xEvent.xselectionclear.selection)));
+ logType(30, strprintf("SelectionRequest: %u,%u,%u",
+ CAST_U32(xEvent.xselectionrequest.selection),
+ CAST_U32(xEvent.xselectionrequest.target),
+ CAST_U32(xEvent.xselectionrequest.property)));
+ logType(31, strprintf("SelectionNotify: %u,%u,%u",
+ CAST_U32(xEvent.xselection.selection),
+ CAST_U32(xEvent.xselection.target),
+ CAST_U32(xEvent.xselection.property)));
+ logType(32, strprintf("ColormapNotify: %u,%d",
+ CAST_U32(xEvent.xcolormap.colormap),
+// xEvent.xcolormap.new ? 1 : 0,
+ xEvent.xcolormap.state));
+ case 33:
+ typeStr = strprintf("ClientMessage: %u,%d (",
+ CAST_U32(xEvent.xclient.message_type),
+ xEvent.xclient.format);
+ for (int f = 0; f < 20; f ++)
+ typeStr.append(strprintf("%c", xEvent.xclient.data.b[f]));
+ typeStr.append(")");
+ break;
+ logType(34, strprintf("MappingNotify: %d,%d,%d",
+ xEvent.xmapping.request,
+ xEvent.xmapping.first_keycode,
+ xEvent.xmapping.count));
logType(35, "GenericEvent");
default:
typeStr = strprintf("Unknown: %d", type);