home *** CD-ROM | disk | FTP | other *** search
- /*
- dispinit.c
-
- % Display manager initialization code.
-
- 5/16/88 by Ted.
-
- OWL 1.2
- Copyright (c) 1988, 1989 by Oakland Group, Inc.
- ALL RIGHTS RESERVED.
-
- Revision History:
- -----------------
- 8/09/88 jmd revised to use new object stuff
- 8/12/88 ted tested return value of ddisp_open()
- 8/17/88 jmd removed eNOMEM
- 8/24/88 ted merged driver and mode in to one stub function pointer.
- 3/20/89 ted made curr_dmgr a static structure
- 8/18/89 ted added disp_Repaint to end of disp_Init.
-
- 11/29/89 jmd added casts for DG
- 1/10/90 ted Added check for re-init and fixed inclose/disp_Ok logic.
- 1/18/90 ted Added dpref structure.
- 2/22/90 ted Added call to HC_DEINITMOUSE for turning off MGR interrupt.
- 3/28/90 jmd ansi-fied
- 5/03/90 jmd Added meta key elements to dpref structure.
- 6/22/90 ted added "void" to no-parameter function per ansii.
- 7/07/90 pmcm added initial value of FALSE for new softflow dpref member
- 7/31/90 bkd changed softflow to default to TRUE
- 9/28/90 pmcm added ctrlmeta and altmeta defaults
- 10/11/90 ted added initialization for pccbrk dpref element.
- */
-
- #include "oakhead.h"
- #include "disppriv.h"
- #include "dpref.h"
- #include "scancode.h" /* for KEY_NONE */
-
- /* The display preferences structure */
- OGLOBAL dpref_struct curr_dprefstruc = {
- 80, 25, FALSE, CTRL_A, CTRL_X, TRUE, FALSE
- };
-
- /* The current display manager structure */
- OGLOBAL dmgr_struct curr_dmgrstruc;
-
- /* The number of dmgrs that have been initted */
- OGLOBAL int num_dmgrs = 0;
-
- static char copyr[] = "OWL 1.2 Copyright (c) 1989 by Oakland Group, Inc.";
- /* -------------------------------------------------------------------------- */
-
- boolean disp_Init(dmode_fptr dmode, class_fptr backwin)
- /*
- Initialize the current display manager structure and its
- Device Interface Group functions.
- Returns TRUE if successful, FALSE if unable to initialize the device
- interface.
-
- 'dmode' Display mode initialization function
- 'backwin' Background window type
- */
- {
- if (disp_Ok()) { /* if curr_dmgr is already valid, don't open another */
- return(FALSE);
- }
- /* Initialize the display and hardware Device Interface Group. */
- if (!dispsetup(dmode)) {
- return(FALSE);
- }
- curr_dmgr->id = copyr[0]; /* To suppress unused-copyr compiler warning */
-
- /* Keep track of how many dmgrs have been initted, */
- /* and assign them consecutive id numbers starting from 1. */
-
- curr_dmgr->id = ++num_dmgrs;
-
- /* Initialize the window manager, w/ tiler and background window */
- if (!wmgr_Init(backwin)) {
- curr_dmgr->id = --num_dmgrs;
- return(FALSE);
- }
- /* Initialize the display */
- disp_Repaint();
-
- return(TRUE);
- }
- /* -------------------------------------------------------------------------- */
-
- void disp_Close(void)
- /*
- Close the current display manager.
- */
- {
- static boolean inclose = FALSE;
-
- /* Prevent re-entrant calls from going through this function */
- if (inclose) {
- return;
- }
- if (!disp_Ok()) { /* if curr_dmgr is not valid, don't close it */
- return;
- }
- inclose = TRUE;
-
- disp_HideMouse(); /* hide mouse */
- hard_Control(HC_DEINITMOUSE, NULL, NULL); /* turn mouse off */
-
- wmgr_Wrapup(); /* free all windows */
-
- disp_RestoreMode(); /* restore hardware display mode */
- disp_CloseDIG(); /* close down Device Interface Group */
-
- /* Wipe the dmgr data structure clean again */
- /* curr_dmgr->id == 0 is the element that we actually look at. */
- memset((VOID *) curr_dmgr, 0, sizeof(dmgr_struct));
-
- inclose = FALSE;
- }
- /* -------------------------------------------------------------------------- */
-
- boolean OWLPRIV dispsetup(dmode_fptr dmode)
- /*
- Do the work of initializing the display manager device interface stuff.
- */
- {
- /* Init disp data pointers to NULL */
- curr_dmgr->disp.info = NULL;
- curr_dmgr->disp.dig.data = NULL;
-
- /* Call the disp_struct's open ptr to set up dig structure and display mode */
- if (!(*dmode)(&curr_dmgr->disp.dig)) { /* Set up driver structure */
- return(FALSE);
- }
-
- /* Get device info struct ptr */
- disp_Control(DC_GETINFO, NULL, &curr_dmgr->disp.info);
-
- curr_dmgr->disp.mouse_timeout = 30; /* n/100 sec dclick/dhold time */
- curr_dmgr->disp.mouse_distout = ofont_GetWidth(disp_GetDefFont());
-
- return(TRUE);
- }
- /* -------------------------------------------------------------------------- */
-