home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / server / ddx / mi / miscrinit.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-05-14  |  5.1 KB  |  150 lines

  1. /*
  2.  
  3. Copyright 1990 by the Massachusetts Institute of Technology
  4.  
  5. Permission to use, copy, modify, distribute, and sell this software and its
  6. documentation for any purpose is hereby granted without fee, provided that
  7. the above copyright notice appear in all copies and that both that
  8. copyright notice and this permission notice appear in supporting
  9. documentation, and that the name of M.I.T. not be used in advertising or
  10. publicity pertaining to distribution of the software without specific,
  11. written prior permission.  M.I.T. makes no representations about the
  12. suitability of this software for any purpose.  It is provided "as is"
  13. without express or implied warranty.
  14.  
  15. */
  16.  
  17. /* $XConsortium: miscrinit.c,v 5.2 91/05/14 11:17:40 rws Exp $ */
  18.  
  19. #include "X.h"
  20. #include "servermd.h"
  21. #include "misc.h"
  22. #include "mi.h"
  23. #include "scrnintstr.h"
  24. #include "pixmapstr.h"
  25. #include "mibstore.h"
  26. #include "dix.h"
  27.  
  28. /*ARGSUSED*/
  29. static Bool
  30. miCloseScreen (index, pScreen)
  31.     int        index;
  32.     ScreenPtr    pScreen;
  33. {
  34.     xfree (pScreen->devPrivate);
  35.     return TRUE;
  36. }
  37.  
  38. /*
  39.  * If you pass in bsfuncs, then you must preinitialize the missing
  40.  * screen procs before calling miScreenInit, so that the backing store
  41.  * code can correctly wrap them.
  42.  */
  43.  
  44. Bool
  45. miScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width,
  46.          rootDepth, numDepths, depths, rootVisual, numVisuals, visuals,
  47.          bsfuncs)
  48.     register ScreenPtr pScreen;
  49.     pointer pbits;        /* pointer to screen bits */
  50.     int xsize, ysize;        /* in pixels */
  51.     int dpix, dpiy;        /* dots per inch */
  52.     int width;            /* pixel width of frame buffer */
  53.     int rootDepth;        /* depth of root window */
  54.     int numDepths;        /* number of depths supported */
  55.     DepthRec *depths;        /* supported depths */
  56.     VisualID rootVisual;    /* root visual */
  57.     int numVisuals;        /* number of visuals supported */
  58.     VisualRec *visuals;        /* supported visuals */
  59.     miBSFuncPtr    bsfuncs;    /* backing store functions */
  60. {
  61.     pScreen->width = xsize;
  62.     pScreen->height = ysize;
  63.     pScreen->mmWidth = (xsize * 254) / (dpix * 10);
  64.     pScreen->mmHeight = (ysize * 254) / (dpiy * 10);
  65.     pScreen->numDepths = numDepths;
  66.     pScreen->rootDepth = rootDepth;
  67.     pScreen->allowedDepths = depths;
  68.     pScreen->rootVisual = rootVisual;
  69.     /* defColormap */
  70.     pScreen->minInstalledCmaps = 1;
  71.     pScreen->maxInstalledCmaps = 1;
  72.     pScreen->backingStoreSupport = Always;
  73.     pScreen->saveUnderSupport = NotUseful;
  74.     /* whitePixel, blackPixel */
  75.     if (width)
  76.     {
  77.     PixmapPtr pPixmap;
  78.  
  79.     pPixmap = (PixmapPtr ) xalloc(sizeof(PixmapRec));
  80.     if (!pPixmap)
  81.         return FALSE;
  82.     pPixmap->drawable.type = DRAWABLE_PIXMAP;
  83.     pPixmap->drawable.depth = rootDepth;
  84.     pPixmap->drawable.pScreen = pScreen;
  85.     pPixmap->drawable.serialNumber = 0;
  86.     pPixmap->drawable.x = 0;
  87.     pPixmap->drawable.y = 0;
  88.     pPixmap->drawable.width = xsize;
  89.     pPixmap->drawable.height = ysize;
  90.     pPixmap->refcnt = 1;
  91.     pPixmap->devPrivate.ptr = pbits;
  92.     pPixmap->devKind = PixmapBytePad(width, rootDepth);
  93.     pScreen->devPrivate = (pointer)pPixmap;
  94. #ifdef MITSHM
  95.     ShmRegisterFbFuncs(pScreen);
  96. #endif
  97.     }
  98.     else
  99.     pScreen->devPrivate = pbits;
  100.     pScreen->numVisuals = numVisuals;
  101.     pScreen->visuals = visuals;
  102.     if (width)
  103.     pScreen->CloseScreen = miCloseScreen;
  104.     /* else CloseScreen */
  105.     /* QueryBestSize, SaveScreen, GetImage, GetSpans */
  106.     pScreen->PointerNonInterestBox = (void (*)()) 0;
  107.     pScreen->SourceValidate = (void (*)()) 0;
  108.     /* CreateWindow, DestroyWindow, PositionWindow, ChangeWindowAttributes */
  109.     /* RealizeWindow, UnrealizeWindow */
  110.     pScreen->ValidateTree = miValidateTree;
  111.     pScreen->PostValidateTree = (void (*)()) 0;
  112.     pScreen->WindowExposures = miWindowExposures;
  113.     /* PaintWindowBackground, PaintWindowBorder, CopyWindow */
  114.     pScreen->ClearToBackground = miClearToBackground;
  115.     pScreen->ClipNotify = (void (*)()) 0;
  116.     /* CreatePixmap, DestroyPixmap */
  117.     /* RealizeFont, UnrealizeFont */
  118.     /* CreateGC */
  119.     /* CreateColormap, DestroyColormap, InstallColormap, UninstallColormap */
  120.     /* ListInstalledColormaps, StoreColors, ResolveColor */
  121.     pScreen->RegionCreate = miRegionCreate;
  122.     pScreen->RegionInit = miRegionInit;
  123.     pScreen->RegionCopy = miRegionCopy;
  124.     pScreen->RegionDestroy = miRegionDestroy;
  125.     pScreen->RegionUninit = miRegionUninit;
  126.     pScreen->Intersect = miIntersect;
  127.     pScreen->Union = miUnion;
  128.     pScreen->Subtract = miSubtract;
  129.     pScreen->Inverse = miInverse;
  130.     pScreen->RegionReset = miRegionReset;
  131.     pScreen->TranslateRegion = miTranslateRegion;
  132.     pScreen->RectIn = miRectIn;
  133.     pScreen->PointInRegion = miPointInRegion;
  134.     pScreen->RegionNotEmpty = miRegionNotEmpty;
  135.     pScreen->RegionEmpty = miRegionEmpty;
  136.     pScreen->RegionExtents = miRegionExtents;
  137.     pScreen->RegionAppend = miRegionAppend;
  138.     pScreen->RegionValidate = miRegionValidate;
  139.     /* BitmapToRegion */
  140.     pScreen->RectsToRegion = miRectsToRegion;
  141.     pScreen->SendGraphicsExpose = miSendGraphicsExpose;
  142.     pScreen->BlockHandler = NoopDDA;
  143.     pScreen->WakeupHandler = NoopDDA;
  144.     pScreen->blockData = (pointer)0;
  145.     pScreen->wakeupData = (pointer)0;
  146.     if (bsfuncs)
  147.     miInitializeBackingStore (pScreen, bsfuncs);
  148.     return TRUE;
  149. }
  150.