1 /* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
2 /***********************************************************
4 Copyright 1987, 1998 The Open Group
6 Permission to use, copy, modify, distribute, and sell this software and its
7 documentation for any purpose is hereby granted without fee, provided that
8 the above copyright notice appear in all copies and that both that
9 copyright notice and this permission notice appear in supporting
12 The above copyright notice and this permission notice shall be included in
13 all copies or substantial portions of the Software.
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
19 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 Except as contained in this notice, the name of The Open Group shall not be
23 used in advertising or otherwise to promote the sale, use or other dealings
24 in this Software without prior written authorization from The Open Group.
27 Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
31 Permission to use, copy, modify, and distribute this software and its
32 documentation for any purpose and without fee is hereby granted,
33 provided that the above copyright notice appear in all copies and that
34 both that copyright notice and this permission notice appear in
35 supporting documentation, and that the name of Digital not be
36 used in advertising or publicity pertaining to distribution of the
37 software without specific, written prior permission.
39 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
40 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
41 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
42 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
43 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
44 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
47 ******************************************************************/
49 #ifdef HAVE_DIX_CONFIG_H
50 #include <dix-config.h>
56 #include "scrnintstr.h"
57 #include "windowstr.h"
60 #include "regionstr.h"
65 register WindowPtr pWin
;
67 register mfbPrivWin
*pPrivWin
;
69 pPrivWin
= (mfbPrivWin
*)(pWin
->devPrivates
[mfbWindowPrivateIndex
].ptr
);
70 pPrivWin
->pRotatedBorder
= NullPixmap
;
71 pPrivWin
->pRotatedBackground
= NullPixmap
;
72 pPrivWin
->fastBackground
= FALSE
;
73 pPrivWin
->fastBorder
= FALSE
;
78 /* This always returns true, because Xfree can't fail. It might be possible
79 * on some devices for Destroy to fail */
81 mfbDestroyWindow(pWin
)
84 register mfbPrivWin
*pPrivWin
;
86 pPrivWin
= (mfbPrivWin
*)(pWin
->devPrivates
[mfbWindowPrivateIndex
].ptr
);
88 if (pPrivWin
->pRotatedBorder
)
89 (*pWin
->drawable
.pScreen
->DestroyPixmap
)(pPrivWin
->pRotatedBorder
);
90 if (pPrivWin
->pRotatedBackground
)
91 (*pWin
->drawable
.pScreen
->DestroyPixmap
)(pPrivWin
->pRotatedBackground
);
96 Bool
mfbMapWindow(pWindow
)
102 /* (x, y) is the upper left corner of the window on the screen
103 do we really need to pass this? (is it a;ready in pWin->absCorner?)
104 we only do the rotation for pixmaps that are 32 bits wide (padded
106 mfbChangeWindowAttributes() has already put a copy of the pixmap
107 in pPrivWin->pRotated*
112 mfbPositionWindow(pWin
, x
, y
)
113 register WindowPtr pWin
;
116 register mfbPrivWin
*pPrivWin
;
119 pPrivWin
= (mfbPrivWin
*)(pWin
->devPrivates
[mfbWindowPrivateIndex
].ptr
);
120 if (pWin
->backgroundState
== BackgroundPixmap
&& pPrivWin
->fastBackground
)
122 mfbXRotatePixmap(pPrivWin
->pRotatedBackground
,
123 pWin
->drawable
.x
- pPrivWin
->oldRotate
.x
);
124 mfbYRotatePixmap(pPrivWin
->pRotatedBackground
,
125 pWin
->drawable
.y
- pPrivWin
->oldRotate
.y
);
129 if (!pWin
->borderIsPixel
&& pPrivWin
->fastBorder
)
131 while (pWin
->backgroundState
== ParentRelative
)
133 mfbXRotatePixmap(pPrivWin
->pRotatedBorder
,
134 pWin
->drawable
.x
- pPrivWin
->oldRotate
.x
);
135 mfbYRotatePixmap(pPrivWin
->pRotatedBorder
,
136 pWin
->drawable
.y
- pPrivWin
->oldRotate
.y
);
141 pPrivWin
->oldRotate
.x
= pWin
->drawable
.x
;
142 pPrivWin
->oldRotate
.y
= pWin
->drawable
.y
;
145 /* This is the "wrong" fix to the right problem, but it doesn't really
146 * cost very much. When the window is moved, we need to invalidate any
147 * RotatedPixmap that exists in any GC currently validated against this
150 pWin
->drawable
.serialNumber
= NEXT_SERIAL_NUMBER
;
152 /* Again, we have no failure modes indicated by any of the routines
153 * we've called, so we have to assume it worked */
159 mfbUnmapWindow(pWindow
)
166 this code calls the bitblt helper code directly.
168 mfbCopyWindow copies only the parts of the destination that are
169 visible in the source.
174 mfbCopyWindow(pWin
, ptOldOrg
, prgnSrc
)
176 DDXPointRec ptOldOrg
;
180 register DDXPointPtr ppt
;
182 register BoxPtr pbox
;
184 register int i
, nbox
;
187 pwinRoot
= WindowTable
[pWin
->drawable
.pScreen
->myNum
];
189 prgnDst
= REGION_CREATE(pWin
->drawable
.pScreen
, NULL
, 1);
191 dx
= ptOldOrg
.x
- pWin
->drawable
.x
;
192 dy
= ptOldOrg
.y
- pWin
->drawable
.y
;
193 REGION_TRANSLATE(pWin
->drawable
.pScreen
, prgnSrc
, -dx
, -dy
);
194 REGION_INTERSECT(pWin
->drawable
.pScreen
, prgnDst
, &pWin
->borderClip
,
197 pbox
= REGION_RECTS(prgnDst
);
198 nbox
= REGION_NUM_RECTS(prgnDst
);
199 if(!(pptSrc
= (DDXPointPtr
)ALLOCATE_LOCAL(nbox
* sizeof(DDXPointRec
))))
203 for (i
=nbox
; --i
>= 0; ppt
++, pbox
++)
205 ppt
->x
= pbox
->x1
+ dx
;
206 ppt
->y
= pbox
->y1
+ dy
;
209 mfbDoBitblt((DrawablePtr
)pwinRoot
, (DrawablePtr
)pwinRoot
,
210 GXcopy
, prgnDst
, pptSrc
);
211 DEALLOCATE_LOCAL(pptSrc
);
212 REGION_DESTROY(pWin
->drawable
.pScreen
, prgnDst
);
217 /* swap in correct PaintWindow* routine. If we can use a fast output
218 routine (i.e. the pixmap is paddable to 32 bits), also pre-rotate a copy
222 mfbChangeWindowAttributes(pWin
, mask
)
223 register WindowPtr pWin
;
224 register unsigned long mask
;
226 register unsigned long index
;
227 register mfbPrivWin
*pPrivWin
;
230 pPrivWin
= (mfbPrivWin
*)(pWin
->devPrivates
[mfbWindowPrivateIndex
].ptr
);
232 * When background state changes from ParentRelative and
233 * we had previously rotated the fast border pixmap to match
234 * the parent relative origin, rerotate to match window
236 if (mask
& (CWBackPixmap
| CWBackPixel
) &&
237 pWin
->backgroundState
!= ParentRelative
&&
238 pPrivWin
->fastBorder
&&
239 (pPrivWin
->oldRotate
.x
!= pWin
->drawable
.x
||
240 pPrivWin
->oldRotate
.y
!= pWin
->drawable
.y
))
242 mfbXRotatePixmap(pPrivWin
->pRotatedBorder
,
243 pWin
->drawable
.x
- pPrivWin
->oldRotate
.x
);
244 mfbYRotatePixmap(pPrivWin
->pRotatedBorder
,
245 pWin
->drawable
.y
- pPrivWin
->oldRotate
.y
);
246 pPrivWin
->oldRotate
.x
= pWin
->drawable
.x
;
247 pPrivWin
->oldRotate
.y
= pWin
->drawable
.y
;
251 index
= lowbit (mask
);
256 if (pWin
->backgroundState
== None
)
258 pPrivWin
->fastBackground
= FALSE
;
260 else if (pWin
->backgroundState
== ParentRelative
)
262 pPrivWin
->fastBackground
= FALSE
;
263 /* Rotate border to match parent origin */
264 if (pPrivWin
->pRotatedBorder
) {
265 for (pBgWin
= pWin
->parent
;
266 pBgWin
->backgroundState
== ParentRelative
;
267 pBgWin
= pBgWin
->parent
);
268 mfbXRotatePixmap(pPrivWin
->pRotatedBorder
,
269 pBgWin
->drawable
.x
- pPrivWin
->oldRotate
.x
);
270 mfbYRotatePixmap(pPrivWin
->pRotatedBorder
,
271 pBgWin
->drawable
.y
- pPrivWin
->oldRotate
.y
);
272 pPrivWin
->oldRotate
.x
= pBgWin
->drawable
.x
;
273 pPrivWin
->oldRotate
.y
= pBgWin
->drawable
.y
;
276 else if ((pWin
->background
.pixmap
->drawable
.width
<= PPW
) &&
277 !(pWin
->background
.pixmap
->drawable
.width
&
278 (pWin
->background
.pixmap
->drawable
.width
- 1)))
280 mfbCopyRotatePixmap(pWin
->background
.pixmap
,
281 &pPrivWin
->pRotatedBackground
,
284 if (pPrivWin
->pRotatedBackground
)
286 pPrivWin
->fastBackground
= TRUE
;
287 pPrivWin
->oldRotate
.x
= pWin
->drawable
.x
;
288 pPrivWin
->oldRotate
.y
= pWin
->drawable
.y
;
292 pPrivWin
->fastBackground
= FALSE
;
297 pPrivWin
->fastBackground
= FALSE
;
302 pPrivWin
->fastBackground
= FALSE
;
306 if ((pWin
->border
.pixmap
->drawable
.width
<= PPW
) &&
307 !(pWin
->border
.pixmap
->drawable
.width
&
308 (pWin
->border
.pixmap
->drawable
.width
- 1)))
311 pBgWin
->backgroundState
== ParentRelative
;
312 pBgWin
= pBgWin
->parent
);
313 mfbCopyRotatePixmap(pWin
->border
.pixmap
,
314 &pPrivWin
->pRotatedBorder
,
317 if (pPrivWin
->pRotatedBorder
)
319 pPrivWin
->fastBorder
= TRUE
;
320 pPrivWin
->oldRotate
.x
= pBgWin
->drawable
.x
;
321 pPrivWin
->oldRotate
.y
= pBgWin
->drawable
.y
;
325 pPrivWin
->fastBorder
= FALSE
;
330 pPrivWin
->fastBorder
= FALSE
;
334 pPrivWin
->fastBorder
= FALSE
;
338 /* Again, we have no failure modes indicated by any of the routines
339 * we've called, so we have to assume it worked */