home *** CD-ROM | disk | FTP | other *** search
- /*
- dispcurr.c
-
- % Functions for borrowing and restoring the current display manager.
-
- 3/21/89 by Ted.
-
- OWL 1.1
- Copyright (c) 1988, 1989 by Oakland Group, Inc.
- ALL RIGHTS RESERVED.
-
- Revision History:
- -----------------
- */
-
- #include "oakhead.h"
- #include "disppriv.h"
-
- /* -------------------------------------------------------------------------- */
-
- VOID *disp_GetCurrent()
- /*
- 'Borrow' the current display manager so that it can be restored later after
- a different display manager has been put into effect.
- */
- {
- VOID *dispp;
-
- /* If the current dmgr is not valid, don't allow it to be copied */
- owl_Assert(disp_Ok(), OE_GC_DISP);
-
- /* Allocate a save area for a copy of the current dmgr */
- dispp = omalloc(OA_SAVDISP, sizeof(dmgr_struct) + curr_dmgr->disp.dig.datasize);
- if (dispp == NULL) {
- return(NULL);
- }
- /* Make a copy of the current dmgr structure */
- memmove(dispp, curr_dmgr, sizeof(dmgr_struct));
-
- /* Make a copy of the current dmgr's dig data */
- memmove(((char *) dispp) + sizeof(dmgr_struct),
- curr_dmgr->disp.dig.data,
- curr_dmgr->disp.dig.datasize);
-
- /* Make the current dmgr invalid because it has been borrowed */
- curr_dmgr->id = 0;
-
- return(dispp);
- }
- /* -------------------------------------------------------------------------- */
-
- boolean disp_SetCurrent(dispp)
- VOID *dispp;
- /*
- Put back into effect a display manager which has previously been 'borrowed'
- using disp_GetCurrent.
- NOTE: This function frees the 'borrowed' display manager. It must be
- borrowed again before it can be restored again.
- */
- {
- /* If the dmgr saved in dispp is not valid, don't install it */
- owl_Assert(dispp != NULL, OE_SC_DISP);
-
- /* Restore into the current dmgr structure */
- memmove(curr_dmgr, dispp, sizeof(dmgr_struct));
-
- /* Restore into the new dmgr's dig data */
- memmove(curr_dmgr->disp.dig.data,
- ((char *) dispp) + sizeof(dmgr_struct),
- curr_dmgr->disp.dig.datasize);
-
- /* Make the saved dmgr invalid because it has been un-borrowed */
- /* (In case someone looks at it even though it's about to be freed) */
- ((dmgr_struct *) dispp)->id = 0;
-
- /* Free the invalidated save area. */
- /* (It has to be borrowed again before it can be restored again) */
- ofree(OA_SAVDISP, dispp);
-
- /* Check the new dmgr now that it is installed */
- owl_Assert(disp_Ok(), OE_SC_DISP);
-
- return(TRUE);
- }
- /* -------------------------------------------------------------------------- */
-
-