2 /* This file is part of the KDE project
4 * Copyright (C) 2002 Till Krech <till@snafu.de>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
22 #include "kxeventutil.h"
26 #include <X11/Xutil.h>
27 #include <X11/Xatom.h>
28 #include <QtCore/QString>
29 #include <QtCore/QStringList>
31 QString
KXEventUtil::getXAnyEventInfo(XEvent
*xevent
) {
32 XAnyEvent
*e
= &xevent
->xany
;
33 QString
winname("window");
40 case ConfigureRequest
:
52 QString
s("serial=%1 send_event=%2 display=0x%3 %4=%5");
56 .arg((long)e
->display
, 0, 16)
60 QString
KXEventUtil::getXButtonEventInfo(XEvent
*xevent
) {
61 XButtonEvent
*e
= &xevent
->xbutton
;
62 QString
s("root=%1 subwindow=%2 time=%3 x=%4 y=%5 x_root=%6 y_root=%7 state=%8 button=%9");
63 QString
t(" same_screen=%1");
74 +t
.arg(e
->same_screen
);
77 QString
KXEventUtil::getXKeyEventInfo(XEvent
*xevent
) {
78 XKeyEvent
*e
= &xevent
->xkey
;
79 QString
s("root=%1 subwindow=%2 time=%3 x=%4 y=%5 x_root=%6 y_root=%7 state=%8 keycode=%9");
80 QString
t(" same_screen=%1");
91 +t
.arg(e
->same_screen
);
94 QString
KXEventUtil::getXMotionEventInfo(XEvent
*xevent
) {
95 XMotionEvent
*e
= &xevent
->xmotion
;
96 QString
s("root=%1 subwindow=%2 time=%3 x=%4 y=%5 x_root=%6 y_root=%7 state=%8 is_hint=%9");
97 QString
t(" same_screen=%1");
108 +t
.arg(e
->same_screen
);
110 QString
KXEventUtil::getXCrossingEventInfo(XEvent
*xevent
) {
111 XCrossingEvent
*e
= &xevent
->xcrossing
;
114 case NotifyNormal
: ms
= "NotifyNormal"; break;
115 case NotifyGrab
: ms
= "NotifyGrab"; break;
116 case NotifyUngrab
: ms
= "NotifyUngrab"; break;
120 case NotifyAncestor
: ds
= "NotifyAncestor"; break;
121 case NotifyVirtual
: ds
= "NotifyVirtual"; break;
122 case NotifyInferior
: ds
= "NotifyInferior"; break;
123 case NotifyNonlinear
: ds
= "NotifyNonlinear"; break;
124 case NotifyNonlinearVirtual
: ds
= "NotifyNonlinearVirtual"; break;
128 QString
s("root=%1 subwindow=%2 time=%3 x=%4 y=%5 x_root=%6 y_root=%7 mode=%8=%9 ");
129 QString
t("detail=%1=%2 same_screen=%3 focus=%4 state=%5");
138 .arg(e
->mode
).arg(ms
)
140 t
.arg(e
->detail
).arg(ds
)
145 QString
KXEventUtil::getXFocusChangeEventInfo(XEvent
*xevent
) {
146 XFocusChangeEvent
*e
= &xevent
->xfocus
;
147 QString
s("mode=%1 detail=%2");
152 QString
KXEventUtil::getXExposeEventInfo(XEvent
*xevent
) {
153 XExposeEvent
*e
= &xevent
->xexpose
;
154 QString
s("x=%1 y=%2 width=%3 height=%4 count=%5");
165 QString
KXEventUtil::getXGraphicsExposeEventInfo(XEvent
*xevent
) {
166 XGraphicsExposeEvent
*e
= &xevent
->xgraphicsexpose
;
167 QString
s("x=%1 y=%2 width=%3 height=%4 count=%5 major_code=%6 minor_code=%7");
177 QString
KXEventUtil::getXNoExposeEventInfo(XEvent
*xevent
) {
178 XNoExposeEvent
*e
= &xevent
->xnoexpose
;
179 QString
s("major_code=%1 minor_code=%2");
186 QString
KXEventUtil::getXCreateWindowEventInfo(XEvent
*xevent
) {
187 XCreateWindowEvent
*e
= &xevent
->xcreatewindow
;
188 QString
s("window=%1 x=%2 y=%3 width=%4 height=%5 border_width=%6 override_redirect=%7");
195 .arg(e
->border_width
)
196 .arg(e
->override_redirect
);
199 QString
KXEventUtil::getXDestroyWindowEventInfo(XEvent
*xevent
) {
200 XDestroyWindowEvent
*e
= &xevent
->xdestroywindow
;
201 QString
s("window=%1");
205 QString
KXEventUtil::getXMapEventInfo(XEvent
*xevent
) {
206 XMapEvent
*e
= &xevent
->xmap
;
207 QString
s("window=%1 override_redirect=%2");
210 .arg(e
->override_redirect
);
212 QString
KXEventUtil::getXMappingEventInfo(XEvent
*xevent
) {
213 XMappingEvent
*e
= &xevent
->xmapping
;
214 QString
s("request=%1 first_keycode=%2 count=%3");
217 .arg(e
->first_keycode
)
220 QString
KXEventUtil::getXReparentEventInfo(XEvent
*xevent
) {
221 XReparentEvent
*e
= &xevent
->xreparent
;
222 QString
s("window=%1 parent=%2 x=%3 y=%4");
229 QString
KXEventUtil::getXUnmapEventInfo(XEvent
*xevent
) {
230 XUnmapEvent
*e
= &xevent
->xunmap
;
231 QString
s("window=%1 from_configure=%2");
234 .arg(e
->from_configure
);
237 QString
KXEventUtil::getXConfigureEventInfo(XEvent
*xevent
) {
238 XConfigureEvent
*e
= &xevent
->xconfigure
;
239 QString
s("window=%1 x=%2 y=%2 width=%3 height=%4 border_width=%5 above=%6 override_redirect=%7");
243 .arg(e
->width
).arg(e
->height
)
244 .arg(e
->border_width
)
246 .arg(e
->override_redirect
);
249 QString
KXEventUtil::getXConfigureRequestEventInfo(XEvent
*xevent
) {
250 XConfigureRequestEvent
*e
= &xevent
->xconfigurerequest
;
251 unsigned vm
= e
->value_mask
;
253 if (vm
& CWX
) vml
.append("CWX");
254 if (vm
& CWY
) vml
.append("CWY");
255 if (vm
& CWWidth
) vml
.append("CWWidth");
256 if (vm
& CWHeight
) vml
.append("CWHeight");
257 if (vm
& CWBorderWidth
) vml
.append("CWBorderWidth");
258 if (vm
& CWSibling
) vml
.append("CWSibling");
259 if (vm
& CWStackMode
) vml
.append("CWStackMode");
260 QString vms
= vml
.join("|");
261 QString
s("window=%1 x=%2 y=%2 width=%3 height=%4 border_width=%5 above=%6 detail=%7 value_mask=0x%8=%9");
265 .arg(e
->width
).arg(e
->height
)
266 .arg(e
->border_width
)
269 .arg(e
->value_mask
, 0, 16)
272 QString
KXEventUtil::getX11EventInfo( XEvent
* e
)
274 QString anyInfo
= getXAnyEventInfo(e
);
281 info
= getXKeyEventInfo(e
);
285 info
= getXKeyEventInfo(e
);
289 info
= getXButtonEventInfo(e
);
293 info
= getXButtonEventInfo(e
);
297 info
= getXMotionEventInfo(e
);
301 info
= getXCrossingEventInfo(e
);
305 info
= getXCrossingEventInfo(e
);
309 info
= getXFocusChangeEventInfo(e
);
313 info
= getXFocusChangeEventInfo(e
);
320 info
= getXExposeEventInfo(e
);
323 s
= "GraphicsExpose";
324 info
= getXGraphicsExposeEventInfo(e
);
327 info
= getXNoExposeEventInfo(e
);
330 case VisibilityNotify
:
331 s
= "VisibilityNotify";
335 info
= getXCreateWindowEventInfo(e
);
339 info
= getXDestroyWindowEventInfo(e
);
343 info
= getXUnmapEventInfo(e
);
347 info
= getXMapEventInfo(e
);
353 s
= "ReparentNotify";
354 info
= getXReparentEventInfo(e
);
356 case ConfigureNotify
:
357 s
= "ConfigureNotify";
358 info
= getXConfigureEventInfo(e
);
360 case ConfigureRequest
:
361 s
= "ConfigureRequest";
362 info
= getXConfigureRequestEventInfo(e
);
370 case CirculateNotify
:
371 s
= "CirculateNofify";
373 case CirculateRequest
:
374 s
= "CirculateRequest";
377 s
= "PropertyNotify";
380 s
= "SelectionClear";
382 case SelectionRequest
:
383 s
= "SelectionRequest";
385 case SelectionNotify
:
386 s
= "SelectionNotify";
389 s
= "ColormapNotify";
396 info
= getXMappingEventInfo(e
);
407 return s
+ ' ' + anyInfo
+ ' ' + info
;