home *** CD-ROM | disk | FTP | other *** search
- /*
- wingo.c 11/17/88
-
- % win_Go, window manager mouse control arbitrator.
- by Ted.
-
- OWL 1.1
- Copyright (c) 1988, by Oakland Group, Inc.
- ALL RIGHTS RESERVED.
-
- Revision History:
- -----------------
- 12/09/88 ted Added ddisp_Cache/Flush calls for mouse.
- 12/11/88 ted Added dhard_Claim/Release calls for reentrancy.
-
- 2/08/89 ted Added dwmgr_SetNewCurrentFlag call to fix mouse support.
- 5/04/89 ted Fixed bug that somehow got in: old, not win to STOPCUR.
- 5/11/89 ted Added MEV_STARTCUR and MEV_STOPCUR messages.
- 8/09/89 jdc Added LNF stuff
- 8/10/89 jmd removed goresult struct
- 8/19/89 jdc added to LNF stuff
- 9/06/89 ted Added fake mouse event notification.
-
- 1/08/89 ted Made MEV_STARTCUR & STOPCUR messages nest, cached trapwin,
- added arg to win_MakeCurrent.
- 1/27/89 jdc preened
- 3/28/90 jmd ansi-fied
- 6/15/90 jdc tweeked LNF_IDLESYS stuff
- 6/21/90 ted Added LNF ifdef for auto "go" var to avoid warnings.
- 7/17/90 jdc fixed IDLESYS ESC case
- 8/03/90 jmd added aux messages
- 8/23/90 jdc removed LNF stuff to lnfwin.c
- 8/27/90 ted Added setting of fromwin before return for my framer stuff.
- 9/07/90 jmd renamed win_GetNextWin
- */
-
- #include "oakhead.h"
- #include "disppriv.h"
-
- /* -------------------------------------------------------------------------- */
-
- int win_Go(win_type win)
- /*
- Passes control to the window's user interaction function, and to any
- windows that window may hand off to.
- */
- {
- int result;
- win_type fromwin, old;
- win_type ttwin; /* temp copy of mouse trapwin */
-
- old = fromwin = disp_GetCurrentWin();
-
- if (win == NULL) {
- win_MakeCurrent(old, NULL);
- return(-1);
- }
- ttwin = disp_GetMouseTrap(); /* Save mouse trapwin in effect now */
-
- for (;;) {
- /* Set where-from window for use by win that's about to go */
- wmgr_setfromwin(fromwin);
-
- /* GO in the window, send Aux messages */
- win_MakeCurrent(win, &ttwin);
- obj_DoAux(win, WINA_STARTGO, NULL, NULL);
- win_Do(win, WINM_GO, NULL, &result);
- obj_DoAux(win, WINA_ENDGO, NULL, NULL);
-
- fromwin = win; /* Remember this for when we go again */
- win = win_GetNextWin(win); /* Set up to go again */
-
- if (win != NULL) {
- win_SetNextWin(fromwin, NULL);
- }
- else {
- win_MakeCurrent(old, &ttwin);
- wmgr_setfromwin(fromwin);
- return(result);
- }
- }
- }
- /* -------------------------------------------------------------------------- */
-
- win_type OWLPRIV win_MakeCurrent(win_type win, win_type *ttwinp)
- {
- /*
- Make 'win' the 'current' window (i.e. the one that can display the text
- cursor and the one that win_Go is currently running in.)
- Returns a pointer to the window that used to be current.
- */
- win_type old;
- boolean dummy;
-
- /* No calling MakeCurrent from within a mouse handler */
- owl_Assert(!wmgr_InMouse(), OE_MC_INMOUSE);
-
- hard_Claim(); /* Here for re-entrancy protection */
- old = disp_GetCurrentWin();
-
- /* Hide cursor etc. in old current window */
- if (old != NULL) {
- owl_Assert(win_Ok(old), OE_MC_OLD);
- win_Do(old, WINM_STOPCUR, old, &dummy);
- /* Make mouse messages nest (don't do stopcur going into a child)*/
- if (win_MouseOk(old) && wmgr_SMMptr() != FNULL &&
- !(win != NULL && win_GetParent(win) == old)) {
- wmgr_SetFakeMouse(TRUE);
- win_DoMouse(old, MEV_STOPCUR, NULL);
- wmgr_SetFakeMouse(FALSE);
- }
- }
- /* Set wmgr current-window ptr to new current window */
- wmgr_setcurrwin(win);
-
- /* Restore the parent's trap win so the startcur messages can see it */
- if (ttwinp != NULL) disp_TrapMouse(*ttwinp);
-
- /* Show cursor etc. in new current window */
- if (win != NULL) {
- owl_Assert(win_Ok(win), OE_MC_WIN);
- win_Do(win, WINM_STARTCUR, win, &dummy);
- /* Make mouse messages nest (don't do startcur returning from a child)*/
- if (win_MouseOk(win) && wmgr_SMMptr() != FNULL &&
- !(old != NULL && win_GetParent(old) == win)) {
- wmgr_SetFakeMouse(TRUE);
- win_DoMouse(win, MEV_STARTCUR, NULL);
- wmgr_SetFakeMouse(FALSE);
- }
- }
-
- /* Set flag for kb_Read/Check to wrap up mouse msgs for new current win */
- if (wmgr_SMMptr() != FNULL) {
- wmgr_SetNewCurrentFlag(TRUE);
- }
- hard_Release();
-
- return(old);
- }
- /* -------------------------------------------------------------------------- */
-
-