home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / x / volume3 / awm2 / part11 / errHndlr.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-02-21  |  2.5 KB  |  110 lines

  1.  
  2. #ifndef lint
  3. static char *rcsid_errHndlr_c = "$Header: /usr/graph2/X11.3/contrib/windowmgrs/awm/RCS/errHndlr.c,v 1.2 89/02/07 21:24:38 jkh Exp $";
  4. #endif  lint
  5.  
  6. #include "X11/copyright.h"
  7. /*
  8.  *
  9.  * Copyright 1987, 1988 by Ardent Computer Corporation, Sunnyvale, Ca.
  10.  *
  11.  * Copyright 1987 by Jordan Hubbard.
  12.  *
  13.  *
  14.  *                         All Rights Reserved
  15.  *
  16.  * Permission to use, copy, modify, and distribute this software and its
  17.  * documentation for any purpose and without fee is hereby granted,
  18.  * provided that the above copyright notice appear in all copies and that
  19.  * both that copyright notice and this permission notice appear in
  20.  * supporting documentation, and that the name of Ardent Computer
  21.  * Corporation or Jordan Hubbard not be used in advertising or publicity
  22.  * pertaining to distribution of the software without specific, written
  23.  * prior permission.
  24.  *
  25.  */
  26.  
  27. #include <stdio.h>
  28. #include "X11/Xlib.h"
  29.  
  30. int errorStatus = False;
  31.  
  32. #ifdef DEBUG
  33. void debug(s, x1, x2, x3, x4, x5, x6, x7, x8)
  34. char *s;
  35. long x1, x2, x3, x4, x5, x6, x7, x8;
  36. {
  37.     static FILE *con = 0;
  38.  
  39.     if (!con)
  40.         con = fopen("/dev/console", "w");
  41.     fprintf(con, s, x1, x2, x3, x4, x5, x6, x7, x8);
  42. }
  43. #endif
  44.  
  45. /*ARGSUSED*/
  46. int ErrorHandler (dpy, event)
  47.     Display *dpy;
  48.     XErrorEvent *event;
  49. {
  50. #ifdef DEBUG
  51.     char *buffer[BUFSIZ];
  52.     XGetErrorText(dpy, event->error_code, buffer, BUFSIZ);
  53.     (void) debug("Hey!\n");
  54.     (void) debug("X Error: %s\n", buffer);
  55.     (void) debug("  Request Major code: %d\n", event->request_code);
  56.     (void) debug("  Request Minor code: %d\n", event->minor_code);
  57.     (void) debug("  ResourceId 0x%x\n", event->resourceid);
  58.     (void) debug("  Error Serial #%d\n", event->serial);
  59.     (void) debug("  Current Serial #%d\n", dpy->request);
  60. #endif
  61.     errorStatus = True;
  62.     return 0;
  63. }
  64.  
  65. static char *eventname[] = {
  66.     "zero",
  67.     "one",
  68.     "KeyPress",
  69.     "KeyRelease",
  70.     "ButtonPress",
  71.     "ButtonRelease",
  72.     "MotionNotify",
  73.     "EnterNotify",
  74.     "LeaveNotify",
  75.     "FocusIn",
  76.     "FocusOut",
  77.     "KeymapNotify",
  78.     "Expose",
  79.     "GraphicsExpose",
  80.     "NoExpose",
  81.     "VisibilityNotify",
  82.     "CreateNotify",
  83.     "DestroyNotify",
  84.     "UnmapNotify",
  85.     "MapNotify",
  86.     "MapRequest",
  87.     "ReparentNotify",
  88.     "ConfigureNotify",
  89.     "ConfigureRequest",
  90.     "GravityNotify",
  91.     "ResizeRequest",
  92.     "CirculateNotify",
  93.     "CirculateRequest",
  94.     "PropertyNotify",
  95.     "SelectionClear",
  96.     "SelectionRequest",
  97.     "SelectionNotify",
  98.     "ColormapNotify",
  99.     "ClientMessage",
  100.     "MappingNotify",
  101. };
  102.  
  103. void print_event_info(s, ev)
  104. char *s;
  105. XEvent *ev;
  106. {
  107.     fprintf(stderr, "%s: EVENT %s(%d) on %x\n", s, eventname[ev->type],
  108.       ev->type, ev->xany.window);
  109. }
  110.