~ubuntu-branches/ubuntu/intrepid/xserver-xgl/intrepid

« back to all changes in this revision

Viewing changes to mi/miwindow.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthew Garrett
  • Date: 2006-02-13 14:21:43 UTC
  • Revision ID: james.westby@ubuntu.com-20060213142143-mad6z9xzem7hzxz9
Tags: upstream-7.0.0
ImportĀ upstreamĀ versionĀ 7.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $XFree86: xc/programs/Xserver/mi/miwindow.c,v 1.9tsi Exp $ */
 
2
/***********************************************************
 
3
 
 
4
Copyright 1987, 1998  The Open Group
 
5
 
 
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
 
10
documentation.
 
11
 
 
12
The above copyright notice and this permission notice shall be included in
 
13
all copies or substantial portions of the Software.
 
14
 
 
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.
 
21
 
 
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.
 
25
 
 
26
 
 
27
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
28
 
 
29
                        All Rights Reserved
 
30
 
 
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.  
 
38
 
 
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
 
45
SOFTWARE.
 
46
 
 
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>
 
51
#endif
 
52
 
 
53
#include <X11/X.h>
 
54
#include "regionstr.h"
 
55
#include "region.h"
 
56
#include "mi.h"
 
57
#include "windowstr.h"
 
58
#include "scrnintstr.h"
 
59
#include "pixmapstr.h"
 
60
#include "mivalidate.h"
 
61
 
 
62
void 
 
63
miClearToBackground(pWin, x, y, w, h, generateExposures)
 
64
    WindowPtr pWin;
 
65
    int x,y;
 
66
    int w,h;
 
67
    Bool generateExposures;
 
68
{
 
69
    BoxRec box;
 
70
    RegionRec   reg;
 
71
    RegionPtr pBSReg = NullRegion;
 
72
    ScreenPtr   pScreen;
 
73
    BoxPtr  extents;
 
74
    int     x1, y1, x2, y2;
 
75
 
 
76
    /* compute everything using ints to avoid overflow */
 
77
 
 
78
    x1 = pWin->drawable.x + x;
 
79
    y1 = pWin->drawable.y + y;
 
80
    if (w)
 
81
        x2 = x1 + (int) w;
 
82
    else
 
83
        x2 = x1 + (int) pWin->drawable.width - (int) x;
 
84
    if (h)
 
85
        y2 = y1 + h;    
 
86
    else
 
87
        y2 = y1 + (int) pWin->drawable.height - (int) y;
 
88
 
 
89
    extents = &pWin->clipList.extents;
 
90
    
 
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.
 
94
     */
 
95
 
 
96
    if (x1 < extents->x1)
 
97
        x1 = extents->x1;
 
98
    if (x2 > extents->x2)
 
99
        x2 = extents->x2;
 
100
    if (y1 < extents->y1)
 
101
        y1 = extents->y1;
 
102
    if (y2 > extents->y2)
 
103
        y2 = extents->y2;
 
104
 
 
105
    if (x2 <= x1 || y2 <= y1)
 
106
    {
 
107
        x2 = x1 = 0;
 
108
        y2 = y1 = 0;
 
109
    }
 
110
 
 
111
    box.x1 = x1;
 
112
    box.x2 = x2;
 
113
    box.y1 = y1;
 
114
    box.y2 = y2;
 
115
 
 
116
    pScreen = pWin->drawable.pScreen;
 
117
    REGION_INIT(pScreen, &reg, &box, 1);
 
118
    if (pWin->backStorage)
 
119
    {
 
120
        /*
 
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).
 
126
         */
 
127
        pBSReg = (* pScreen->ClearBackingStore)(pWin, x, y, w, h,
 
128
                                                 generateExposures);
 
129
    }
 
130
 
 
131
    REGION_INTERSECT(pScreen, &reg, &reg, &pWin->clipList);
 
132
    if (generateExposures)
 
133
        (*pScreen->WindowExposures)(pWin, &reg, pBSReg);
 
134
    else if (pWin->backgroundState != None)
 
135
        (*pScreen->PaintWindowBackground)(pWin, &reg, PW_BACKGROUND);
 
136
    REGION_UNINIT(pScreen, &reg);
 
137
    if (pBSReg)
 
138
        REGION_DESTROY(pScreen, pBSReg);
 
139
}
 
140
 
 
141
/*
 
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
 
146
 */
 
147
 
 
148
/*-
 
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.
 
154
 *
 
155
 * Results:
 
156
 *      TRUE if any windows need to have backing-store removed.
 
157
 *
 
158
 * Side Effects:
 
159
 *      Windows may have backing-store turned on or off.
 
160
 *
 
161
 *-----------------------------------------------------------------------
 
162
 */
 
163
static Bool
 
164
miCheckSubSaveUnder(
 
165
    register WindowPtr  pParent,        /* Parent to check */
 
166
    WindowPtr           pFirst,         /* first reconfigured window */
 
167
    RegionPtr           pRegion)        /* Initial area obscured by saveUnder */
 
168
{
 
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 */
 
174
 
 
175
    pScreen = pParent->drawable.pScreen;
 
176
    if ( (pChild = pParent->firstChild) )
 
177
    {
 
178
        /*
 
179
         * build region above first changed window
 
180
         */
 
181
 
 
182
        for (; pChild != pFirst; pChild = pChild->nextSib)
 
183
            if (pChild->viewable && pChild->saveUnder)
 
184
                REGION_UNION(pScreen, pRegion, pRegion, &pChild->borderSize);
 
185
        
 
186
        /*
 
187
         * check region below and including first changed window
 
188
         */
 
189
 
 
190
        for (; pChild; pChild = pChild->nextSib)
 
191
        {
 
192
            if (pChild->viewable)
 
193
            {
 
194
                /*
 
195
                 * don't save under nephew/niece windows;
 
196
                 * use a separate region
 
197
                 */
 
198
 
 
199
                if (pChild->firstChild)
 
200
                {
 
201
                    if (!subInited)
 
202
                    {
 
203
                        REGION_NULL(pScreen, &SubRegion);
 
204
                        subInited = TRUE;
 
205
                    }
 
206
                    REGION_COPY(pScreen, &SubRegion, pRegion);
 
207
                    res |= miCheckSubSaveUnder(pChild, pChild->firstChild,
 
208
                                             &SubRegion);
 
209
                }
 
210
                else
 
211
                {
 
212
                    res |= miCheckSubSaveUnder(pChild, pChild->firstChild,
 
213
                                             pRegion);
 
214
                }
 
215
 
 
216
                if (pChild->saveUnder)
 
217
                    REGION_UNION(pScreen, pRegion, pRegion, &pChild->borderSize);
 
218
            }
 
219
        }
 
220
 
 
221
        if (subInited)
 
222
            REGION_UNINIT(pScreen, &SubRegion);
 
223
    }
 
224
 
 
225
    /*
 
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
 
229
     */
 
230
 
 
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)
 
236
    {
 
237
        if (!pParent->DIXsaveUnder)
 
238
        {
 
239
            pParent->DIXsaveUnder = TRUE;
 
240
            (*pScreen->ChangeWindowAttributes) (pParent, CWBackingStore);
 
241
        }
 
242
    }
 
243
    else
 
244
    {
 
245
        if (pParent->DIXsaveUnder)
 
246
        {
 
247
            res = TRUE;
 
248
            pParent->DIXsaveUnder = FALSE;
 
249
        }
 
250
    }
 
251
    return res;
 
252
}
 
253
 
 
254
 
 
255
/*-
 
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.
 
260
 *      
 
261
 * Results:
 
262
 *      TRUE if any windows need to have backing-store removed (which
 
263
 *      means that PostChangeSaveUnder needs to be called later to 
 
264
 *      finish the job).
 
265
 *
 
266
 * Side Effects:
 
267
 *      Windows may have backing-store turned on or off.
 
268
 *
 
269
 *-----------------------------------------------------------------------
 
270
 */
 
271
Bool
 
272
miChangeSaveUnder(pWin, first)
 
273
    register WindowPtr  pWin;
 
274
    WindowPtr           first;          /* First window to check.
 
275
                                         * Used when pWin was restacked */
 
276
{
 
277
    RegionRec   rgn;    /* Area obscured by saveUnder windows */
 
278
    register ScreenPtr pScreen;
 
279
    Bool        res;
 
280
 
 
281
    if (!deltaSaveUndersViewable && !numSaveUndersViewable)
 
282
        return FALSE;
 
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,
 
289
                               &rgn);
 
290
    REGION_UNINIT(pScreen, &rgn);
 
291
    return res;
 
292
}
 
293
 
 
294
/*-
 
295
 *-----------------------------------------------------------------------
 
296
 * miPostChangeSaveUnder --
 
297
 *      Actually turn backing-store off for those windows that no longer
 
298
 *      need to have it on.
 
299
 *
 
300
 * Results:
 
301
 *      None.
 
302
 *
 
303
 * Side Effects:
 
304
 *      Backing-store and SAVE_UNDER_CHANGE_BIT are turned off for those
 
305
 *      windows affected.
 
306
 *
 
307
 *-----------------------------------------------------------------------
 
308
 */
 
309
void
 
310
miPostChangeSaveUnder(pWin, pFirst)
 
311
    WindowPtr           pWin;
 
312
    WindowPtr           pFirst;
 
313
{
 
314
    register WindowPtr pParent, pChild;
 
315
    ChangeWindowAttributesProcPtr ChangeWindowAttributes;
 
316
 
 
317
    if (!(pParent = pWin->parent))
 
318
        return;
 
319
    ChangeWindowAttributes = pParent->drawable.pScreen->ChangeWindowAttributes;
 
320
    if (!pParent->DIXsaveUnder &&
 
321
        (pParent->backingStore == NotUseful) && pParent->backStorage)
 
322
        (*ChangeWindowAttributes)(pParent, CWBackingStore);
 
323
    if (!(pChild = pFirst))
 
324
        return;
 
325
    while (1)
 
326
    {
 
327
        if (!pChild->DIXsaveUnder &&
 
328
            (pChild->backingStore == NotUseful) && pChild->backStorage)
 
329
            (*ChangeWindowAttributes)(pChild, CWBackingStore);
 
330
        if (pChild->firstChild)
 
331
        {
 
332
            pChild = pChild->firstChild;
 
333
            continue;
 
334
        }
 
335
        while (!pChild->nextSib)
 
336
        {
 
337
            pChild = pChild->parent;
 
338
            if (pChild == pParent)
 
339
                return;
 
340
        }
 
341
        pChild = pChild->nextSib;
 
342
    }
 
343
}
 
344
 
 
345
void
 
346
miMarkWindow(pWin)
 
347
    register WindowPtr pWin;
 
348
{
 
349
    register ValidatePtr val;
 
350
 
 
351
    if (pWin->valdata)
 
352
        return;
 
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;
 
358
    pWin->valdata = val;
 
359
}
 
360
 
 
361
Bool
 
362
miMarkOverlappedWindows(pWin, pFirst, ppLayerWin)
 
363
    WindowPtr pWin;
 
364
    WindowPtr pFirst;
 
365
    WindowPtr *ppLayerWin;
 
366
{
 
367
    register BoxPtr box;
 
368
    register WindowPtr pChild, pLast;
 
369
    Bool anyMarked = FALSE;
 
370
    MarkWindowProcPtr MarkWindow = pWin->drawable.pScreen->MarkWindow;
 
371
    ScreenPtr pScreen;
 
372
 
 
373
    pScreen = pWin->drawable.pScreen;
 
374
 
 
375
    /* single layered systems are easy */
 
376
    if (ppLayerWin) *ppLayerWin = pWin;
 
377
 
 
378
    if (pWin == pFirst)
 
379
    {
 
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.
 
383
         */
 
384
        pChild = pWin;
 
385
        while (1)
 
386
        {
 
387
            if (pChild->viewable)
 
388
            {
 
389
                if (REGION_BROKEN (pScreen, &pChild->winSize))
 
390
                    SetWinSize (pChild);
 
391
                if (REGION_BROKEN (pScreen, &pChild->borderSize))
 
392
                    SetBorderSize (pChild);
 
393
                (* MarkWindow)(pChild);
 
394
                if (pChild->firstChild)
 
395
                {
 
396
                    pChild = pChild->firstChild;
 
397
                    continue;
 
398
                }
 
399
            }
 
400
            while (!pChild->nextSib && (pChild != pWin))
 
401
                pChild = pChild->parent;
 
402
            if (pChild == pWin)
 
403
                break;
 
404
            pChild = pChild->nextSib;
 
405
        }
 
406
        anyMarked = TRUE;
 
407
        pFirst = pFirst->nextSib;
 
408
    }
 
409
    if ( (pChild = pFirst) )
 
410
    {
 
411
        box = REGION_EXTENTS(pChild->drawable.pScreen, &pWin->borderSize);
 
412
        pLast = pChild->parent->lastChild;
 
413
        while (1)
 
414
        {
 
415
            if (pChild->viewable)
 
416
            {
 
417
                if (REGION_BROKEN (pScreen, &pChild->winSize))
 
418
                    SetWinSize (pChild);
 
419
                if (REGION_BROKEN (pScreen, &pChild->borderSize))
 
420
                    SetBorderSize (pChild);
 
421
                if (RECT_IN_REGION(pScreen, &pChild->borderSize, box))
 
422
                {
 
423
                    (* MarkWindow)(pChild);
 
424
                    anyMarked = TRUE;
 
425
                    if (pChild->firstChild)
 
426
                    {
 
427
                        pChild = pChild->firstChild;
 
428
                        continue;
 
429
                    }
 
430
                }
 
431
            }
 
432
            while (!pChild->nextSib && (pChild != pLast))
 
433
                pChild = pChild->parent;
 
434
            if (pChild == pLast)
 
435
                break;
 
436
            pChild = pChild->nextSib;
 
437
        }
 
438
    }
 
439
    if (anyMarked)
 
440
        (* MarkWindow)(pWin->parent);
 
441
    return anyMarked;
 
442
}
 
443
 
 
444
/*****
 
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
 
449
 *****/
 
450
void
 
451
miHandleValidateExposures(pWin)
 
452
    WindowPtr pWin;
 
453
{
 
454
    register WindowPtr pChild;
 
455
    register ValidatePtr val;
 
456
    ScreenPtr pScreen;
 
457
    WindowExposuresProcPtr WindowExposures;
 
458
 
 
459
    pScreen = pWin->drawable.pScreen;
 
460
 
 
461
    pChild = pWin;
 
462
    WindowExposures = pChild->drawable.pScreen->WindowExposures;
 
463
    while (1)
 
464
    {
 
465
        if ( (val = pChild->valdata) )
 
466
        {
 
467
            if (REGION_NOTEMPTY(pScreen, &val->after.borderExposed))
 
468
                (*pChild->drawable.pScreen->PaintWindowBorder)(pChild,
 
469
                                                    &val->after.borderExposed,
 
470
                                                    PW_BORDER);
 
471
            REGION_UNINIT(pScreen, &val->after.borderExposed);
 
472
            (*WindowExposures)(pChild, &val->after.exposed, NullRegion);
 
473
            REGION_UNINIT(pScreen, &val->after.exposed);
 
474
            xfree(val);
 
475
            pChild->valdata = (ValidatePtr)NULL;
 
476
            if (pChild->firstChild)
 
477
            {
 
478
                pChild = pChild->firstChild;
 
479
                continue;
 
480
            }
 
481
        }
 
482
        while (!pChild->nextSib && (pChild != pWin))
 
483
            pChild = pChild->parent;
 
484
        if (pChild == pWin)
 
485
            break;
 
486
        pChild = pChild->nextSib;
 
487
    }
 
488
}
 
489
 
 
490
void
 
491
miMoveWindow(pWin, x, y, pNextSib, kind)
 
492
    register WindowPtr pWin;
 
493
    int x,y;
 
494
    WindowPtr pNextSib;
 
495
    VTKind kind;
 
496
{
 
497
    WindowPtr pParent;
 
498
    Bool WasViewable = (Bool)(pWin->viewable);
 
499
    short bw;
 
500
    RegionPtr oldRegion = NULL;
 
501
    DDXPointRec oldpt;
 
502
    Bool anyMarked = FALSE;
 
503
    register ScreenPtr pScreen;
 
504
    WindowPtr windowToValidate;
 
505
#ifdef DO_SAVE_UNDERS
 
506
    Bool dosave = FALSE;
 
507
#endif
 
508
    WindowPtr pLayerWin;
 
509
 
 
510
    /* if this is a root window, can't be moved */
 
511
    if (!(pParent = pWin->parent))
 
512
       return ;
 
513
    pScreen = pWin->drawable.pScreen;
 
514
    bw = wBorderWidth (pWin);
 
515
 
 
516
    oldpt.x = pWin->drawable.x;
 
517
    oldpt.y = pWin->drawable.y;
 
518
    if (WasViewable)
 
519
    {
 
520
        oldRegion = REGION_CREATE(pScreen, NullBox, 1);
 
521
        REGION_COPY(pScreen, oldRegion, &pWin->borderClip);
 
522
        anyMarked = (*pScreen->MarkOverlappedWindows)(pWin, pWin, &pLayerWin);
 
523
    }
 
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;
 
528
 
 
529
    SetWinSize (pWin);
 
530
    SetBorderSize (pWin);
 
531
 
 
532
    (*pScreen->PositionWindow)(pWin, x, y);
 
533
 
 
534
    windowToValidate = MoveWindowInStack(pWin, pNextSib);
 
535
 
 
536
    ResizeChildrenWinSize(pWin, x - oldpt.x, y - oldpt.y, 0, 0);
 
537
 
 
538
    if (WasViewable)
 
539
    {
 
540
        if (pLayerWin == pWin)
 
541
            anyMarked |= (*pScreen->MarkOverlappedWindows)
 
542
                                (pWin, windowToValidate, (WindowPtr *)NULL);
 
543
        else
 
544
            anyMarked |= (*pScreen->MarkOverlappedWindows)
 
545
                                (pWin, pLayerWin, (WindowPtr *)NULL);
 
546
 
 
547
#ifdef DO_SAVE_UNDERS
 
548
        if (DO_SAVE_UNDERS(pWin))
 
549
        {
 
550
            dosave = (*pScreen->ChangeSaveUnder)(pLayerWin, windowToValidate);
 
551
        }
 
552
#endif /* DO_SAVE_UNDERS */
 
553
 
 
554
        if (anyMarked)
 
555
        {
 
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);
 
561
        }
 
562
#ifdef DO_SAVE_UNDERS
 
563
        if (dosave)
 
564
            (*pScreen->PostChangeSaveUnder)(pLayerWin, windowToValidate);
 
565
#endif /* DO_SAVE_UNDERS */
 
566
        if (anyMarked && pScreen->PostValidateTree)
 
567
            (*pScreen->PostValidateTree)(pLayerWin->parent, NullWindow, kind);
 
568
    }
 
569
    if (pWin->realized)
 
570
        WindowsRestructured ();
 
571
}
 
572
 
 
573
 
 
574
/*
 
575
 * pValid is a region of the screen which has been
 
576
 * successfully copied -- recomputed exposed regions for affected windows
 
577
 */
 
578
 
 
579
static int
 
580
miRecomputeExposures (
 
581
    register WindowPtr  pWin,
 
582
    pointer             value) /* must conform to VisitWindowProcPtr */
 
583
{
 
584
    register ScreenPtr  pScreen;
 
585
    RegionPtr   pValid = (RegionPtr)value;
 
586
 
 
587
    if (pWin->valdata)
 
588
    {
 
589
        pScreen = pWin->drawable.pScreen;
 
590
        /*
 
591
         * compute exposed regions of this window
 
592
         */
 
593
        REGION_SUBTRACT(pScreen, &pWin->valdata->after.exposed,
 
594
                        &pWin->clipList, pValid);
 
595
        /*
 
596
         * compute exposed regions of the border
 
597
         */
 
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;
 
603
    }
 
604
    return WT_NOMATCH;
 
605
}
 
606
 
 
607
void
 
608
miSlideAndSizeWindow(pWin, x, y, w, h, pSib)
 
609
    register WindowPtr pWin;
 
610
    int x,y;
 
611
    unsigned int w, h;
 
612
    WindowPtr pSib;
 
613
{
 
614
    WindowPtr pParent;
 
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);
 
621
    short dw, dh;
 
622
    DDXPointRec oldpt;
 
623
    RegionPtr oldRegion = NULL;
 
624
    Bool anyMarked = FALSE;
 
625
    register ScreenPtr pScreen;
 
626
    WindowPtr pFirstChange;
 
627
    register WindowPtr pChild;
 
628
    RegionPtr   gravitate[StaticGravity + 1];
 
629
    register unsigned g;
 
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
 
640
    Bool        dosave = FALSE;
 
641
#endif
 
642
    WindowPtr  pLayerWin;
 
643
 
 
644
    /* if this is a root window, can't be resized */
 
645
    if (!(pParent = pWin->parent))
 
646
        return ;
 
647
 
 
648
    pScreen = pWin->drawable.pScreen;
 
649
    newx = pParent->drawable.x + x + bw;
 
650
    newy = pParent->drawable.y + y + bw;
 
651
    if (WasViewable)
 
652
    {
 
653
        anyMarked = FALSE;
 
654
        /*
 
655
         * save the visible region of the window
 
656
         */
 
657
        oldRegion = REGION_CREATE(pScreen, NullBox, 1);
 
658
        REGION_COPY(pScreen, oldRegion, &pWin->winSize);
 
659
 
 
660
        /*
 
661
         * categorize child windows into regions to be moved
 
662
         */
 
663
        for (g = 0; g <= StaticGravity; g++)
 
664
            gravitate[g] = (RegionPtr) NULL;
 
665
        for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib)
 
666
        {
 
667
            g = pChild->winGravity;
 
668
            if (g != UnmapGravity)
 
669
            {
 
670
                if (!gravitate[g])
 
671
                    gravitate[g] = REGION_CREATE(pScreen, NullBox, 1);
 
672
                REGION_UNION(pScreen, gravitate[g],
 
673
                                   gravitate[g], &pChild->borderClip);
 
674
            }
 
675
            else
 
676
            {
 
677
                UnmapWindow(pChild, TRUE);
 
678
                anyMarked = TRUE;
 
679
            }
 
680
        }
 
681
        anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin, pWin, 
 
682
                                                       &pLayerWin);
 
683
 
 
684
        oldWinClip = NULL;
 
685
        if (pWin->bitGravity != ForgetGravity)
 
686
        {
 
687
            oldWinClip = REGION_CREATE(pScreen, NullBox, 1);
 
688
            REGION_COPY(pScreen, oldWinClip, &pWin->clipList);
 
689
        }
 
690
        /*
 
691
         * if the window is changing size, borderExposed
 
692
         * can't be computed correctly without some help.
 
693
         */
 
694
        if (pWin->drawable.height > h || pWin->drawable.width > w)
 
695
            shrunk = TRUE;
 
696
 
 
697
        if (newx != oldx || newy != oldy)
 
698
            moved = TRUE;
 
699
 
 
700
        if ((pWin->drawable.height != h || pWin->drawable.width != w) &&
 
701
            HasBorder (pWin))
 
702
        {
 
703
            borderVisible = REGION_CREATE(pScreen, NullBox, 1);
 
704
            /* for tiled borders, we punt and draw the whole thing */
 
705
            if (pWin->borderIsPixel || !moved)
 
706
            {
 
707
                if (shrunk || moved)
 
708
                    REGION_SUBTRACT(pScreen, borderVisible,
 
709
                                          &pWin->borderClip,
 
710
                                          &pWin->winSize);
 
711
                else
 
712
                    REGION_COPY(pScreen, borderVisible,
 
713
                                            &pWin->borderClip);
 
714
            }
 
715
        }
 
716
    }
 
717
    pWin->origin.x = x + bw;
 
718
    pWin->origin.y = y + bw;
 
719
    pWin->drawable.height = h;
 
720
    pWin->drawable.width = w;
 
721
 
 
722
    x = pWin->drawable.x = newx;
 
723
    y = pWin->drawable.y = newy;
 
724
 
 
725
    SetWinSize (pWin);
 
726
    SetBorderSize (pWin);
 
727
 
 
728
    dw = (int)w - (int)width;
 
729
    dh = (int)h - (int)height;
 
730
    ResizeChildrenWinSize(pWin, x - oldx, y - oldy, dw, dh);
 
731
 
 
732
    /* let the hardware adjust background and border pixmaps, if any */
 
733
    (*pScreen->PositionWindow)(pWin, x, y);
 
734
 
 
735
    pFirstChange = MoveWindowInStack(pWin, pSib);
 
736
 
 
737
    if (WasViewable)
 
738
    {
 
739
        pRegion = REGION_CREATE(pScreen, NullBox, 1);
 
740
        if (pWin->backStorage)
 
741
            REGION_COPY(pScreen, pRegion, &pWin->clipList);
 
742
 
 
743
        if (pLayerWin == pWin)
 
744
            anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin, pFirstChange,
 
745
                                                (WindowPtr *)NULL);
 
746
        else
 
747
            anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin, pLayerWin,
 
748
                                                (WindowPtr *)NULL);
 
749
 
 
750
        if (pWin->valdata)
 
751
        {
 
752
            pWin->valdata->before.resized = TRUE;
 
753
            pWin->valdata->before.borderVisible = borderVisible;
 
754
        }
 
755
 
 
756
#ifdef DO_SAVE_UNDERS
 
757
        if (DO_SAVE_UNDERS(pWin))
 
758
        {
 
759
            dosave = (*pScreen->ChangeSaveUnder)(pLayerWin, pFirstChange);
 
760
        }
 
761
#endif /* DO_SAVE_UNDERS */
 
762
 
 
763
        if (anyMarked)
 
764
            (*pScreen->ValidateTree)(pLayerWin->parent, pFirstChange, VTOther);
 
765
        /*
 
766
         * the entire window is trashed unless bitGravity
 
767
         * recovers portions of it
 
768
         */
 
769
        REGION_COPY(pScreen, &pWin->valdata->after.exposed, &pWin->clipList);
 
770
    }
 
771
 
 
772
    GravityTranslate (x, y, oldx, oldy, dw, dh, pWin->bitGravity, &nx, &ny);
 
773
 
 
774
    if (pWin->backStorage &&
 
775
        ((pWin->backingStore == Always) || WasViewable))
 
776
    {
 
777
        if (!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);
 
782
        else
 
783
        {
 
784
            bsExposed = (*pScreen->TranslateBackingStore)
 
785
                             (pWin, nx - x, ny - y, pRegion, oldx, oldy);
 
786
        }
 
787
    }
 
788
 
 
789
    if (WasViewable)
 
790
    {
 
791
        /* avoid the border */
 
792
        if (HasBorder (pWin))
 
793
        {
 
794
            int offx, offy, dx, dy;
 
795
 
 
796
            /* kruft to avoid double translates for each gravity */
 
797
            offx = 0;
 
798
            offy = 0;
 
799
            for (g = 0; g <= StaticGravity; g++)
 
800
            {
 
801
                if (!gravitate[g])
 
802
                    continue;
 
803
 
 
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);
 
808
                
 
809
                dx = (oldx - nx) - offx;
 
810
                dy = (oldy - ny) - offy;
 
811
                if (dx || dy)
 
812
                {
 
813
                    REGION_TRANSLATE(pScreen, &pWin->winSize, dx, dy);
 
814
                    offx += dx;
 
815
                    offy += dy;
 
816
                }
 
817
                REGION_INTERSECT(pScreen, gravitate[g], gravitate[g],
 
818
                                 &pWin->winSize);
 
819
            }
 
820
            /* get winSize back where it belongs */
 
821
            if (offx || offy)
 
822
                REGION_TRANSLATE(pScreen, &pWin->winSize, -offx, -offy);
 
823
        }
 
824
        /*
 
825
         * add screen bits to the appropriate bucket
 
826
         */
 
827
 
 
828
        if (oldWinClip)
 
829
        {
 
830
            /*
 
831
             * clip to new clipList
 
832
             */
 
833
            REGION_COPY(pScreen, pRegion, oldWinClip);
 
834
            REGION_TRANSLATE(pScreen, pRegion, nx - oldx, ny - oldy);
 
835
            REGION_INTERSECT(pScreen, oldWinClip, pRegion, &pWin->clipList);
 
836
            /*
 
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
 
839
             * in gravity order.
 
840
             */
 
841
            for (g = pWin->bitGravity + 1; g <= StaticGravity; g++)
 
842
            {
 
843
                if (gravitate[g])
 
844
                    REGION_SUBTRACT(pScreen, oldWinClip, oldWinClip,
 
845
                                        gravitate[g]);
 
846
            }
 
847
            REGION_TRANSLATE(pScreen, oldWinClip, oldx - nx, oldy - ny);
 
848
            g = pWin->bitGravity;
 
849
            if (!gravitate[g])
 
850
                gravitate[g] = oldWinClip;
 
851
            else
 
852
            {
 
853
                REGION_UNION(pScreen, gravitate[g], gravitate[g], oldWinClip);
 
854
                REGION_DESTROY(pScreen, oldWinClip);
 
855
            }
 
856
        }
 
857
 
 
858
        /*
 
859
         * move the bits on the screen
 
860
         */
 
861
 
 
862
        destClip = NULL;
 
863
 
 
864
        for (g = 0; g <= StaticGravity; g++)
 
865
        {
 
866
            if (!gravitate[g])
 
867
                continue;
 
868
 
 
869
            GravityTranslate (x, y, oldx, oldy, dw, dh, g, &nx, &ny);
 
870
 
 
871
            oldpt.x = oldx + (x - nx);
 
872
            oldpt.y = oldy + (y - ny);
 
873
 
 
874
            /* Note that gravitate[g] is *translated* by CopyWindow */
 
875
 
 
876
            /* only copy the remaining useful bits */
 
877
 
 
878
            REGION_INTERSECT(pScreen, gravitate[g], gravitate[g], oldRegion);
 
879
 
 
880
            /* clip to not overwrite already copied areas */
 
881
 
 
882
            if (destClip) {
 
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);
 
886
            }
 
887
 
 
888
            /* and move those bits */
 
889
 
 
890
            if (oldpt.x != x || oldpt.y != y
 
891
#ifdef COMPOSITE
 
892
                || pWin->redirectDraw
 
893
#endif
 
894
                )
 
895
            {
 
896
                (*pWin->drawable.pScreen->CopyWindow)(pWin, oldpt, gravitate[g]);
 
897
            }
 
898
 
 
899
            /* remove any overwritten bits from the remaining useful bits */
 
900
 
 
901
            REGION_SUBTRACT(pScreen, oldRegion, oldRegion, gravitate[g]);
 
902
 
 
903
            /*
 
904
             * recompute exposed regions of child windows
 
905
             */
 
906
        
 
907
            for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib)
 
908
            {
 
909
                if (pChild->winGravity != g)
 
910
                    continue;
 
911
                REGION_INTERSECT(pScreen, pRegion,
 
912
                                       &pChild->borderClip, gravitate[g]);
 
913
                TraverseTree (pChild, miRecomputeExposures, (pointer)pRegion);
 
914
            }
 
915
 
 
916
            /*
 
917
             * remove the successfully copied regions of the
 
918
             * window from its exposed region
 
919
             */
 
920
 
 
921
            if (g == pWin->bitGravity)
 
922
                REGION_SUBTRACT(pScreen, &pWin->valdata->after.exposed,
 
923
                                     &pWin->valdata->after.exposed, gravitate[g]);
 
924
            if (!destClip)
 
925
                destClip = gravitate[g];
 
926
            else
 
927
            {
 
928
                REGION_UNION(pScreen, destClip, destClip, gravitate[g]);
 
929
                REGION_DESTROY(pScreen, gravitate[g]);
 
930
            }
 
931
        }
 
932
 
 
933
        REGION_DESTROY(pScreen, oldRegion);
 
934
        REGION_DESTROY(pScreen, pRegion);
 
935
        if (destClip)
 
936
            REGION_DESTROY(pScreen, destClip);
 
937
        if (bsExposed)
 
938
        {
 
939
            RegionPtr   valExposed = NullRegion;
 
940
 
 
941
            if (pWin->valdata)
 
942
                valExposed = &pWin->valdata->after.exposed;
 
943
            (*pScreen->WindowExposures) (pWin, valExposed, bsExposed);
 
944
            if (valExposed)
 
945
                REGION_EMPTY(pScreen, valExposed);
 
946
            REGION_DESTROY(pScreen, bsExposed);
 
947
        }
 
948
        if (anyMarked)
 
949
            (*pScreen->HandleExposures)(pLayerWin->parent);
 
950
#ifdef DO_SAVE_UNDERS
 
951
        if (dosave)
 
952
        {
 
953
            (*pScreen->PostChangeSaveUnder)(pLayerWin, pFirstChange);
 
954
        }
 
955
#endif /* DO_SAVE_UNDERS */
 
956
        if (anyMarked && pScreen->PostValidateTree)
 
957
            (*pScreen->PostValidateTree)(pLayerWin->parent, pFirstChange,
 
958
                                          VTOther);
 
959
    }
 
960
    else if (bsExposed)
 
961
    {
 
962
        (*pScreen->WindowExposures) (pWin, NullRegion, bsExposed);
 
963
        REGION_DESTROY(pScreen, bsExposed);
 
964
    }
 
965
    if (pWin->realized)
 
966
        WindowsRestructured ();
 
967
}
 
968
 
 
969
WindowPtr
 
970
miGetLayerWindow(pWin)
 
971
    WindowPtr pWin;
 
972
{
 
973
    return pWin->firstChild;
 
974
}
 
975
 
 
976
#ifdef SHAPE
 
977
/******
 
978
 *
 
979
 * miSetShape
 
980
 *    The border/window shape has changed.  Recompute winSize/borderSize
 
981
 *    and send appropriate exposure events
 
982
 */
 
983
 
 
984
void
 
985
miSetShape(pWin)
 
986
    register WindowPtr  pWin;
 
987
{
 
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
 
993
    Bool        dosave = FALSE;
 
994
#endif
 
995
    WindowPtr   pLayerWin;
 
996
 
 
997
    if (WasViewable)
 
998
    {
 
999
        anyMarked = (*pScreen->MarkOverlappedWindows)(pWin, pWin,
 
1000
                                                      &pLayerWin);
 
1001
        if (pWin->valdata)
 
1002
        {
 
1003
            if (HasBorder (pWin))
 
1004
            {
 
1005
                RegionPtr       borderVisible;
 
1006
 
 
1007
                borderVisible = REGION_CREATE(pScreen, NullBox, 1);
 
1008
                REGION_SUBTRACT(pScreen, borderVisible,
 
1009
                                      &pWin->borderClip, &pWin->winSize);
 
1010
                pWin->valdata->before.borderVisible = borderVisible;
 
1011
            }
 
1012
            pWin->valdata->before.resized = TRUE;
 
1013
        }
 
1014
    }
 
1015
 
 
1016
    SetWinSize (pWin);
 
1017
    SetBorderSize (pWin);
 
1018
 
 
1019
    ResizeChildrenWinSize(pWin, 0, 0, 0, 0);
 
1020
 
 
1021
    if (WasViewable)
 
1022
    {
 
1023
        if (pWin->backStorage)
 
1024
        {
 
1025
            pOldClip = REGION_CREATE(pScreen, NullBox, 1);
 
1026
            REGION_COPY(pScreen, pOldClip, &pWin->clipList);
 
1027
        }
 
1028
 
 
1029
        anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin, pWin,
 
1030
                                                (WindowPtr *)NULL);
 
1031
 
 
1032
#ifdef DO_SAVE_UNDERS
 
1033
        if (DO_SAVE_UNDERS(pWin))
 
1034
        {
 
1035
            dosave = (*pScreen->ChangeSaveUnder)(pLayerWin, pLayerWin);
 
1036
        }
 
1037
#endif /* DO_SAVE_UNDERS */
 
1038
 
 
1039
        if (anyMarked)
 
1040
            (*pScreen->ValidateTree)(pLayerWin->parent, NullWindow, VTOther);
 
1041
    }
 
1042
 
 
1043
    if (pWin->backStorage &&
 
1044
        ((pWin->backingStore == Always) || WasViewable))
 
1045
    {
 
1046
        if (!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);
 
1051
        if (WasViewable)
 
1052
            REGION_DESTROY(pScreen, pOldClip);
 
1053
        if (bsExposed)
 
1054
        {
 
1055
            RegionPtr   valExposed = NullRegion;
 
1056
    
 
1057
            if (pWin->valdata)
 
1058
                valExposed = &pWin->valdata->after.exposed;
 
1059
            (*pScreen->WindowExposures) (pWin, valExposed, bsExposed);
 
1060
            if (valExposed)
 
1061
                REGION_EMPTY(pScreen, valExposed);
 
1062
            REGION_DESTROY(pScreen, bsExposed);
 
1063
        }
 
1064
    }
 
1065
    if (WasViewable)
 
1066
    {
 
1067
        if (anyMarked)
 
1068
            (*pScreen->HandleExposures)(pLayerWin->parent);
 
1069
#ifdef DO_SAVE_UNDERS
 
1070
        if (dosave)
 
1071
            (*pScreen->PostChangeSaveUnder)(pLayerWin, pLayerWin);
 
1072
#endif /* DO_SAVE_UNDERS */
 
1073
        if (anyMarked && pScreen->PostValidateTree)
 
1074
            (*pScreen->PostValidateTree)(pLayerWin->parent, NullWindow, VTOther);
 
1075
    }
 
1076
    if (pWin->realized)
 
1077
        WindowsRestructured ();
 
1078
    CheckCursorConfinement(pWin);
 
1079
}
 
1080
#endif
 
1081
 
 
1082
/* Keeps the same inside(!) origin */
 
1083
 
 
1084
void
 
1085
miChangeBorderWidth(pWin, width)
 
1086
    register WindowPtr pWin;
 
1087
    unsigned int width;
 
1088
{
 
1089
    int oldwidth;
 
1090
    Bool anyMarked = FALSE;
 
1091
    register ScreenPtr pScreen;
 
1092
    Bool WasViewable = (Bool)(pWin->viewable);
 
1093
    Bool HadBorder;
 
1094
#ifdef DO_SAVE_UNDERS
 
1095
    Bool        dosave = FALSE;
 
1096
#endif
 
1097
    WindowPtr  pLayerWin;
 
1098
 
 
1099
    oldwidth = wBorderWidth (pWin);
 
1100
    if (oldwidth == width)
 
1101
        return;
 
1102
    HadBorder = HasBorder(pWin);
 
1103
    pScreen = pWin->drawable.pScreen;
 
1104
    if (WasViewable && width < oldwidth)
 
1105
        anyMarked = (*pScreen->MarkOverlappedWindows)(pWin, pWin, &pLayerWin);
 
1106
 
 
1107
    pWin->borderWidth = width;
 
1108
    SetBorderSize (pWin);
 
1109
 
 
1110
    if (WasViewable)
 
1111
    {
 
1112
        if (width > oldwidth)
 
1113
        {
 
1114
            anyMarked = (*pScreen->MarkOverlappedWindows)(pWin, pWin,
 
1115
                                                          &pLayerWin);
 
1116
            /*
 
1117
             * save the old border visible region to correctly compute
 
1118
             * borderExposed.
 
1119
             */
 
1120
            if (pWin->valdata && HadBorder)
 
1121
            {
 
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;
 
1127
            }
 
1128
        }
 
1129
#ifdef DO_SAVE_UNDERS
 
1130
        if (DO_SAVE_UNDERS(pWin))
 
1131
        {
 
1132
            dosave = (*pScreen->ChangeSaveUnder)(pLayerWin, pWin->nextSib);
 
1133
        }
 
1134
#endif /* DO_SAVE_UNDERS */
 
1135
 
 
1136
        if (anyMarked)
 
1137
        {
 
1138
            (*pScreen->ValidateTree)(pLayerWin->parent, pLayerWin, VTOther);
 
1139
            (*pScreen->HandleExposures)(pLayerWin->parent);
 
1140
        }
 
1141
#ifdef DO_SAVE_UNDERS
 
1142
        if (dosave)
 
1143
            (*pScreen->PostChangeSaveUnder)(pLayerWin, pWin->nextSib);
 
1144
#endif /* DO_SAVE_UNDERS */
 
1145
        if (anyMarked && pScreen->PostValidateTree)
 
1146
            (*pScreen->PostValidateTree)(pLayerWin->parent, pLayerWin,
 
1147
                                          VTOther);
 
1148
    }
 
1149
    if (pWin->realized)
 
1150
        WindowsRestructured ();
 
1151
}
 
1152
 
 
1153
void
 
1154
miMarkUnrealizedWindow(pChild, pWin, fromConfigure)
 
1155
    WindowPtr pChild;
 
1156
    WindowPtr pWin;
 
1157
    Bool fromConfigure;
 
1158
{
 
1159
    if ((pChild != pWin) || fromConfigure)
 
1160
    {
 
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);
 
1165
    }
 
1166
}
 
1167
 
 
1168
void
 
1169
miSegregateChildren(WindowPtr pWin, RegionPtr pReg, int depth)
 
1170
{
 
1171
    ScreenPtr pScreen;
 
1172
    WindowPtr pChild;
 
1173
 
 
1174
    pScreen = pWin->drawable.pScreen;
 
1175
 
 
1176
    for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib)
 
1177
    {
 
1178
        if (pChild->drawable.depth == depth)
 
1179
            REGION_UNION(pScreen, pReg, pReg, &pChild->borderClip);
 
1180
 
 
1181
        if (pChild->firstChild)
 
1182
            miSegregateChildren(pChild, pReg, depth);
 
1183
    }
 
1184
}