1 /* $XConsortium: mfbwindow.c,v 5.14 94/04/17 20:28:36 dpw Exp $ */
2 /* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
3 /***********************************************************
5 Copyright (c) 1987 X Consortium
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software and associated documentation files (the "Software"), to deal
9 in the Software without restriction, including without limitation the rights
10 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 copies of the Software, and to permit persons to whom the Software is
12 furnished to do so, subject to the following conditions:
14 The above copyright notice and this permission notice shall be included in
15 all copies or substantial portions of the Software.
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 Except as contained in this notice, the name of the X Consortium shall not be
25 used in advertising or otherwise to promote the sale, use or other dealings
26 in this Software without prior written authorization from the X Consortium.
29 Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
33 Permission to use, copy, modify, and distribute this software and its
34 documentation for any purpose and without fee is hereby granted,
35 provided that the above copyright notice appear in all copies and that
36 both that copyright notice and this permission notice appear in
37 supporting documentation, and that the name of Digital not be
38 used in advertising or publicity pertaining to distribution of the
39 software without specific, written prior permission.
41 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
42 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
43 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
44 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
45 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
46 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
49 ******************************************************************/
52 #include "scrnintstr.h"
53 #include "windowstr.h"
56 #include "regionstr.h"
59 extern WindowPtr *WindowTable;
63 register WindowPtr pWin;
65 register mfbPrivWin *pPrivWin;
67 pPrivWin = (mfbPrivWin *)(pWin->devPrivates[mfbWindowPrivateIndex].ptr);
68 pPrivWin->pRotatedBorder = NullPixmap;
69 pPrivWin->pRotatedBackground = NullPixmap;
70 pPrivWin->fastBackground = FALSE;
71 pPrivWin->fastBorder = FALSE;
76 /* This always returns true, because Xfree can't fail. It might be possible
77 * on some devices for Destroy to fail */
79 mfbDestroyWindow(pWin)
82 register mfbPrivWin *pPrivWin;
84 pPrivWin = (mfbPrivWin *)(pWin->devPrivates[mfbWindowPrivateIndex].ptr);
86 if (pPrivWin->pRotatedBorder)
87 (*pWin->drawable.pScreen->DestroyPixmap)(pPrivWin->pRotatedBorder);
88 if (pPrivWin->pRotatedBackground)
89 (*pWin->drawable.pScreen->DestroyPixmap)(pPrivWin->pRotatedBackground);
94 Bool mfbMapWindow(pWindow)
100 /* (x, y) is the upper left corner of the window on the screen
101 do we really need to pass this? (is it a;ready in pWin->absCorner?)
102 we only do the rotation for pixmaps that are 32 bits wide (padded
104 mfbChangeWindowAttributes() has already put a copy of the pixmap
105 in pPrivWin->pRotated*
110 mfbPositionWindow(pWin, x, y)
111 register WindowPtr pWin;
114 register mfbPrivWin *pPrivWin;
117 pPrivWin = (mfbPrivWin *)(pWin->devPrivates[mfbWindowPrivateIndex].ptr);
118 if (pWin->backgroundState == BackgroundPixmap && pPrivWin->fastBackground)
120 mfbXRotatePixmap(pPrivWin->pRotatedBackground,
121 pWin->drawable.x - pPrivWin->oldRotate.x);
122 mfbYRotatePixmap(pPrivWin->pRotatedBackground,
123 pWin->drawable.y - pPrivWin->oldRotate.y);
127 if (!pWin->borderIsPixel && pPrivWin->fastBorder)
129 while (pWin->backgroundState == ParentRelative)
131 mfbXRotatePixmap(pPrivWin->pRotatedBorder,
132 pWin->drawable.x - pPrivWin->oldRotate.x);
133 mfbYRotatePixmap(pPrivWin->pRotatedBorder,
134 pWin->drawable.y - pPrivWin->oldRotate.y);
139 pPrivWin->oldRotate.x = pWin->drawable.x;
140 pPrivWin->oldRotate.y = pWin->drawable.y;
143 /* This is the "wrong" fix to the right problem, but it doesn't really
144 * cost very much. When the window is moved, we need to invalidate any
145 * RotatedPixmap that exists in any GC currently validated against this
148 pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER;
150 /* Again, we have no failure modes indicated by any of the routines
151 * we've called, so we have to assume it worked */
157 mfbUnmapWindow(pWindow)
164 this code calls the bitblt helper code directly.
166 mfbCopyWindow copies only the parts of the destination that are
167 visible in the source.
172 mfbCopyWindow(pWin, ptOldOrg, prgnSrc)
174 DDXPointRec ptOldOrg;
178 register DDXPointPtr ppt;
180 register BoxPtr pbox;
182 register int i, nbox;
185 pwinRoot = WindowTable[pWin->drawable.pScreen->myNum];
187 prgnDst = REGION_CREATE(pWin->drawable.pScreen, NULL, 1);
189 dx = ptOldOrg.x - pWin->drawable.x;
190 dy = ptOldOrg.y - pWin->drawable.y;
191 REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy);
192 REGION_INTERSECT(pWin->drawable.pScreen, prgnDst, &pWin->borderClip,
195 pbox = REGION_RECTS(prgnDst);
196 nbox = REGION_NUM_RECTS(prgnDst);
197 if(!(pptSrc = (DDXPointPtr )ALLOCATE_LOCAL(nbox * sizeof(DDXPointRec))))
201 for (i=nbox; --i >= 0; ppt++, pbox++)
203 ppt->x = pbox->x1 + dx;
204 ppt->y = pbox->y1 + dy;
207 mfbDoBitblt((DrawablePtr)pwinRoot, (DrawablePtr)pwinRoot,
208 GXcopy, prgnDst, pptSrc);
209 DEALLOCATE_LOCAL(pptSrc);
210 REGION_DESTROY(pWin->drawable.pScreen, prgnDst);
215 /* swap in correct PaintWindow* routine. If we can use a fast output
216 routine (i.e. the pixmap is paddable to 32 bits), also pre-rotate a copy
220 mfbChangeWindowAttributes(pWin, mask)
221 register WindowPtr pWin;
222 register unsigned long mask;
224 register unsigned long index;
225 register mfbPrivWin *pPrivWin;
228 pPrivWin = (mfbPrivWin *)(pWin->devPrivates[mfbWindowPrivateIndex].ptr);
230 * When background state changes from ParentRelative and
231 * we had previously rotated the fast border pixmap to match
232 * the parent relative origin, rerotate to match window
234 if (mask & (CWBackPixmap | CWBackPixel) &&
235 pWin->backgroundState != ParentRelative &&
236 pPrivWin->fastBorder &&
237 (pPrivWin->oldRotate.x != pWin->drawable.x ||
238 pPrivWin->oldRotate.y != pWin->drawable.y))
240 mfbXRotatePixmap(pPrivWin->pRotatedBorder,
241 pWin->drawable.x - pPrivWin->oldRotate.x);
242 mfbYRotatePixmap(pPrivWin->pRotatedBorder,
243 pWin->drawable.y - pPrivWin->oldRotate.y);
244 pPrivWin->oldRotate.x = pWin->drawable.x;
245 pPrivWin->oldRotate.y = pWin->drawable.y;
249 index = lowbit (mask);
254 if (pWin->backgroundState == None)
256 pPrivWin->fastBackground = FALSE;
258 else if (pWin->backgroundState == ParentRelative)
260 pPrivWin->fastBackground = FALSE;
261 /* Rotate border to match parent origin */
262 if (pPrivWin->pRotatedBorder) {
263 for (pBgWin = pWin->parent;
264 pBgWin->backgroundState == ParentRelative;
265 pBgWin = pBgWin->parent);
266 mfbXRotatePixmap(pPrivWin->pRotatedBorder,
267 pBgWin->drawable.x - pPrivWin->oldRotate.x);
268 mfbYRotatePixmap(pPrivWin->pRotatedBorder,
269 pBgWin->drawable.y - pPrivWin->oldRotate.y);
270 pPrivWin->oldRotate.x = pBgWin->drawable.x;
271 pPrivWin->oldRotate.y = pBgWin->drawable.y;
274 else if ((pWin->background.pixmap->drawable.width <= PPW) &&
275 !(pWin->background.pixmap->drawable.width &
276 (pWin->background.pixmap->drawable.width - 1)))
278 mfbCopyRotatePixmap(pWin->background.pixmap,
279 &pPrivWin->pRotatedBackground,
282 if (pPrivWin->pRotatedBackground)
284 pPrivWin->fastBackground = TRUE;
285 pPrivWin->oldRotate.x = pWin->drawable.x;
286 pPrivWin->oldRotate.y = pWin->drawable.y;
290 pPrivWin->fastBackground = FALSE;
295 pPrivWin->fastBackground = FALSE;
300 pPrivWin->fastBackground = FALSE;
304 if ((pWin->border.pixmap->drawable.width <= PPW) &&
305 !(pWin->border.pixmap->drawable.width &
306 (pWin->border.pixmap->drawable.width - 1)))
309 pBgWin->backgroundState == ParentRelative;
310 pBgWin = pBgWin->parent);
311 mfbCopyRotatePixmap(pWin->border.pixmap,
312 &pPrivWin->pRotatedBorder,
315 if (pPrivWin->pRotatedBorder)
317 pPrivWin->fastBorder = TRUE;
318 pPrivWin->oldRotate.x = pBgWin->drawable.x;
319 pPrivWin->oldRotate.y = pBgWin->drawable.y;
323 pPrivWin->fastBorder = FALSE;
328 pPrivWin->fastBorder = FALSE;
332 pPrivWin->fastBorder = FALSE;
336 /* Again, we have no failure modes indicated by any of the routines
337 * we've called, so we have to assume it worked */