home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / server / ddx / mi / miwindow.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-05-29  |  3.4 KB  |  111 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: miwindow.c,v 5.8 91/05/29 14:56:14 keith Exp $ */
  25. #include "X.h"
  26. #include "miscstruct.h"
  27. #include "region.h"
  28. #include "mi.h"
  29. #include "windowstr.h"
  30. #include "scrnintstr.h"
  31. #include "pixmapstr.h"
  32.  
  33. void 
  34. miClearToBackground(pWin, x, y, w, h, generateExposures)
  35.     WindowPtr pWin;
  36.     short x,y;
  37.     unsigned short w,h;
  38.     Bool generateExposures;
  39. {
  40.     BoxRec box;
  41.     RegionRec    reg;
  42.     RegionPtr pBSReg = NullRegion;
  43.     ScreenPtr    pScreen;
  44.     BoxPtr  extents;
  45.     int        x1, y1, x2, y2;
  46.  
  47.     /* compute everything using ints to avoid overflow */
  48.  
  49.     x1 = pWin->drawable.x + x;
  50.     y1 = pWin->drawable.y + y;
  51.     if (w)
  52.         x2 = x1 + (int) w;
  53.     else
  54.         x2 = x1 + (int) pWin->drawable.width - (int) x;
  55.     if (h)
  56.         y2 = y1 + h;    
  57.     else
  58.         y2 = y1 + (int) pWin->drawable.height - (int) y;
  59.  
  60.     extents = &pWin->clipList.extents;
  61.     
  62.     /* clip the resulting rectangle to the window clipList extents.  This
  63.      * makes sure that the result will fit in a box, given that the
  64.      * screen is < 32768 on a side.
  65.      */
  66.  
  67.     if (x1 < extents->x1)
  68.     x1 = extents->x1;
  69.     if (x2 > extents->x2)
  70.     x2 = extents->x2;
  71.     if (y1 < extents->y1)
  72.     y1 = extents->y1;
  73.     if (y2 > extents->y2)
  74.     y2 = extents->y2;
  75.  
  76.     if (x2 <= x1 || y2 <= y1)
  77.     {
  78.     x2 = x1 = 0;
  79.     y2 = y1 = 0;
  80.     }
  81.  
  82.     box.x1 = x1;
  83.     box.x2 = x2;
  84.     box.y1 = y1;
  85.     box.y2 = y2;
  86.  
  87.     pScreen = pWin->drawable.pScreen;
  88.     (*pScreen->RegionInit) (®, &box, 1);
  89.     if (pWin->backStorage)
  90.     {
  91.     /*
  92.      * If the window has backing-store on, call through the
  93.      * ClearToBackground vector to handle the special semantics
  94.      * (i.e. things backing store is to be cleared out and
  95.      * an Expose event is to be generated for those areas in backing
  96.      * store if generateExposures is TRUE).
  97.      */
  98.     pBSReg = (* pScreen->ClearBackingStore)(pWin, x, y, w, h,
  99.                          generateExposures);
  100.     }
  101.  
  102.     (* pScreen->Intersect)(®, ®, &pWin->clipList);
  103.     if (generateExposures)
  104.     (*pScreen->WindowExposures)(pWin, ®, pBSReg);
  105.     else if (pWin->backgroundState != None)
  106.         (*pScreen->PaintWindowBackground)(pWin, ®, PW_BACKGROUND);
  107.     (* pScreen->RegionUninit)(®);
  108.     if (pBSReg)
  109.     (* pScreen->RegionDestroy)(pBSReg);
  110. }
  111.