home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / server / ddx / mfb / mfbscrinit.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-09-23  |  4.5 KB  |  130 lines

  1. /***********************************************************
  2. Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
  3. and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  4.  
  5.                         All Rights Reserved
  6.  
  7. Permission to use, copy, modify, and distribute this software and its 
  8. documentation for any purpose and without fee is hereby granted, 
  9. provided that the above copyright notice appear in all copies and that
  10. both that copyright notice and this permission notice appear in 
  11. supporting documentation, and that the names of Digital or MIT not be
  12. used in advertising or publicity pertaining to distribution of the
  13. software without specific, written prior permission.  
  14.  
  15. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  16. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  17. DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  18. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  19. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  20. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  21. SOFTWARE.
  22.  
  23. ******************************************************************/
  24. /* $XConsortium: mfbscrinit.c,v 5.12 90/09/24 10:19:29 rws Exp $ */
  25.  
  26. #include "X.h"
  27. #include "Xproto.h"    /* for xColorItem */
  28. #include "Xmd.h"
  29. #include "scrnintstr.h"
  30. #include "pixmapstr.h"
  31. #include "resource.h"
  32. #include "colormap.h"
  33. #include "mfb.h"
  34. #include "mistruct.h"
  35. #include "dix.h"
  36. #include "mi.h"
  37. #include "mibstore.h"
  38. #include "servermd.h"
  39.  
  40. extern RegionPtr mfbPixmapToRegion();
  41.  
  42. int mfbWindowPrivateIndex;
  43. int mfbGCPrivateIndex;
  44. static unsigned long mfbGeneration = 0;
  45.  
  46. static VisualRec visual = {
  47. /* vid  class       bpRGB cmpE nplan rMask gMask bMask oRed oGreen oBlue */
  48.    0,   StaticGray, 1,    2,   1,    0,    0,    0,    0,   0,     0
  49. };
  50.  
  51. static VisualID VID;
  52.  
  53. static DepthRec depth = {
  54. /* depth    numVid        vids */
  55.     1,        1,        &VID
  56. };
  57.  
  58. miBSFuncRec mfbBSFuncRec = {
  59.     mfbSaveAreas,
  60.     mfbRestoreAreas,
  61.     (void (*)()) 0,
  62.     (PixmapPtr (*)()) 0,
  63.     (PixmapPtr (*)()) 0,
  64. };
  65.  
  66. Bool
  67. mfbAllocatePrivates(pScreen, pWinIndex, pGCIndex)
  68.     ScreenPtr pScreen;
  69.     int *pWinIndex, *pGCIndex;
  70. {
  71.     if (mfbGeneration != serverGeneration)
  72.     {
  73.     mfbWindowPrivateIndex = AllocateWindowPrivateIndex();
  74.     mfbGCPrivateIndex = AllocateGCPrivateIndex();
  75.     visual.vid = FakeClientID(0);
  76.     VID = visual.vid;
  77.     mfbGeneration = serverGeneration;
  78.     }
  79.     if (pWinIndex)
  80.     *pWinIndex = mfbWindowPrivateIndex;
  81.     if (pGCIndex)
  82.     *pGCIndex = mfbGCPrivateIndex;
  83.     return (AllocateWindowPrivate(pScreen, mfbWindowPrivateIndex,
  84.                   sizeof(mfbPrivWin)) &&
  85.         AllocateGCPrivate(pScreen, mfbGCPrivateIndex, sizeof(mfbPrivGC)));
  86. }
  87.  
  88. /* dts * (inch/dot) * (25.4 mm / inch) = mm */
  89. Bool
  90. mfbScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width)
  91.     register ScreenPtr pScreen;
  92.     pointer pbits;        /* pointer to screen bitmap */
  93.     int xsize, ysize;        /* in pixels */
  94.     int dpix, dpiy;        /* dots per inch */
  95.     int width;            /* pixel width of frame buffer */
  96. {
  97.     if     (!mfbAllocatePrivates(pScreen, (int *)NULL, (int *)NULL))
  98.     return FALSE;
  99.     pScreen->defColormap = (Colormap) FakeClientID(0);
  100.     /* whitePixel, blackPixel */
  101.     pScreen->QueryBestSize = mfbQueryBestSize;
  102.     /* SaveScreen */
  103.     pScreen->GetImage = mfbGetImage;
  104.     pScreen->GetSpans = mfbGetSpans;
  105.     pScreen->CreateWindow = mfbCreateWindow;
  106.     pScreen->DestroyWindow = mfbDestroyWindow;
  107.     pScreen->PositionWindow = mfbPositionWindow;
  108.     pScreen->ChangeWindowAttributes = mfbChangeWindowAttributes;
  109.     pScreen->RealizeWindow = mfbMapWindow;
  110.     pScreen->UnrealizeWindow = mfbUnmapWindow;
  111.     pScreen->PaintWindowBackground = mfbPaintWindow;
  112.     pScreen->PaintWindowBorder = mfbPaintWindow;
  113.     pScreen->CopyWindow = mfbCopyWindow;
  114.     pScreen->CreatePixmap = mfbCreatePixmap;
  115.     pScreen->DestroyPixmap = mfbDestroyPixmap;
  116.     pScreen->RealizeFont = mfbRealizeFont;
  117.     pScreen->UnrealizeFont = mfbUnrealizeFont;
  118.     pScreen->CreateGC = mfbCreateGC;
  119.     pScreen->CreateColormap = mfbCreateColormap;
  120.     pScreen->DestroyColormap = mfbDestroyColormap;
  121.     pScreen->InstallColormap = mfbInstallColormap;
  122.     pScreen->UninstallColormap = mfbUninstallColormap;
  123.     pScreen->ListInstalledColormaps = mfbListInstalledColormaps;
  124.     pScreen->StoreColors = NoopDDA;
  125.     pScreen->ResolveColor = mfbResolveColor;
  126.     pScreen->BitmapToRegion = mfbPixmapToRegion;
  127.     return miScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width,
  128.             1, 1, &depth, VID, 1, &visual, &mfbBSFuncRec);
  129. }
  130.