You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
408 lines
12 KiB
408 lines
12 KiB
15 years ago
|
/* This file is part of the KDE project
|
||
|
*
|
||
|
* Copyright (C) 2002 Till Krech <till@snafu.de>
|
||
|
*
|
||
|
* This library is free software; you can redistribute it and/or
|
||
|
* modify it under the terms of the GNU Library General Public
|
||
|
* License as published by the Free Software Foundation; either
|
||
|
* version 2 of the License, or (at your option) any later version.
|
||
|
*
|
||
|
* This library is distributed in the hope that it will be useful,
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
|
* Library General Public License for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU Library General Public License
|
||
|
* along with this library; see the file COPYING.LIB. If not, write to
|
||
|
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||
|
* Boston, MA 02110-1301, USA.
|
||
|
*/
|
||
|
|
||
|
#include <X11/X.h>
|
||
|
#include <X11/Xlib.h>
|
||
|
#include <X11/Xutil.h>
|
||
|
#include <X11/Xatom.h>
|
||
15 years ago
|
#include <tqstring.h>
|
||
|
#include <tqstringlist.h>
|
||
15 years ago
|
|
||
|
#include "kxeventutil.h"
|
||
|
|
||
15 years ago
|
TQString KXEventUtil::getXAnyEventInfo(XEvent *xevent) {
|
||
15 years ago
|
XAnyEvent *e = &xevent->xany;
|
||
15 years ago
|
TQString winname("window");
|
||
15 years ago
|
switch (e->type) {
|
||
|
case GraphicsExpose:
|
||
|
case NoExpose:
|
||
|
winname="drawable";
|
||
|
break;
|
||
|
case CreateNotify:
|
||
|
case ConfigureRequest:
|
||
|
winname="parent";
|
||
|
break;
|
||
|
case DestroyNotify:
|
||
|
case ConfigureNotify:
|
||
|
case MapNotify:
|
||
|
case ReparentNotify:
|
||
|
case UnmapNotify:
|
||
|
winname="event";
|
||
|
default:
|
||
|
break;
|
||
|
}
|
||
15 years ago
|
TQString s("serial=%1 send_event=%2 display=0x%3 %4=%5");
|
||
15 years ago
|
return
|
||
|
s.arg(e->serial)
|
||
|
.arg(e->send_event)
|
||
|
.arg((long)e->display, 0, 16)
|
||
|
.arg(winname)
|
||
|
.arg(e->window);
|
||
|
}
|
||
15 years ago
|
TQString KXEventUtil::getXButtonEventInfo(XEvent *xevent) {
|
||
15 years ago
|
XButtonEvent *e = &xevent->xbutton;
|
||
15 years ago
|
TQString s("root=%1 subwindow=%2 time=%3 x=%4 y=%5 x_root=%6 y_root=%7 state=%8 button=%9");
|
||
|
TQString t(" same_screen=%1");
|
||
15 years ago
|
return
|
||
|
s.arg(e->root)
|
||
|
.arg(e->subwindow)
|
||
|
.arg(e->time)
|
||
|
.arg(e->x)
|
||
|
.arg(e->y)
|
||
|
.arg(e->x_root)
|
||
|
.arg(e->y_root)
|
||
|
.arg(e->state)
|
||
|
.arg(e->button)
|
||
|
+t.arg(e->same_screen);
|
||
|
}
|
||
|
|
||
15 years ago
|
TQString KXEventUtil::getXKeyEventInfo(XEvent *xevent) {
|
||
15 years ago
|
XKeyEvent *e = &xevent->xkey;
|
||
15 years ago
|
TQString s("root=%1 subwindow=%2 time=%3 x=%4 y=%5 x_root=%6 y_root=%7 state=%8 keycode=%9");
|
||
|
TQString t(" same_screen=%1");
|
||
15 years ago
|
return
|
||
|
s.arg(e->root)
|
||
|
.arg(e->subwindow)
|
||
|
.arg(e->time)
|
||
|
.arg(e->x)
|
||
|
.arg(e->y)
|
||
|
.arg(e->x_root)
|
||
|
.arg(e->y_root)
|
||
|
.arg(e->state)
|
||
|
.arg(e->keycode)
|
||
|
+t.arg(e->same_screen);
|
||
|
}
|
||
|
|
||
15 years ago
|
TQString KXEventUtil::getXMotionEventInfo(XEvent *xevent) {
|
||
15 years ago
|
XMotionEvent *e = &xevent->xmotion;
|
||
15 years ago
|
TQString s("root=%1 subwindow=%2 time=%3 x=%4 y=%5 x_root=%6 y_root=%7 state=%8 is_hint=%9");
|
||
|
TQString t(" same_screen=%1");
|
||
15 years ago
|
return
|
||
|
s.arg(e->root)
|
||
|
.arg(e->subwindow)
|
||
|
.arg(e->time)
|
||
|
.arg(e->x)
|
||
|
.arg(e->y)
|
||
|
.arg(e->x_root)
|
||
|
.arg(e->y_root)
|
||
|
.arg(e->state)
|
||
|
.arg(e->is_hint)
|
||
|
+t.arg(e->same_screen);
|
||
|
}
|
||
15 years ago
|
TQString KXEventUtil::getXCrossingEventInfo(XEvent *xevent) {
|
||
15 years ago
|
XCrossingEvent *e = &xevent->xcrossing;
|
||
15 years ago
|
TQString ms, ds;
|
||
15 years ago
|
switch (e->mode) {
|
||
|
case NotifyNormal: ms = "NotifyNormal"; break;
|
||
|
case NotifyGrab: ms = "NotifyGrab"; break;
|
||
|
case NotifyUngrab: ms = "NotifyUngrab"; break;
|
||
|
default: ms="?";
|
||
|
}
|
||
|
switch (e->detail) {
|
||
|
case NotifyAncestor: ds = "NotifyAncestor"; break;
|
||
|
case NotifyVirtual: ds = "NotifyVirtual"; break;
|
||
|
case NotifyInferior: ds = "NotifyInferior"; break;
|
||
|
case NotifyNonlinear: ds = "NotifyNonlinear"; break;
|
||
|
case NotifyNonlinearVirtual: ds = "NotifyNonlinearVirtual"; break;
|
||
|
default: ds="?";
|
||
|
}
|
||
|
|
||
15 years ago
|
TQString s("root=%1 subwindow=%2 time=%3 x=%4 y=%5 x_root=%6 y_root=%7 mode=%8=%9 ");
|
||
|
TQString t("detail=%1=%2 same_screen=%3 focus=%4 state=%5");
|
||
15 years ago
|
return
|
||
|
s.arg(e->root)
|
||
|
.arg(e->subwindow)
|
||
|
.arg(e->time)
|
||
|
.arg(e->x)
|
||
|
.arg(e->y)
|
||
|
.arg(e->x_root)
|
||
|
.arg(e->y_root)
|
||
|
.arg(e->mode).arg(ms)
|
||
|
+
|
||
|
t.arg(e->detail).arg(ds)
|
||
|
.arg(e->same_screen)
|
||
|
.arg(e->focus)
|
||
|
.arg(e->state);
|
||
|
}
|
||
15 years ago
|
TQString KXEventUtil::getXFocusChangeEventInfo(XEvent *xevent) {
|
||
15 years ago
|
XFocusChangeEvent *e = &xevent->xfocus;
|
||
15 years ago
|
TQString s("mode=%1 detail=%2");
|
||
15 years ago
|
return
|
||
|
s.arg(e->mode)
|
||
|
.arg(e->detail);
|
||
|
}
|
||
15 years ago
|
TQString KXEventUtil::getXExposeEventInfo(XEvent *xevent) {
|
||
15 years ago
|
XExposeEvent *e = &xevent->xexpose;
|
||
15 years ago
|
TQString s("x=%1 y=%2 width=%3 height=%4 count=%5");
|
||
15 years ago
|
return
|
||
|
s.arg(e->x)
|
||
|
.arg(e->y)
|
||
|
.arg(e->width)
|
||
|
.arg(e->height)
|
||
|
.arg(e->count);
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
15 years ago
|
TQString KXEventUtil::getXGraphicsExposeEventInfo(XEvent *xevent) {
|
||
15 years ago
|
XGraphicsExposeEvent *e = &xevent->xgraphicsexpose;
|
||
15 years ago
|
TQString s("x=%1 y=%2 width=%3 height=%4 count=%5 major_code=%6 minor_code=%7");
|
||
15 years ago
|
return
|
||
|
s.arg(e->x)
|
||
|
.arg(e->y)
|
||
|
.arg(e->width)
|
||
|
.arg(e->height)
|
||
|
.arg(e->count)
|
||
|
.arg(e->major_code)
|
||
|
.arg(e->minor_code);
|
||
|
}
|
||
15 years ago
|
TQString KXEventUtil::getXNoExposeEventInfo(XEvent *xevent) {
|
||
15 years ago
|
XNoExposeEvent *e = &xevent->xnoexpose;
|
||
15 years ago
|
TQString s("major_code=%1 minor_code=%2");
|
||
15 years ago
|
return
|
||
|
s.arg(e->major_code)
|
||
|
.arg(e->minor_code);
|
||
|
}
|
||
|
|
||
|
|
||
15 years ago
|
TQString KXEventUtil::getXCreateWindowEventInfo(XEvent *xevent) {
|
||
15 years ago
|
XCreateWindowEvent *e = &xevent->xcreatewindow;
|
||
15 years ago
|
TQString s("window=%1 x=%2 y=%3 width=%4 height=%5 border_width=%6 override_redirect=%7");
|
||
15 years ago
|
return
|
||
|
s.arg(e->window)
|
||
|
.arg(e->x)
|
||
|
.arg(e->y)
|
||
|
.arg(e->width)
|
||
|
.arg(e->height)
|
||
|
.arg(e->border_width)
|
||
|
.arg(e->override_redirect);
|
||
|
}
|
||
|
|
||
15 years ago
|
TQString KXEventUtil::getXDestroyWindowEventInfo(XEvent *xevent) {
|
||
15 years ago
|
XDestroyWindowEvent *e = &xevent->xdestroywindow;
|
||
15 years ago
|
TQString s("window=%1");
|
||
15 years ago
|
return
|
||
|
s.arg(e->window);
|
||
|
}
|
||
15 years ago
|
TQString KXEventUtil::getXMapEventInfo(XEvent *xevent) {
|
||
15 years ago
|
XMapEvent *e = &xevent->xmap;
|
||
15 years ago
|
TQString s("window=%1 override_redirect=%2");
|
||
15 years ago
|
return
|
||
|
s.arg(e->window)
|
||
|
.arg(e->override_redirect);
|
||
|
}
|
||
15 years ago
|
TQString KXEventUtil::getXMappingEventInfo(XEvent *xevent) {
|
||
15 years ago
|
XMappingEvent *e = &xevent->xmapping;
|
||
15 years ago
|
TQString s("request=%1 first_keycode=%2 count=%3");
|
||
15 years ago
|
return
|
||
|
s.arg(e->request)
|
||
|
.arg(e->first_keycode)
|
||
|
.arg(e->count);
|
||
|
}
|
||
15 years ago
|
TQString KXEventUtil::getXReparentEventInfo(XEvent *xevent) {
|
||
15 years ago
|
XReparentEvent *e = &xevent->xreparent;
|
||
15 years ago
|
TQString s("window=%1 parent=%2 x=%3 y=%4");
|
||
15 years ago
|
return
|
||
|
s.arg(e->window)
|
||
|
.arg(e->parent)
|
||
|
.arg(e->x)
|
||
|
.arg(e->y);
|
||
|
}
|
||
15 years ago
|
TQString KXEventUtil::getXUnmapEventInfo(XEvent *xevent) {
|
||
15 years ago
|
XUnmapEvent *e = &xevent->xunmap;
|
||
15 years ago
|
TQString s("window=%1 from_configure=%2");
|
||
15 years ago
|
return
|
||
|
s.arg(e->window)
|
||
|
.arg(e->from_configure);
|
||
|
}
|
||
|
|
||
15 years ago
|
TQString KXEventUtil::getXConfigureEventInfo(XEvent *xevent) {
|
||
15 years ago
|
XConfigureEvent *e = &xevent->xconfigure;
|
||
15 years ago
|
TQString s("window=%1 x=%2 y=%2 width=%3 height=%4 border_width=%5 above=%6 override_redirect=%7");
|
||
15 years ago
|
return
|
||
|
s.arg(e->window)
|
||
|
.arg(e->x).arg(e->y)
|
||
|
.arg(e->width).arg(e->height)
|
||
|
.arg(e->border_width)
|
||
|
.arg(e->above)
|
||
|
.arg(e->override_redirect);
|
||
|
}
|
||
|
|
||
15 years ago
|
TQString KXEventUtil::getXConfigureRequestEventInfo(XEvent *xevent) {
|
||
15 years ago
|
XConfigureRequestEvent *e = &xevent->xconfigurerequest;
|
||
14 years ago
|
unsigned vm = e->value_mask;
|
||
15 years ago
|
TQStringList vml;
|
||
15 years ago
|
if (vm & CWX) vml.append("CWX");
|
||
|
if (vm & CWY) vml.append("CWY");
|
||
|
if (vm & CWWidth) vml.append("CWWidth");
|
||
|
if (vm & CWHeight) vml.append("CWHeight");
|
||
|
if (vm & CWBorderWidth) vml.append("CWBorderWidth");
|
||
|
if (vm & CWSibling) vml.append("CWSibling");
|
||
|
if (vm & CWStackMode) vml.append("CWStackMode");
|
||
15 years ago
|
TQString vms = vml.join("|");
|
||
14 years ago
|
TQString s("window=%1 x=%2 y=%2 width=%3 height=%4 border_width=%5 above=%6 detail=%7 value_mask=0x%8=%9");
|
||
15 years ago
|
return
|
||
|
s.arg(e->window)
|
||
|
.arg(e->x).arg(e->y)
|
||
|
.arg(e->width).arg(e->height)
|
||
|
.arg(e->border_width)
|
||
|
.arg(e->above)
|
||
|
.arg(e->detail)
|
||
14 years ago
|
.arg(e->value_mask, 0, 16)
|
||
15 years ago
|
.arg(vms);
|
||
|
}
|
||
15 years ago
|
TQString KXEventUtil::getX11EventInfo( XEvent* e )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQString anyInfo = getXAnyEventInfo(e);
|
||
|
TQString info = "";
|
||
|
TQString s;
|
||
15 years ago
|
switch( e->type )
|
||
|
{
|
||
|
case KeyPress:
|
||
|
s = "KeyPress";
|
||
|
info = getXKeyEventInfo(e);
|
||
|
break;
|
||
|
case KeyRelease:
|
||
|
s = "KeyRelease";
|
||
|
info = getXKeyEventInfo(e);
|
||
|
break;
|
||
|
case ButtonPress:
|
||
|
s = "ButtonPress";
|
||
|
info = getXButtonEventInfo(e);
|
||
|
break;
|
||
|
case ButtonRelease:
|
||
|
s = "ButtonRelease";
|
||
|
info = getXButtonEventInfo(e);
|
||
|
break;
|
||
|
case MotionNotify:
|
||
|
s = "MotionNotify";
|
||
|
info = getXMotionEventInfo(e);
|
||
|
break;
|
||
|
case EnterNotify:
|
||
|
s = "EnterNotify";
|
||
|
info = getXCrossingEventInfo(e);
|
||
|
break;
|
||
|
case LeaveNotify:
|
||
|
s = "LeaveNotify";
|
||
|
info = getXCrossingEventInfo(e);
|
||
|
break;
|
||
|
case FocusIn:
|
||
|
s = "FocusIn";
|
||
|
info = getXFocusChangeEventInfo(e);
|
||
|
break;
|
||
|
case FocusOut:
|
||
|
s = "FocusOut";
|
||
|
info = getXFocusChangeEventInfo(e);
|
||
|
break;
|
||
|
case KeymapNotify:
|
||
|
s = "KeymapNotify";
|
||
|
break;
|
||
|
case Expose:
|
||
|
s = "Expose";
|
||
|
info = getXExposeEventInfo(e);
|
||
|
break;
|
||
|
case GraphicsExpose:
|
||
|
s = "GraphicsExpose";
|
||
|
info = getXGraphicsExposeEventInfo(e);
|
||
|
break;
|
||
|
case NoExpose:
|
||
|
info = getXNoExposeEventInfo(e);
|
||
|
s = "NoExpose";
|
||
|
break;
|
||
|
case VisibilityNotify:
|
||
|
s = "VisibilityNotify";
|
||
|
break;
|
||
|
case CreateNotify:
|
||
|
s = "CreateNotify";
|
||
|
info = getXCreateWindowEventInfo(e);
|
||
|
break;
|
||
|
case DestroyNotify:
|
||
|
s = "DestroyNotify";
|
||
|
info = getXDestroyWindowEventInfo(e);
|
||
|
break;
|
||
|
case UnmapNotify:
|
||
|
s = "UnmapNotify";
|
||
|
info = getXUnmapEventInfo(e);
|
||
|
break;
|
||
|
case MapNotify:
|
||
|
s = "MapNotify";
|
||
|
info = getXMapEventInfo(e);
|
||
|
break;
|
||
|
case MapRequest:
|
||
|
s = "MapRequest";
|
||
|
break;
|
||
|
case ReparentNotify:
|
||
|
s = "ReparentNotify";
|
||
|
info = getXReparentEventInfo(e);
|
||
|
break;
|
||
|
case ConfigureNotify:
|
||
|
s = "ConfigureNotify";
|
||
|
info = getXConfigureEventInfo(e);
|
||
|
break;
|
||
|
case ConfigureRequest:
|
||
|
s = "ConfigureRequest";
|
||
|
info = getXConfigureRequestEventInfo(e);
|
||
|
break;
|
||
|
case GravityNotify:
|
||
|
s = "GravityNotify";
|
||
|
break;
|
||
|
case ResizeRequest:
|
||
|
s = "ResizeRequest";
|
||
|
break;
|
||
|
case CirculateNotify:
|
||
|
s = "CirculateNofify";
|
||
|
break;
|
||
|
case CirculateRequest:
|
||
|
s = "CirculateRequest";
|
||
|
break;
|
||
|
case PropertyNotify:
|
||
|
s = "PropertyNotify";
|
||
|
break;
|
||
|
case SelectionClear:
|
||
|
s = "SelectionClear";
|
||
|
break;
|
||
|
case SelectionRequest:
|
||
|
s = "SelectionRequest";
|
||
|
break;
|
||
|
case SelectionNotify:
|
||
|
s = "SelectionNotify";
|
||
|
break;
|
||
|
case ColormapNotify:
|
||
|
s = "ColormapNotify";
|
||
|
break;
|
||
|
case ClientMessage:
|
||
|
s = "ClientMessage";
|
||
|
break;
|
||
|
case MappingNotify:
|
||
|
s = "MappingNotify";
|
||
|
info = getXMappingEventInfo(e);
|
||
|
break;
|
||
|
case LASTEvent:
|
||
|
s = "LASTEvent";
|
||
|
break;
|
||
|
|
||
|
default:
|
||
|
s = "Undefined";
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
return s + " " + anyInfo + " " + info;
|
||
|
}
|