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.
- */
-
- #ifdef LNF
- # include "lnf.h"
- # include "winpriv.h"
- # include "scancode.h"
- #else
- # include "oakhead.h"
- # include "disppriv.h"
- #endif
- /* -------------------------------------------------------------------------- */
-
- int win_Go(win)
- 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;
-
- old = fromwin = disp_GetCurrentWin();
-
- for (;;) {
- /* Set where-from window for use by win that's about to go */
- wmgr_setfromwin(fromwin);
-
- if (win == NULL) {
- win_MakeCurrent(old);
- return(-1);
- }
- /* GO in the window */
- win_MakeCurrent(win);
-
- win_Do(win, WINM_GO, NULL, &result);
-
- #ifdef LNF
- if (win == lnf->scrs[SCR_MENU]) {
- /* pass ret as command from menubar */
- lnf->menubar_code = result;
- win_PutUnder(win, disp_GetBotWin());
- win = lnf_GetComWin(lnf);
- win_SetNextWin(fromwin, NULL);
- sed_SetMouseCode(fromwin, BOB_QUIT); /* bypass kb_Read() */
- }
- else
- #endif
- if (win_nextwin(win) == NULL) {
- win_MakeCurrent(old);
- return(result);
- }
- else {
- fromwin = win; /* Remember this for when we go again */
- win = win_nextwin(fromwin); /* Set up to go again */
- win_SetNextWin(fromwin, NULL);
- }
- }
- }
- /* -------------------------------------------------------------------------- */
-
- win_type OWLPRIV win_MakeCurrent(win)
- win_type win;
- {
- /*
- 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);
- if (win_MouseOk(old) && wmgr_SMMptr() != FNULL) {
- wmgr_SetFakeMouse(TRUE);
- win_DoMouse(old, MEV_STOPCUR, NULL);
- wmgr_SetFakeMouse(FALSE);
- }
- }
-
- /* Set wmgr current-window ptr to new current window */
- wmgr_setcurrwin(win);
-
- /* 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);
- if (win_MouseOk(win) && wmgr_SMMptr() != FNULL) {
- 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);
- }
- /* -------------------------------------------------------------------------- */
-
-