29 PRAGMA48(GCC diagnostic ignored
"-Wshadow")
30 #include <SDL_events.h>
31 #include <SDL_syswm.h>
34 #include "utils/cast.h"
39 #define logType(val, str) \
44 bool X11Logger::logEvent(
const SDL_Event &event)
46 if (event.syswm.msg->subsystem != SDL_SYSWM_X11)
51 XEvent &xEvent =
event.syswm.msg->msg.x11.event;
54 XEvent &xEvent =
event.syswm.msg->event.xevent;
57 const int type = xEvent.type;
61 logType(2,
strprintf(
"KeyPress: %u,%u %d,%d",
66 logType(3,
strprintf(
"KeyRelease: %u,%u %d,%d",
71 logType(4,
strprintf(
"ButtonPress: %u,%u %d,%d",
72 xEvent.xbutton.button,
76 logType(5,
strprintf(
"ButtonRelease: %u,%u %d,%d",
77 xEvent.xbutton.button,
81 logType(6,
strprintf(
"MotionNotify: %d,%u %d,%d",
86 logType(7,
strprintf(
"EnterNotify: %d,%d,%d,%u, %d,%d",
87 xEvent.xcrossing.mode,
88 xEvent.xcrossing.detail,
89 xEvent.xcrossing.focus ? 1 : 0,
90 xEvent.xcrossing.state,
93 logType(8,
strprintf(
"LeaveNotify: %d,%d,%d,%u, %d,%d",
94 xEvent.xcrossing.mode,
95 xEvent.xcrossing.detail,
96 xEvent.xcrossing.focus ? 1 : 0,
97 xEvent.xcrossing.state,
102 xEvent.xfocus.detail));
105 xEvent.xfocus.detail));
107 typeStr =
"KeymapNotify: ";
108 for (
int f = 0; f < 32; f ++)
111 CAST_U32(xEvent.xkeymap.key_vector[f])));
114 logType(12,
strprintf(
"Expose: %d,%d,%d,%d %d",
117 xEvent.xexpose.width,
118 xEvent.xexpose.height,
119 xEvent.xexpose.count));
120 logType(13,
strprintf(
"GraphicsExpose: %d,%d,%d,%d %d,%d,%d",
121 xEvent.xgraphicsexpose.x,
122 xEvent.xgraphicsexpose.y,
123 xEvent.xgraphicsexpose.width,
124 xEvent.xgraphicsexpose.height,
125 xEvent.xgraphicsexpose.count,
126 xEvent.xgraphicsexpose.major_code,
127 xEvent.xgraphicsexpose.minor_code));
129 xEvent.xnoexpose.major_code,
130 xEvent.xnoexpose.minor_code));
131 logType(15,
strprintf(
"VisibilityNotify: %d",
132 xEvent.xvisibility.state));
133 logType(16,
strprintf(
"CreateNotify: %d,%d,%d,%d %d,%d",
134 xEvent.xcreatewindow.x,
135 xEvent.xcreatewindow.y,
136 xEvent.xcreatewindow.width,
137 xEvent.xcreatewindow.height,
138 xEvent.xcreatewindow.border_width,
139 xEvent.xcreatewindow.override_redirect ? 1 : 0));
140 logType(17,
"DestroyNotify");
142 xEvent.xunmap.from_configure ? 1: 0));
144 xEvent.xmap.override_redirect ? 1 : 0));
145 logType(20,
"MapRequest");
146 logType(21,
strprintf(
"ReparentNotify: %d,%d, %d",
149 xEvent.xreparent.override_redirect ? 1 : 0));
150 logType(22,
strprintf(
"ConfigureNotify: %d,%d %d,%d %d,%d",
153 xEvent.xconfigure.width,
154 xEvent.xconfigure.height,
155 xEvent.xconfigure.border_width,
156 xEvent.xconfigure.override_redirect ? 1 : 0));
157 logType(23,
strprintf(
"ConfigureRequest: %d,%d %d,%d %d,%d",
158 xEvent.xconfigurerequest.x,
159 xEvent.xconfigurerequest.y,
160 xEvent.xconfigurerequest.width,
161 xEvent.xconfigurerequest.height,
162 xEvent.xconfigurerequest.border_width,
163 xEvent.xconfigurerequest.detail));
164 logType(24,
strprintf(
"GravityNotify: %d,%d",
167 logType(25,
strprintf(
"ResizeRequest: %d,%d",
168 xEvent.xresizerequest.width,
169 xEvent.xresizerequest.height));
170 logType(26,
strprintf(
"CirculateNotify: %d",
171 xEvent.xcirculate.place));
172 logType(27,
strprintf(
"CirculateRequest: %d",
173 xEvent.xcirculaterequest.place));
174 logType(28,
strprintf(
"PropertyNotify: %u, %d",
176 xEvent.xproperty.state));
177 logType(29,
strprintf(
"SelectionClear: %u",
178 CAST_U32(xEvent.xselectionclear.selection)));
179 logType(30,
strprintf(
"SelectionRequest: %u,%u,%u",
180 CAST_U32(xEvent.xselectionrequest.selection),
181 CAST_U32(xEvent.xselectionrequest.target),
182 CAST_U32(xEvent.xselectionrequest.property)));
183 logType(31,
strprintf(
"SelectionNotify: %u,%u,%u",
184 CAST_U32(xEvent.xselection.selection),
186 CAST_U32(xEvent.xselection.property)));
187 logType(32,
strprintf(
"ColormapNotify: %u,%d",
188 CAST_U32(xEvent.xcolormap.colormap),
190 xEvent.xcolormap.state));
192 typeStr =
strprintf(
"ClientMessage: %u,%d (",
193 CAST_U32(xEvent.xclient.message_type),
194 xEvent.xclient.format);
195 for (
int f = 0; f < 20; f ++)
196 typeStr.append(
strprintf(
"%c", xEvent.xclient.data.b[f]));
199 logType(34,
strprintf(
"MappingNotify: %d,%d,%d",
200 xEvent.xmapping.request,
201 xEvent.xmapping.first_keycode,
202 xEvent.xmapping.count));
203 logType(35,
"GenericEvent");
205 typeStr =
strprintf(
"Unknown: %d", type);
209 logger->
log(
"event: SDL_SYSWMEVENT: X11: %s",
void log(const char *const log_text,...)
std::string strprintf(const char *const format,...)