home *** CD-ROM | disk | FTP | other *** search
- /*
- wmgrinit.c
-
- % Window manager functions.
- 3/24/89 by Ted.
-
- Extracted from win.c.
-
- OWL 1.1
- Copyright (c) 1988, 1989 by Oakland Group, Inc.
- ALL RIGHTS RESERVED.
-
- Revision History:
- -----------------
- 7/07/89 gam Changed NULL to FNULL where necessary
- */
-
- #include "oakhead.h"
- #include "disppriv.h"
- #include "scancode.h" /* for mouse pseudo-scancodes */
-
- OGLOBAL win_type vid_win = NULL; /* Global window ptr for old vid_funcs to use */
-
- byte VACUUM = 0x07;
- byte VACUUMSHADOW = 0x07;
-
- /* -------------------------------------------------------------------------- */
-
- boolean OWLPRIV wmgr_Init(backwin)
- class_fptr backwin; /* the background window type */
- /*
- Initialize the windowing system.
- Create the background window.
- */
- {
- ptd_struct ptdata;
- winopendata_struct wod;
- opbox dbox;
-
- owl_Assert(disp_Ok(), OE_WI_DISP);
-
- hard_Claim(); /* Here for re-entrancy protection */
-
- disp_SetMouseCode(MOU_IGNORE);
- wmgr_SetReplyStash(MOU_IGNORE);
-
- /* Note: all inits to 0, FALSE, NULL, & FNULL are superfluous because */
- /* dmgr/wmgr structure is initted to 0's. */
- #ifdef OAK_NULLNOT0
- wmgr_SetInMouseMsgFlag(FALSE);
- wmgr_SetNewCurrentFlag(FALSE);
- wmgr_SetSMMptr(FNULL); /* SendMouseMessages ptr (init to NULL to be neat) */
- wmgr_setcurrwin(NULL);
- wmgr_lastmev()->win = NULL; /* needed to initialize mouse handling */
- disp_TrapMouseOff();
- #endif
-
- if (!wmgr_OpenTiler()) {
- goto Quit0;
- }
- vid_win = NULL; /* Start with vid_win NULL */
-
- /* Initialize employed and unemployed window lists */
- if (wmgr_setemployedhead(wmgr_ListOpen()) == NULL) {
- goto Quit1;
- }
- if (wmgr_setunemployedhead(wmgr_ListOpen()) == NULL) {
- goto Quit2;
- }
- win_setemployed(wmgr_employedhead(), TRUE);
- wmgr_setbotsyswin(wmgr_employedhead());
- wmgr_setbotemployedwin(wmgr_employedhead());
-
- /* Create the display-covering pseudo-window */
- dbox.ymin = 0;
- dbox.xmin = 0;
- dbox.ymax = disp_GetPixHeight();
- dbox.xmax = disp_GetPixWidth();
-
- wod.boxp = &dbox;
- wod.font = disp_GetDefFont();
- wod.list = NULL;
-
- if (wmgr_setdispwin(win_OpenRaw(npwin_Class, &wod)) == NULL) {
- goto Quit3;
- }
- disp_SetAttr(VACUUM);
- disp_SetShadowAttr(VACUUMSHADOW);
- win_SetCharSize(disp_GetDispWin(), FALSE);
-
- /* Open the background window and put it in the employed list. */
- if (backwin != FNULL) {
- wod.list = wmgr_employedhead();
- if (wmgr_setbackwin(win_OpenRaw(backwin, &wod)) == NULL) {
- goto Quit4;
- }
- /* We don't call win_Employ on it to avoid double painting and */
- /* because we're still technically initializing the window manager. */
- win_setemployed(disp_GetBackWin(), TRUE);
-
- /* Attempt to save from screen into background window */
- ptdata.win = disp_GetBackWin();
- ptdata.relboxp = &dbox;
- ptdata.emsgdata = NULL;
- win_Do(disp_GetBackWin(), WINM_ISAVE, &ptdata, NULL);
-
- if (win_GetId(disp_GetBackWin()) == ID_CMWIN) {
- vid_win = disp_GetBackWin();
- }
- }
- else wmgr_setbackwin(NULL); /* No background window */
-
- /* Initialize the no-painting system windows */
- /* Note: this function is macroed to nothing except on systems that need it.*/
- owl_InitSysWins();
-
- hard_Release();
- return(TRUE);
-
- Quit4: obj_Close(disp_GetDispWin());
- Quit3: wmgr_ListClose(wmgr_unemployedhead());
- Quit2: wmgr_ListClose(wmgr_employedhead());
- Quit1: wmgr_CloseTiler();
- Quit0: disp_Flush();
- hard_Release();
- return(FALSE);
- }
- /* -------------------------------------------------------------------------- */
-
- void OWLPRIV wmgr_Wrapup()
- /*
- Shut down windowing system.
- */
- {
- win_type twin;
-
- owl_Assert(disp_Ok(), OE_WW_DISP);
-
- hard_Claim(); /* Here for re-entrancy protection */
-
- /* Massive Layoffs! */
- /* Poke all employed windows unemployed before closing them, so they */
- /* won't waste time unpainting themselves */
- /* (Must all be done in advance because one could close another that */
- /* wasn't unemployed yet) */
- for (twin = wmgr_employedhead(); twin != NULL; twin = win_GetBelow(twin)) {
- win_setemployed(twin, FALSE);
- }
- wmgr_ListClose(wmgr_employedhead());
- wmgr_setemployedhead(NULL);
-
- wmgr_ListClose(wmgr_unemployedhead());
- wmgr_setunemployedhead(NULL);
-
- obj_Close(disp_GetDispWin());
- wmgr_setdispwin(NULL);
-
- wmgr_CloseTiler();
-
- hard_Release();
- }
- /* -------------------------------------------------------------------------- */
-
-