home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0020 - 0029 / ibm0020-0029 / ibm0028.tar / ibm0028 / CSCAP323.ZIP / OWLSRC.EXE / WMGRINIT.C < prev   
Encoding:
C/C++ Source or Header  |  1990-09-23  |  4.6 KB  |  174 lines

  1. /*
  2.     wmgrinit.c
  3.  
  4.     % Window manager functions.
  5.     3/24/89 by Ted.
  6.  
  7.     Extracted from win.c.
  8.  
  9.     OWL 1.2
  10.     Copyright (c) 1988, 1989 by Oakland Group, Inc.
  11.     ALL RIGHTS RESERVED.
  12.  
  13.     Revision History:
  14.     -----------------
  15.      7/07/89 gam    Changed NULL to FNULL where necessary
  16.  
  17.      3/28/90 jmd    ansi-fied
  18.      6/06/90 jmd    preened
  19.      6/22/90 ted    added "void" to no-parameter function per ansii.
  20.      8/08/90 ted    Changed references from disp_SetMouseCode to kb_Stuff.
  21.      8/30/90 ted    Added call to wmgr_EvInit.
  22.      9/23/90 ted    added null - currmev initialization.
  23. */
  24.  
  25. #include "oakhead.h"
  26. #include "disppriv.h"
  27. #include "scancode.h"    /* for mouse pseudo-scancodes */
  28.  
  29. OGLOBAL win_type vid_win = NULL;    /* Global window ptr for old vid_funcs to use */
  30.  
  31. byte VACUUM          = 0x07;
  32. byte VACUUMSHADOW = 0x07;
  33.  
  34. /* -------------------------------------------------------------------------- */
  35.  
  36. boolean OWLPRIV wmgr_Init(class_fptr backwin)
  37. /*
  38.     Initialize the windowing system.
  39.     Create the background window.
  40. */
  41. {
  42.     ptd_struct ptdata;
  43.     winopendata_struct wod;
  44.     opbox dbox;
  45.  
  46.     owl_Assert(disp_Ok(), OE_WI_DISP);
  47.  
  48.     hard_Claim();            /* Here for re-entrancy protection */
  49.  
  50.     kb_Stuff(MOU_IGNORE);
  51.     wmgr_SetReplyStash(MOU_IGNORE);
  52.  
  53. /*    Note: all inits to 0, FALSE, NULL, & FNULL are superfluous because */
  54. /*    dmgr/wmgr structure is initted to 0's. */
  55. #ifdef OAK_NULLNOT0
  56.     wmgr_SetInMouseMsgFlag(FALSE);
  57.     wmgr_SetNewCurrentFlag(FALSE);
  58.     wmgr_EvInit();
  59.     wmgr_SetSMMptr(FNULL);    /* SendMouseMessages ptr (init to NULL to be neat) */
  60.     wmgr_setcurrwin(NULL);
  61.     wmgr_currmev()->win = NULL;    /* needed to initialize mouse handling */
  62.     wmgr_lastmev()->win = NULL;
  63.     disp_TrapMouseOff();
  64. #endif
  65.  
  66.     if (!wmgr_OpenTiler()) {
  67.         goto Quit0;
  68.     }
  69.     vid_win = NULL;    /* Start with vid_win NULL */
  70.  
  71.     /* Initialize employed and unemployed window lists */
  72.     if (wmgr_setemployedhead(wmgr_ListOpen()) == NULL) {
  73.         goto Quit1;
  74.     }
  75.     if (wmgr_setunemployedhead(wmgr_ListOpen()) == NULL) {
  76.         goto Quit2;
  77.     }
  78.     win_setemployed(wmgr_employedhead(), TRUE);
  79.     wmgr_setbotsyswin(wmgr_employedhead());
  80.     wmgr_setbotemployedwin(wmgr_employedhead());
  81.  
  82.     /* Create the display-covering pseudo-window */
  83.     dbox.ymin = 0;
  84.     dbox.xmin = 0;
  85.     dbox.ymax = disp_GetPixHeight();
  86.     dbox.xmax = disp_GetPixWidth();
  87.  
  88.     wod.boxp = &dbox;
  89.     wod.font = disp_GetDefFont();
  90.     wod.list = NULL;
  91.  
  92.     if (wmgr_setdispwin(win_OpenRaw(npwin_Class, &wod)) == NULL) {
  93.         goto Quit3;
  94.     }
  95.     disp_SetAttr(VACUUM);
  96.     disp_SetShadowAttr(VACUUMSHADOW);
  97.     win_SetCharSize(disp_GetDispWin(), FALSE);
  98.  
  99.     /* Open the background window and put it in the employed list. */
  100.     if (backwin != FNULL) {
  101.         wod.list = wmgr_employedhead();
  102.         if (wmgr_setbackwin(win_OpenRaw(backwin, &wod)) == NULL) {
  103.             goto Quit4;
  104.         }
  105.         /* We don't call win_Employ on it to avoid double painting and */
  106.         /* because we're still technically initializing the window manager. */
  107.         win_setemployed(disp_GetBackWin(), TRUE);
  108.  
  109.         /* Attempt to save from screen into background window */
  110.         ptdata.win = disp_GetBackWin();
  111.         ptdata.relboxp = &dbox;
  112.         ptdata.emsgdata = NULL;
  113.         win_Do(disp_GetBackWin(), WINM_ISAVE, &ptdata, NULL);
  114.  
  115.         if (win_GetId(disp_GetBackWin()) == ID_CMWIN) {
  116.             vid_win = disp_GetBackWin();
  117.         }
  118.     }
  119.     else {
  120.         wmgr_setbackwin(NULL);        /* No background window */
  121.     }
  122.  
  123.     /* Initialize the no-painting system windows */
  124.     /* Note: this function is macroed to nothing except on systems that need it.*/
  125.     owl_InitSysWins();
  126.  
  127.     hard_Release();
  128.     return(TRUE);
  129.  
  130. Quit4:    obj_Close(disp_GetDispWin());
  131. Quit3:    wmgr_ListClose(wmgr_unemployedhead());
  132. Quit2:    wmgr_ListClose(wmgr_employedhead());
  133. Quit1:    wmgr_CloseTiler();
  134. Quit0:    disp_Flush();
  135.         hard_Release();
  136.     return(FALSE);
  137. }
  138. /* -------------------------------------------------------------------------- */
  139.  
  140. void OWLPRIV wmgr_Wrapup(void)
  141. /*
  142.     Shut down windowing system.
  143. */
  144. {
  145.     win_type twin;
  146.  
  147.     owl_Assert(disp_Ok(), OE_WW_DISP);
  148.  
  149.     hard_Claim();        /* Here for re-entrancy protection */
  150.  
  151.     /* Massive Layoffs! */
  152.     /* Poke all employed windows unemployed before closing them, so they  */
  153.     /* won't waste time unpainting themselves */
  154.     /* (Must all be done in advance because one could close another that */
  155.     /*  wasn't unemployed yet) */
  156.     for (twin = wmgr_employedhead(); twin != NULL; twin = win_GetBelow(twin)) {
  157.         win_setemployed(twin, FALSE);
  158.     }
  159.     wmgr_ListClose(wmgr_employedhead());
  160.     wmgr_setemployedhead(NULL);
  161.  
  162.     wmgr_ListClose(wmgr_unemployedhead());
  163.     wmgr_setunemployedhead(NULL);
  164.  
  165.     obj_Close(disp_GetDispWin());
  166.     wmgr_setdispwin(NULL);
  167.  
  168.     wmgr_CloseTiler();
  169.  
  170.     hard_Release();
  171. }
  172. /* -------------------------------------------------------------------------- */
  173.  
  174.