home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c185 / 2.ddi / OWLSRC.EXE / CSCAPE / SOURCE / WMGRINIT.C < prev   
Encoding:
C/C++ Source or Header  |  1989-09-06  |  4.3 KB  |  164 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.1
  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.  
  18. #include "oakhead.h"
  19. #include "disppriv.h"
  20. #include "scancode.h"    /* for mouse pseudo-scancodes */
  21.  
  22. OGLOBAL win_type vid_win = NULL;    /* Global window ptr for old vid_funcs to use */
  23.  
  24. byte VACUUM          = 0x07;
  25. byte VACUUMSHADOW = 0x07;
  26.  
  27. /* -------------------------------------------------------------------------- */
  28.  
  29. boolean OWLPRIV wmgr_Init(backwin)
  30.     class_fptr backwin;         /* the background window type */
  31. /*
  32.     Initialize the windowing system.
  33.     Create the background window.
  34. */
  35. {
  36.     ptd_struct ptdata;
  37.     winopendata_struct wod;
  38.     opbox dbox;
  39.  
  40.     owl_Assert(disp_Ok(), OE_WI_DISP);
  41.  
  42.     hard_Claim();            /* Here for re-entrancy protection */
  43.  
  44.     disp_SetMouseCode(MOU_IGNORE);
  45.     wmgr_SetReplyStash(MOU_IGNORE);
  46.  
  47. /*    Note: all inits to 0, FALSE, NULL, & FNULL are superfluous because */
  48. /*    dmgr/wmgr structure is initted to 0's. */
  49. #ifdef OAK_NULLNOT0
  50.     wmgr_SetInMouseMsgFlag(FALSE);
  51.     wmgr_SetNewCurrentFlag(FALSE);
  52.     wmgr_SetSMMptr(FNULL);    /* SendMouseMessages ptr (init to NULL to be neat) */
  53.     wmgr_setcurrwin(NULL);
  54.     wmgr_lastmev()->win = NULL;    /* needed to initialize mouse handling */
  55.     disp_TrapMouseOff();
  56. #endif
  57.  
  58.     if (!wmgr_OpenTiler()) {
  59.         goto Quit0;
  60.     }
  61.     vid_win = NULL;    /* Start with vid_win NULL */
  62.  
  63.     /* Initialize employed and unemployed window lists */
  64.     if (wmgr_setemployedhead(wmgr_ListOpen()) == NULL) {
  65.         goto Quit1;
  66.     }
  67.     if (wmgr_setunemployedhead(wmgr_ListOpen()) == NULL) {
  68.         goto Quit2;
  69.     }
  70.     win_setemployed(wmgr_employedhead(), TRUE);
  71.     wmgr_setbotsyswin(wmgr_employedhead());
  72.     wmgr_setbotemployedwin(wmgr_employedhead());
  73.  
  74.     /* Create the display-covering pseudo-window */
  75.     dbox.ymin = 0;
  76.     dbox.xmin = 0;
  77.     dbox.ymax = disp_GetPixHeight();
  78.     dbox.xmax = disp_GetPixWidth();
  79.  
  80.     wod.boxp = &dbox;
  81.     wod.font = disp_GetDefFont();
  82.     wod.list = NULL;
  83.  
  84.     if (wmgr_setdispwin(win_OpenRaw(npwin_Class, &wod)) == NULL) {
  85.         goto Quit3;
  86.     }
  87.     disp_SetAttr(VACUUM);
  88.     disp_SetShadowAttr(VACUUMSHADOW);
  89.     win_SetCharSize(disp_GetDispWin(), FALSE);
  90.  
  91.     /* Open the background window and put it in the employed list. */
  92.     if (backwin != FNULL) {
  93.         wod.list = wmgr_employedhead();
  94.         if (wmgr_setbackwin(win_OpenRaw(backwin, &wod)) == NULL) {
  95.             goto Quit4;
  96.         }
  97.         /* We don't call win_Employ on it to avoid double painting and */
  98.         /* because we're still technically initializing the window manager. */
  99.         win_setemployed(disp_GetBackWin(), TRUE);
  100.  
  101.         /* Attempt to save from screen into background window */
  102.         ptdata.win = disp_GetBackWin();
  103.         ptdata.relboxp = &dbox;
  104.         ptdata.emsgdata = NULL;
  105.         win_Do(disp_GetBackWin(), WINM_ISAVE, &ptdata, NULL);
  106.  
  107.         if (win_GetId(disp_GetBackWin()) == ID_CMWIN) {
  108.             vid_win = disp_GetBackWin();
  109.         }
  110.     }
  111.     else wmgr_setbackwin(NULL);        /* No background window */
  112.  
  113.     /* Initialize the no-painting system windows */
  114.     /* Note: this function is macroed to nothing except on systems that need it.*/
  115.     owl_InitSysWins();
  116.  
  117.     hard_Release();
  118.     return(TRUE);
  119.  
  120. Quit4:    obj_Close(disp_GetDispWin());
  121. Quit3:    wmgr_ListClose(wmgr_unemployedhead());
  122. Quit2:    wmgr_ListClose(wmgr_employedhead());
  123. Quit1:    wmgr_CloseTiler();
  124. Quit0:    disp_Flush();
  125.         hard_Release();
  126.     return(FALSE);
  127. }
  128. /* -------------------------------------------------------------------------- */
  129.  
  130. void OWLPRIV wmgr_Wrapup()
  131. /*
  132.     Shut down windowing system.
  133. */
  134. {
  135.     win_type twin;
  136.  
  137.     owl_Assert(disp_Ok(), OE_WW_DISP);
  138.  
  139.     hard_Claim();        /* Here for re-entrancy protection */
  140.  
  141.     /* Massive Layoffs! */
  142.     /* Poke all employed windows unemployed before closing them, so they  */
  143.     /* won't waste time unpainting themselves */
  144.     /* (Must all be done in advance because one could close another that */
  145.     /*  wasn't unemployed yet) */
  146.     for (twin = wmgr_employedhead(); twin != NULL; twin = win_GetBelow(twin)) {
  147.         win_setemployed(twin, FALSE);
  148.     }
  149.     wmgr_ListClose(wmgr_employedhead());
  150.     wmgr_setemployedhead(NULL);
  151.  
  152.     wmgr_ListClose(wmgr_unemployedhead());
  153.     wmgr_setunemployedhead(NULL);
  154.  
  155.     obj_Close(disp_GetDispWin());
  156.     wmgr_setdispwin(NULL);
  157.  
  158.     wmgr_CloseTiler();
  159.  
  160.     hard_Release();
  161. }
  162. /* -------------------------------------------------------------------------- */
  163.  
  164.