don't discard iframe children.
[kdelibs.git] / khtml / java / kxeventutil.cpp
blob3d98402dcb5acb58bded53715fdab458d9a8def8
1 // -*- c++ -*-
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"
24 #include <X11/X.h>
25 #include <X11/Xlib.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");
34 switch (e->type) {
35 case GraphicsExpose:
36 case NoExpose:
37 winname="drawable";
38 break;
39 case CreateNotify:
40 case ConfigureRequest:
41 winname="parent";
42 break;
43 case DestroyNotify:
44 case ConfigureNotify:
45 case MapNotify:
46 case ReparentNotify:
47 case UnmapNotify:
48 winname="event";
49 default:
50 break;
52 QString s("serial=%1 send_event=%2 display=0x%3 %4=%5");
53 return
54 s.arg(e->serial)
55 .arg(e->send_event)
56 .arg((long)e->display, 0, 16)
57 .arg(winname)
58 .arg(e->window);
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");
64 return
65 s.arg(e->root)
66 .arg(e->subwindow)
67 .arg(e->time)
68 .arg(e->x)
69 .arg(e->y)
70 .arg(e->x_root)
71 .arg(e->y_root)
72 .arg(e->state)
73 .arg(e->button)
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");
81 return
82 s.arg(e->root)
83 .arg(e->subwindow)
84 .arg(e->time)
85 .arg(e->x)
86 .arg(e->y)
87 .arg(e->x_root)
88 .arg(e->y_root)
89 .arg(e->state)
90 .arg(e->keycode)
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");
98 return
99 s.arg(e->root)
100 .arg(e->subwindow)
101 .arg(e->time)
102 .arg(e->x)
103 .arg(e->y)
104 .arg(e->x_root)
105 .arg(e->y_root)
106 .arg(e->state)
107 .arg(e->is_hint)
108 +t.arg(e->same_screen);
110 QString KXEventUtil::getXCrossingEventInfo(XEvent *xevent) {
111 XCrossingEvent *e = &xevent->xcrossing;
112 QString ms, ds;
113 switch (e->mode) {
114 case NotifyNormal: ms = "NotifyNormal"; break;
115 case NotifyGrab: ms = "NotifyGrab"; break;
116 case NotifyUngrab: ms = "NotifyUngrab"; break;
117 default: ms="?";
119 switch (e->detail) {
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;
125 default: ds="?";
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");
130 return
131 s.arg(e->root)
132 .arg(e->subwindow)
133 .arg(e->time)
134 .arg(e->x)
135 .arg(e->y)
136 .arg(e->x_root)
137 .arg(e->y_root)
138 .arg(e->mode).arg(ms)
140 t.arg(e->detail).arg(ds)
141 .arg(e->same_screen)
142 .arg(e->focus)
143 .arg(e->state);
145 QString KXEventUtil::getXFocusChangeEventInfo(XEvent *xevent) {
146 XFocusChangeEvent *e = &xevent->xfocus;
147 QString s("mode=%1 detail=%2");
148 return
149 s.arg(e->mode)
150 .arg(e->detail);
152 QString KXEventUtil::getXExposeEventInfo(XEvent *xevent) {
153 XExposeEvent *e = &xevent->xexpose;
154 QString s("x=%1 y=%2 width=%3 height=%4 count=%5");
155 return
156 s.arg(e->x)
157 .arg(e->y)
158 .arg(e->width)
159 .arg(e->height)
160 .arg(e->count);
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");
168 return
169 s.arg(e->x)
170 .arg(e->y)
171 .arg(e->width)
172 .arg(e->height)
173 .arg(e->count)
174 .arg(e->major_code)
175 .arg(e->minor_code);
177 QString KXEventUtil::getXNoExposeEventInfo(XEvent *xevent) {
178 XNoExposeEvent *e = &xevent->xnoexpose;
179 QString s("major_code=%1 minor_code=%2");
180 return
181 s.arg(e->major_code)
182 .arg(e->minor_code);
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");
189 return
190 s.arg(e->window)
191 .arg(e->x)
192 .arg(e->y)
193 .arg(e->width)
194 .arg(e->height)
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");
202 return
203 s.arg(e->window);
205 QString KXEventUtil::getXMapEventInfo(XEvent *xevent) {
206 XMapEvent *e = &xevent->xmap;
207 QString s("window=%1 override_redirect=%2");
208 return
209 s.arg(e->window)
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");
215 return
216 s.arg(e->request)
217 .arg(e->first_keycode)
218 .arg(e->count);
220 QString KXEventUtil::getXReparentEventInfo(XEvent *xevent) {
221 XReparentEvent *e = &xevent->xreparent;
222 QString s("window=%1 parent=%2 x=%3 y=%4");
223 return
224 s.arg(e->window)
225 .arg(e->parent)
226 .arg(e->x)
227 .arg(e->y);
229 QString KXEventUtil::getXUnmapEventInfo(XEvent *xevent) {
230 XUnmapEvent *e = &xevent->xunmap;
231 QString s("window=%1 from_configure=%2");
232 return
233 s.arg(e->window)
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");
240 return
241 s.arg(e->window)
242 .arg(e->x).arg(e->y)
243 .arg(e->width).arg(e->height)
244 .arg(e->border_width)
245 .arg(e->above)
246 .arg(e->override_redirect);
249 QString KXEventUtil::getXConfigureRequestEventInfo(XEvent *xevent) {
250 XConfigureRequestEvent *e = &xevent->xconfigurerequest;
251 unsigned vm = e->value_mask;
252 QStringList vml;
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");
262 return
263 s.arg(e->window)
264 .arg(e->x).arg(e->y)
265 .arg(e->width).arg(e->height)
266 .arg(e->border_width)
267 .arg(e->above)
268 .arg(e->detail)
269 .arg(e->value_mask, 0, 16)
270 .arg(vms);
272 QString KXEventUtil::getX11EventInfo( XEvent* e )
274 QString anyInfo = getXAnyEventInfo(e);
275 QString info = "";
276 QString s;
277 switch( e->type )
279 case KeyPress:
280 s = "KeyPress";
281 info = getXKeyEventInfo(e);
282 break;
283 case KeyRelease:
284 s = "KeyRelease";
285 info = getXKeyEventInfo(e);
286 break;
287 case ButtonPress:
288 s = "ButtonPress";
289 info = getXButtonEventInfo(e);
290 break;
291 case ButtonRelease:
292 s = "ButtonRelease";
293 info = getXButtonEventInfo(e);
294 break;
295 case MotionNotify:
296 s = "MotionNotify";
297 info = getXMotionEventInfo(e);
298 break;
299 case EnterNotify:
300 s = "EnterNotify";
301 info = getXCrossingEventInfo(e);
302 break;
303 case LeaveNotify:
304 s = "LeaveNotify";
305 info = getXCrossingEventInfo(e);
306 break;
307 case FocusIn:
308 s = "FocusIn";
309 info = getXFocusChangeEventInfo(e);
310 break;
311 case FocusOut:
312 s = "FocusOut";
313 info = getXFocusChangeEventInfo(e);
314 break;
315 case KeymapNotify:
316 s = "KeymapNotify";
317 break;
318 case Expose:
319 s = "Expose";
320 info = getXExposeEventInfo(e);
321 break;
322 case GraphicsExpose:
323 s = "GraphicsExpose";
324 info = getXGraphicsExposeEventInfo(e);
325 break;
326 case NoExpose:
327 info = getXNoExposeEventInfo(e);
328 s = "NoExpose";
329 break;
330 case VisibilityNotify:
331 s = "VisibilityNotify";
332 break;
333 case CreateNotify:
334 s = "CreateNotify";
335 info = getXCreateWindowEventInfo(e);
336 break;
337 case DestroyNotify:
338 s = "DestroyNotify";
339 info = getXDestroyWindowEventInfo(e);
340 break;
341 case UnmapNotify:
342 s = "UnmapNotify";
343 info = getXUnmapEventInfo(e);
344 break;
345 case MapNotify:
346 s = "MapNotify";
347 info = getXMapEventInfo(e);
348 break;
349 case MapRequest:
350 s = "MapRequest";
351 break;
352 case ReparentNotify:
353 s = "ReparentNotify";
354 info = getXReparentEventInfo(e);
355 break;
356 case ConfigureNotify:
357 s = "ConfigureNotify";
358 info = getXConfigureEventInfo(e);
359 break;
360 case ConfigureRequest:
361 s = "ConfigureRequest";
362 info = getXConfigureRequestEventInfo(e);
363 break;
364 case GravityNotify:
365 s = "GravityNotify";
366 break;
367 case ResizeRequest:
368 s = "ResizeRequest";
369 break;
370 case CirculateNotify:
371 s = "CirculateNofify";
372 break;
373 case CirculateRequest:
374 s = "CirculateRequest";
375 break;
376 case PropertyNotify:
377 s = "PropertyNotify";
378 break;
379 case SelectionClear:
380 s = "SelectionClear";
381 break;
382 case SelectionRequest:
383 s = "SelectionRequest";
384 break;
385 case SelectionNotify:
386 s = "SelectionNotify";
387 break;
388 case ColormapNotify:
389 s = "ColormapNotify";
390 break;
391 case ClientMessage:
392 s = "ClientMessage";
393 break;
394 case MappingNotify:
395 s = "MappingNotify";
396 info = getXMappingEventInfo(e);
397 break;
398 case LASTEvent:
399 s = "LASTEvent";
400 break;
402 default:
403 s = "Undefined";
404 break;
407 return s + ' ' + anyInfo + ' ' + info;