#include <exec/types.h>
#include <intuition/intuition.h>
#include <intuition/intuisup.h>
#include "patch.h"


extern struct Window *theEventWindow;

extern ULONG          PatchSignal;
extern struct Task   *PatchTask;

VOID
MyOpenWindow(window)
register struct   Window   *window;
{
   PatchWindow(window);
}

VOID
MyCloseWindow(window)
register struct   Window  *window;
{
   register struct WindowPatch   *p;

   Forbid();
   if (p = (struct WindowPatch *)FindWPatch(window))
      UnPatchWindow(p, FALSE);
   Permit();
}

BYTE
MyPutMsg(port, msg)
register struct   MsgPort        *port;
register struct   IntuiMessage   *msg;
{
   if (msg->Class==GADGETUP || msg->Class==GADGETDOWN)
      {
      register USHORT id = ((struct Gadget *)(msg->IAddress))->GadgetID;
      if (id==ICONGADGET)
         {
         theEventWindow = msg->IDCMPWindow;
         Signal(PatchTask, 1 << PatchSignal);
         ReplyMsg(msg);
         return(1);
         }
      }
   return(0);
}


