home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / Samples / CSAPE32.ARJ / SOURCE / OWLSCR / WINGO.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-09-07  |  4.2 KB  |  142 lines

  1. /*
  2.     wingo.c    11/17/88
  3.  
  4.     % win_Go, window manager mouse control arbitrator.
  5.     by Ted.
  6.  
  7.     OWL 1.1
  8.     Copyright (c) 1988, by Oakland Group, Inc.
  9.     ALL RIGHTS RESERVED.
  10.  
  11.     Revision History:
  12.     -----------------
  13.     12/09/88 ted    Added ddisp_Cache/Flush calls for mouse.
  14.     12/11/88 ted    Added dhard_Claim/Release calls for reentrancy.
  15.  
  16.      2/08/89 ted    Added dwmgr_SetNewCurrentFlag call to fix mouse support.
  17.      5/04/89 ted    Fixed bug that somehow got in: old, not win to STOPCUR.
  18.      5/11/89 ted    Added MEV_STARTCUR and MEV_STOPCUR messages.
  19.      8/09/89 jdc    Added LNF stuff
  20.      8/10/89 jmd    removed goresult struct
  21.      8/19/89 jdc    added to LNF stuff
  22.      9/06/89 ted    Added fake mouse event notification.
  23.  
  24.      1/08/89 ted    Made MEV_STARTCUR & STOPCUR messages nest, cached trapwin,
  25.                     added arg to win_MakeCurrent.
  26.      1/27/89 jdc    preened
  27.      3/28/90 jmd    ansi-fied
  28.      6/15/90 jdc    tweeked LNF_IDLESYS stuff
  29.      6/21/90 ted    Added LNF ifdef for auto "go" var to avoid warnings.
  30.      7/17/90 jdc    fixed IDLESYS ESC case
  31.      8/03/90 jmd    added aux messages
  32.      8/23/90 jdc    removed LNF stuff to lnfwin.c
  33.      8/27/90 ted    Added setting of fromwin before return for my framer stuff.
  34.      9/07/90 jmd    renamed win_GetNextWin
  35. */
  36.  
  37. #include "oakhead.h"
  38. #include "disppriv.h"
  39.  
  40. /* -------------------------------------------------------------------------- */
  41.  
  42. int win_Go(win_type win)
  43. /*
  44.     Passes control to the window's user interaction function, and to any
  45.     windows that window may hand off to.
  46. */
  47. {
  48.     int result;
  49.     win_type fromwin, old;
  50.     win_type ttwin;                /* temp copy of mouse trapwin */
  51.  
  52.     old = fromwin = disp_GetCurrentWin();
  53.  
  54.     if (win == NULL) {
  55.         win_MakeCurrent(old, NULL);
  56.         return(-1);
  57.     }
  58.     ttwin = disp_GetMouseTrap();    /* Save mouse trapwin in effect now */
  59.  
  60.     for (;;) {
  61.         /* Set where-from window for use by win that's about to go */
  62.         wmgr_setfromwin(fromwin);
  63.  
  64.     /* GO in the window, send Aux messages */
  65.         win_MakeCurrent(win, &ttwin);
  66.         obj_DoAux(win, WINA_STARTGO, NULL, NULL);
  67.         win_Do(win, WINM_GO, NULL, &result);
  68.         obj_DoAux(win, WINA_ENDGO, NULL, NULL);
  69.  
  70.         fromwin = win;                /* Remember this for when we go again */
  71.         win = win_GetNextWin(win);    /* Set up to go again */
  72.  
  73.         if (win != NULL) {
  74.             win_SetNextWin(fromwin, NULL);
  75.         }
  76.         else {
  77.             win_MakeCurrent(old, &ttwin);
  78.             wmgr_setfromwin(fromwin);
  79.             return(result);
  80.         }
  81.     }
  82. }
  83. /* -------------------------------------------------------------------------- */
  84.  
  85. win_type OWLPRIV win_MakeCurrent(win_type win, win_type *ttwinp)
  86. {
  87. /*
  88.     Make 'win' the 'current' window (i.e. the one that can display the text
  89.     cursor and the one that win_Go is currently running in.)
  90.     Returns a pointer to the window that used to be current.
  91. */
  92.     win_type old;
  93.     boolean dummy;
  94.  
  95.     /* No calling MakeCurrent from within a mouse handler */
  96.     owl_Assert(!wmgr_InMouse(), OE_MC_INMOUSE);
  97.  
  98.     hard_Claim();        /* Here for re-entrancy protection */
  99.     old = disp_GetCurrentWin();
  100.  
  101.     /* Hide cursor etc. in old current window */
  102.     if (old != NULL) {
  103.         owl_Assert(win_Ok(old), OE_MC_OLD);
  104.         win_Do(old, WINM_STOPCUR, old, &dummy);
  105.         /* Make mouse messages nest (don't do stopcur going into a child)*/
  106.         if (win_MouseOk(old) && wmgr_SMMptr() != FNULL &&
  107.             !(win != NULL && win_GetParent(win) == old)) {
  108.             wmgr_SetFakeMouse(TRUE);
  109.             win_DoMouse(old, MEV_STOPCUR, NULL);
  110.             wmgr_SetFakeMouse(FALSE);
  111.         }
  112.     }
  113.     /* Set wmgr current-window ptr to new current window */
  114.     wmgr_setcurrwin(win);
  115.  
  116.     /* Restore the parent's trap win so the startcur messages can see it */
  117.     if (ttwinp != NULL) disp_TrapMouse(*ttwinp);
  118.  
  119.     /* Show cursor etc. in new current window */
  120.     if (win != NULL) {
  121.         owl_Assert(win_Ok(win), OE_MC_WIN);
  122.         win_Do(win, WINM_STARTCUR, win, &dummy);
  123.         /* Make mouse messages nest (don't do startcur returning from a child)*/
  124.         if (win_MouseOk(win) && wmgr_SMMptr() != FNULL &&
  125.             !(old != NULL && win_GetParent(old) == win)) {
  126.             wmgr_SetFakeMouse(TRUE);
  127.             win_DoMouse(win, MEV_STARTCUR, NULL);
  128.             wmgr_SetFakeMouse(FALSE);
  129.         }
  130.     }
  131.  
  132.     /* Set flag for kb_Read/Check to wrap up mouse msgs for new current win */
  133.     if (wmgr_SMMptr() != FNULL) {
  134.         wmgr_SetNewCurrentFlag(TRUE);
  135.     }
  136.     hard_Release();
  137.  
  138.     return(old);
  139. }
  140. /* -------------------------------------------------------------------------- */
  141.  
  142.