home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c185 / 2.ddi / OWLSRC.EXE / CSCAPE / SOURCE / WINGO.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-09-06  |  3.5 KB  |  136 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.  
  25. #ifdef LNF
  26. #    include "lnf.h"
  27. #    include "winpriv.h"
  28. #    include "scancode.h"
  29. #else
  30. #    include "oakhead.h"
  31. #    include "disppriv.h"
  32. #endif
  33. /* -------------------------------------------------------------------------- */
  34.  
  35. int win_Go(win)
  36.     win_type win;
  37. /*
  38.     Passes control to the window's user interaction function, and to any
  39.     windows that window may hand off to.
  40. */
  41. {
  42.     int result;
  43.     win_type fromwin, old;
  44.  
  45.     old = fromwin = disp_GetCurrentWin();
  46.  
  47.     for (;;) {
  48.         /* Set where-from window for use by win that's about to go */
  49.         wmgr_setfromwin(fromwin);
  50.  
  51.         if (win == NULL) {
  52.             win_MakeCurrent(old);
  53.             return(-1);
  54.         }
  55.     /* GO in the window */
  56.         win_MakeCurrent(win);
  57.  
  58.         win_Do(win, WINM_GO, NULL, &result);
  59.  
  60. #ifdef LNF
  61.         if (win == lnf->scrs[SCR_MENU]) {
  62.             /* pass ret as command from menubar */
  63.             lnf->menubar_code = result;
  64.             win_PutUnder(win, disp_GetBotWin());
  65.             win = lnf_GetComWin(lnf);
  66.             win_SetNextWin(fromwin, NULL);
  67.             sed_SetMouseCode(fromwin, BOB_QUIT);    /* bypass kb_Read() */
  68.         }
  69.         else
  70. #endif
  71.         if (win_nextwin(win) == NULL) {
  72.             win_MakeCurrent(old);
  73.             return(result);
  74.         }
  75.         else {
  76.             fromwin = win;            /* Remember this for when we go again */
  77.             win = win_nextwin(fromwin);    /* Set up to go again */
  78.             win_SetNextWin(fromwin, NULL);
  79.         }
  80.     }
  81. }
  82. /* -------------------------------------------------------------------------- */
  83.  
  84. win_type OWLPRIV win_MakeCurrent(win)
  85.     win_type win;
  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.         if (win_MouseOk(old) && wmgr_SMMptr() != FNULL) {
  106.             wmgr_SetFakeMouse(TRUE);
  107.             win_DoMouse(old, MEV_STOPCUR, NULL);
  108.             wmgr_SetFakeMouse(FALSE);
  109.         }
  110.     }
  111.  
  112.     /* Set wmgr current-window ptr to new current window */
  113.     wmgr_setcurrwin(win);
  114.  
  115.     /* Show cursor etc. in new current window */
  116.     if (win != NULL) {
  117.         owl_Assert(win_Ok(win), OE_MC_WIN);
  118.         win_Do(win, WINM_STARTCUR, win, &dummy);
  119.         if (win_MouseOk(win) && wmgr_SMMptr() != FNULL) {
  120.             wmgr_SetFakeMouse(TRUE);
  121.             win_DoMouse(win, MEV_STARTCUR, NULL);
  122.             wmgr_SetFakeMouse(FALSE);
  123.         }
  124.     }
  125.  
  126.     /* Set flag for kb_Read/Check to wrap up mouse msgs for new current win */
  127.     if (wmgr_SMMptr() != FNULL) {
  128.         wmgr_SetNewCurrentFlag(TRUE);
  129.     }
  130.     hard_Release();
  131.  
  132.     return(old);
  133. }
  134. /* -------------------------------------------------------------------------- */
  135.  
  136.