kxeventutil.cpp Source File (khtml Library)

| # khtml Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# kxeventutil.cpp

    00001 // -*- c++ -*-
    00002 /* This file is part of the KDE project
    00003  *
    00004  * Copyright (C) 2002 Till Krech <till@snafu.de>
    00005  *
    00006  * This library is free software; you can redistribute it and/or
    00007  * modify it under the terms of the GNU Library General Public
    00008  * License as published by the Free Software Foundation; either
    00009  * version 2 of the License, or (at your option) any later version.
    00010  *
    00011  * This library is distributed in the hope that it will be useful,
    00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00014  * Library General Public License for more details.
    00015  *
    00016  * You should have received a copy of the GNU Library General Public License
    00017  * along with this library; see the file COPYING.LIB.  If not, write to
    00018  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00019  * Boston, MA 02111-1307, USA.
    00020  */
    00021
    00022 #include <X11/X.h>
    00023 #include <X11/Xlib.h>
    00024 #include <X11/Xutil.h>
    00025 #include <X11/Xatom.h>
    00026 #include <qstring.h>
    00027 #include <qstringlist.h>
    00028
    00029 #include "kxeventutil.h"
    00030
    00031 QString KXEventUtil::getXAnyEventInfo(XEvent *xevent) {
    00032     XAnyEvent *e = &xevent->xany;
    00033     QString winname("window");
    00034     switch (e->type) {
    00035         case  GraphicsExpose:
    00036         case  NoExpose:
    00037             winname="drawable";
    00038             break;
    00039         case  CreateNotify:
    00040         case  ConfigureRequest:
    00041             winname="parent";
    00042             break;
    00043         case  DestroyNotify:
    00044         case  ConfigureNotify:
    00045         case  MapNotify:
    00046         case  ReparentNotify:
    00047         case  UnmapNotify:
    00048             winname="event";
    00049         default:
    00050             break;
    00051     }
    00052     QString s("serial=%1 send_event=%2 display=0x%3 %4=%5");
    00053     return
    00054      s.arg(e->serial)
    00055      .arg(e->send_event)
    00056      .arg((long)e->display, 0, 16)
    00057      .arg(winname)
    00058      .arg(e->window);
    00059 }
    00060 QString KXEventUtil::getXButtonEventInfo(XEvent *xevent) {
    00061     XButtonEvent *e = &xevent->xbutton;
    00062     QString s("root=%1 subwindow=%2 time=%3 x=%4 y=%5 x_root=%6 y_root=%7 state=%8 button=%9");
    00063     QString t(" same_screen=%1");
    00064     return
    00065      s.arg(e->root)
    00066      .arg(e->subwindow)
    00067      .arg(e->time)
    00068      .arg(e->x)
    00069      .arg(e->y)
    00070      .arg(e->x_root)
    00071      .arg(e->y_root)
    00072      .arg(e->state)
    00073      .arg(e->button)
    00074      +t.arg(e->same_screen);
    00075 }
    00076
    00077 QString KXEventUtil::getXKeyEventInfo(XEvent *xevent) {
    00078     XKeyEvent *e = &xevent->xkey;
    00079     QString s("root=%1 subwindow=%2 time=%3 x=%4 y=%5 x_root=%6 y_root=%7 state=%8 keycode=%9");
    00080     QString t(" same_screen=%1");
    00081     return
    00082      s.arg(e->root)
    00083      .arg(e->subwindow)
    00084      .arg(e->time)
    00085      .arg(e->x)
    00086      .arg(e->y)
    00087      .arg(e->x_root)
    00088      .arg(e->y_root)
    00089      .arg(e->state)
    00090      .arg(e->keycode)
    00091      +t.arg(e->same_screen);
    00092 }
    00093
    00094 QString KXEventUtil::getXMotionEventInfo(XEvent *xevent) {
    00095     XMotionEvent *e = &xevent->xmotion;
    00096     QString s("root=%1 subwindow=%2 time=%3 x=%4 y=%5 x_root=%6 y_root=%7 state=%8 is_hint=%9");
    00097     QString t(" same_screen=%1");
    00098     return
    00099      s.arg(e->root)
    00100      .arg(e->subwindow)
    00101      .arg(e->time)
    00102      .arg(e->x)
    00103      .arg(e->y)
    00104      .arg(e->x_root)
    00105      .arg(e->y_root)
    00106      .arg(e->state)
    00107      .arg(e->is_hint)
    00108      +t.arg(e->same_screen);
    00109 }
    00110 QString KXEventUtil::getXCrossingEventInfo(XEvent *xevent) {
    00111     XCrossingEvent *e = &xevent->xcrossing;
    00112     QString ms, ds;
    00113     switch (e->mode) {
    00114         case NotifyNormal: ms = "NotifyNormal"; break;
    00115         case NotifyGrab: ms = "NotifyGrab"; break;
    00116         case NotifyUngrab: ms = "NotifyUngrab"; break;
    00117         default: ms="?";
    00118     }
    00119     switch (e->detail) {
    00120         case NotifyAncestor: ds = "NotifyAncestor"; break;
    00121         case NotifyVirtual: ds = "NotifyVirtual"; break;
    00122         case NotifyInferior: ds = "NotifyInferior"; break;
    00123         case NotifyNonlinear: ds = "NotifyNonlinear"; break;
    00124         case NotifyNonlinearVirtual: ds = "NotifyNonlinearVirtual"; break;
    00125         default: ds="?";
    00126     }
    00127
    00128     QString s("root=%1 subwindow=%2 time=%3 x=%4 y=%5 x_root=%6 y_root=%7 mode=%8=%9 ");
    00129     QString t("detail=%1=%2 same_screen=%3 focus=%4 state=%5");
    00130     return
    00131      s.arg(e->root)
    00132      .arg(e->subwindow)
    00133      .arg(e->time)
    00134      .arg(e->x)
    00135      .arg(e->y)
    00136      .arg(e->x_root)
    00137      .arg(e->y_root)
    00138      .arg(e->mode).arg(ms)
    00139      +
    00140      t.arg(e->detail).arg(ds)
    00141      .arg(e->same_screen)
    00142      .arg(e->focus)
    00143      .arg(e->state);
    00144 }
    00145 QString KXEventUtil::getXFocusChangeEventInfo(XEvent *xevent) {
    00146     XFocusChangeEvent *e = &xevent->xfocus;
    00147     QString s("mode=%1 detail=%2");
    00148     return
    00149      s.arg(e->mode)
    00150      .arg(e->detail);
    00151 }
    00152 QString KXEventUtil::getXExposeEventInfo(XEvent *xevent) {
    00153     XExposeEvent *e = &xevent->xexpose;
    00154     QString s("x=%1 y=%2 width=%3 height=%4 count=%5");
    00155     return
    00156      s.arg(e->x)
    00157      .arg(e->y)
    00158      .arg(e->width)
    00159      .arg(e->height)
    00160      .arg(e->count);
    00161 }
    00162
    00163
    00164
    00165 QString KXEventUtil::getXGraphicsExposeEventInfo(XEvent *xevent) {
    00166     XGraphicsExposeEvent *e = &xevent->xgraphicsexpose;
    00167     QString s("x=%1 y=%2 width=%3 height=%4 count=%5 major_code=%6 minor_code=%7");
    00168     return
    00169      s.arg(e->x)
    00170      .arg(e->y)
    00171      .arg(e->width)
    00172      .arg(e->height)
    00173      .arg(e->count)
    00174      .arg(e->major_code)
    00175      .arg(e->minor_code);
    00176 }
    00177 QString KXEventUtil::getXNoExposeEventInfo(XEvent *xevent) {
    00178     XNoExposeEvent *e = &xevent->xnoexpose;
    00179     QString s("major_code=%1 minor_code=%2");
    00180     return
    00181      s.arg(e->major_code)
    00182      .arg(e->minor_code);
    00183 }
    00184
    00185
    00186 QString KXEventUtil::getXCreateWindowEventInfo(XEvent *xevent) {
    00187     XCreateWindowEvent *e = &xevent->xcreatewindow;
    00188     QString s("window=%1 x=%2 y=%3 width=%4 height=%5 border_width=%6 override_redirect=%7");
    00189     return
    00190      s.arg(e->window)
    00191      .arg(e->x)
    00192      .arg(e->y)
    00193      .arg(e->width)
    00194      .arg(e->height)
    00195      .arg(e->border_width)
    00196      .arg(e->override_redirect);
    00197 }
    00198
    00199 QString KXEventUtil::getXDestroyWindowEventInfo(XEvent *xevent) {
    00200     XDestroyWindowEvent *e = &xevent->xdestroywindow;
    00201     QString s("window=%1");
    00202     return
    00203      s.arg(e->window);
    00204 }
    00205 QString KXEventUtil::getXMapEventInfo(XEvent *xevent) {
    00206     XMapEvent *e = &xevent->xmap;
    00207     QString s("window=%1 override_redirect=%2");
    00208     return
    00209      s.arg(e->window)
    00210      .arg(e->override_redirect);
    00211 }
    00212 QString KXEventUtil::getXMappingEventInfo(XEvent *xevent) {
    00213     XMappingEvent *e = &xevent->xmapping;
    00214     QString s("request=%1 first_keycode=%2 count=%3");
    00215     return
    00216      s.arg(e->request)
    00217      .arg(e->first_keycode)
    00218      .arg(e->count);
    00219 }
    00220 QString KXEventUtil::getXReparentEventInfo(XEvent *xevent) {
    00221     XReparentEvent *e = &xevent->xreparent;
    00222     QString s("window=%1 parent=%2 x=%3 y=%4");
    00223     return
    00224      s.arg(e->window)
    00225      .arg(e->parent)
    00226      .arg(e->x)
    00227      .arg(e->y);
    00228 }
    00229 QString KXEventUtil::getXUnmapEventInfo(XEvent *xevent) {
    00230     XUnmapEvent *e = &xevent->xunmap;
    00231     QString s("window=%1 from_configure=%2");
    00232     return
    00233      s.arg(e->window)
    00234      .arg(e->from_configure);
    00235 }
    00236
    00237 QString KXEventUtil::getXConfigureEventInfo(XEvent *xevent) {
    00238     XConfigureEvent *e = &xevent->xconfigure;
    00239     QString s("window=%1 x=%2 y=%2 width=%3 height=%4 border_width=%5 above=%6 override_redirect=%7");
    00240     return
    00241         s.arg(e->window)
    00242         .arg(e->x).arg(e->y)
    00243         .arg(e->width).arg(e->height)
    00244         .arg(e->border_width)
    00245         .arg(e->above)
    00246         .arg(e->override_redirect);
    00247 }
    00248
    00249 QString KXEventUtil::getXConfigureRequestEventInfo(XEvent *xevent) {
    00250     XConfigureRequestEvent *e = &xevent->xconfigurerequest;
    00251     unsigned vm = e->value_mask;
    00252     QStringList vml;
    00253     if (vm & CWX)           vml.append("CWX");
    00254     if (vm & CWY)           vml.append("CWY");
    00255     if (vm & CWWidth)       vml.append("CWWidth");
    00256     if (vm & CWHeight)      vml.append("CWHeight");
    00257     if (vm & CWBorderWidth) vml.append("CWBorderWidth");
    00258     if (vm & CWSibling)     vml.append("CWSibling");
    00259     if (vm & CWStackMode)   vml.append("CWStackMode");
    00260     QString vms = vml.join("|");
    00261     QString s("window=%1 x=%2 y=%2 width=%3 height=%4 border_width=%5 above=%6 detail=%7 value_mask=0x%8=%9");
    00262     return
    00263         s.arg(e->window)
    00264         .arg(e->x).arg(e->y)
    00265         .arg(e->width).arg(e->height)
    00266         .arg(e->border_width)
    00267         .arg(e->above)
    00268         .arg(e->detail)
    00269         .arg(e->value_mask, 0, 16)
    00270         .arg(vms);
    00271 }
    00272 QString KXEventUtil::getX11EventInfo( XEvent* e )
    00273 {
    00274     QString anyInfo = getXAnyEventInfo(e);
    00275     QString info = "";
    00276     QString s;
    00277     switch( e->type )
    00278     {
    00279         case KeyPress:
    00280             s = "KeyPress";
    00281             info = getXKeyEventInfo(e);
    00282             break;
    00283         case KeyRelease:
    00284             s = "KeyRelease";
    00285             info = getXKeyEventInfo(e);
    00286             break;
    00287         case ButtonPress:
    00288             s = "ButtonPress";
    00289             info = getXButtonEventInfo(e);
    00290             break;
    00291         case ButtonRelease:
    00292             s = "ButtonRelease";
    00293             info = getXButtonEventInfo(e);
    00294             break;
    00295         case MotionNotify:
    00296             s = "MotionNotify";
    00297             info = getXMotionEventInfo(e);
    00298             break;
    00299         case EnterNotify:
    00300             s = "EnterNotify";
    00301             info = getXCrossingEventInfo(e);
    00302             break;
    00303         case LeaveNotify:
    00304             s = "LeaveNotify";
    00305             info = getXCrossingEventInfo(e);
    00306             break;
    00307         case FocusIn:
    00308             s = "FocusIn";
    00309             info = getXFocusChangeEventInfo(e);
    00310             break;
    00311         case FocusOut:
    00312             s = "FocusOut";
    00313             info = getXFocusChangeEventInfo(e);
    00314             break;
    00315         case KeymapNotify:
    00316             s = "KeymapNotify";
    00317             break;
    00318         case Expose:
    00319             s = "Expose";
    00320             info = getXExposeEventInfo(e);
    00321             break;
    00322         case GraphicsExpose:
    00323             s = "GraphicsExpose";
    00324             info = getXGraphicsExposeEventInfo(e);
    00325             break;
    00326         case NoExpose:
    00327             info = getXNoExposeEventInfo(e);
    00328             s = "NoExpose";
    00329             break;
    00330         case VisibilityNotify:
    00331             s = "VisibilityNotify";
    00332             break;
    00333         case CreateNotify:
    00334             s = "CreateNotify";
    00335             info = getXCreateWindowEventInfo(e);
    00336             break;
    00337         case DestroyNotify:
    00338             s = "DestroyNotify";
    00339             info = getXDestroyWindowEventInfo(e);
    00340             break;
    00341         case UnmapNotify:
    00342             s = "UnmapNotify";
    00343             info = getXUnmapEventInfo(e);
    00344             break;
    00345         case MapNotify:
    00346             s = "MapNotify";
    00347             info = getXMapEventInfo(e);
    00348             break;
    00349         case MapRequest:
    00350             s = "MapRequest";
    00351             break;
    00352         case ReparentNotify:
    00353             s = "ReparentNotify";
    00354             info = getXReparentEventInfo(e);
    00355             break;
    00356         case ConfigureNotify:
    00357             s = "ConfigureNotify";
    00358             info = getXConfigureEventInfo(e);
    00359             break;
    00360         case ConfigureRequest:
    00361             s = "ConfigureRequest";
    00362             info = getXConfigureRequestEventInfo(e);
    00363             break;
    00364         case GravityNotify:
    00365             s = "GravityNotify";
    00366             break;
    00367         case ResizeRequest:
    00368             s = "ResizeRequest";
    00369             break;
    00370         case CirculateNotify:
    00371             s = "CirculateNofify";
    00372             break;
    00373         case CirculateRequest:
    00374             s = "CirculateRequest";
    00375             break;
    00376         case PropertyNotify:
    00377             s = "PropertyNotify";
    00378             break;
    00379         case SelectionClear:
    00380             s = "SelectionClear";
    00381             break;
    00382         case SelectionRequest:
    00383             s = "SelectionRequest";
    00384             break;
    00385         case SelectionNotify:
    00386             s = "SelectionNotify";
    00387             break;
    00388         case ColormapNotify:
    00389             s = "ColormapNotify";
    00390             break;
    00391         case ClientMessage:
    00392             s = "ClientMessage";
    00393             break;
    00394         case MappingNotify:
    00395             s = "MappingNotify";
    00396             info = getXMappingEventInfo(e);
    00397             break;
    00398         case LASTEvent:
    00399             s = "LASTEvent";
    00400             break;
    00401
    00402         default:
    00403             s = "Undefined";
    00404             break;
    00405     }
    00406
    00407     return s + " " + anyInfo + " " + info;
    00408 }

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 13:34:28 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001