home *** CD-ROM | disk | FTP | other *** search
/ World of A1200 / World_Of_A1200.iso / programs / workbench / stickit2 / source.lha / source / events.c < prev    next >
C/C++ Source or Header  |  1995-01-09  |  2KB  |  92 lines

  1. /**********************************************
  2.  **************   events.c   ******************
  3.  **********************************************/
  4.  
  5. #define INTUI_V36_NAMES_ONLY
  6.  
  7. #include <exec/exec.h>
  8. #include <intuition/intuition.h>
  9.  
  10. #include <clib/exec_protos.h>
  11. #include <clib/gadtools_protos.h>
  12.  
  13. #include "stickit2.h"
  14.  
  15. #include <stdio.h>        /* For printf */
  16.  
  17. #include "consts.h"
  18. #include "structs.h"
  19. #include "proto.h"
  20.  
  21. extern prj_p prj;
  22.  
  23. /*
  24. Function : void events_mainloop(void)
  25. Purpose : Handles the incoming events from all the ports and dispatches the
  26.     calls to the appropriate handler.
  27. */
  28.  
  29. void events_mainloop(void)
  30. {
  31.     ULONG signals;
  32.     BOOL done = FALSE;
  33.  
  34.     while (!done) {
  35.         signals = Wait((1L << prj->broker_msg_port->mp_SigBit) |
  36. (1L << prj->main_msg_port->mp_SigBit));
  37.  
  38.         if (signals & (1L << prj->broker_msg_port->mp_SigBit))
  39.             done = commod_event();
  40.         else if (signals & (1L << prj->main_msg_port->mp_SigBit))
  41.             done = main_event();
  42.     }
  43. }
  44.  
  45. /*
  46. Function : BOOL main_event()
  47. Purpose : A message has arrived in the main message port. It may be from the
  48.     commodities window (hence the GT_GetIMsg) or from a note.
  49. */
  50.  
  51. BOOL main_event()
  52. {
  53.     struct IntuiMessage *msg;
  54.     struct IntuiMessage curr_msg;
  55.  
  56.     BOOL done = FALSE;
  57.  
  58.     while (msg = (struct IntuiMessage *)GT_GetIMsg(prj->main_msg_port)) {
  59.         curr_msg.Code = msg->Code;
  60.         curr_msg.Class = msg->Class;
  61.         curr_msg.Qualifier = msg->Qualifier;
  62.         curr_msg.IAddress = msg->IAddress;
  63.         curr_msg.MouseX = msg->MouseX;
  64.         curr_msg.MouseY = msg->MouseY;
  65.         curr_msg.Seconds = msg->Seconds;
  66.         curr_msg.Micros = msg->Micros;
  67.         curr_msg.IDCMPWindow = msg->IDCMPWindow;
  68.  
  69.         GT_ReplyIMsg ((struct IntuiMessage *)msg);
  70.  
  71.         if ((commod) && (curr_msg.IDCMPWindow == commod))
  72.             done = commodwin_event(&curr_msg);
  73.         else
  74.             done = note_event(&curr_msg);
  75.  
  76.         if (done)
  77.             break;
  78.     }
  79.  
  80.     /* If the done was from the commod window, check to see whether it */
  81.     /* is a quit or hide */
  82.  
  83.     if ((done) && (commod) && (curr_msg.IDCMPWindow == commod)) {
  84.         if (!prj->abouttoquit) {
  85.             closewindowcommod();
  86.             done = FALSE;
  87.         }
  88.     }
  89.  
  90.     return(done);
  91. }
  92.