105
105
#include "globals.h"
107
int RootlessMiValidateTree (WindowPtr pRoot, WindowPtr pChild, VTKind kind);
107
int RootlessMiValidateTree(WindowPtr pRoot, WindowPtr pChild, VTKind kind);
110
110
* Compute the visibility of a shaped window
113
RootlessShapedWindowIn (RegionPtr universe,
114
RegionPtr bounding, BoxPtr rect, int x, int y)
113
RootlessShapedWindowIn(RegionPtr universe,
114
RegionPtr bounding, BoxPtr rect, int x, int y)
117
register BoxPtr boundBox;
119
Bool someIn, someOut;
117
register BoxPtr boundBox;
119
Bool someIn, someOut;
120
120
register int t, x1, y1, x2, y2;
122
nbox = RegionNumRects (bounding);
123
boundBox = RegionRects (bounding);
122
nbox = RegionNumRects(bounding);
123
boundBox = RegionRects(bounding);
124
124
someIn = someOut = FALSE;
131
if ((t = boundBox->x1 + x) < x1)
134
if ((t = boundBox->y1 + y) < y1)
137
if ((t = boundBox->x2 + x) > x2)
140
if ((t = boundBox->y2 + y) > y2)
147
switch (RegionContainsRect(universe, &box))
130
if ((t = boundBox->x1 + x) < x1)
133
if ((t = boundBox->y1 + y) < y1)
136
if ((t = boundBox->x2 + x) > x2)
139
if ((t = boundBox->y2 + y) > y2)
146
switch (RegionContainsRect(universe, &box)) {
211
208
borderSize.x1 = pParent->drawable.x - wBorderWidth(pParent);
212
209
borderSize.y1 = pParent->drawable.y - wBorderWidth(pParent);
213
dx = (int) pParent->drawable.x + (int) pParent->drawable.width + wBorderWidth(pParent);
210
dx = (int) pParent->drawable.x + (int) pParent->drawable.width +
211
wBorderWidth(pParent);
216
214
borderSize.x2 = dx;
217
dy = (int) pParent->drawable.y + (int) pParent->drawable.height + wBorderWidth(pParent);
215
dy = (int) pParent->drawable.y + (int) pParent->drawable.height +
216
wBorderWidth(pParent);
220
219
borderSize.y2 = dy;
222
221
oldVis = pParent->visibility;
223
switch (RegionContainsRect(universe, &borderSize))
222
switch (RegionContainsRect(universe, &borderSize)) {
226
newVis = VisibilityUnobscured;
229
newVis = VisibilityPartiallyObscured;
224
newVis = VisibilityUnobscured;
227
newVis = VisibilityPartiallyObscured;
233
if ((pBounding = wBoundingShape (pParent)))
235
switch (RootlessShapedWindowIn (universe,
236
pBounding, &borderSize,
238
pParent->drawable.y))
241
newVis = VisibilityUnobscured;
244
newVis = VisibilityFullyObscured;
251
newVis = VisibilityFullyObscured;
231
if ((pBounding = wBoundingShape(pParent))) {
232
switch (RootlessShapedWindowIn(universe,
233
pBounding, &borderSize,
235
pParent->drawable.y)) {
237
newVis = VisibilityUnobscured;
240
newVis = VisibilityFullyObscured;
247
newVis = VisibilityFullyObscured;
255
251
pParent->visibility = newVis;
256
252
if (oldVis != newVis &&
257
((pParent->eventMask | wOtherEventMasks(pParent)) & VisibilityChangeMask))
258
SendVisibilityNotify(pParent);
254
eventMask | wOtherEventMasks(pParent)) & VisibilityChangeMask))
255
SendVisibilityNotify(pParent);
260
257
dx = pParent->drawable.x - pParent->valdata->before.oldAbsCorner.x;
261
258
dy = pParent->drawable.y - pParent->valdata->before.oldAbsCorner.y;
273
if ((oldVis == newVis) &&
274
((oldVis == VisibilityFullyObscured) ||
275
(oldVis == VisibilityUnobscured)))
280
if (pChild->viewable)
282
if (pChild->visibility != VisibilityFullyObscured)
284
RegionTranslate(&pChild->borderClip,
286
RegionTranslate(&pChild->clipList,
288
pChild->drawable.serialNumber = NEXT_SERIAL_NUMBER;
289
if (pScreen->ClipNotify)
290
(* pScreen->ClipNotify) (pChild, dx, dy);
270
if ((oldVis == newVis) &&
271
((oldVis == VisibilityFullyObscured) ||
272
(oldVis == VisibilityUnobscured))) {
275
if (pChild->viewable) {
276
if (pChild->visibility != VisibilityFullyObscured) {
277
RegionTranslate(&pChild->borderClip, dx, dy);
278
RegionTranslate(&pChild->clipList, dx, dy);
279
pChild->drawable.serialNumber = NEXT_SERIAL_NUMBER;
280
if (pScreen->ClipNotify)
281
(*pScreen->ClipNotify) (pChild, dx, dy);
295
RegionNull(&pChild->valdata->after.borderExposed);
296
if (HasParentRelativeBorder(pChild))
298
RegionSubtract(&pChild->valdata->after.borderExposed,
302
RegionNull(&pChild->valdata->after.exposed);
304
if (pChild->firstChild)
306
pChild = pChild->firstChild;
310
while (!pChild->nextSib && (pChild != pParent))
311
pChild = pChild->parent;
312
if (pChild == pParent)
314
pChild = pChild->nextSib;
284
if (pChild->valdata) {
285
RegionNull(&pChild->valdata->after.borderExposed);
286
if (HasParentRelativeBorder(pChild)) {
287
RegionSubtract(&pChild->valdata->after.
288
borderExposed, &pChild->borderClip,
291
RegionNull(&pChild->valdata->after.exposed);
293
if (pChild->firstChild) {
294
pChild = pChild->firstChild;
298
while (!pChild->nextSib && (pChild != pParent))
299
pChild = pChild->parent;
300
if (pChild == pParent)
302
pChild = pChild->nextSib;
321
* To calculate exposures correctly, we have to translate the old
322
* borderClip and clipList regions to the window's new location so there
323
* is a correspondence between pieces of the new and old clipping regions.
328
* We translate the old clipList because that will be exposed or copied
329
* if gravity is right.
331
RegionTranslate(&pParent->borderClip, dx, dy);
332
RegionTranslate(&pParent->clipList, dx, dy);
309
* To calculate exposures correctly, we have to translate the old
310
* borderClip and clipList regions to the window's new location so there
311
* is a correspondence between pieces of the new and old clipping regions.
315
* We translate the old clipList because that will be exposed or copied
316
* if gravity is right.
318
RegionTranslate(&pParent->borderClip, dx, dy);
319
RegionTranslate(&pParent->clipList, dx, dy);
336
RegionEmpty(&pParent->borderClip);
337
RegionEmpty(&pParent->clipList);
323
RegionEmpty(&pParent->borderClip);
324
RegionEmpty(&pParent->clipList);
341
328
borderVisible = pParent->valdata->before.borderVisible;
351
338
* This leaves a region of pieces that weren't exposed before.
354
if (HasBorder (pParent))
359
* when the border changes shape, the old visible portions
360
* of the border will be saved by DIX in borderVisible --
361
* use that region and destroy it
363
RegionSubtract(exposed, universe, borderVisible);
364
RegionDestroy(borderVisible);
368
RegionSubtract(exposed, universe, &pParent->borderClip);
370
if (HasParentRelativeBorder(pParent) && (dx || dy)) {
371
RegionSubtract(&pParent->valdata->after.borderExposed,
375
RegionSubtract(&pParent->valdata->after.borderExposed,
376
exposed, &pParent->winSize);
379
RegionCopy(&pParent->borderClip, universe);
382
* To get the right clipList for the parent, and to make doubly sure
383
* that no child overlaps the parent's border, we remove the parent's
384
* border from the universe before proceeding.
387
RegionIntersect(universe, universe, &pParent->winSize);
341
if (HasBorder(pParent)) {
344
* when the border changes shape, the old visible portions
345
* of the border will be saved by DIX in borderVisible --
346
* use that region and destroy it
348
RegionSubtract(exposed, universe, borderVisible);
349
RegionDestroy(borderVisible);
352
RegionSubtract(exposed, universe, &pParent->borderClip);
354
if (HasParentRelativeBorder(pParent) && (dx || dy)) {
355
RegionSubtract(&pParent->valdata->after.borderExposed,
356
universe, &pParent->winSize);
359
RegionSubtract(&pParent->valdata->after.borderExposed,
360
exposed, &pParent->winSize);
363
RegionCopy(&pParent->borderClip, universe);
366
* To get the right clipList for the parent, and to make doubly sure
367
* that no child overlaps the parent's border, we remove the parent's
368
* border from the universe before proceeding.
371
RegionIntersect(universe, universe, &pParent->winSize);
390
RegionCopy(&pParent->borderClip, universe);
392
if ((pChild = pParent->firstChild) && pParent->mapped)
394
RegionNull(&childUniverse);
395
RegionNull(&childUnion);
396
if ((pChild->drawable.y < pParent->lastChild->drawable.y) ||
397
((pChild->drawable.y == pParent->lastChild->drawable.y) &&
398
(pChild->drawable.x < pParent->lastChild->drawable.x)))
400
for (; pChild; pChild = pChild->nextSib)
402
if (pChild->viewable)
403
RegionAppend(&childUnion, &pChild->borderSize);
408
for (pChild = pParent->lastChild; pChild; pChild = pChild->prevSib)
410
if (pChild->viewable)
411
RegionAppend(&childUnion, &pChild->borderSize);
414
RegionValidate(&childUnion, &overlap);
416
for (pChild = pParent->firstChild;
418
pChild = pChild->nextSib)
420
if (pChild->viewable) {
422
* If the child is viewable, we want to remove its extents
423
* from the current universe, but we only re-clip it if
426
if (pChild->valdata) {
428
* Figure out the new universe from the child's
429
* perspective and recurse.
431
RegionIntersect(&childUniverse,
433
&pChild->borderSize);
434
RootlessComputeClips (pChild, pScreen, &childUniverse,
438
* Once the child has been processed, we remove its extents
439
* from the current universe, thus denying its space to any
443
RegionSubtract(universe, universe,
444
&pChild->borderSize);
448
RegionSubtract(universe, universe, &childUnion);
449
RegionUninit(&childUnion);
450
RegionUninit(&childUniverse);
451
} /* if any children */
374
RegionCopy(&pParent->borderClip, universe);
376
if ((pChild = pParent->firstChild) && pParent->mapped) {
377
RegionNull(&childUniverse);
378
RegionNull(&childUnion);
379
if ((pChild->drawable.y < pParent->lastChild->drawable.y) ||
380
((pChild->drawable.y == pParent->lastChild->drawable.y) &&
381
(pChild->drawable.x < pParent->lastChild->drawable.x))) {
382
for (; pChild; pChild = pChild->nextSib) {
383
if (pChild->viewable)
384
RegionAppend(&childUnion, &pChild->borderSize);
388
for (pChild = pParent->lastChild; pChild; pChild = pChild->prevSib) {
389
if (pChild->viewable)
390
RegionAppend(&childUnion, &pChild->borderSize);
393
RegionValidate(&childUnion, &overlap);
395
for (pChild = pParent->firstChild; pChild; pChild = pChild->nextSib) {
396
if (pChild->viewable) {
398
* If the child is viewable, we want to remove its extents
399
* from the current universe, but we only re-clip it if
402
if (pChild->valdata) {
404
* Figure out the new universe from the child's
405
* perspective and recurse.
407
RegionIntersect(&childUniverse,
408
universe, &pChild->borderSize);
409
RootlessComputeClips(pChild, pScreen, &childUniverse,
413
* Once the child has been processed, we remove its extents
414
* from the current universe, thus denying its space to any
418
RegionSubtract(universe, universe, &pChild->borderSize);
422
RegionSubtract(universe, universe, &childUnion);
423
RegionUninit(&childUnion);
424
RegionUninit(&childUniverse);
425
} /* if any children */
454
428
* 'universe' now contains the new clipList for the parent window.
457
431
* new, just as for the border.
460
if (oldVis == VisibilityFullyObscured ||
461
oldVis == VisibilityNotViewable)
463
RegionCopy(&pParent->valdata->after.exposed, universe);
434
if (oldVis == VisibilityFullyObscured || oldVis == VisibilityNotViewable) {
435
RegionCopy(&pParent->valdata->after.exposed, universe);
465
437
else if (newVis != VisibilityFullyObscured &&
466
newVis != VisibilityNotViewable)
468
RegionSubtract(&pParent->valdata->after.exposed,
469
universe, &pParent->clipList);
438
newVis != VisibilityNotViewable) {
439
RegionSubtract(&pParent->valdata->after.exposed,
440
universe, &pParent->clipList);
472
443
/* HACK ALERT - copying contents of regions, instead of regions */
476
tmp = pParent->clipList;
477
pParent->clipList = *universe;
447
tmp = pParent->clipList;
448
pParent->clipList = *universe;
485
456
pParent->drawable.serialNumber = NEXT_SERIAL_NUMBER;
487
458
if (pScreen->ClipNotify)
488
(* pScreen->ClipNotify) (pParent, dx, dy);
459
(*pScreen->ClipNotify) (pParent, dx, dy);
492
463
RootlessTreeObscured(WindowPtr pParent)
494
465
register WindowPtr pChild;
497
468
pChild = pParent;
500
if (pChild->viewable)
502
oldVis = pChild->visibility;
503
if (oldVis != (pChild->visibility = VisibilityFullyObscured) &&
504
((pChild->eventMask | wOtherEventMasks(pChild)) & VisibilityChangeMask))
505
SendVisibilityNotify(pChild);
506
if (pChild->firstChild)
508
pChild = pChild->firstChild;
512
while (!pChild->nextSib && (pChild != pParent))
513
pChild = pChild->parent;
514
if (pChild == pParent)
516
pChild = pChild->nextSib;
470
if (pChild->viewable) {
471
oldVis = pChild->visibility;
472
if (oldVis != (pChild->visibility = VisibilityFullyObscured) &&
474
eventMask | wOtherEventMasks(pChild)) & VisibilityChangeMask))
475
SendVisibilityNotify(pChild);
476
if (pChild->firstChild) {
477
pChild = pChild->firstChild;
481
while (!pChild->nextSib && (pChild != pParent))
482
pChild = pChild->parent;
483
if (pChild == pParent)
485
pChild = pChild->nextSib;
551
520
We need to make sure top-level windows don't clip each other,
552
521
and that top-level windows aren't clipped to the root window.
555
524
// fixme this is ugly
556
525
// Xprint/ValTree.c doesn't work, but maybe that method can?
558
RootlessMiValidateTree (WindowPtr pRoot, /* Parent to validate */
559
WindowPtr pChild, /* First child of pRoot that was
561
VTKind kind /* What kind of configuration caused call */)
527
RootlessMiValidateTree(WindowPtr pRoot, /* Parent to validate */
528
WindowPtr pChild, /* First child of pRoot that was
530
VTKind kind /* What kind of configuration caused call */
563
RegionRec childClip; /* The new borderClip for the current
565
RegionRec exposed; /* For intermediate calculations */
566
register ScreenPtr pScreen;
567
register WindowPtr pWin;
533
RegionRec childClip; /* The new borderClip for the current
535
RegionRec exposed; /* For intermediate calculations */
536
register ScreenPtr pScreen;
537
register WindowPtr pWin;
569
539
pScreen = pRoot->drawable.pScreen;
570
540
if (pChild == NullWindow)
571
pChild = pRoot->firstChild;
541
pChild = pRoot->firstChild;
573
543
RegionNull(&childClip);
574
544
RegionNull(&exposed);
576
if (RegionBroken(&pRoot->clipList) &&
577
!RegionBroken(&pRoot->borderClip))
546
if (RegionBroken(&pRoot->clipList) && !RegionBroken(&pRoot->borderClip)) {
579
547
// fixme this might not work, but hopefully doesn't happen anyway.
581
549
RegionEmpty(&pRoot->clipList);