Enlightenment CVS committal

Author  : kwo
Project : e16
Module  : e

Dir     : e16/e/src


Modified Files:
        E.h events.c evhandlers.c globals.c ipc.c main.c 


Log Message:
Added some event debugging code.
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/E.h,v
retrieving revision 1.172
retrieving revision 1.173
diff -u -3 -r1.172 -r1.173
--- E.h 3 Jan 2004 23:59:06 -0000       1.172
+++ E.h 4 Jan 2004 18:07:18 -0000       1.173
@@ -1714,8 +1714,11 @@
 void                PasteMask(Display * d, Drawable w, Pixmap p, int x, int y,
                              int wd, int ht);
 
+/* events.c */
 void                CheckEvent(void);
 void                WaitEvent(void);
+void                EventDebugInit(const char *s);
+void                EventShow(const XEvent * ev);
 
 void                DetermineEwinFloat(EWin * ewin, int dx, int dy);
 void                SetEInfoOnAll(void);
@@ -2844,7 +2847,3 @@
 #ifdef HAS_XINERAMA
 extern char         xinerama_active;
 #endif
-
-#define EDBUG_CLIENT_MESSAGES  0x00000001
-#define EDBUG_PROPERTY_CHANGE  0x00000002
-extern int          debug_flags;
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/events.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -3 -r1.40 -r1.41
--- events.c    3 Jan 2004 12:29:58 -0000       1.40
+++ events.c    4 Jan 2004 18:07:18 -0000       1.41
@@ -27,6 +27,12 @@
 #include <io.h>                        /* EMX select() */
 #endif
 
+#define ENABLE_DEBUG_EVENTS 1
+
+#if ENABLE_DEBUG_EVENTS
+static int          EventDebug(unsigned int type);
+#endif
+
 char                throw_move_events_away = 0;
 
 static char         diddeskaccount = 1;
@@ -103,125 +109,6 @@
    return ok;
 }
 
-#if 0
-static void
-DebugEvent(XEvent * ev)
-{
-   EDBUG(8, "DebugEvent");
-   if (ev->type == event_base_shape + ShapeNotify)
-      fprintf(stderr, "EV: ShapeNotify:\n");
-   else
-     {
-       switch (ev->type)
-         {
-         case KeyPress:
-            fprintf(stderr, "EV: KeyPress:\n");
-            break;
-         case KeyRelease:
-            fprintf(stderr, "EV: KeyRelease:\n");
-            break;
-         case ButtonPress:
-            fprintf(stderr, "EV: ButtonPress:\n");
-            break;
-         case ButtonRelease:
-            fprintf(stderr, "EV: ButtonRelease:\n");
-            break;
-         case MotionNotify:
-            fprintf(stderr, "EV: MotionNotify:\n");
-            break;
-         case EnterNotify:
-            fprintf(stderr, "EV: EnterNotify:\n");
-            break;
-         case LeaveNotify:
-            fprintf(stderr, "EV: LeaveNotify:\n");
-            break;
-         case FocusIn:
-            fprintf(stderr, "EV: FocusIn:\n");
-            break;
-         case FocusOut:
-            fprintf(stderr, "EV: FocusOut:\n");
-            break;
-         case KeymapNotify:
-            fprintf(stderr, "EV: KeymapNotify:\n");
-            break;
-         case Expose:
-            fprintf(stderr, "EV: Expose:\n");
-            break;
-         case GraphicsExpose:
-            fprintf(stderr, "EV: GraphicsExpose:\n");
-            break;
-         case NoExpose:
-            fprintf(stderr, "EV: NoExpose:\n");
-            break;
-         case VisibilityNotify:
-            fprintf(stderr, "EV: VisibilityNotify:\n");
-            break;
-         case CreateNotify:
-            fprintf(stderr, "EV: CreateNotify:\n");
-            break;
-         case DestroyNotify:
-            fprintf(stderr, "EV: DestroyNotify:\n");
-            break;
-         case UnmapNotify:
-            fprintf(stderr, "EV: UnmapNotify:\n");
-            break;
-         case MapNotify:
-            fprintf(stderr, "EV: MapNotify:\n");
-            break;
-         case MapRequest:
-            fprintf(stderr, "EV: MapRequest:\n");
-            break;
-         case ReparentNotify:
-            fprintf(stderr, "EV: ReparentNotify:\n");
-            break;
-         case ConfigureNotify:
-            fprintf(stderr, "EV: ConfigureNotify:\n");
-            break;
-         case ConfigureRequest:
-            fprintf(stderr, "EV: ConfigureRequest:\n");
-            break;
-         case GravityNotify:
-            fprintf(stderr, "EV: GravityNotify:\n");
-            break;
-         case ResizeRequest:
-            fprintf(stderr, "EV: ResizeRequest:\n");
-            break;
-         case CirculateNotify:
-            fprintf(stderr, "EV: CirculateNotify:\n");
-            break;
-         case CirculateRequest:
-            fprintf(stderr, "EV: CirculateRequest:\n");
-            break;
-         case PropertyNotify:
-            fprintf(stderr, "EV: PropertyNotify:\n");
-            break;
-         case SelectionClear:
-            fprintf(stderr, "EV: SelectionClear:\n");
-            break;
-         case SelectionRequest:
-            fprintf(stderr, "EV: SelectionRequest:\n");
-            break;
-         case SelectionNotify:
-            fprintf(stderr, "EV: SelectionNotify:\n");
-            break;
-         case ColormapNotify:
-            fprintf(stderr, "EV: ColormapNotify:\n");
-            break;
-         case ClientMessage:
-            fprintf(stderr, "EV: ClientMessage:\n");
-            break;
-         case MappingNotify:
-            fprintf(stderr, "EV: MappingNotify:\n");
-            break;
-         default:
-            fprintf(stderr, "EV: ???\n");
-            break;
-         }
-     }
-   EDBUG_RETURN_;
-}
-#endif
-
 static void
 HKeyPress(XEvent * ev)
 {
@@ -657,6 +544,11 @@
 
    EDBUG(7, "HandleEvent");
 
+#if ENABLE_DEBUG_EVENTS
+   if (EventDebug(ev->type))
+      EventShow(ev);
+#endif
+
    if (ev->type == event_base_shape + ShapeNotify)
       HandleChildShapeChange(ev);
 
@@ -703,7 +595,7 @@
 }
 
 void
-CheckEvent()
+CheckEvent(void)
 {
    XEvent              ev;
 
@@ -738,7 +630,7 @@
    */
 
 void
-WaitEvent()
+WaitEvent(void)
 {
 /*  XEvent              ev; */
    fd_set              fdset;
@@ -892,3 +784,195 @@
 
    EDBUG_RETURN_;
 }
+
+#if ENABLE_DEBUG_EVENTS
+/*
+ * Event debug stuff
+ */
+#define N_DEBUG_FLAGS 64
+static char         ev_debug;
+static char         ev_debug_flags[N_DEBUG_FLAGS];
+
+/*
+ * param is <EventNumber>[:<EventNumber> ... ]
+ */
+void
+EventDebugInit(const char *param)
+{
+   const char         *s;
+   int                 ix, onoff;
+
+   if (!param)
+      return;
+
+   for (;;)
+     {
+       s = strchr(param, ':');
+       if (!param[0])
+          break;
+       ev_debug = 1;
+       ix = strtol(param, NULL, 0);
+       onoff = (ix >= 0);
+       if (ix < 0)
+          ix = -ix;
+       if (ix < N_DEBUG_FLAGS)
+          ev_debug_flags[ix] = onoff;
+       if (!s)
+          break;
+       param = s + 1;
+     }
+}
+
+static int
+EventDebug(unsigned int type)
+{
+   return ev_debug && (type < sizeof(ev_debug_flags)) && ev_debug_flags[type];
+}
+
+static const char  *const TxtEventNames[] = {
+   "Error", "Reply", "KeyPress", "KeyRelease", "ButtonPress",
+   "ButtonRelease", "MotionNotify", "EnterNotify", "LeaveNotify", "FocusIn",
+   "FocusOut", "KeymapNotify", "Expose", "GraphicsExpose", "NoExpose",
+   "VisibilityNotify", "CreateNotify", "DestroyNotify", "UnmapNotify",
+   "MapNotify",
+   "MapRequest", "ReparentNotify", "ConfigureNotify", "ConfigureRequest",
+   "GravityNotify",
+   "ResizeRequest", "CirculateNotify", "CirculateRequest", "PropertyNotify",
+   "SelectionClear",
+   "SelectionRequest", "SelectionNotify", "ColormapNotify", "ClientMessage",
+   "MappingNotify"
+};
+#define N_EVENT_NAMES (sizeof(TxtEventNames)/sizeof(char*))
+
+static const char  *
+EventName(unsigned int type)
+{
+   if (type < N_EVENT_NAMES)
+      return TxtEventNames[type];
+
+   return "Unknown";
+}
+
+static const char  *const TxtEventNotifyModeNames[] = {
+   "NotifyNormal", "NotifyGrab", "NotifyUngrab", "NotifyWhileGrabbed"
+};
+#define N_EVENT_NOTIFY_MODE_NAMES (sizeof(TxtEventNotifyModeNames)/sizeof(char*))
+
+static const char  *
+EventNotifyModeName(unsigned int mode)
+{
+   if (mode < N_EVENT_NOTIFY_MODE_NAMES)
+      return TxtEventNotifyModeNames[mode];
+
+   return "Unknown";
+}
+
+static const char  *const TxtEventNotifyDetailNames[] = {
+   "NotifyAncestor", "NotifyVirtual", "NotifyInferior", "NotifyNonlinear",
+   "NotifyNonlinearVirtual", "NotifyPointer", "NotifyPointerRoot",
+   "NotifyDetailNone"
+};
+#define N_EVENT_NOTIFY_DETAIL_NAMES (sizeof(TxtEventNotifyDetailNames)/sizeof(char*))
+
+static const char  *
+EventNotifyDetailName(unsigned int detail)
+{
+   if (detail < N_EVENT_NOTIFY_DETAIL_NAMES)
+      return TxtEventNotifyDetailNames[detail];
+
+   return "Unknown";
+}
+
+void
+EventShow(const XEvent * ev)
+{
+   Window              win = ev->xany.window;
+   const char         *name = EventName(ev->type);
+   const char         *txt;
+
+   switch (ev->type)
+     {
+     case KeyPress:
+     case KeyRelease:
+       printf("EV-%s win=%#lx\n", name, win);
+       break;
+     case ButtonPress:
+     case ButtonRelease:
+       printf("EV-%s win=%#lx state=%#x button=%#x\n", name, win,
+              ev->xbutton.state, ev->xbutton.button);
+       break;
+     case MotionNotify:
+       printf("EV-%s win=%#lx\n", name, win);
+       break;
+     case EnterNotify:
+     case LeaveNotify:
+       printf("EV-%s win=%#lx m=%s d=%s\n", name, win,
+              EventNotifyModeName(ev->xcrossing.mode),
+              EventNotifyDetailName(ev->xcrossing.detail));
+       break;
+     case FocusIn:
+     case FocusOut:
+       printf("EV-%s win=%#lx m=%s d=%s\n", name, win,
+              EventNotifyModeName(ev->xfocus.mode),
+              EventNotifyDetailName(ev->xfocus.detail));
+       break;
+     case KeymapNotify:
+     case Expose:
+     case GraphicsExpose:
+     case NoExpose:
+     case VisibilityNotify:
+     case CreateNotify:
+     case DestroyNotify:
+     case UnmapNotify:
+     case MapNotify:
+     case MapRequest:
+     case ReparentNotify:
+     case ConfigureNotify:
+     case ConfigureRequest:
+     case GravityNotify:
+     case ResizeRequest:
+     case CirculateNotify:
+     case CirculateRequest:
+       printf("EV-%s win=%#lx\n", name, win);
+       break;
+     case PropertyNotify:
+       txt = XGetAtomName(disp, ev->xproperty.atom);
+       printf("EV-%s: win=%#lx Atom=%s(%ld)\n",
+              name, win, txt, ev->xproperty.atom);
+       XFree(txt);
+       break;
+     case SelectionClear:
+     case SelectionRequest:
+     case SelectionNotify:
+     case ColormapNotify:
+       printf("EV-%s win=%#lx\n", name, win);
+       break;
+     case ClientMessage:
+       txt = XGetAtomName(disp, ev->xclient.message_type);
+       printf
+          ("EV-%s win=%#lx ev_type=%s(%ld) data[0-3]= %08lx %08lx %08lx %08lx\n",
+           name, win, txt, ev->xclient.message_type, ev->xclient.data.l[0],
+           ev->xclient.data.l[1], ev->xclient.data.l[2],
+           ev->xclient.data.l[3]);
+       XFree(txt);
+       break;
+     case MappingNotify:
+       printf("EV-%s win=%#lx\n", name, win);
+       break;
+     default:
+       if (ev->type == event_base_shape + ShapeNotify)
+          printf("EV-ShapeNotify win=%#lx\n", win);
+       else
+          printf("EV-??? Type=%d win=%#lx\n", ev->type, win);
+       break;
+     }
+}
+
+#else
+
+void
+EventDebugInit(const char *param)
+{
+}
+
+#endif /* INCLUDE_DEBUG_STUFF */
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/evhandlers.c,v
retrieving revision 1.132
retrieving revision 1.133
diff -u -3 -r1.132 -r1.133
--- evhandlers.c        21 Dec 2003 12:13:41 -0000      1.132
+++ evhandlers.c        4 Jan 2004 18:07:18 -0000       1.133
@@ -100,19 +100,6 @@
 {
    EDBUG(5, "HandleClientMessage");
 
-   if (debug_flags & EDBUG_CLIENT_MESSAGES)
-     {
-       char               *name = XGetAtomName(disp, ev->xclient.message_type);
-
-       printf
-          ("HandleClientMessage: ev_type=%s(%d) ev_win=%#x data[0-3]= %08lx %08lx 
%08lx %08lx\n",
-           name, (unsigned)ev->xclient.message_type,
-           (unsigned)ev->xclient.window, ev->xclient.data.l[0],
-           ev->xclient.data.l[1], ev->xclient.data.l[2],
-           ev->xclient.data.l[3]);
-       XFree(name);
-     }
-
    HintsProcessClientMessage(&(ev->xclient));
 
    EDBUG_RETURN_;
@@ -938,16 +925,6 @@
    EWin               *ewin;
    char                title[10240];
    int                 desktop;
-
-   if (debug_flags & EDBUG_PROPERTY_CHANGE)
-     {
-       char               *name = XGetAtomName(disp, ev->xproperty.atom);
-
-       printf("HandleProperty: Atom=%s(%d) id=%#x\n",
-              name, (unsigned)ev->xproperty.atom,
-              (unsigned)ev->xproperty.window);
-       XFree(name);
-     }
 
    EDBUG(5, "HandleProperty");
 
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/globals.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -3 -r1.21 -r1.22
--- globals.c   3 Jan 2004 12:29:58 -0000       1.21
+++ globals.c   4 Jan 2004 18:07:18 -0000       1.22
@@ -82,4 +82,3 @@
 int                 debug_level;
 char               *call_stack[1024];
 #endif
-int                 debug_flags = 0;
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/ipc.c,v
retrieving revision 1.128
retrieving revision 1.129
diff -u -3 -r1.128 -r1.129
--- ipc.c       3 Jan 2004 23:59:06 -0000       1.128
+++ ipc.c       4 Jan 2004 18:07:18 -0000       1.129
@@ -105,6 +105,7 @@
 static void         IPC_GroupOps(char *params, Client * c);
 static void         IPC_Group(char *params, Client * c);
 static void         IPC_Hints(char *params, Client * c);
+static void         IPC_Debug(char *params, Client * c);
 
 /* the IPC Array */
 
@@ -564,7 +565,12 @@
     IPC_Hints,
     "hints", NULL,
     "Set hint options.",
-    "usage:\n" "  hints xroot <normal/root>"}
+    "usage:\n" "  hints xroot <normal/root>"},
+   {
+    IPC_Debug,
+    "debug", NULL,
+    "Set debug options.",
+    "usage:\n" "  debug events <EvNo>:<EvNo>..."}
 };
 
 static int
@@ -5171,6 +5177,28 @@
 
    Esnprintf(buf, sizeof(buf), "Set _XROOT* hints: %s",
             (mode.hints_set_xroot_info_on_root_window) ? "root" : "normal");
+
+   CommsSend(c, buf);
+}
+
+static void
+IPC_Debug(char *params, Client * c)
+{
+   char                buf[FILEPATH_LEN_MAX];
+   char                param1[FILEPATH_LEN_MAX];
+   char                param2[FILEPATH_LEN_MAX];
+
+   buf[0] = 0;
+   param1[0] = 0;
+   param2[0] = 0;
+
+   word(params, 1, param1);
+   word(params, 2, param2);
+
+   if (!strncmp(param1, "event", 2))
+     {
+       EventDebugInit(param2);
+     }
 
    CommsSend(c, buf);
 }
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/main.c,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -3 -r1.67 -r1.68
--- main.c      3 Jan 2004 12:55:08 -0000       1.67
+++ main.c      4 Jan 2004 18:07:18 -0000       1.68
@@ -73,7 +73,7 @@
 #endif
    str = getenv("EDBUG_FLAGS");
    if (str)
-      debug_flags = strtoul(str, NULL, 0);
+      EventDebugInit(str);
 
    EDBUG(1, "main");
 




-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to