home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c185 / 2.ddi / OWLSRC.EXE / CSCAPE / SOURCE / DISPCURR.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-09-06  |  2.4 KB  |  87 lines

  1. /*
  2.     dispcurr.c
  3.  
  4.     % Functions for borrowing and restoring the current display manager.
  5.  
  6.     3/21/89  by Ted.
  7.  
  8.     OWL 1.1
  9.     Copyright (c) 1988, 1989 by Oakland Group, Inc.
  10.     ALL RIGHTS RESERVED.
  11.  
  12.     Revision History:
  13.     -----------------
  14. */
  15.  
  16. #include "oakhead.h"
  17. #include "disppriv.h"
  18.  
  19. /* -------------------------------------------------------------------------- */
  20.  
  21. VOID *disp_GetCurrent()
  22. /*
  23.     'Borrow' the current display manager so that it can be restored later after
  24.     a different display manager has been put into effect.
  25. */
  26. {
  27.     VOID *dispp;
  28.  
  29.     /* If the current dmgr is not valid, don't allow it to be copied */
  30.     owl_Assert(disp_Ok(), OE_GC_DISP);
  31.  
  32.     /* Allocate a save area for a copy of the current dmgr */
  33.     dispp = omalloc(OA_SAVDISP, sizeof(dmgr_struct) + curr_dmgr->disp.dig.datasize);
  34.     if (dispp == NULL) {
  35.         return(NULL);
  36.     }
  37.     /* Make a copy of the current dmgr structure */
  38.     memmove(dispp, curr_dmgr, sizeof(dmgr_struct));
  39.  
  40.     /* Make a copy of the current dmgr's dig data */
  41.     memmove(((char *) dispp) + sizeof(dmgr_struct),
  42.             curr_dmgr->disp.dig.data,
  43.             curr_dmgr->disp.dig.datasize);
  44.  
  45.     /* Make the current dmgr invalid because it has been borrowed */
  46.     curr_dmgr->id = 0;
  47.  
  48.     return(dispp);
  49. }
  50. /* -------------------------------------------------------------------------- */
  51.  
  52. boolean disp_SetCurrent(dispp)
  53.     VOID *dispp;
  54. /*
  55.     Put back into effect a display manager which has previously been 'borrowed'
  56.     using disp_GetCurrent.
  57.     NOTE: This function frees the 'borrowed' display manager. It must be
  58.     borrowed again before it can be restored again.
  59. */
  60. {
  61.     /* If the dmgr saved in dispp is not valid, don't install it */
  62.     owl_Assert(dispp != NULL, OE_SC_DISP);
  63.  
  64.     /* Restore into the current dmgr structure */
  65.     memmove(curr_dmgr, dispp, sizeof(dmgr_struct));
  66.  
  67.     /* Restore into the new dmgr's dig data */
  68.     memmove(curr_dmgr->disp.dig.data,
  69.             ((char *) dispp) + sizeof(dmgr_struct),
  70.             curr_dmgr->disp.dig.datasize);
  71.  
  72.     /* Make the saved dmgr invalid because it has been un-borrowed */
  73.     /* (In case someone looks at it even though it's about to be freed) */
  74.     ((dmgr_struct *) dispp)->id = 0;
  75.  
  76.     /* Free the invalidated save area. */
  77.     /* (It has to be borrowed again before it can be restored again) */
  78.     ofree(OA_SAVDISP, dispp);
  79.  
  80.     /* Check the new dmgr now that it is installed */
  81.     owl_Assert(disp_Ok(), OE_SC_DISP);
  82.  
  83.     return(TRUE);
  84. }
  85. /* -------------------------------------------------------------------------- */
  86.  
  87.