home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / x / xibm.zip / common / ibmSave.c < prev    next >
C/C++ Source or Header  |  1991-09-20  |  8KB  |  304 lines

  1. /*
  2.  * $Id: ibmSave.c,v 1.1 1991/09/20 18:24:03 mtranle Exp $
  3.  *
  4.  * Copyright IBM Corporation 1987,1988,1989
  5.  *
  6.  * All Rights Reserved
  7.  *
  8.  * Permission to use, copy, modify, and distribute this software and its
  9.  * documentation for any purpose and without fee is hereby granted,
  10.  * provided that the above copyright notice appear in all copies and that 
  11.  * both that copyright notice and this permission notice appear in
  12.  * supporting documentation, and that the name of IBM not be
  13.  * used in advertising or publicity pertaining to distribution of the
  14.  * software without specific, written prior permission.
  15.  *
  16.  * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  17.  * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  18.  * IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  19.  * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  20.  * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  21.  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  22.  * SOFTWARE.
  23.  *
  24. */
  25. #if defined(IBM_OS_HAS_HFT) && !defined(IBM_OS_HAS_X_QUEUE)
  26. #define HFT_HACKS "Oh !"
  27. #endif
  28.  
  29. #if defined(HFT_HACKS)
  30.  
  31. #include <sys/types.h>
  32. #include <sys/time.h>
  33.  
  34. #define NEED_EVENTS
  35.  
  36. #include "X.h"
  37. #define NEED_REPLIES
  38. #include "Xproto.h"
  39. #include "misc.h"
  40. #include "scrnintstr.h"
  41. #include "os.h"
  42. #include "regionstr.h"
  43. #include "windowstr.h"
  44. #include "input.h"
  45. #include "resource.h"
  46. #include "colormapst.h"
  47. #include "cursorstr.h"
  48. #include "dixstruct.h"
  49. #include "gc.h"
  50. #include "gcstruct.h"
  51. #include "servermd.h"
  52. #include "miscstruct.h"
  53. #include "pixmapstr.h"
  54. #include "colormap.h"
  55.  
  56. #include "ibmKeybd.h"
  57. #include "ibmMouse.h"
  58. #include "ibmCmdArgs.h"
  59. #include "ibmScreen.h"
  60.  
  61. #include "OSio.h"
  62. #include "OScompiler.h"
  63.  
  64. #else 
  65.  
  66. #include "X.h"
  67. #include "scrnintstr.h"
  68. #include "cursor.h"
  69. #include "windowstr.h"
  70. #include "window.h"
  71.  
  72. #endif /* defined(HFT_HACKS) */
  73.  
  74. #include "ibmTrace.h"
  75.  
  76. extern WindowPtr *WindowTable ;
  77.  
  78. /***====================================================================***/
  79.  
  80. WindowPtr
  81. ObscureEntireScreen( pScreen )
  82. register ScreenPtr pScreen ;
  83. {
  84. register WindowPtr pWin ;
  85. static unsigned mask = CWSaveUnder ;
  86. #if defined(DO_SCREEN_SAVE_UNDERS_ON_HOTKEY)
  87. static XID attributes = 1 ;
  88. #else
  89. static XID attributes = 0 ;
  90. #endif
  91. int result ;
  92.  
  93.     TRACE( ( "ObscureEntireScreen(0x%X) %d\n", pScreen, attributes ) ) ;
  94.  
  95.     pWin =
  96.     CreateWindow( FakeClientID( 0 ) ,        /* window id */
  97.               WindowTable[pScreen->myNum],    /* parent */
  98.               0, 0,                /* x, y */
  99.               pScreen->width,            /* width */
  100.               pScreen->height,            /* height */
  101.               0,                /* border width */
  102.               InputOutput,            /* class */
  103.               mask,
  104.               &attributes,            /* attributes */
  105.               0,                /* depth */
  106.               (ClientPtr) NULL,            /* client */
  107.               WindowTable[pScreen->myNum]->optional->visual,
  108.                              /* visual */
  109.               &result ) ;            /* error */
  110.     AddResource( pWin->drawable.id, RT_WINDOW, (pointer) pWin ) ;
  111.     pWin->overrideRedirect = TRUE ;
  112.     /* pWin->cursor = BlankCursor ; Should use special cursor !! */
  113.     MapWindow( pWin, TRUE, FALSE, FALSE, (ClientPtr) NULL ) ;
  114.     return pWin ;
  115. }
  116.  
  117. #if defined(HFT_HACKS)
  118.  
  119. /***====================================================================***/
  120.  
  121. static    WindowPtr obscuringWins[MAXSCREENS];
  122. extern    int    ScreenSaverTime,ScreenSaverInterval;
  123. extern long defaultScreenSaverTime, defaultScreenSaverInterval;
  124. static    int    realSaverTime = -1;
  125. static    int    realSaverInterval = -1;
  126. #ifdef AIXrt
  127.     int    ibmRefreshOnActivate= FALSE;
  128. #else
  129.     int    ibmRefreshOnActivate= TRUE;
  130. #endif
  131.  
  132. /***====================================================================***/
  133.  
  134.     /*
  135.      * 11/20/88 () -- do we want to turn on save unders here if
  136.      *    RefreshOnActivate is false?
  137.      */
  138. void
  139. ibmObscureScreen(pScreen)
  140. ScreenPtr    pScreen;
  141. {
  142.     TRACE(("ibmObscureScreen()\n"));
  143.     obscuringWins[pScreen->myNum]= ObscureEntireScreen( pScreen ) ;
  144.     return;
  145. }
  146.  
  147. /***====================================================================***/
  148.  
  149. void
  150. ibmExposeScreen(pScreen)
  151. ScreenPtr    pScreen;
  152. {
  153. WindowPtr    pWin= obscuringWins[pScreen->myNum];
  154.  
  155.     TRACE(("ibmExposeScreen(0x%x)\n",pScreen));
  156.     FreeResource(pWin->drawable.id,RC_VANILLA);
  157.     obscuringWins[pScreen->myNum]= NULL;
  158.     return;
  159. }
  160.  
  161. /***====================================================================***/
  162.  
  163. static    PixmapPtr saveMaps[MAXSCREENS];
  164.  
  165. PixmapPtr
  166. ibmSaveScreenData(pScreen,pSaveFunc)
  167. ScreenPtr    pScreen;
  168. void        (*pSaveFunc)();
  169. {
  170. RegionPtr    pRgn;
  171. PixmapPtr    pPix;
  172.  
  173.     TRACE(("ibmSaveScreenData(0x%x)\n",pScreen));
  174.     pRgn= &(WindowTable[pScreen->myNum]->winSize);
  175.     if (!saveMaps[pScreen->myNum]) {
  176.     saveMaps[pScreen->myNum]= (*pScreen->CreatePixmap)(pScreen,
  177.                         REGION_RECTS(pRgn)->x2,
  178.                         REGION_RECTS(pRgn)->y2,
  179.                         pScreen->rootDepth);
  180.     }
  181.     pPix= saveMaps[pScreen->myNum];
  182.     (*pSaveFunc)(pPix,pRgn,0,0);
  183.     return(pPix);
  184. }
  185.  
  186. /***====================================================================***/
  187.  
  188. void
  189. ibmRestoreScreenData(pScreen,pRestoreFunc)
  190. ScreenPtr    pScreen;
  191. void        (*pRestoreFunc)();
  192. {
  193. RegionPtr    pRgn;
  194.  
  195.     TRACE(("ibmRestoreScreenData(0x%x)\n",pScreen));
  196.     pRgn= &(WindowTable[pScreen->myNum]->winSize);
  197.     (*pRestoreFunc)(saveMaps[pScreen->myNum],pRgn,0,0);
  198.     return;
  199. }
  200.  
  201. /***====================================================================***/
  202.  
  203. void
  204. ibmDeactivateScreens()
  205. {
  206. ScreenPtr     pScreen;
  207. void         (*fnp)();
  208. int        scrn;
  209.  
  210.     TRACE(("ibmDeactivateScreens()\n"));
  211. #ifdef OS_SaveState
  212.     OS_SaveState();
  213. #endif
  214.     /*
  215.      * 11/20/88 (ef) -- XXX!  Temporary.  once we deal with the nuances
  216.      *        of keeping the server alive when screens go away, we won't
  217.      *        have to deal with the screen saver anymore.
  218.      */
  219.     realSaverTime= ScreenSaverTime;
  220.     realSaverInterval= ScreenSaverInterval;
  221.     ScreenSaverTime= ScreenSaverInterval= 0;
  222.     for (scrn = 0; scrn < ibmNumScreens; scrn++) {
  223.  
  224.     pScreen = ibmScreen(scrn);
  225.     if ((!pScreen)||(ibmScreenState(pScreen->myNum)!=SCREEN_ACTIVE))
  226.         continue;
  227.     if (!pScreen) {
  228.         ErrorF("WSGO!!! trying to deactivate null screen\n");
  229.         ErrorF("to debug: ask Paquin what's going on here\n");
  230.         return ;
  231.     }
  232.  
  233.     if (ibmRefreshOnActivate)    ibmObscureScreen(pScreen);
  234.  
  235.     /* find out what the screen wants to do vis-a-vis saving */
  236.     fnp = ibmScreens[scrn]->ibm_SaveFunc;
  237.     if (fnp) (*fnp)(pScreen,!ibmRefreshOnActivate);
  238.     ibmSetScreenState(pScreen->myNum,SCREEN_INACTIVE);
  239.     }
  240.     /*
  241.      * 11/20/88 (ef) -- XXX!!  Temporary.  We really want to keep the
  242.      *       server alive but obscured.
  243.      */
  244.     DontListenToAnybody();
  245.     return;
  246. }
  247.  
  248. void
  249. ibmReactivateScreens()
  250. {
  251. ScreenPtr     pScreen;
  252. void         (*fnp)(); /* "fnp" means "FunctionPointer" */
  253. int        scrn;
  254. WindowPtr    pRoot;
  255. ColormapPtr    pCmap;
  256.  
  257.  
  258.     TRACE(("ibmReactivateScreens()\n"));
  259. #ifdef OS_RestoreState
  260.     OS_RestoreState();
  261. #endif
  262.  
  263.     /*
  264.      * 11/20/88 (ef) -- XXX! Temporary -- we really want to keep the server
  265.      *        alive.  Once we do, we won't have to disable the screen
  266.      *        saver anymore.
  267.      */
  268.     if ( realSaverTime == -1 )
  269.     {
  270.     realSaverTime = defaultScreenSaverTime;
  271.     }
  272.     if ( realSaverInterval == -1 )
  273.     {
  274.     realSaverInterval = defaultScreenSaverInterval;
  275.     }
  276.     ScreenSaverTime= realSaverTime;
  277.     ScreenSaverInterval= realSaverInterval;;
  278.     PayAttentionToClientsAgain();
  279.     for (scrn = 0; scrn < ibmNumScreens; scrn++) {
  280.     pScreen = ibmScreen(scrn);
  281.     if ((!pScreen)||(ibmScreenState(pScreen->myNum)!=SCREEN_INACTIVE))
  282.         continue;
  283.  
  284.     /*
  285.      * 11/21/88 (ef) -- XXX!  PS/2 screens are setting their own
  286.      *        screen state, RT screens expect us to do it
  287.      *        for them.  It's not clear to me if it makes
  288.      *        all that much of a difference.   Leave it for
  289.      *        now, but we should figure this out someday.
  290.      */
  291. #ifdef AIXrt
  292.     ibmSetScreenState(pScreen->myNum,SCREEN_ACTIVE);
  293. #endif
  294.  
  295.     fnp = ibmScreens[scrn]->ibm_RestoreFunc;
  296.     if (fnp)
  297.         (*fnp)(pScreen,!ibmRefreshOnActivate);
  298.     if (ibmRefreshOnActivate)    ibmExposeScreen(pScreen);
  299.     }
  300.     return;
  301. }
  302.  
  303. #endif /* HFT_HACKS */
  304.