home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 200-299 / ff274.lzh / Snap / patch.c < prev    next >
Text File  |  1989-11-16  |  2KB  |  48 lines

  1. /* This patch is a quite ugly way to solve the problem
  2. ** that occurs when Intuition tries to draw something
  3. ** in a screen which has it's layers locked.
  4. ** The problem is solved by disabling dangerous functions.
  5. ** Some functions remain because they require more work.
  6. ** An example of this is OpenWindow(), since OpenWindow()
  7. ** can't be as easily ignored as the functions that ARE
  8. ** patched here. OpenWindow() would require some sort of
  9. ** semaphore locking and waiting - and so we're back where
  10. ** we started.
  11. */
  12.  
  13. IMPORT struct IntuitionBase *IntuitionBase;
  14.  
  15. IMPORT SHORT lvoActivateWindow, lvoWindowToFront, lvoWindowToBack;
  16. VOID myActivateWindow(), myWindowToFront(), myWindowToBack();
  17.  
  18. LONG oldActivateWindow, oldWindowToFront, oldWindowToBack;
  19.  
  20. STATIC WORD patched = 0;
  21.  
  22. VOID SafePatch()
  23. {
  24.     if (!patched) {
  25.         Forbid();     /* I don't expect interrupts to do much intuition */
  26.         oldActivateWindow =
  27.           SetFunction(IntuitionBase, (LONG)lvoActivateWindow, myActivateWindow);
  28.         oldWindowToFront =
  29.           SetFunction(IntuitionBase, (LONG)lvoWindowToFront, myWindowToFront);
  30.         oldWindowToBack =
  31.           SetFunction(IntuitionBase, (LONG)lvoWindowToBack, myWindowToBack);
  32.         Permit();
  33.         patched = 1;
  34.     }
  35. }
  36.  
  37. VOID SafeRestore()
  38. {
  39.     if (patched) {
  40.         Forbid();
  41.         (VOID)SetFunction(IntuitionBase, (LONG)lvoActivateWindow, oldActivateWindow);
  42.         (VOID)SetFunction(IntuitionBase, (LONG)lvoWindowToFront, oldWindowToFront);
  43.         (VOID)SetFunction(IntuitionBase, (LONG)lvoWindowToBack, oldWindowToBack);
  44.         Permit();
  45.         patched = 0;
  46.     }
  47. }
  48.