1
/* $XFree86: xc/programs/Xserver/iplan2p4/iplwindow.c,v 3.0tsi Exp $ */
2
/* $XConsortium: iplwindow.c,v 5.22 94/04/17 20:29:07 dpw Exp $ */
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
******************************************************************/
51
/* Modified nov 94 by Martin Schaller (Martin_Schaller@maus.r.de) for use with
54
#ifdef HAVE_DIX_CONFIG_H
55
#include <dix-config.h>
59
#include "scrnintstr.h"
60
#include "windowstr.h"
63
#include "regionstr.h"
64
#include "iplmskbits.h"
66
extern WindowPtr *WindowTable;
74
pPrivWin = iplGetWindowPrivate(pWin);
75
pPrivWin->pRotatedBorder = NullPixmap;
76
pPrivWin->pRotatedBackground = NullPixmap;
77
pPrivWin->fastBackground = FALSE;
78
pPrivWin->fastBorder = FALSE;
79
pPrivWin->oldRotate.x = 0;
80
pPrivWin->oldRotate.y = 0;
82
#ifdef PIXMAP_PER_WINDOW
83
/* Setup pointer to Screen pixmap */
84
pWin->devPrivates[frameWindowPrivateIndex].ptr =
85
(pointer) iplGetScreenPixmap(pWin->drawable.pScreen);
92
iplDestroyWindow(pWin)
97
pPrivWin = iplGetWindowPrivate(pWin);
99
if (pPrivWin->pRotatedBorder)
100
(*pWin->drawable.pScreen->DestroyPixmap)(pPrivWin->pRotatedBorder);
101
if (pPrivWin->pRotatedBackground)
102
(*pWin->drawable.pScreen->DestroyPixmap)(pPrivWin->pRotatedBackground);
108
iplMapWindow(pWindow)
114
/* (x, y) is the upper left corner of the window on the screen
115
do we really need to pass this? (is it a;ready in pWin->absCorner?)
116
we only do the rotation for pixmaps that are 32 bits wide (padded
118
iplChangeWindowAttributes() has already put a copy of the pixmap
119
in pPrivWin->pRotated*
123
iplPositionWindow(pWin, x, y)
127
iplPrivWin *pPrivWin;
130
pPrivWin = iplGetWindowPrivate(pWin);
131
if (pWin->backgroundState == BackgroundPixmap && pPrivWin->fastBackground)
133
iplXRotatePixmap(pPrivWin->pRotatedBackground,
134
pWin->drawable.x - pPrivWin->oldRotate.x);
135
iplYRotatePixmap(pPrivWin->pRotatedBackground,
136
pWin->drawable.y - pPrivWin->oldRotate.y);
140
if (!pWin->borderIsPixel && pPrivWin->fastBorder)
142
while (pWin->backgroundState == ParentRelative)
144
iplXRotatePixmap(pPrivWin->pRotatedBorder,
145
pWin->drawable.x - pPrivWin->oldRotate.x);
146
iplYRotatePixmap(pPrivWin->pRotatedBorder,
147
pWin->drawable.y - pPrivWin->oldRotate.y);
152
pPrivWin->oldRotate.x = pWin->drawable.x;
153
pPrivWin->oldRotate.y = pWin->drawable.y;
160
iplUnmapWindow(pWindow)
167
this code calls the bitblt helper code directly.
169
iplCopyWindow copies only the parts of the destination that are
170
visible in the source.
175
iplCopyWindow(pWin, ptOldOrg, prgnSrc)
177
DDXPointRec ptOldOrg;
181
register DDXPointPtr ppt;
183
register BoxPtr pbox;
185
register int i, nbox;
188
pwinRoot = WindowTable[pWin->drawable.pScreen->myNum];
190
REGION_NULL(pWin->drawable.pScreen, &rgnDst);
192
dx = ptOldOrg.x - pWin->drawable.x;
193
dy = ptOldOrg.y - pWin->drawable.y;
194
REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy);
195
REGION_INTERSECT(pWin->drawable.pScreen, &rgnDst, &pWin->borderClip, prgnSrc);
197
pbox = REGION_RECTS(&rgnDst);
198
nbox = REGION_NUM_RECTS(&rgnDst);
199
if(!nbox || !(pptSrc = (DDXPointPtr )ALLOCATE_LOCAL(nbox * sizeof(DDXPointRec))))
201
REGION_UNINIT(pWin->drawable.pScreen, &rgnDst);
206
for (i = nbox; --i >= 0; ppt++, pbox++)
208
ppt->x = pbox->x1 + dx;
209
ppt->y = pbox->y1 + dy;
212
iplDoBitbltCopy((DrawablePtr)pwinRoot, (DrawablePtr)pwinRoot,
213
GXcopy, &rgnDst, pptSrc, ~0L);
214
DEALLOCATE_LOCAL(pptSrc);
215
REGION_UNINIT(pWin->drawable.pScreen, &rgnDst);
220
/* swap in correct PaintWindow* routine. If we can use a fast output
221
routine (i.e. the pixmap is paddable to 32 bits), also pre-rotate a copy
222
of it in devPrivates[iplWindowPrivateIndex].ptr.
225
iplChangeWindowAttributes(pWin, mask)
229
register unsigned long index;
230
register iplPrivWin *pPrivWin;
234
pPrivWin = iplGetWindowPrivate(pWin);
237
* When background state changes from ParentRelative and
238
* we had previously rotated the fast border pixmap to match
239
* the parent relative origin, rerotate to match window
241
if (mask & (CWBackPixmap | CWBackPixel) &&
242
pWin->backgroundState != ParentRelative &&
243
pPrivWin->fastBorder &&
244
(pPrivWin->oldRotate.x != pWin->drawable.x ||
245
pPrivWin->oldRotate.y != pWin->drawable.y))
247
iplXRotatePixmap(pPrivWin->pRotatedBorder,
248
pWin->drawable.x - pPrivWin->oldRotate.x);
249
iplYRotatePixmap(pPrivWin->pRotatedBorder,
250
pWin->drawable.y - pPrivWin->oldRotate.y);
251
pPrivWin->oldRotate.x = pWin->drawable.x;
252
pPrivWin->oldRotate.y = pWin->drawable.y;
256
index = lowbit (mask);
261
if (pWin->backgroundState == None)
263
pPrivWin->fastBackground = FALSE;
265
else if (pWin->backgroundState == ParentRelative)
267
pPrivWin->fastBackground = FALSE;
268
/* Rotate border to match parent origin */
269
if (pPrivWin->pRotatedBorder) {
270
for (pBgWin = pWin->parent;
271
pBgWin->backgroundState == ParentRelative;
272
pBgWin = pBgWin->parent);
273
iplXRotatePixmap(pPrivWin->pRotatedBorder,
274
pBgWin->drawable.x - pPrivWin->oldRotate.x);
275
iplYRotatePixmap(pPrivWin->pRotatedBorder,
276
pBgWin->drawable.y - pPrivWin->oldRotate.y);
277
pPrivWin->oldRotate.x = pBgWin->drawable.x;
278
pPrivWin->oldRotate.y = pBgWin->drawable.y;
281
else if (((width = (pWin->background.pixmap->drawable.width))
282
<= INTER_PGSZ) && !(width & (width - 1)))
284
iplCopyRotatePixmap(pWin->background.pixmap,
285
&pPrivWin->pRotatedBackground,
288
if (pPrivWin->pRotatedBackground)
290
pPrivWin->fastBackground = TRUE;
291
pPrivWin->oldRotate.x = pWin->drawable.x;
292
pPrivWin->oldRotate.y = pWin->drawable.y;
296
pPrivWin->fastBackground = FALSE;
301
pPrivWin->fastBackground = FALSE;
306
pPrivWin->fastBackground = FALSE;
310
if (((width = (pWin->border.pixmap->drawable.width)) <= INTER_PGSZ) &&
311
!(width & (width - 1)))
314
pBgWin->backgroundState == ParentRelative;
315
pBgWin = pBgWin->parent);
316
iplCopyRotatePixmap(pWin->border.pixmap,
317
&pPrivWin->pRotatedBorder,
320
if (pPrivWin->pRotatedBorder)
322
pPrivWin->fastBorder = TRUE;
323
pPrivWin->oldRotate.x = pBgWin->drawable.x;
324
pPrivWin->oldRotate.y = pBgWin->drawable.y;
328
pPrivWin->fastBorder = FALSE;
333
pPrivWin->fastBorder = FALSE;
337
pPrivWin->fastBorder = FALSE;