aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/miext/rootless/rootlessValTree.c
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/miext/rootless/rootlessValTree.c')
-rw-r--r--xorg-server/miext/rootless/rootlessValTree.c589
1 files changed, 278 insertions, 311 deletions
diff --git a/xorg-server/miext/rootless/rootlessValTree.c b/xorg-server/miext/rootless/rootlessValTree.c
index 9aa881423..730d2917e 100644
--- a/xorg-server/miext/rootless/rootlessValTree.c
+++ b/xorg-server/miext/rootless/rootlessValTree.c
@@ -86,14 +86,14 @@ Equipment Corporation.
* Summer '89: Joel McCormack -- so fast you wouldn't believe it possible.
* In particular, much improved code for window mapping and
* circulating.
- * Bob Scheifler -- avoid miComputeClips for unmapped windows,
- * valdata changes
+ * Bob Scheifler -- avoid miComputeClips for unmapped windows,
+ * valdata changes
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
-#include <stddef.h> /* For NULL */
+#include <stddef.h> /* For NULL */
#include <X11/X.h>
#include "scrnintstr.h"
#include "validate.h"
@@ -104,65 +104,63 @@ Equipment Corporation.
#include "globals.h"
-int RootlessMiValidateTree (WindowPtr pRoot, WindowPtr pChild, VTKind kind);
+int RootlessMiValidateTree(WindowPtr pRoot, WindowPtr pChild, VTKind kind);
/*
* Compute the visibility of a shaped window
*/
static int
-RootlessShapedWindowIn (RegionPtr universe,
- RegionPtr bounding, BoxPtr rect, int x, int y)
+RootlessShapedWindowIn(RegionPtr universe,
+ RegionPtr bounding, BoxPtr rect, int x, int y)
{
- BoxRec box;
- register BoxPtr boundBox;
- int nbox;
- Bool someIn, someOut;
+ BoxRec box;
+ register BoxPtr boundBox;
+ int nbox;
+ Bool someIn, someOut;
register int t, x1, y1, x2, y2;
- nbox = RegionNumRects (bounding);
- boundBox = RegionRects (bounding);
+ nbox = RegionNumRects(bounding);
+ boundBox = RegionRects(bounding);
someIn = someOut = FALSE;
x1 = rect->x1;
y1 = rect->y1;
x2 = rect->x2;
y2 = rect->y2;
- while (nbox--)
- {
- if ((t = boundBox->x1 + x) < x1)
- t = x1;
- box.x1 = t;
- if ((t = boundBox->y1 + y) < y1)
- t = y1;
- box.y1 = t;
- if ((t = boundBox->x2 + x) > x2)
- t = x2;
- box.x2 = t;
- if ((t = boundBox->y2 + y) > y2)
- t = y2;
- box.y2 = t;
- if (box.x1 > box.x2)
- box.x2 = box.x1;
- if (box.y1 > box.y2)
- box.y2 = box.y1;
- switch (RegionContainsRect(universe, &box))
- {
- case rgnIN:
- if (someOut)
- return rgnPART;
- someIn = TRUE;
- break;
- case rgnOUT:
- if (someIn)
- return rgnPART;
- someOut = TRUE;
- break;
- default:
- return rgnPART;
- }
- boundBox++;
+ while (nbox--) {
+ if ((t = boundBox->x1 + x) < x1)
+ t = x1;
+ box.x1 = t;
+ if ((t = boundBox->y1 + y) < y1)
+ t = y1;
+ box.y1 = t;
+ if ((t = boundBox->x2 + x) > x2)
+ t = x2;
+ box.x2 = t;
+ if ((t = boundBox->y2 + y) > y2)
+ t = y2;
+ box.y2 = t;
+ if (box.x1 > box.x2)
+ box.x2 = box.x1;
+ if (box.y1 > box.y2)
+ box.y2 = box.y1;
+ switch (RegionContainsRect(universe, &box)) {
+ case rgnIN:
+ if (someOut)
+ return rgnPART;
+ someIn = TRUE;
+ break;
+ case rgnOUT:
+ if (someIn)
+ return rgnPART;
+ someOut = TRUE;
+ break;
+ default:
+ return rgnPART;
+ }
+ boundBox++;
}
if (someIn)
- return rgnIN;
+ return rgnIN;
return rgnOUT;
}
@@ -170,7 +168,6 @@ RootlessShapedWindowIn (RegionPtr universe,
HasBorder(w) && \
(w)->backgroundState == ParentRelative)
-
/*
*-----------------------------------------------------------------------
* RootlessComputeClips --
@@ -188,18 +185,18 @@ RootlessShapedWindowIn (RegionPtr universe,
*-----------------------------------------------------------------------
*/
static void
-RootlessComputeClips (WindowPtr pParent, ScreenPtr pScreen,
- RegionPtr universe, VTKind kind, RegionPtr exposed)
+RootlessComputeClips(WindowPtr pParent, ScreenPtr pScreen,
+ RegionPtr universe, VTKind kind, RegionPtr exposed)
{
- int dx,
- dy;
- RegionRec childUniverse;
- register WindowPtr pChild;
- int oldVis, newVis;
- BoxRec borderSize;
- RegionRec childUnion;
- Bool overlap;
- RegionPtr borderVisible;
+ int dx, dy;
+ RegionRec childUniverse;
+ register WindowPtr pChild;
+ int oldVis, newVis;
+ BoxRec borderSize;
+ RegionRec childUnion;
+ Bool overlap;
+ RegionPtr borderVisible;
+
/*
* Figure out the new visibility of this window.
* The extent of the universe should be the same as the extent of
@@ -210,52 +207,52 @@ RootlessComputeClips (WindowPtr pParent, ScreenPtr pScreen,
*/
borderSize.x1 = pParent->drawable.x - wBorderWidth(pParent);
borderSize.y1 = pParent->drawable.y - wBorderWidth(pParent);
- dx = (int) pParent->drawable.x + (int) pParent->drawable.width + wBorderWidth(pParent);
+ dx = (int) pParent->drawable.x + (int) pParent->drawable.width +
+ wBorderWidth(pParent);
if (dx > 32767)
- dx = 32767;
+ dx = 32767;
borderSize.x2 = dx;
- dy = (int) pParent->drawable.y + (int) pParent->drawable.height + wBorderWidth(pParent);
+ dy = (int) pParent->drawable.y + (int) pParent->drawable.height +
+ wBorderWidth(pParent);
if (dy > 32767)
- dy = 32767;
+ dy = 32767;
borderSize.y2 = dy;
oldVis = pParent->visibility;
- switch (RegionContainsRect(universe, &borderSize))
- {
+ switch (RegionContainsRect(universe, &borderSize)) {
case rgnIN:
- newVis = VisibilityUnobscured;
- break;
- case rgnPART:
- newVis = VisibilityPartiallyObscured;
- {
- RegionPtr pBounding;
-
- if ((pBounding = wBoundingShape (pParent)))
- {
- switch (RootlessShapedWindowIn (universe,
- pBounding, &borderSize,
- pParent->drawable.x,
- pParent->drawable.y))
- {
- case rgnIN:
- newVis = VisibilityUnobscured;
- break;
- case rgnOUT:
- newVis = VisibilityFullyObscured;
- break;
- }
- }
- }
- break;
- default:
- newVis = VisibilityFullyObscured;
- break;
+ newVis = VisibilityUnobscured;
+ break;
+ case rgnPART:
+ newVis = VisibilityPartiallyObscured;
+ {
+ RegionPtr pBounding;
+
+ if ((pBounding = wBoundingShape(pParent))) {
+ switch (RootlessShapedWindowIn(universe,
+ pBounding, &borderSize,
+ pParent->drawable.x,
+ pParent->drawable.y)) {
+ case rgnIN:
+ newVis = VisibilityUnobscured;
+ break;
+ case rgnOUT:
+ newVis = VisibilityFullyObscured;
+ break;
+ }
+ }
+ }
+ break;
+ default:
+ newVis = VisibilityFullyObscured;
+ break;
}
pParent->visibility = newVis;
if (oldVis != newVis &&
- ((pParent->eventMask | wOtherEventMasks(pParent)) & VisibilityChangeMask))
- SendVisibilityNotify(pParent);
+ ((pParent->
+ eventMask | wOtherEventMasks(pParent)) & VisibilityChangeMask))
+ SendVisibilityNotify(pParent);
dx = pParent->drawable.x - pParent->valdata->before.oldAbsCorner.x;
dy = pParent->drawable.y - pParent->valdata->before.oldAbsCorner.y;
@@ -268,74 +265,64 @@ RootlessComputeClips (WindowPtr pParent, ScreenPtr pScreen,
case VTMap:
case VTStack:
case VTUnmap:
- break;
+ break;
case VTMove:
- if ((oldVis == newVis) &&
- ((oldVis == VisibilityFullyObscured) ||
- (oldVis == VisibilityUnobscured)))
- {
- pChild = pParent;
- while (1)
- {
- if (pChild->viewable)
- {
- if (pChild->visibility != VisibilityFullyObscured)
- {
- RegionTranslate(&pChild->borderClip,
- dx, dy);
- RegionTranslate(&pChild->clipList,
- dx, dy);
- pChild->drawable.serialNumber = NEXT_SERIAL_NUMBER;
- if (pScreen->ClipNotify)
- (* pScreen->ClipNotify) (pChild, dx, dy);
-
- }
- if (pChild->valdata)
- {
- RegionNull(&pChild->valdata->after.borderExposed);
- if (HasParentRelativeBorder(pChild))
- {
- RegionSubtract(&pChild->valdata->after.borderExposed,
- &pChild->borderClip,
- &pChild->winSize);
- }
- RegionNull(&pChild->valdata->after.exposed);
- }
- if (pChild->firstChild)
- {
- pChild = pChild->firstChild;
- continue;
- }
- }
- while (!pChild->nextSib && (pChild != pParent))
- pChild = pChild->parent;
- if (pChild == pParent)
- break;
- pChild = pChild->nextSib;
- }
- return;
- }
- /* fall through */
+ if ((oldVis == newVis) &&
+ ((oldVis == VisibilityFullyObscured) ||
+ (oldVis == VisibilityUnobscured))) {
+ pChild = pParent;
+ while (1) {
+ if (pChild->viewable) {
+ if (pChild->visibility != VisibilityFullyObscured) {
+ RegionTranslate(&pChild->borderClip, dx, dy);
+ RegionTranslate(&pChild->clipList, dx, dy);
+ pChild->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+ if (pScreen->ClipNotify)
+ (*pScreen->ClipNotify) (pChild, dx, dy);
+
+ }
+ if (pChild->valdata) {
+ RegionNull(&pChild->valdata->after.borderExposed);
+ if (HasParentRelativeBorder(pChild)) {
+ RegionSubtract(&pChild->valdata->after.
+ borderExposed, &pChild->borderClip,
+ &pChild->winSize);
+ }
+ RegionNull(&pChild->valdata->after.exposed);
+ }
+ if (pChild->firstChild) {
+ pChild = pChild->firstChild;
+ continue;
+ }
+ }
+ while (!pChild->nextSib && (pChild != pParent))
+ pChild = pChild->parent;
+ if (pChild == pParent)
+ break;
+ pChild = pChild->nextSib;
+ }
+ return;
+ }
+ /* fall through */
default:
- /*
- * To calculate exposures correctly, we have to translate the old
- * borderClip and clipList regions to the window's new location so there
- * is a correspondence between pieces of the new and old clipping regions.
- */
- if (dx || dy)
- {
- /*
- * We translate the old clipList because that will be exposed or copied
- * if gravity is right.
- */
- RegionTranslate(&pParent->borderClip, dx, dy);
- RegionTranslate(&pParent->clipList, dx, dy);
- }
- break;
+ /*
+ * To calculate exposures correctly, we have to translate the old
+ * borderClip and clipList regions to the window's new location so there
+ * is a correspondence between pieces of the new and old clipping regions.
+ */
+ if (dx || dy) {
+ /*
+ * We translate the old clipList because that will be exposed or copied
+ * if gravity is right.
+ */
+ RegionTranslate(&pParent->borderClip, dx, dy);
+ RegionTranslate(&pParent->clipList, dx, dy);
+ }
+ break;
case VTBroken:
- RegionEmpty(&pParent->borderClip);
- RegionEmpty(&pParent->clipList);
- break;
+ RegionEmpty(&pParent->borderClip);
+ RegionEmpty(&pParent->clipList);
+ break;
}
borderVisible = pParent->valdata->before.borderVisible;
@@ -351,104 +338,91 @@ RootlessComputeClips (WindowPtr pParent, ScreenPtr pScreen,
* This leaves a region of pieces that weren't exposed before.
*/
- if (HasBorder (pParent))
- {
- if (borderVisible)
- {
- /*
- * when the border changes shape, the old visible portions
- * of the border will be saved by DIX in borderVisible --
- * use that region and destroy it
- */
- RegionSubtract(exposed, universe, borderVisible);
- RegionDestroy(borderVisible);
- }
- else
- {
- RegionSubtract(exposed, universe, &pParent->borderClip);
- }
- if (HasParentRelativeBorder(pParent) && (dx || dy)) {
- RegionSubtract(&pParent->valdata->after.borderExposed,
- universe,
- &pParent->winSize);
- } else {
- RegionSubtract(&pParent->valdata->after.borderExposed,
- exposed, &pParent->winSize);
- }
-
- RegionCopy(&pParent->borderClip, universe);
-
- /*
- * To get the right clipList for the parent, and to make doubly sure
- * that no child overlaps the parent's border, we remove the parent's
- * border from the universe before proceeding.
- */
-
- RegionIntersect(universe, universe, &pParent->winSize);
+ if (HasBorder(pParent)) {
+ if (borderVisible) {
+ /*
+ * when the border changes shape, the old visible portions
+ * of the border will be saved by DIX in borderVisible --
+ * use that region and destroy it
+ */
+ RegionSubtract(exposed, universe, borderVisible);
+ RegionDestroy(borderVisible);
+ }
+ else {
+ RegionSubtract(exposed, universe, &pParent->borderClip);
+ }
+ if (HasParentRelativeBorder(pParent) && (dx || dy)) {
+ RegionSubtract(&pParent->valdata->after.borderExposed,
+ universe, &pParent->winSize);
+ }
+ else {
+ RegionSubtract(&pParent->valdata->after.borderExposed,
+ exposed, &pParent->winSize);
+ }
+
+ RegionCopy(&pParent->borderClip, universe);
+
+ /*
+ * To get the right clipList for the parent, and to make doubly sure
+ * that no child overlaps the parent's border, we remove the parent's
+ * border from the universe before proceeding.
+ */
+
+ RegionIntersect(universe, universe, &pParent->winSize);
}
else
- RegionCopy(&pParent->borderClip, universe);
-
- if ((pChild = pParent->firstChild) && pParent->mapped)
- {
- RegionNull(&childUniverse);
- RegionNull(&childUnion);
- if ((pChild->drawable.y < pParent->lastChild->drawable.y) ||
- ((pChild->drawable.y == pParent->lastChild->drawable.y) &&
- (pChild->drawable.x < pParent->lastChild->drawable.x)))
- {
- for (; pChild; pChild = pChild->nextSib)
- {
- if (pChild->viewable)
- RegionAppend(&childUnion, &pChild->borderSize);
- }
- }
- else
- {
- for (pChild = pParent->lastChild; pChild; pChild = pChild->prevSib)
- {
- if (pChild->viewable)
- RegionAppend(&childUnion, &pChild->borderSize);
- }
- }
- RegionValidate(&childUnion, &overlap);
-
- for (pChild = pParent->firstChild;
- pChild;
- pChild = pChild->nextSib)
- {
- if (pChild->viewable) {
- /*
- * If the child is viewable, we want to remove its extents
- * from the current universe, but we only re-clip it if
- * it's been marked.
- */
- if (pChild->valdata) {
- /*
- * Figure out the new universe from the child's
- * perspective and recurse.
- */
- RegionIntersect(&childUniverse,
- universe,
- &pChild->borderSize);
- RootlessComputeClips (pChild, pScreen, &childUniverse,
- kind, exposed);
- }
- /*
- * Once the child has been processed, we remove its extents
- * from the current universe, thus denying its space to any
- * other sibling.
- */
- if (overlap)
- RegionSubtract(universe, universe,
- &pChild->borderSize);
- }
- }
- if (!overlap)
- RegionSubtract(universe, universe, &childUnion);
- RegionUninit(&childUnion);
- RegionUninit(&childUniverse);
- } /* if any children */
+ RegionCopy(&pParent->borderClip, universe);
+
+ if ((pChild = pParent->firstChild) && pParent->mapped) {
+ RegionNull(&childUniverse);
+ RegionNull(&childUnion);
+ if ((pChild->drawable.y < pParent->lastChild->drawable.y) ||
+ ((pChild->drawable.y == pParent->lastChild->drawable.y) &&
+ (pChild->drawable.x < pParent->lastChild->drawable.x))) {
+ for (; pChild; pChild = pChild->nextSib) {
+ if (pChild->viewable)
+ RegionAppend(&childUnion, &pChild->borderSize);
+ }
+ }
+ else {
+ for (pChild = pParent->lastChild; pChild; pChild = pChild->prevSib) {
+ if (pChild->viewable)
+ RegionAppend(&childUnion, &pChild->borderSize);
+ }
+ }
+ RegionValidate(&childUnion, &overlap);
+
+ for (pChild = pParent->firstChild; pChild; pChild = pChild->nextSib) {
+ if (pChild->viewable) {
+ /*
+ * If the child is viewable, we want to remove its extents
+ * from the current universe, but we only re-clip it if
+ * it's been marked.
+ */
+ if (pChild->valdata) {
+ /*
+ * Figure out the new universe from the child's
+ * perspective and recurse.
+ */
+ RegionIntersect(&childUniverse,
+ universe, &pChild->borderSize);
+ RootlessComputeClips(pChild, pScreen, &childUniverse,
+ kind, exposed);
+ }
+ /*
+ * Once the child has been processed, we remove its extents
+ * from the current universe, thus denying its space to any
+ * other sibling.
+ */
+ if (overlap)
+ RegionSubtract(universe, universe, &pChild->borderSize);
+ }
+ }
+ if (!overlap)
+ RegionSubtract(universe, universe, &childUnion);
+ RegionUninit(&childUnion);
+ RegionUninit(&childUniverse);
+ } /* if any children */
/*
* 'universe' now contains the new clipList for the parent window.
@@ -457,25 +431,22 @@ RootlessComputeClips (WindowPtr pParent, ScreenPtr pScreen,
* new, just as for the border.
*/
- if (oldVis == VisibilityFullyObscured ||
- oldVis == VisibilityNotViewable)
- {
- RegionCopy(&pParent->valdata->after.exposed, universe);
+ if (oldVis == VisibilityFullyObscured || oldVis == VisibilityNotViewable) {
+ RegionCopy(&pParent->valdata->after.exposed, universe);
}
else if (newVis != VisibilityFullyObscured &&
- newVis != VisibilityNotViewable)
- {
- RegionSubtract(&pParent->valdata->after.exposed,
- universe, &pParent->clipList);
+ newVis != VisibilityNotViewable) {
+ RegionSubtract(&pParent->valdata->after.exposed,
+ universe, &pParent->clipList);
}
/* HACK ALERT - copying contents of regions, instead of regions */
{
- RegionRec tmp;
+ RegionRec tmp;
- tmp = pParent->clipList;
- pParent->clipList = *universe;
- *universe = tmp;
+ tmp = pParent->clipList;
+ pParent->clipList = *universe;
+ *universe = tmp;
}
#ifdef NOTDEF
@@ -485,35 +456,33 @@ RootlessComputeClips (WindowPtr pParent, ScreenPtr pScreen,
pParent->drawable.serialNumber = NEXT_SERIAL_NUMBER;
if (pScreen->ClipNotify)
- (* pScreen->ClipNotify) (pParent, dx, dy);
+ (*pScreen->ClipNotify) (pParent, dx, dy);
}
static void
RootlessTreeObscured(WindowPtr pParent)
{
register WindowPtr pChild;
- register int oldVis;
+ register int oldVis;
pChild = pParent;
- while (1)
- {
- if (pChild->viewable)
- {
- oldVis = pChild->visibility;
- if (oldVis != (pChild->visibility = VisibilityFullyObscured) &&
- ((pChild->eventMask | wOtherEventMasks(pChild)) & VisibilityChangeMask))
- SendVisibilityNotify(pChild);
- if (pChild->firstChild)
- {
- pChild = pChild->firstChild;
- continue;
- }
- }
- while (!pChild->nextSib && (pChild != pParent))
- pChild = pChild->parent;
- if (pChild == pParent)
- break;
- pChild = pChild->nextSib;
+ while (1) {
+ if (pChild->viewable) {
+ oldVis = pChild->visibility;
+ if (oldVis != (pChild->visibility = VisibilityFullyObscured) &&
+ ((pChild->
+ eventMask | wOtherEventMasks(pChild)) & VisibilityChangeMask))
+ SendVisibilityNotify(pChild);
+ if (pChild->firstChild) {
+ pChild = pChild->firstChild;
+ continue;
+ }
+ }
+ while (!pChild->nextSib && (pChild != pParent))
+ pChild = pChild->parent;
+ if (pChild == pParent)
+ break;
+ pChild = pChild->nextSib;
}
}
@@ -551,31 +520,30 @@ RootlessTreeObscured(WindowPtr pParent)
We need to make sure top-level windows don't clip each other,
and that top-level windows aren't clipped to the root window.
*/
-/*ARGSUSED*/
+ /*ARGSUSED*/
// fixme this is ugly
// Xprint/ValTree.c doesn't work, but maybe that method can?
-int
-RootlessMiValidateTree (WindowPtr pRoot, /* Parent to validate */
- WindowPtr pChild, /* First child of pRoot that was
- * affected */
- VTKind kind /* What kind of configuration caused call */)
+ int
+RootlessMiValidateTree(WindowPtr pRoot, /* Parent to validate */
+ WindowPtr pChild, /* First child of pRoot that was
+ * affected */
+ VTKind kind /* What kind of configuration caused call */
+ )
{
- RegionRec childClip; /* The new borderClip for the current
- * child */
- RegionRec exposed; /* For intermediate calculations */
- register ScreenPtr pScreen;
- register WindowPtr pWin;
+ RegionRec childClip; /* The new borderClip for the current
+ * child */
+ RegionRec exposed; /* For intermediate calculations */
+ register ScreenPtr pScreen;
+ register WindowPtr pWin;
pScreen = pRoot->drawable.pScreen;
if (pChild == NullWindow)
- pChild = pRoot->firstChild;
+ pChild = pRoot->firstChild;
RegionNull(&childClip);
RegionNull(&exposed);
- if (RegionBroken(&pRoot->clipList) &&
- !RegionBroken(&pRoot->borderClip))
- {
+ if (RegionBroken(&pRoot->clipList) && !RegionBroken(&pRoot->borderClip)) {
// fixme this might not work, but hopefully doesn't happen anyway.
kind = VTBroken;
RegionEmpty(&pRoot->clipList);
@@ -588,22 +556,21 @@ RootlessMiValidateTree (WindowPtr pRoot, /* Parent to validate */
* childClip is always reset to that child's size.
*/
- for (pWin = pChild;
- pWin != NullWindow;
- pWin = pWin->nextSib)
- {
+ for (pWin = pChild; pWin != NullWindow; pWin = pWin->nextSib) {
if (pWin->viewable) {
if (pWin->valdata) {
RegionCopy(&childClip, &pWin->borderSize);
- RootlessComputeClips (pWin, pScreen, &childClip, kind, &exposed);
- } else if (pWin->visibility == VisibilityNotViewable) {
+ RootlessComputeClips(pWin, pScreen, &childClip, kind, &exposed);
+ }
+ else if (pWin->visibility == VisibilityNotViewable) {
RootlessTreeObscured(pWin);
}
- } else {
+ }
+ else {
if (pWin->valdata) {
RegionEmpty(&pWin->clipList);
if (pScreen->ClipNotify)
- (* pScreen->ClipNotify) (pWin, 0, 0);
+ (*pScreen->ClipNotify) (pWin, 0, 0);
RegionEmpty(&pWin->borderClip);
pWin->valdata = NULL;
}