home *** CD-ROM | disk | FTP | other *** search
- /*
- * Lock user input from a window. We take a clue from ASL and open
- * an invisible Requester in the window in question. This keeps us
- * from mucking with the window gadget list, which causes problems
- * in WBMode.
- *
- */
-
- #include <exec/types.h>
- #include <exec/memory.h>
- #include <exec/execbase.h>
- #include <intuition/intuition.h>
- #include <clib/exec_protos.h>
- #include <clib/graphics_protos.h>
- #include <clib/intuition_protos.h>
-
-
- extern struct ExecBase *SysBase;
-
-
- struct Locker {
- struct Window *Window;
- struct Requester Request;
- };
-
-
- #define WAIT_HEIGHT (16)
- #define WAIT_XO (-6)
- #define WAIT_YO (0)
-
- /*
- * This is a 2.0-style Clock...
- */
- USHORT __chip WaitSprite[] =
- {
- 0x0000,0x0000,
- 0x0400,0x07C0,0x0000,0x07C0,0x0100,0x0380,0x0000,0x07E0,
- 0x07C0,0x1FF8,0x1FF0,0x3FEC,0x3FF8,0x7FDE,0x3FF8,0x7FBE,
- 0x7FFC,0xFF7F,0x7EFC,0xFFFF,0x7FFC,0xFFFF,0x3FF8,0x7FFE,
- 0x3FF8,0x7FFE,0x1FF0,0x3FFC,0x07C0,0x1FF8,0x0000,0x07E0,
- 0x0000,0x0000,
- };
-
- void Busy (struct Window *w)
- {
- if (SysBase->LibNode.lib_Version >= 39)
- SetWindowPointer(w, WA_BusyPointer, TRUE, TAG_END);
- else
- SetPointer (w, WaitSprite, WAIT_HEIGHT, 16, WAIT_XO, WAIT_YO);
- }
-
- APTR LockInput (struct Window *w)
- {
- struct Requester *req;
- struct Locker *lock;
-
- if (w == NULL) return(NULL);
-
- if (lock = AllocMem(sizeof(struct Locker), MEMF_CLEAR)) {
-
- lock->Window = w;
-
- req = &lock->Request;
-
- req->Flags = NOISYREQ; /* we want mouse clicks */
- req->LeftEdge = 0;
- req->TopEdge = 0;
- req->Width = 1;
- req->Height = 1;
- req->BackFill = ReadPixel(w->RPort, 0, 0);
-
- Busy(w);
- Request(req, w);
-
- return((APTR)lock);
- }
- return(NULL);
- }
-
- void UnlockInput (APTR alock)
- {
- struct Locker *lock;
-
- if (lock = (struct Locker *)alock) {
- EndRequest(&lock->Request, lock->Window);
- ClearPointer(lock->Window);
- FreeMem(lock, sizeof(struct Locker));
- }
- }
-
-