1
/* $XFree86: xc/programs/Xserver/mi/miwindow.c,v 1.9tsi Exp $ */
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
******************************************************************/
48
/* $Xorg: miwindow.c,v 1.4 2001/02/09 02:05:22 xorgcvs Exp $ */
49
#ifdef HAVE_DIX_CONFIG_H
50
#include <dix-config.h>
54
#include "regionstr.h"
57
#include "windowstr.h"
58
#include "scrnintstr.h"
59
#include "pixmapstr.h"
60
#include "mivalidate.h"
63
miClearToBackground(pWin, x, y, w, h, generateExposures)
67
Bool generateExposures;
71
RegionPtr pBSReg = NullRegion;
76
/* compute everything using ints to avoid overflow */
78
x1 = pWin->drawable.x + x;
79
y1 = pWin->drawable.y + y;
83
x2 = x1 + (int) pWin->drawable.width - (int) x;
87
y2 = y1 + (int) pWin->drawable.height - (int) y;
89
extents = &pWin->clipList.extents;
91
/* clip the resulting rectangle to the window clipList extents. This
92
* makes sure that the result will fit in a box, given that the
93
* screen is < 32768 on a side.
100
if (y1 < extents->y1)
102
if (y2 > extents->y2)
105
if (x2 <= x1 || y2 <= y1)
116
pScreen = pWin->drawable.pScreen;
117
REGION_INIT(pScreen, ®, &box, 1);
118
if (pWin->backStorage)
121
* If the window has backing-store on, call through the
122
* ClearToBackground vector to handle the special semantics
123
* (i.e. things backing store is to be cleared out and
124
* an Expose event is to be generated for those areas in backing
125
* store if generateExposures is TRUE).
127
pBSReg = (* pScreen->ClearBackingStore)(pWin, x, y, w, h,
131
REGION_INTERSECT(pScreen, ®, ®, &pWin->clipList);
132
if (generateExposures)
133
(*pScreen->WindowExposures)(pWin, ®, pBSReg);
134
else if (pWin->backgroundState != None)
135
(*pScreen->PaintWindowBackground)(pWin, ®, PW_BACKGROUND);
136
REGION_UNINIT(pScreen, ®);
138
REGION_DESTROY(pScreen, pBSReg);
142
* For SaveUnders using backing-store. The idea is that when a window is mapped
143
* with saveUnder set TRUE, any windows it obscures will have its backing
144
* store turned on setting the DIXsaveUnder bit,
145
* The backing-store code must be written to allow for this
149
*-----------------------------------------------------------------------
150
* miCheckSubSaveUnder --
151
* Check all the inferiors of a window for coverage by saveUnder
152
* windows. Called from ChangeSaveUnder and CheckSaveUnder.
153
* This code is very inefficient.
156
* TRUE if any windows need to have backing-store removed.
159
* Windows may have backing-store turned on or off.
161
*-----------------------------------------------------------------------
165
register WindowPtr pParent, /* Parent to check */
166
WindowPtr pFirst, /* first reconfigured window */
167
RegionPtr pRegion) /* Initial area obscured by saveUnder */
169
register WindowPtr pChild; /* Current child */
170
register ScreenPtr pScreen; /* Screen to use */
171
RegionRec SubRegion; /* Area of children obscured */
172
Bool res = FALSE; /* result */
173
Bool subInited=FALSE;/* SubRegion initialized */
175
pScreen = pParent->drawable.pScreen;
176
if ( (pChild = pParent->firstChild) )
179
* build region above first changed window
182
for (; pChild != pFirst; pChild = pChild->nextSib)
183
if (pChild->viewable && pChild->saveUnder)
184
REGION_UNION(pScreen, pRegion, pRegion, &pChild->borderSize);
187
* check region below and including first changed window
190
for (; pChild; pChild = pChild->nextSib)
192
if (pChild->viewable)
195
* don't save under nephew/niece windows;
196
* use a separate region
199
if (pChild->firstChild)
203
REGION_NULL(pScreen, &SubRegion);
206
REGION_COPY(pScreen, &SubRegion, pRegion);
207
res |= miCheckSubSaveUnder(pChild, pChild->firstChild,
212
res |= miCheckSubSaveUnder(pChild, pChild->firstChild,
216
if (pChild->saveUnder)
217
REGION_UNION(pScreen, pRegion, pRegion, &pChild->borderSize);
222
REGION_UNINIT(pScreen, &SubRegion);
226
* Check the state of this window. DIX save unders are
227
* enabled for viewable windows with some client expressing
228
* exposure interest and which intersect the save under region
231
if (pParent->viewable &&
232
((pParent->eventMask | wOtherEventMasks(pParent)) & ExposureMask) &&
233
REGION_NOTEMPTY(pScreen, &pParent->borderSize) &&
234
RECT_IN_REGION(pScreen, pRegion, REGION_EXTENTS(pScreen,
235
&pParent->borderSize)) != rgnOUT)
237
if (!pParent->DIXsaveUnder)
239
pParent->DIXsaveUnder = TRUE;
240
(*pScreen->ChangeWindowAttributes) (pParent, CWBackingStore);
245
if (pParent->DIXsaveUnder)
248
pParent->DIXsaveUnder = FALSE;
256
*-----------------------------------------------------------------------
257
* miChangeSaveUnder --
258
* Change the save-under state of a tree of windows. Called when
259
* a window with saveUnder TRUE is mapped/unmapped/reconfigured.
262
* TRUE if any windows need to have backing-store removed (which
263
* means that PostChangeSaveUnder needs to be called later to
267
* Windows may have backing-store turned on or off.
269
*-----------------------------------------------------------------------
272
miChangeSaveUnder(pWin, first)
273
register WindowPtr pWin;
274
WindowPtr first; /* First window to check.
275
* Used when pWin was restacked */
277
RegionRec rgn; /* Area obscured by saveUnder windows */
278
register ScreenPtr pScreen;
281
if (!deltaSaveUndersViewable && !numSaveUndersViewable)
283
numSaveUndersViewable += deltaSaveUndersViewable;
284
deltaSaveUndersViewable = 0;
285
pScreen = pWin->drawable.pScreen;
286
REGION_NULL(pScreen, &rgn);
287
res = miCheckSubSaveUnder (pWin->parent,
288
pWin->saveUnder ? first : pWin->nextSib,
290
REGION_UNINIT(pScreen, &rgn);
295
*-----------------------------------------------------------------------
296
* miPostChangeSaveUnder --
297
* Actually turn backing-store off for those windows that no longer
298
* need to have it on.
304
* Backing-store and SAVE_UNDER_CHANGE_BIT are turned off for those
307
*-----------------------------------------------------------------------
310
miPostChangeSaveUnder(pWin, pFirst)
314
register WindowPtr pParent, pChild;
315
ChangeWindowAttributesProcPtr ChangeWindowAttributes;
317
if (!(pParent = pWin->parent))
319
ChangeWindowAttributes = pParent->drawable.pScreen->ChangeWindowAttributes;
320
if (!pParent->DIXsaveUnder &&
321
(pParent->backingStore == NotUseful) && pParent->backStorage)
322
(*ChangeWindowAttributes)(pParent, CWBackingStore);
323
if (!(pChild = pFirst))
327
if (!pChild->DIXsaveUnder &&
328
(pChild->backingStore == NotUseful) && pChild->backStorage)
329
(*ChangeWindowAttributes)(pChild, CWBackingStore);
330
if (pChild->firstChild)
332
pChild = pChild->firstChild;
335
while (!pChild->nextSib)
337
pChild = pChild->parent;
338
if (pChild == pParent)
341
pChild = pChild->nextSib;
347
register WindowPtr pWin;
349
register ValidatePtr val;
353
val = (ValidatePtr)xnfalloc(sizeof(ValidateRec));
354
val->before.oldAbsCorner.x = pWin->drawable.x;
355
val->before.oldAbsCorner.y = pWin->drawable.y;
356
val->before.borderVisible = NullRegion;
357
val->before.resized = FALSE;
362
miMarkOverlappedWindows(pWin, pFirst, ppLayerWin)
365
WindowPtr *ppLayerWin;
368
register WindowPtr pChild, pLast;
369
Bool anyMarked = FALSE;
370
MarkWindowProcPtr MarkWindow = pWin->drawable.pScreen->MarkWindow;
373
pScreen = pWin->drawable.pScreen;
375
/* single layered systems are easy */
376
if (ppLayerWin) *ppLayerWin = pWin;
380
/* Blindly mark pWin and all of its inferiors. This is a slight
381
* overkill if there are mapped windows that outside pWin's border,
382
* but it's better than wasting time on RectIn checks.
387
if (pChild->viewable)
389
if (REGION_BROKEN (pScreen, &pChild->winSize))
391
if (REGION_BROKEN (pScreen, &pChild->borderSize))
392
SetBorderSize (pChild);
393
(* MarkWindow)(pChild);
394
if (pChild->firstChild)
396
pChild = pChild->firstChild;
400
while (!pChild->nextSib && (pChild != pWin))
401
pChild = pChild->parent;
404
pChild = pChild->nextSib;
407
pFirst = pFirst->nextSib;
409
if ( (pChild = pFirst) )
411
box = REGION_EXTENTS(pChild->drawable.pScreen, &pWin->borderSize);
412
pLast = pChild->parent->lastChild;
415
if (pChild->viewable)
417
if (REGION_BROKEN (pScreen, &pChild->winSize))
419
if (REGION_BROKEN (pScreen, &pChild->borderSize))
420
SetBorderSize (pChild);
421
if (RECT_IN_REGION(pScreen, &pChild->borderSize, box))
423
(* MarkWindow)(pChild);
425
if (pChild->firstChild)
427
pChild = pChild->firstChild;
432
while (!pChild->nextSib && (pChild != pLast))
433
pChild = pChild->parent;
436
pChild = pChild->nextSib;
440
(* MarkWindow)(pWin->parent);
445
* miHandleValidateExposures(pWin)
446
* starting at pWin, draw background in any windows that have exposure
447
* regions, translate the regions, restore any backing store,
448
* and then send any regions still exposed to the client
451
miHandleValidateExposures(pWin)
454
register WindowPtr pChild;
455
register ValidatePtr val;
457
WindowExposuresProcPtr WindowExposures;
459
pScreen = pWin->drawable.pScreen;
462
WindowExposures = pChild->drawable.pScreen->WindowExposures;
465
if ( (val = pChild->valdata) )
467
if (REGION_NOTEMPTY(pScreen, &val->after.borderExposed))
468
(*pChild->drawable.pScreen->PaintWindowBorder)(pChild,
469
&val->after.borderExposed,
471
REGION_UNINIT(pScreen, &val->after.borderExposed);
472
(*WindowExposures)(pChild, &val->after.exposed, NullRegion);
473
REGION_UNINIT(pScreen, &val->after.exposed);
475
pChild->valdata = (ValidatePtr)NULL;
476
if (pChild->firstChild)
478
pChild = pChild->firstChild;
482
while (!pChild->nextSib && (pChild != pWin))
483
pChild = pChild->parent;
486
pChild = pChild->nextSib;
491
miMoveWindow(pWin, x, y, pNextSib, kind)
492
register WindowPtr pWin;
498
Bool WasViewable = (Bool)(pWin->viewable);
500
RegionPtr oldRegion = NULL;
502
Bool anyMarked = FALSE;
503
register ScreenPtr pScreen;
504
WindowPtr windowToValidate;
505
#ifdef DO_SAVE_UNDERS
510
/* if this is a root window, can't be moved */
511
if (!(pParent = pWin->parent))
513
pScreen = pWin->drawable.pScreen;
514
bw = wBorderWidth (pWin);
516
oldpt.x = pWin->drawable.x;
517
oldpt.y = pWin->drawable.y;
520
oldRegion = REGION_CREATE(pScreen, NullBox, 1);
521
REGION_COPY(pScreen, oldRegion, &pWin->borderClip);
522
anyMarked = (*pScreen->MarkOverlappedWindows)(pWin, pWin, &pLayerWin);
524
pWin->origin.x = x + (int)bw;
525
pWin->origin.y = y + (int)bw;
526
x = pWin->drawable.x = pParent->drawable.x + x + (int)bw;
527
y = pWin->drawable.y = pParent->drawable.y + y + (int)bw;
530
SetBorderSize (pWin);
532
(*pScreen->PositionWindow)(pWin, x, y);
534
windowToValidate = MoveWindowInStack(pWin, pNextSib);
536
ResizeChildrenWinSize(pWin, x - oldpt.x, y - oldpt.y, 0, 0);
540
if (pLayerWin == pWin)
541
anyMarked |= (*pScreen->MarkOverlappedWindows)
542
(pWin, windowToValidate, (WindowPtr *)NULL);
544
anyMarked |= (*pScreen->MarkOverlappedWindows)
545
(pWin, pLayerWin, (WindowPtr *)NULL);
547
#ifdef DO_SAVE_UNDERS
548
if (DO_SAVE_UNDERS(pWin))
550
dosave = (*pScreen->ChangeSaveUnder)(pLayerWin, windowToValidate);
552
#endif /* DO_SAVE_UNDERS */
556
(*pScreen->ValidateTree)(pLayerWin->parent, NullWindow, kind);
557
(* pWin->drawable.pScreen->CopyWindow)(pWin, oldpt, oldRegion);
558
REGION_DESTROY(pScreen, oldRegion);
559
/* XXX need to retile border if ParentRelative origin */
560
(*pScreen->HandleExposures)(pLayerWin->parent);
562
#ifdef DO_SAVE_UNDERS
564
(*pScreen->PostChangeSaveUnder)(pLayerWin, windowToValidate);
565
#endif /* DO_SAVE_UNDERS */
566
if (anyMarked && pScreen->PostValidateTree)
567
(*pScreen->PostValidateTree)(pLayerWin->parent, NullWindow, kind);
570
WindowsRestructured ();
575
* pValid is a region of the screen which has been
576
* successfully copied -- recomputed exposed regions for affected windows
580
miRecomputeExposures (
581
register WindowPtr pWin,
582
pointer value) /* must conform to VisitWindowProcPtr */
584
register ScreenPtr pScreen;
585
RegionPtr pValid = (RegionPtr)value;
589
pScreen = pWin->drawable.pScreen;
591
* compute exposed regions of this window
593
REGION_SUBTRACT(pScreen, &pWin->valdata->after.exposed,
594
&pWin->clipList, pValid);
596
* compute exposed regions of the border
598
REGION_SUBTRACT(pScreen, &pWin->valdata->after.borderExposed,
599
&pWin->borderClip, &pWin->winSize);
600
REGION_SUBTRACT(pScreen, &pWin->valdata->after.borderExposed,
601
&pWin->valdata->after.borderExposed, pValid);
602
return WT_WALKCHILDREN;
608
miSlideAndSizeWindow(pWin, x, y, w, h, pSib)
609
register WindowPtr pWin;
615
Bool WasViewable = (Bool)(pWin->viewable);
616
unsigned short width = pWin->drawable.width,
617
height = pWin->drawable.height;
618
short oldx = pWin->drawable.x,
619
oldy = pWin->drawable.y;
620
int bw = wBorderWidth (pWin);
623
RegionPtr oldRegion = NULL;
624
Bool anyMarked = FALSE;
625
register ScreenPtr pScreen;
626
WindowPtr pFirstChange;
627
register WindowPtr pChild;
628
RegionPtr gravitate[StaticGravity + 1];
630
int nx, ny; /* destination x,y */
631
int newx, newy; /* new inner window position */
632
RegionPtr pRegion = NULL;
633
RegionPtr destClip; /* portions of destination already written */
634
RegionPtr oldWinClip = NULL; /* old clip list for window */
635
RegionPtr borderVisible = NullRegion; /* visible area of the border */
636
RegionPtr bsExposed = NullRegion; /* backing store exposures */
637
Bool shrunk = FALSE; /* shrunk in an inner dimension */
638
Bool moved = FALSE; /* window position changed */
639
#ifdef DO_SAVE_UNDERS
644
/* if this is a root window, can't be resized */
645
if (!(pParent = pWin->parent))
648
pScreen = pWin->drawable.pScreen;
649
newx = pParent->drawable.x + x + bw;
650
newy = pParent->drawable.y + y + bw;
655
* save the visible region of the window
657
oldRegion = REGION_CREATE(pScreen, NullBox, 1);
658
REGION_COPY(pScreen, oldRegion, &pWin->winSize);
661
* categorize child windows into regions to be moved
663
for (g = 0; g <= StaticGravity; g++)
664
gravitate[g] = (RegionPtr) NULL;
665
for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib)
667
g = pChild->winGravity;
668
if (g != UnmapGravity)
671
gravitate[g] = REGION_CREATE(pScreen, NullBox, 1);
672
REGION_UNION(pScreen, gravitate[g],
673
gravitate[g], &pChild->borderClip);
677
UnmapWindow(pChild, TRUE);
681
anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin, pWin,
685
if (pWin->bitGravity != ForgetGravity)
687
oldWinClip = REGION_CREATE(pScreen, NullBox, 1);
688
REGION_COPY(pScreen, oldWinClip, &pWin->clipList);
691
* if the window is changing size, borderExposed
692
* can't be computed correctly without some help.
694
if (pWin->drawable.height > h || pWin->drawable.width > w)
697
if (newx != oldx || newy != oldy)
700
if ((pWin->drawable.height != h || pWin->drawable.width != w) &&
703
borderVisible = REGION_CREATE(pScreen, NullBox, 1);
704
/* for tiled borders, we punt and draw the whole thing */
705
if (pWin->borderIsPixel || !moved)
708
REGION_SUBTRACT(pScreen, borderVisible,
712
REGION_COPY(pScreen, borderVisible,
717
pWin->origin.x = x + bw;
718
pWin->origin.y = y + bw;
719
pWin->drawable.height = h;
720
pWin->drawable.width = w;
722
x = pWin->drawable.x = newx;
723
y = pWin->drawable.y = newy;
726
SetBorderSize (pWin);
728
dw = (int)w - (int)width;
729
dh = (int)h - (int)height;
730
ResizeChildrenWinSize(pWin, x - oldx, y - oldy, dw, dh);
732
/* let the hardware adjust background and border pixmaps, if any */
733
(*pScreen->PositionWindow)(pWin, x, y);
735
pFirstChange = MoveWindowInStack(pWin, pSib);
739
pRegion = REGION_CREATE(pScreen, NullBox, 1);
740
if (pWin->backStorage)
741
REGION_COPY(pScreen, pRegion, &pWin->clipList);
743
if (pLayerWin == pWin)
744
anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin, pFirstChange,
747
anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin, pLayerWin,
752
pWin->valdata->before.resized = TRUE;
753
pWin->valdata->before.borderVisible = borderVisible;
756
#ifdef DO_SAVE_UNDERS
757
if (DO_SAVE_UNDERS(pWin))
759
dosave = (*pScreen->ChangeSaveUnder)(pLayerWin, pFirstChange);
761
#endif /* DO_SAVE_UNDERS */
764
(*pScreen->ValidateTree)(pLayerWin->parent, pFirstChange, VTOther);
766
* the entire window is trashed unless bitGravity
767
* recovers portions of it
769
REGION_COPY(pScreen, &pWin->valdata->after.exposed, &pWin->clipList);
772
GravityTranslate (x, y, oldx, oldy, dw, dh, pWin->bitGravity, &nx, &ny);
774
if (pWin->backStorage &&
775
((pWin->backingStore == Always) || WasViewable))
778
pRegion = &pWin->clipList; /* a convenient empty region */
779
if (pWin->bitGravity == ForgetGravity)
780
bsExposed = (*pScreen->TranslateBackingStore)
781
(pWin, 0, 0, NullRegion, oldx, oldy);
784
bsExposed = (*pScreen->TranslateBackingStore)
785
(pWin, nx - x, ny - y, pRegion, oldx, oldy);
791
/* avoid the border */
792
if (HasBorder (pWin))
794
int offx, offy, dx, dy;
796
/* kruft to avoid double translates for each gravity */
799
for (g = 0; g <= StaticGravity; g++)
804
/* align winSize to gravitate[g].
805
* winSize is in new coordinates,
806
* gravitate[g] is still in old coordinates */
807
GravityTranslate (x, y, oldx, oldy, dw, dh, g, &nx, &ny);
809
dx = (oldx - nx) - offx;
810
dy = (oldy - ny) - offy;
813
REGION_TRANSLATE(pScreen, &pWin->winSize, dx, dy);
817
REGION_INTERSECT(pScreen, gravitate[g], gravitate[g],
820
/* get winSize back where it belongs */
822
REGION_TRANSLATE(pScreen, &pWin->winSize, -offx, -offy);
825
* add screen bits to the appropriate bucket
831
* clip to new clipList
833
REGION_COPY(pScreen, pRegion, oldWinClip);
834
REGION_TRANSLATE(pScreen, pRegion, nx - oldx, ny - oldy);
835
REGION_INTERSECT(pScreen, oldWinClip, pRegion, &pWin->clipList);
837
* don't step on any gravity bits which will be copied after this
838
* region. Note -- this assumes that the regions will be copied
841
for (g = pWin->bitGravity + 1; g <= StaticGravity; g++)
844
REGION_SUBTRACT(pScreen, oldWinClip, oldWinClip,
847
REGION_TRANSLATE(pScreen, oldWinClip, oldx - nx, oldy - ny);
848
g = pWin->bitGravity;
850
gravitate[g] = oldWinClip;
853
REGION_UNION(pScreen, gravitate[g], gravitate[g], oldWinClip);
854
REGION_DESTROY(pScreen, oldWinClip);
859
* move the bits on the screen
864
for (g = 0; g <= StaticGravity; g++)
869
GravityTranslate (x, y, oldx, oldy, dw, dh, g, &nx, &ny);
871
oldpt.x = oldx + (x - nx);
872
oldpt.y = oldy + (y - ny);
874
/* Note that gravitate[g] is *translated* by CopyWindow */
876
/* only copy the remaining useful bits */
878
REGION_INTERSECT(pScreen, gravitate[g], gravitate[g], oldRegion);
880
/* clip to not overwrite already copied areas */
883
REGION_TRANSLATE(pScreen, destClip, oldpt.x - x, oldpt.y - y);
884
REGION_SUBTRACT(pScreen, gravitate[g], gravitate[g], destClip);
885
REGION_TRANSLATE(pScreen, destClip, x - oldpt.x, y - oldpt.y);
888
/* and move those bits */
890
if (oldpt.x != x || oldpt.y != y
892
|| pWin->redirectDraw
896
(*pWin->drawable.pScreen->CopyWindow)(pWin, oldpt, gravitate[g]);
899
/* remove any overwritten bits from the remaining useful bits */
901
REGION_SUBTRACT(pScreen, oldRegion, oldRegion, gravitate[g]);
904
* recompute exposed regions of child windows
907
for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib)
909
if (pChild->winGravity != g)
911
REGION_INTERSECT(pScreen, pRegion,
912
&pChild->borderClip, gravitate[g]);
913
TraverseTree (pChild, miRecomputeExposures, (pointer)pRegion);
917
* remove the successfully copied regions of the
918
* window from its exposed region
921
if (g == pWin->bitGravity)
922
REGION_SUBTRACT(pScreen, &pWin->valdata->after.exposed,
923
&pWin->valdata->after.exposed, gravitate[g]);
925
destClip = gravitate[g];
928
REGION_UNION(pScreen, destClip, destClip, gravitate[g]);
929
REGION_DESTROY(pScreen, gravitate[g]);
933
REGION_DESTROY(pScreen, oldRegion);
934
REGION_DESTROY(pScreen, pRegion);
936
REGION_DESTROY(pScreen, destClip);
939
RegionPtr valExposed = NullRegion;
942
valExposed = &pWin->valdata->after.exposed;
943
(*pScreen->WindowExposures) (pWin, valExposed, bsExposed);
945
REGION_EMPTY(pScreen, valExposed);
946
REGION_DESTROY(pScreen, bsExposed);
949
(*pScreen->HandleExposures)(pLayerWin->parent);
950
#ifdef DO_SAVE_UNDERS
953
(*pScreen->PostChangeSaveUnder)(pLayerWin, pFirstChange);
955
#endif /* DO_SAVE_UNDERS */
956
if (anyMarked && pScreen->PostValidateTree)
957
(*pScreen->PostValidateTree)(pLayerWin->parent, pFirstChange,
962
(*pScreen->WindowExposures) (pWin, NullRegion, bsExposed);
963
REGION_DESTROY(pScreen, bsExposed);
966
WindowsRestructured ();
970
miGetLayerWindow(pWin)
973
return pWin->firstChild;
980
* The border/window shape has changed. Recompute winSize/borderSize
981
* and send appropriate exposure events
986
register WindowPtr pWin;
988
Bool WasViewable = (Bool)(pWin->viewable);
989
register ScreenPtr pScreen = pWin->drawable.pScreen;
990
Bool anyMarked = FALSE;
991
RegionPtr pOldClip = NULL, bsExposed;
992
#ifdef DO_SAVE_UNDERS
999
anyMarked = (*pScreen->MarkOverlappedWindows)(pWin, pWin,
1003
if (HasBorder (pWin))
1005
RegionPtr borderVisible;
1007
borderVisible = REGION_CREATE(pScreen, NullBox, 1);
1008
REGION_SUBTRACT(pScreen, borderVisible,
1009
&pWin->borderClip, &pWin->winSize);
1010
pWin->valdata->before.borderVisible = borderVisible;
1012
pWin->valdata->before.resized = TRUE;
1017
SetBorderSize (pWin);
1019
ResizeChildrenWinSize(pWin, 0, 0, 0, 0);
1023
if (pWin->backStorage)
1025
pOldClip = REGION_CREATE(pScreen, NullBox, 1);
1026
REGION_COPY(pScreen, pOldClip, &pWin->clipList);
1029
anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin, pWin,
1032
#ifdef DO_SAVE_UNDERS
1033
if (DO_SAVE_UNDERS(pWin))
1035
dosave = (*pScreen->ChangeSaveUnder)(pLayerWin, pLayerWin);
1037
#endif /* DO_SAVE_UNDERS */
1040
(*pScreen->ValidateTree)(pLayerWin->parent, NullWindow, VTOther);
1043
if (pWin->backStorage &&
1044
((pWin->backingStore == Always) || WasViewable))
1047
pOldClip = &pWin->clipList; /* a convenient empty region */
1048
bsExposed = (*pScreen->TranslateBackingStore)
1049
(pWin, 0, 0, pOldClip,
1050
pWin->drawable.x, pWin->drawable.y);
1052
REGION_DESTROY(pScreen, pOldClip);
1055
RegionPtr valExposed = NullRegion;
1058
valExposed = &pWin->valdata->after.exposed;
1059
(*pScreen->WindowExposures) (pWin, valExposed, bsExposed);
1061
REGION_EMPTY(pScreen, valExposed);
1062
REGION_DESTROY(pScreen, bsExposed);
1068
(*pScreen->HandleExposures)(pLayerWin->parent);
1069
#ifdef DO_SAVE_UNDERS
1071
(*pScreen->PostChangeSaveUnder)(pLayerWin, pLayerWin);
1072
#endif /* DO_SAVE_UNDERS */
1073
if (anyMarked && pScreen->PostValidateTree)
1074
(*pScreen->PostValidateTree)(pLayerWin->parent, NullWindow, VTOther);
1077
WindowsRestructured ();
1078
CheckCursorConfinement(pWin);
1082
/* Keeps the same inside(!) origin */
1085
miChangeBorderWidth(pWin, width)
1086
register WindowPtr pWin;
1090
Bool anyMarked = FALSE;
1091
register ScreenPtr pScreen;
1092
Bool WasViewable = (Bool)(pWin->viewable);
1094
#ifdef DO_SAVE_UNDERS
1095
Bool dosave = FALSE;
1097
WindowPtr pLayerWin;
1099
oldwidth = wBorderWidth (pWin);
1100
if (oldwidth == width)
1102
HadBorder = HasBorder(pWin);
1103
pScreen = pWin->drawable.pScreen;
1104
if (WasViewable && width < oldwidth)
1105
anyMarked = (*pScreen->MarkOverlappedWindows)(pWin, pWin, &pLayerWin);
1107
pWin->borderWidth = width;
1108
SetBorderSize (pWin);
1112
if (width > oldwidth)
1114
anyMarked = (*pScreen->MarkOverlappedWindows)(pWin, pWin,
1117
* save the old border visible region to correctly compute
1120
if (pWin->valdata && HadBorder)
1122
RegionPtr borderVisible;
1123
borderVisible = REGION_CREATE(pScreen, NULL, 1);
1124
REGION_SUBTRACT(pScreen, borderVisible,
1125
&pWin->borderClip, &pWin->winSize);
1126
pWin->valdata->before.borderVisible = borderVisible;
1129
#ifdef DO_SAVE_UNDERS
1130
if (DO_SAVE_UNDERS(pWin))
1132
dosave = (*pScreen->ChangeSaveUnder)(pLayerWin, pWin->nextSib);
1134
#endif /* DO_SAVE_UNDERS */
1138
(*pScreen->ValidateTree)(pLayerWin->parent, pLayerWin, VTOther);
1139
(*pScreen->HandleExposures)(pLayerWin->parent);
1141
#ifdef DO_SAVE_UNDERS
1143
(*pScreen->PostChangeSaveUnder)(pLayerWin, pWin->nextSib);
1144
#endif /* DO_SAVE_UNDERS */
1145
if (anyMarked && pScreen->PostValidateTree)
1146
(*pScreen->PostValidateTree)(pLayerWin->parent, pLayerWin,
1150
WindowsRestructured ();
1154
miMarkUnrealizedWindow(pChild, pWin, fromConfigure)
1159
if ((pChild != pWin) || fromConfigure)
1161
REGION_EMPTY(pChild->drawable.pScreen, &pChild->clipList);
1162
if (pChild->drawable.pScreen->ClipNotify)
1163
(* pChild->drawable.pScreen->ClipNotify)(pChild, 0, 0);
1164
REGION_EMPTY(pChild->drawable.pScreen, &pChild->borderClip);
1169
miSegregateChildren(WindowPtr pWin, RegionPtr pReg, int depth)
1174
pScreen = pWin->drawable.pScreen;
1176
for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib)
1178
if (pChild->drawable.depth == depth)
1179
REGION_UNION(pScreen, pReg, pReg, &pChild->borderClip);
1181
if (pChild->firstChild)
1182
miSegregateChildren(pChild, pReg, depth);