home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / XAP / XFM / XFM-1.3 / XFM-1 / xfm-1.3 / xfm / FmComms.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-04  |  2.0 KB  |  69 lines

  1. /*-----------------------------------------------------------------------------
  2.   FmComms.c
  3.  
  4.   (c) Simon Marlow 1990-1993
  5.   (c) Albert Graef 1994
  6.  
  7.   support for receiving instructions from other X processes
  8. ------------------------------------------------------------------------------*/
  9.  
  10. #include <X11/Intrinsic.h>
  11.  
  12. #include "Fm.h"
  13. #include "Am.h"
  14. #include "FmComms.h"
  15.  
  16. Atom xfm_open_window, xfm_update_window, wm_delete_window, wm_protocols;
  17.  
  18. void clientMessageHandler(Widget w, XtPointer closure, XEvent *e)
  19. {
  20.   /* The client message handler must be re-entrant because the invokation of
  21.      the callbacks in response to a wm_delete_window message can cause more
  22.      events to be dispatched. We handle this by just ignoring these recursive
  23.      calls. */
  24.  
  25.   static int in_use = 0;
  26.   XClientMessageEvent *c = (XClientMessageEvent *)e;
  27.  
  28.   if (in_use || e->type != ClientMessage || c->message_type != wm_protocols &&
  29.       freeze)
  30.     return;
  31.   in_use = 1;
  32.  
  33.   if (c->message_type == xfm_open_window)
  34.     ; /**/ /* to be implemented */
  35.   else if (c->message_type == xfm_update_window)
  36.     ; /**/ /* to be implemented */
  37.   else if (c->message_type == wm_protocols)
  38.     if (w == aw.shell)
  39.       appCloseCb(w, file_windows, (XtPointer)NULL);
  40.     else {
  41.       FileWindowRec *fw;
  42.       for (fw = file_windows; fw; fw = fw->next)
  43.     if (w == fw->shell) break;
  44.       if (!fw)
  45.     error("Internal error:", "Widget not found in clientMessageHandler");
  46.       else
  47.     fileCloseCb(w, fw, (XtPointer)NULL);
  48.     }
  49.  
  50.   in_use = 0;
  51. }
  52.  
  53. void initComms(void)
  54. {
  55.   /* Make up some new atoms */
  56.   xfm_open_window = XInternAtom(XtDisplay(aw.shell), XFM_OPEN_WINDOW,
  57.                  False);
  58.   xfm_update_window = XInternAtom(XtDisplay(aw.shell), XFM_UPDATE_WINDOW,
  59.                   False);
  60.   wm_delete_window = XInternAtom(XtDisplay(aw.shell), WM_DELETE_WINDOW,
  61.                  False);
  62.   wm_protocols = XInternAtom(XtDisplay(aw.shell), WM_PROTOCOLS,
  63.                  False);
  64.  
  65.   if (xfm_open_window == None || xfm_update_window == None ||
  66.       wm_delete_window == None || wm_protocols == None)
  67.     abortXfm("Couldn't initialize client message handler");
  68. }
  69.