1 /* $XConsortium: cfbwindow.c,v 5.22 94/04/17 20:29:07 dpw Exp $ */
2 /***********************************************************
4 Copyright (c) 1987 X Consortium
6 Permission is hereby granted, free of charge, to any person obtaining a copy
7 of this software and associated documentation files (the "Software"), to deal
8 in the Software without restriction, including without limitation the rights
9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 copies of the Software, and to permit persons to whom the Software is
11 furnished to do so, subject to the following conditions:
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 Except as contained in this notice, the name of the X Consortium shall not be
24 used in advertising or otherwise to promote the sale, use or other dealings
25 in this Software without prior written authorization from the X Consortium.
28 Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
32 Permission to use, copy, modify, and distribute this software and its
33 documentation for any purpose and without fee is hereby granted,
34 provided that the above copyright notice appear in all copies and that
35 both that copyright notice and this permission notice appear in
36 supporting documentation, and that the name of Digital not be
37 used in advertising or publicity pertaining to distribution of the
38 software without specific, written prior permission.
40 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
41 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
42 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
43 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
44 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
45 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
48 ******************************************************************/
51 #include "scrnintstr.h"
52 #include "windowstr.h"
55 #include "regionstr.h"
56 #include "cfbmskbits.h"
58 extern WindowPtr *WindowTable;
66 pPrivWin = cfbGetWindowPrivate(pWin);
67 pPrivWin->pRotatedBorder = NullPixmap;
68 pPrivWin->pRotatedBackground = NullPixmap;
69 pPrivWin->fastBackground = FALSE;
70 pPrivWin->fastBorder = FALSE;
71 pPrivWin->oldRotate.x = 0;
72 pPrivWin->oldRotate.y = 0;
74 #ifdef PIXMAP_PER_WINDOW
75 /* Setup pointer to Screen pixmap */
76 pWin->devPrivates[frameWindowPrivateIndex].ptr =
77 (pointer) cfbGetScreenPixmap(pWin->drawable.pScreen);
84 cfbDestroyWindow(pWin)
89 pPrivWin = cfbGetWindowPrivate(pWin);
91 if (pPrivWin->pRotatedBorder)
92 (*pWin->drawable.pScreen->DestroyPixmap)(pPrivWin->pRotatedBorder);
93 if (pPrivWin->pRotatedBackground)
94 (*pWin->drawable.pScreen->DestroyPixmap)(pPrivWin->pRotatedBackground);
100 cfbMapWindow(pWindow)
106 /* (x, y) is the upper left corner of the window on the screen
107 do we really need to pass this? (is it a;ready in pWin->absCorner?)
108 we only do the rotation for pixmaps that are 32 bits wide (padded
110 cfbChangeWindowAttributes() has already put a copy of the pixmap
111 in pPrivWin->pRotated*
115 cfbPositionWindow(pWin, x, y)
119 cfbPrivWin *pPrivWin;
122 pPrivWin = cfbGetWindowPrivate(pWin);
123 if (pWin->backgroundState == BackgroundPixmap && pPrivWin->fastBackground)
125 cfbXRotatePixmap(pPrivWin->pRotatedBackground,
126 pWin->drawable.x - pPrivWin->oldRotate.x);
127 cfbYRotatePixmap(pPrivWin->pRotatedBackground,
128 pWin->drawable.y - pPrivWin->oldRotate.y);
132 if (!pWin->borderIsPixel && pPrivWin->fastBorder)
134 while (pWin->backgroundState == ParentRelative)
136 cfbXRotatePixmap(pPrivWin->pRotatedBorder,
137 pWin->drawable.x - pPrivWin->oldRotate.x);
138 cfbYRotatePixmap(pPrivWin->pRotatedBorder,
139 pWin->drawable.y - pPrivWin->oldRotate.y);
144 pPrivWin->oldRotate.x = pWin->drawable.x;
145 pPrivWin->oldRotate.y = pWin->drawable.y;
152 cfbUnmapWindow(pWindow)
159 this code calls the bitblt helper code directly.
161 cfbCopyWindow copies only the parts of the destination that are
162 visible in the source.
167 cfbCopyWindow(pWin, ptOldOrg, prgnSrc)
169 DDXPointRec ptOldOrg;
173 register DDXPointPtr ppt;
175 register BoxPtr pbox;
177 register int i, nbox;
180 pwinRoot = WindowTable[pWin->drawable.pScreen->myNum];
182 REGION_INIT(pWin->drawable.pScreen, &rgnDst, NullBox, 0);
184 dx = ptOldOrg.x - pWin->drawable.x;
185 dy = ptOldOrg.y - pWin->drawable.y;
186 REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy);
187 REGION_INTERSECT(pWin->drawable.pScreen, &rgnDst, &pWin->borderClip, prgnSrc);
189 pbox = REGION_RECTS(&rgnDst);
190 nbox = REGION_NUM_RECTS(&rgnDst);
191 if(!nbox || !(pptSrc = (DDXPointPtr )ALLOCATE_LOCAL(nbox * sizeof(DDXPointRec))))
193 REGION_UNINIT(pWin->drawable.pScreen, &rgnDst);
198 for (i = nbox; --i >= 0; ppt++, pbox++)
200 ppt->x = pbox->x1 + dx;
201 ppt->y = pbox->y1 + dy;
204 cfbDoBitbltCopy((DrawablePtr)pwinRoot, (DrawablePtr)pwinRoot,
205 GXcopy, &rgnDst, pptSrc, ~0L);
206 DEALLOCATE_LOCAL(pptSrc);
207 REGION_UNINIT(pWin->drawable.pScreen, &rgnDst);
212 /* swap in correct PaintWindow* routine. If we can use a fast output
213 routine (i.e. the pixmap is paddable to 32 bits), also pre-rotate a copy
214 of it in devPrivates[cfbWindowPrivateIndex].ptr.
217 cfbChangeWindowAttributes(pWin, mask)
221 register unsigned long index;
222 register cfbPrivWin *pPrivWin;
226 pPrivWin = cfbGetWindowPrivate(pWin);
229 * When background state changes from ParentRelative and
230 * we had previously rotated the fast border pixmap to match
231 * the parent relative origin, rerotate to match window
233 if (mask & (CWBackPixmap | CWBackPixel) &&
234 pWin->backgroundState != ParentRelative &&
235 pPrivWin->fastBorder &&
236 (pPrivWin->oldRotate.x != pWin->drawable.x ||
237 pPrivWin->oldRotate.y != pWin->drawable.y))
239 cfbXRotatePixmap(pPrivWin->pRotatedBorder,
240 pWin->drawable.x - pPrivWin->oldRotate.x);
241 cfbYRotatePixmap(pPrivWin->pRotatedBorder,
242 pWin->drawable.y - pPrivWin->oldRotate.y);
243 pPrivWin->oldRotate.x = pWin->drawable.x;
244 pPrivWin->oldRotate.y = pWin->drawable.y;
248 index = lowbit (mask);
253 if (pWin->backgroundState == None)
255 pPrivWin->fastBackground = FALSE;
257 else if (pWin->backgroundState == ParentRelative)
259 pPrivWin->fastBackground = FALSE;
260 /* Rotate border to match parent origin */
261 if (pPrivWin->pRotatedBorder) {
262 for (pBgWin = pWin->parent;
263 pBgWin->backgroundState == ParentRelative;
264 pBgWin = pBgWin->parent);
265 cfbXRotatePixmap(pPrivWin->pRotatedBorder,
266 pBgWin->drawable.x - pPrivWin->oldRotate.x);
267 cfbYRotatePixmap(pPrivWin->pRotatedBorder,
268 pBgWin->drawable.y - pPrivWin->oldRotate.y);
269 pPrivWin->oldRotate.x = pBgWin->drawable.x;
270 pPrivWin->oldRotate.y = pBgWin->drawable.y;
273 else if (((width = (pWin->background.pixmap->drawable.width * PSZ))
274 <= PGSZ) && !(width & (width - 1)))
276 cfbCopyRotatePixmap(pWin->background.pixmap,
277 &pPrivWin->pRotatedBackground,
280 if (pPrivWin->pRotatedBackground)
282 pPrivWin->fastBackground = TRUE;
283 pPrivWin->oldRotate.x = pWin->drawable.x;
284 pPrivWin->oldRotate.y = pWin->drawable.y;
288 pPrivWin->fastBackground = FALSE;
293 pPrivWin->fastBackground = FALSE;
298 pPrivWin->fastBackground = FALSE;
302 if (((width = (pWin->border.pixmap->drawable.width * PSZ)) <= PGSZ) &&
303 !(width & (width - 1)))
306 pBgWin->backgroundState == ParentRelative;
307 pBgWin = pBgWin->parent);
308 cfbCopyRotatePixmap(pWin->border.pixmap,
309 &pPrivWin->pRotatedBorder,
312 if (pPrivWin->pRotatedBorder)
314 pPrivWin->fastBorder = TRUE;
315 pPrivWin->oldRotate.x = pBgWin->drawable.x;
316 pPrivWin->oldRotate.y = pBgWin->drawable.y;
320 pPrivWin->fastBorder = FALSE;
325 pPrivWin->fastBorder = FALSE;
329 pPrivWin->fastBorder = FALSE;