renamed the tree parsing/child iteration functions, I think it is much clearer now what they do, more likely to find bugs too

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13572 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2005-07-10 17:16:31 +00:00
parent a98b74b72e
commit 642467d077
4 changed files with 160 additions and 154 deletions
+102 -110
View File
@@ -69,11 +69,13 @@ Layer::Layer(BRect frame, const char* name, int32 token,
// Layer does not start out as a part of the tree // Layer does not start out as a part of the tree
fOwner(NULL), fOwner(NULL),
fParent(NULL), fParent(NULL),
fUpperSibling(NULL), fPreviousSibling(NULL),
fLowerSibling(NULL), fNextSibling(NULL),
fTopChild(NULL), fFirstChild(NULL),
fBottomChild(NULL), fLastChild(NULL),
fCurrent(NULL), fCurrent(NULL),
// all regions (fVisible, fFullVisible, fFull) start empty // all regions (fVisible, fFullVisible, fFull) start empty
@@ -169,15 +171,15 @@ Layer::AddChild(Layer* layer, ServerWindow* serverWin)
// 1) attach layer to the tree structure // 1) attach layer to the tree structure
layer->fParent = this; layer->fParent = this;
// if we have children already, bump the current front child back one and // if we have children already, bump the current last child back one and
// make the new child the frontmost layer // make the new child the last layer
if (fBottomChild) { if (fLastChild) {
layer->fUpperSibling = fBottomChild; layer->fPreviousSibling = fLastChild;
fBottomChild->fLowerSibling = layer; fLastChild->fNextSibling = layer;
} else { } else {
fTopChild = layer; fFirstChild = layer;
} }
fBottomChild = layer; fLastChild = layer;
// if we have no RootLayer yet, then there is no need to set any parameters -- // if we have no RootLayer yet, then there is no need to set any parameters --
// they will be set when the RootLayer for this tree will be added // they will be set when the RootLayer for this tree will be added
@@ -208,27 +210,27 @@ Layer::AddChild(Layer* layer, ServerWindow* serverWin)
c->RebuildFullRegion(); c->RebuildFullRegion();
#endif #endif
// tree parsing algorithm // tree parsing algorithm
if (c->fTopChild) { if (c->fFirstChild) {
// go deep // go deep
c = c->fTopChild; c = c->fFirstChild;
} else { } else {
// go right or up // go right or up
if (c == stop) // our trip is over if (c == stop) // our trip is over
break; break;
if (c->fLowerSibling) { if (c->fNextSibling) {
// go right // go right
c = c->fLowerSibling; c = c->fNextSibling;
} else { } else {
// go up // go up
while (!c->fParent->fLowerSibling && c->fParent != stop) while (!c->fParent->fNextSibling && c->fParent != stop)
c = c->fParent; c = c->fParent;
if (c->fParent == stop) // that's enough! if (c->fParent == stop) // that's enough!
break; break;
c = c->fParent->fLowerSibling; c = c->fParent->fNextSibling;
} }
} }
} }
@@ -249,7 +251,7 @@ Layer::RemoveChild(Layer *layer)
STRACE(("Layer(%s)::RemoveChild(%s) START\n", Name(), layer->Name())); STRACE(("Layer(%s)::RemoveChild(%s) START\n", Name(), layer->Name()));
if (!layer->fParent) { if (!layer->fParent) {
printf("ERROR: RemoveChild(): Layer doesn't have a fParent\n"); printf("ERROR: RemoveChild(): Layer doesn't have a parent\n");
return; return;
} }
@@ -263,21 +265,21 @@ Layer::RemoveChild(Layer *layer)
// Take care of fParent // Take care of fParent
layer->fParent = NULL; layer->fParent = NULL;
if (fTopChild == layer) if (fFirstChild == layer)
fTopChild = layer->fLowerSibling; fFirstChild = layer->fNextSibling;
if (fBottomChild == layer) if (fLastChild == layer)
fBottomChild = layer->fUpperSibling; fLastChild = layer->fPreviousSibling;
// Take care of siblings // Take care of siblings
if (layer->fUpperSibling != NULL) if (layer->fPreviousSibling != NULL)
layer->fUpperSibling->fLowerSibling = layer->fLowerSibling; layer->fPreviousSibling->fNextSibling = layer->fNextSibling;
if (layer->fLowerSibling != NULL) if (layer->fNextSibling != NULL)
layer->fLowerSibling->fUpperSibling = layer->fUpperSibling; layer->fNextSibling->fPreviousSibling = layer->fPreviousSibling;
layer->fUpperSibling = NULL; layer->fPreviousSibling = NULL;
layer->fLowerSibling = NULL; layer->fNextSibling = NULL;
#ifdef NEW_CLIPPING #ifdef NEW_CLIPPING
layer->clear_visible_regions(); layer->clear_visible_regions();
@@ -307,26 +309,26 @@ Layer::RemoveChild(Layer *layer)
} }
// tree parsing algorithm // tree parsing algorithm
if (c->fTopChild) { if (c->fFirstChild) {
// go deep // go deep
c = c->fTopChild; c = c->fFirstChild;
} else { } else {
// go right or up // go right or up
if (c == stop) // out trip is over if (c == stop) // out trip is over
break; break;
if (c->fLowerSibling) { if (c->fNextSibling) {
// go right // go right
c = c->fLowerSibling; c = c->fNextSibling;
} else { } else {
// go up // go up
while(!c->fParent->fLowerSibling && c->fParent != stop) while(!c->fParent->fNextSibling && c->fParent != stop)
c = c->fParent; c = c->fParent;
if (c->fParent == stop) // that enough! if (c->fParent == stop) // that enough!
break; break;
c = c->fParent->fLowerSibling; c = c->fParent->fNextSibling;
} }
} }
} }
@@ -339,21 +341,20 @@ Layer::RemoveSelf()
{ {
// A Layer removes itself from the tree (duh) // A Layer removes itself from the tree (duh)
if (fParent == NULL) { if (fParent == NULL) {
printf("ERROR: RemoveSelf(): Layer doesn't have a fParent\n"); printf("ERROR: RemoveSelf(): Layer doesn't have a parent\n");
return; return;
} }
fParent->RemoveChild(this); fParent->RemoveChild(this);
} }
/*! /*!
\brief Determins if the calling layer has the passed layer as a child \return true if the child is owned by this Layer, false if not
\return true if the child is owned by the caller, false if not
*/ */
bool bool
Layer::HasChild(Layer* layer) Layer::HasChild(Layer* layer)
{ {
for (Layer *lay = TopChild(); lay; lay = LowerSibling()) { for (Layer* child = FirstChild(); child; child = NextChild()) {
if (lay == layer) if (child == layer)
return true; return true;
} }
return false; return false;
@@ -361,12 +362,12 @@ Layer::HasChild(Layer* layer)
//! Returns the number of children //! Returns the number of children
uint32 uint32
Layer::CountChildren(void) const Layer::CountChildren() const
{ {
uint32 count = 0; uint32 count = 0;
Layer *lay = TopChild(); Layer* child = FirstChild();
while (lay != NULL) { while (child != NULL) {
lay = LowerSibling(); child = NextChild();
count++; count++;
} }
return count; return count;
@@ -380,25 +381,20 @@ Layer::CountChildren(void) const
Layer* Layer*
Layer::FindLayer(const int32 token) Layer::FindLayer(const int32 token)
{ {
// recursive search for a layer based on its view token // (recursive) search for a layer based on its view token
Layer* lay;
Layer* trylay;
// Search child layers first // iterate only over direct child layers first
for (lay = TopChild(); lay; lay = LowerSibling()) { for (Layer* child = FirstChild(); child; child = NextChild()) {
if (lay->fViewToken == token) if (child->fViewToken == token)
return lay; return child;
} }
// Hmmm... not in this layer's children. Try lower descendants // try a recursive search
for (lay = TopChild(); lay != NULL; lay = LowerSibling()) { for (Layer* child = FirstChild(); child; child = NextChild()) {
trylay = lay->FindLayer(token); if (Layer* layer = child->FindLayer(token))
if (trylay) return layer;
return trylay;
} }
// Well, we got this far in the function,
// so apparently there is no match to be found
return NULL; return NULL;
} }
@@ -415,11 +411,9 @@ Layer::LayerAt(const BPoint &pt)
return this; return this;
if (fFullVisible.Contains(pt)) { if (fFullVisible.Contains(pt)) {
Layer *lay = NULL; for (Layer* child = LastChild(); child; child = PreviousChild()) {
for (Layer* child = BottomChild(); child; child = UpperSibling()) { if (Layer* layer = child->LayerAt(pt))
lay = child->LayerAt(pt); return layer;
if (lay)
return lay;
} }
} }
#else #else
@@ -427,46 +421,44 @@ Layer::LayerAt(const BPoint &pt)
return this; return this;
if (fFullVisible2.Contains(pt)) { if (fFullVisible2.Contains(pt)) {
Layer *lay = NULL; for (Layer* child = LastChild(); child; child = PreviousChild()) {
for (Layer* child = BottomChild(); child; child = UpperSibling()) { if (Layer* layer = child->LayerAt(pt))
lay = child->LayerAt(pt); return layer;
if (lay)
return lay;
} }
} }
#endif #endif
return NULL; return NULL;
} }
// TopChild // FirstChild
Layer* Layer*
Layer::TopChild() const Layer::FirstChild() const
{ {
fCurrent = fTopChild; fCurrent = fFirstChild;
return fCurrent; return fCurrent;
} }
// LowerSibling // NextChild
Layer* Layer*
Layer::LowerSibling() const Layer::NextChild() const
{ {
fCurrent = fCurrent->fLowerSibling; fCurrent = fCurrent->fNextSibling;
return fCurrent; return fCurrent;
} }
// UpperSibling // PreviousChild
Layer* Layer*
Layer::UpperSibling() const Layer::PreviousChild() const
{ {
fCurrent = fCurrent->fUpperSibling; fCurrent = fCurrent->fPreviousSibling;
return fCurrent; return fCurrent;
} }
// BottomChild // LastChild
Layer* Layer*
Layer::BottomChild() const Layer::LastChild() const
{ {
fCurrent = fBottomChild; fCurrent = fLastChild;
return fCurrent; return fCurrent;
} }
@@ -526,7 +518,7 @@ Layer::StartRebuildRegions( const BRegion& reg, Layer *target, uint32 action, BP
fVisible = fFullVisible; fVisible = fFullVisible;
// Rebuild regions for children... // Rebuild regions for children...
for (Layer *lay = BottomChild(); lay; lay = UpperSibling()) { for (Layer *lay = LastChild(); lay; lay = PreviousChild()) {
if (lay == target) if (lay == target)
lay->RebuildRegions(reg, action, pt, BPoint(0.0f, 0.0f)); lay->RebuildRegions(reg, action, pt, BPoint(0.0f, 0.0f));
else else
@@ -732,7 +724,7 @@ Layer::RebuildRegions( const BRegion& reg, uint32 action, BPoint pt, BPoint ptOf
} }
// Rebuild regions for children... // Rebuild regions for children...
for(Layer *lay = BottomChild(); lay != NULL; lay = UpperSibling()) for(Layer *lay = LastChild(); lay != NULL; lay = PreviousChild())
lay->RebuildRegions(reg, newAction, newPt, newOffset); lay->RebuildRegions(reg, newAction, newPt, newOffset);
#ifdef DEBUG_LAYER_REBUILD #ifdef DEBUG_LAYER_REBUILD
@@ -1341,15 +1333,15 @@ Layer::PruneTree(void)
Layer* lay; Layer* lay;
Layer* nextlay; Layer* nextlay;
lay = fTopChild; lay = fFirstChild;
fTopChild = NULL; fFirstChild = NULL;
while (lay != NULL) { while (lay != NULL) {
if (lay->fTopChild != NULL) if (lay->fFirstChild != NULL)
lay->PruneTree(); lay->PruneTree();
nextlay = lay->fLowerSibling; nextlay = lay->fNextSibling;
lay->fLowerSibling = NULL; lay->fNextSibling = NULL;
delete lay; delete lay;
lay = nextlay; lay = nextlay;
@@ -1365,12 +1357,12 @@ Layer::PrintToStream()
printf("\t Parent: %s", fParent ? fParent->Name() : "<no parent>"); printf("\t Parent: %s", fParent ? fParent->Name() : "<no parent>");
printf("\t us: %s\t ls: %s\n", printf("\t us: %s\t ls: %s\n",
fUpperSibling ? fUpperSibling->Name() : "<none>", fPreviousSibling ? fPreviousSibling->Name() : "<none>",
fLowerSibling ? fLowerSibling->Name() : "<none>"); fNextSibling ? fNextSibling->Name() : "<none>");
printf("\t topChild: %s\t bottomChild: %s\n", printf("\t topChild: %s\t bottomChild: %s\n",
fTopChild ? fTopChild->Name() : "<none>", fFirstChild ? fFirstChild->Name() : "<none>",
fBottomChild ? fBottomChild->Name() : "<none>"); fLastChild ? fLastChild->Name() : "<none>");
printf("Frame: (%f, %f, %f, %f)\n", fFrame.left, fFrame.top, fFrame.right, fFrame.bottom); printf("Frame: (%f, %f, %f, %f)\n", fFrame.left, fFrame.top, fFrame.right, fFrame.bottom);
printf("LocalOrigin: (%f, %f)\n", BoundsOrigin().x, BoundsOrigin().y); printf("LocalOrigin: (%f, %f)\n", BoundsOrigin().x, BoundsOrigin().y);
@@ -1396,23 +1388,23 @@ Layer::PrintNode()
else else
printf("Parent: NULL\n"); printf("Parent: NULL\n");
if (fUpperSibling) if (fPreviousSibling)
printf("Upper sibling: %s (%p)\n", fUpperSibling->Name(), fUpperSibling); printf("Upper sibling: %s (%p)\n", fPreviousSibling->Name(), fPreviousSibling);
else else
printf("Upper sibling: NULL\n"); printf("Upper sibling: NULL\n");
if (fLowerSibling) if (fNextSibling)
printf("Lower sibling: %s (%p)\n", fLowerSibling->Name(), fLowerSibling); printf("Lower sibling: %s (%p)\n", fNextSibling->Name(), fNextSibling);
else else
printf("Lower sibling: NULL\n"); printf("Lower sibling: NULL\n");
if (fTopChild) if (fFirstChild)
printf("Top child: %s (%p)\n", fTopChild->Name(), fTopChild); printf("Top child: %s (%p)\n", fFirstChild->Name(), fFirstChild);
else else
printf("Top child: NULL\n"); printf("Top child: NULL\n");
if (fBottomChild) if (fLastChild)
printf("Bottom child: %s (%p)\n", fBottomChild->Name(), fBottomChild); printf("Bottom child: %s (%p)\n", fLastChild->Name(), fLastChild);
else else
printf("Bottom child: NULL\n"); printf("Bottom child: NULL\n");
#ifndef NEW_CLIPPING #ifndef NEW_CLIPPING
@@ -1426,7 +1418,7 @@ Layer::PrintTree()
{ {
printf("\n Tree structure:\n"); printf("\n Tree structure:\n");
printf("\t%s\t%s\n", Name(), IsHidden()? "Hidden": "NOT hidden"); printf("\t%s\t%s\n", Name(), IsHidden()? "Hidden": "NOT hidden");
for(Layer *lay = BottomChild(); lay != NULL; lay = UpperSibling()) for(Layer *lay = LastChild(); lay != NULL; lay = PreviousChild())
printf("\t%s\t%s\n", lay->Name(), lay->IsHidden()? "Hidden": "NOT hidden"); printf("\t%s\t%s\n", lay->Name(), lay->IsHidden()? "Hidden": "NOT hidden");
} }
@@ -1484,7 +1476,7 @@ if (fOwner->cnt != 1)
} }
} }
for (Layer *lay = BottomChild(); lay != NULL; lay = UpperSibling()) { for (Layer *lay = LastChild(); lay != NULL; lay = PreviousChild()) {
if (lay == startFrom) if (lay == startFrom)
redraw = true; redraw = true;
@@ -1531,7 +1523,7 @@ if (fOwner->cnt != 1)
} }
} }
for (Layer *lay = BottomChild(); lay != NULL; lay = UpperSibling()) { for (Layer *lay = LastChild(); lay != NULL; lay = PreviousChild()) {
if (lay == startFrom) if (lay == startFrom)
redraw = true; redraw = true;
@@ -2084,7 +2076,7 @@ Layer::do_Invalidate(const BRegion &invalid, const Layer *startFrom)
BRegion localVisible(fFullVisible2); BRegion localVisible(fFullVisible2);
localVisible.IntersectWith(&invalid); localVisible.IntersectWith(&invalid);
rebuild_visible_regions(invalid, localVisible, rebuild_visible_regions(invalid, localVisible,
startFrom? startFrom: BottomChild()); startFrom? startFrom: LastChild());
// add localVisible to our RootLayer's redraw region. // add localVisible to our RootLayer's redraw region.
// GetRootLayer()->fRedrawReg.Include(&localVisible); // GetRootLayer()->fRedrawReg.Include(&localVisible);
@@ -2152,7 +2144,7 @@ Layer::resize_layer_frame_by(float x, float y)
// call hook function // call hook function
ResizedByHook(dx, dy, true); // automatic ResizedByHook(dx, dy, true); // automatic
for (Layer *lay = BottomChild(); lay; lay = UpperSibling()) for (Layer *lay = LastChild(); lay; lay = PreviousChild())
lay->resize_layer_frame_by(dx, dy); lay->resize_layer_frame_by(dx, dy);
} }
else else
@@ -2166,7 +2158,7 @@ Layer::rezize_layer_redraw_more(BRegion &reg, float dx, float dy)
if (dx == 0 && dy == 0) if (dx == 0 && dy == 0)
return; return;
for (Layer *lay = BottomChild(); lay; lay = UpperSibling()) { for (Layer *lay = LastChild(); lay; lay = PreviousChild()) {
uint16 rm = lay->fResizeMode & 0x0000FFFF; uint16 rm = lay->fResizeMode & 0x0000FFFF;
if ((rm & 0x0F0F) == (uint16)B_FOLLOW_LEFT_RIGHT || (rm & 0xF0F0) == (uint16)B_FOLLOW_TOP_BOTTOM) { if ((rm & 0x0F0F) == (uint16)B_FOLLOW_LEFT_RIGHT || (rm & 0xF0F0) == (uint16)B_FOLLOW_TOP_BOTTOM) {
@@ -2217,7 +2209,7 @@ Layer::resize_layer_full_update_on_resize(BRegion &reg, float dx, float dy)
if (dx == 0 && dy == 0) if (dx == 0 && dy == 0)
return; return;
for (Layer *lay = BottomChild(); lay; lay = UpperSibling()) { for (Layer *lay = LastChild(); lay; lay = PreviousChild()) {
uint16 rm = lay->fResizeMode & 0x0000FFFF; uint16 rm = lay->fResizeMode & 0x0000FFFF;
if ((rm & 0x0F0F) == (uint16)B_FOLLOW_LEFT_RIGHT || (rm & 0xF0F0) == (uint16)B_FOLLOW_TOP_BOTTOM) { if ((rm & 0x0F0F) == (uint16)B_FOLLOW_LEFT_RIGHT || (rm & 0xF0F0) == (uint16)B_FOLLOW_TOP_BOTTOM) {
@@ -2237,7 +2229,7 @@ Layer::do_ResizeBy(float dx, float dy)
fFrame.Set(fFrame.left, fFrame.top, fFrame.right+dx, fFrame.bottom+dy); fFrame.Set(fFrame.left, fFrame.top, fFrame.right+dx, fFrame.bottom+dy);
// resize children using their resize_mask. // resize children using their resize_mask.
for (Layer *lay = BottomChild(); lay; lay = UpperSibling()) for (Layer *lay = LastChild(); lay; lay = PreviousChild())
lay->resize_layer_frame_by(dx, dy); lay->resize_layer_frame_by(dx, dy);
// call hook function // call hook function
@@ -2359,7 +2351,7 @@ Layer::do_ScrollBy(float dx, float dy)
clear_visible_regions(); clear_visible_regions();
rebuild_visible_regions(invalid, invalid, BottomChild()); rebuild_visible_regions(invalid, invalid, LastChild());
// for the moment we say that the whole surface needs to be redraw. // for the moment we say that the whole surface needs to be redraw.
BRegion redrawReg(fFullVisible2); BRegion redrawReg(fFullVisible2);
@@ -2465,12 +2457,12 @@ Layer::rebuild_visible_regions(const BRegion &invalid,
BRegion unalteredVisible(common); BRegion unalteredVisible(common);
bool altered = alter_visible_for_children(common); bool altered = alter_visible_for_children(common);
for (Layer *lay = BottomChild(); lay; lay = UpperSibling()) { for (Layer *lay = LastChild(); lay; lay = PreviousChild()) {
if (lay == startFrom) if (lay == startFrom)
fullRebuild = true; fullRebuild = true;
if (fullRebuild) if (fullRebuild)
lay->rebuild_visible_regions(invalid, common, lay->BottomChild()); lay->rebuild_visible_regions(invalid, common, lay->LastChild());
// to let children know much they can take from parent's visible region // to let children know much they can take from parent's visible region
common.Exclude(&lay->fFullVisible2); common.Exclude(&lay->fFullVisible2);
@@ -2504,7 +2496,7 @@ Layer::clear_visible_regions()
fVisible2.MakeEmpty(); fVisible2.MakeEmpty();
fFullVisible2.MakeEmpty(); fFullVisible2.MakeEmpty();
for (Layer *child = BottomChild(); child; child = UpperSibling()) for (Layer *child = LastChild(); child; child = PreviousChild())
child->clear_visible_regions(); child->clear_visible_regions();
} }
+11 -11
View File
@@ -86,6 +86,8 @@ class Layer {
void RemoveSelf(); void RemoveSelf();
bool HasChild(Layer* layer); bool HasChild(Layer* layer);
void SetRootLayer(RootLayer* rl)
{ fRootLayer = rl; }
RootLayer* GetRootLayer() const RootLayer* GetRootLayer() const
{ return fRootLayer; } { return fRootLayer; }
@@ -93,10 +95,10 @@ class Layer {
Layer* FindLayer(const int32 token); Layer* FindLayer(const int32 token);
Layer* LayerAt(const BPoint &pt); Layer* LayerAt(const BPoint &pt);
virtual Layer* TopChild() const; virtual Layer* FirstChild() const;
virtual Layer* LowerSibling() const; virtual Layer* NextChild() const;
virtual Layer* UpperSibling() const; virtual Layer* PreviousChild() const;
virtual Layer* BottomChild() const; virtual Layer* LastChild() const;
virtual void SetName(const char* name); virtual void SetName(const char* name);
inline const char* Name() const inline const char* Name() const
@@ -196,9 +198,6 @@ class Layer {
void PrintTree(); void PrintTree();
// server "private" - should not be used // server "private" - should not be used
void SetRootLayer(RootLayer* rl)
{ fRootLayer = rl; }
void SetAsTopLayer(bool option) void SetAsTopLayer(bool option)
{ fIsTopLayer = option; } { fIsTopLayer = option; }
@@ -305,11 +304,12 @@ friend class OffscreenWinBorder;
// value.) // value.)
// BPoint fBoundsLeftTop; // BPoint fBoundsLeftTop;
WinBorder* fOwner; WinBorder* fOwner;
Layer* fParent; Layer* fParent;
Layer* fUpperSibling; Layer* fPreviousSibling;
Layer* fLowerSibling; Layer* fNextSibling;
Layer* fTopChild; Layer* fFirstChild;
Layer* fBottomChild; Layer* fLastChild;
mutable Layer* fCurrent; mutable Layer* fCurrent;
+42 -28
View File
@@ -234,10 +234,10 @@ RootLayer::WorkingThread(void *data)
oneRootLayer->rebuild_visible_regions( oneRootLayer->rebuild_visible_regions(
BRegion(oneRootLayer->Bounds()), BRegion(oneRootLayer->Bounds()),
BRegion(oneRootLayer->Bounds()), BRegion(oneRootLayer->Bounds()),
oneRootLayer->BottomChild()); oneRootLayer->LastChild());
oneRootLayer->fRedrawReg.Include(oneRootLayer->Bounds()); oneRootLayer->fRedrawReg.Include(oneRootLayer->Bounds());
oneRootLayer->RequestDraw(oneRootLayer->fRedrawReg, oneRootLayer->BottomChild()); oneRootLayer->RequestDraw(oneRootLayer->fRedrawReg, oneRootLayer->LastChild());
#endif #endif
oneRootLayer->Unlock(); oneRootLayer->Unlock();
@@ -502,45 +502,53 @@ RootLayer::ResizeBy(float x, float y)
} }
Layer * Layer*
RootLayer::TopChild() const RootLayer::FirstChild() const
{ {
fWinBorderIndex = fWinBorderCount-1; fWinBorderIndex = fWinBorderCount - 1;
if (fWinBorderIndex >= 0)
return fWinBorderList[fWinBorderIndex];
return NULL;
}
Layer*
RootLayer::NextChild() const
{
fWinBorderIndex--;
if (fWinBorderIndex < fWinBorderCount && fWinBorderIndex >= 0) if (fWinBorderIndex < fWinBorderCount && fWinBorderIndex >= 0)
return fWinBorderList[fWinBorderIndex--]; return fWinBorderList[fWinBorderIndex];
return NULL; return NULL;
} }
Layer* RootLayer::LowerSibling() const Layer*
RootLayer::PreviousChild() const
{ {
if (fWinBorderIndex < fWinBorderCount && fWinBorderIndex > 0) fWinBorderIndex++;
return fWinBorderList[fWinBorderIndex--];
if (fWinBorderIndex < fWinBorderCount && fWinBorderIndex >= 0)
return fWinBorderList[fWinBorderIndex];
return NULL; return NULL;
} }
Layer* RootLayer::UpperSibling() const Layer*
{ RootLayer::LastChild() const
if (fWinBorderIndex < fWinBorderCount && fWinBorderIndex > 0)
return fWinBorderList[fWinBorderIndex++];
return NULL;
}
Layer* RootLayer::BottomChild() const
{ {
fWinBorderIndex = 0; fWinBorderIndex = 0;
if (fWinBorderIndex < fWinBorderCount && fWinBorderIndex >= 0) if (fWinBorderIndex < fWinBorderCount)
return fWinBorderList[fWinBorderIndex++]; return fWinBorderList[fWinBorderIndex];
return NULL; return NULL;
} }
void RootLayer::AddWinBorder(WinBorder* winBorder) void
RootLayer::AddWinBorder(WinBorder* winBorder)
{ {
if (!winBorder->IsHidden()) if (!winBorder->IsHidden())
{ {
@@ -1116,6 +1124,8 @@ RootLayer::MouseEventHandler(int32 code, BPrivate::PortLink& msg)
msg.Read<int32>(&evt.buttons); msg.Read<int32>(&evt.buttons);
msg.Read<int32>(&evt.clicks); msg.Read<int32>(&evt.clicks);
evt.where.ConstrainTo(fFrame);
if (fLastMousePosition != evt.where) { if (fLastMousePosition != evt.where) {
// TODO: a B_MOUSE_MOVED message might have to be generated in order to // TODO: a B_MOUSE_MOVED message might have to be generated in order to
// correctly trigger entered/exited view transits. // correctly trigger entered/exited view transits.
@@ -1223,6 +1233,8 @@ RootLayer::MouseEventHandler(int32 code, BPrivate::PortLink& msg)
msg.Read<float>(&evt.where.y); msg.Read<float>(&evt.where.y);
msg.Read<int32>(&evt.modifiers); msg.Read<int32>(&evt.modifiers);
evt.where.ConstrainTo(fFrame);
if (fLastMouseMoved == NULL) { if (fLastMouseMoved == NULL) {
CRITICAL("RootLayer::MouseEventHandler(B_MOUSE_UP) fLastMouseMoved is null!\n"); CRITICAL("RootLayer::MouseEventHandler(B_MOUSE_UP) fLastMouseMoved is null!\n");
break; break;
@@ -1302,6 +1314,8 @@ fprintf(stderr, "mouse position changed in B_MOUSE_UP (%.1f, %.1f) from last B_M
msg.Read<float>(&evt.where.y); msg.Read<float>(&evt.where.y);
msg.Read<int32>(&evt.buttons); msg.Read<int32>(&evt.buttons);
evt.where.ConstrainTo(fFrame);
GetHWInterface()->MoveCursorTo(evt.where.x, evt.where.y); GetHWInterface()->MoveCursorTo(evt.where.x, evt.where.y);
fLastMousePosition = evt.where; fLastMousePosition = evt.where;
@@ -1921,8 +1935,8 @@ RootLayer::show_winBorder(WinBorder *winBorder)
if (fActiveWksIndex == i) { if (fActiveWksIndex == i) {
invalidate = invalid; invalidate = invalid;
if (dynamic_cast<class WorkspacesLayer *>(winBorder->TopChild()) != NULL) if (dynamic_cast<class WorkspacesLayer *>(winBorder->FirstChild()) != NULL)
SetWorkspacesLayer(winBorder->TopChild()); SetWorkspacesLayer(winBorder->FirstChild());
} }
} }
@@ -1957,7 +1971,7 @@ RootLayer::hide_winBorder(WinBorder *winBorder)
if (fActiveWksIndex == i) { if (fActiveWksIndex == i) {
invalidate = invalid; invalidate = invalid;
if (dynamic_cast<class WorkspacesLayer *>(winBorder->TopChild()) != NULL) if (dynamic_cast<class WorkspacesLayer *>(winBorder->FirstChild()) != NULL)
SetWorkspacesLayer(NULL); SetWorkspacesLayer(NULL);
} }
} }
@@ -2041,8 +2055,8 @@ bool RootLayer::get_workspace_windows()
SetWorkspacesLayer(NULL); SetWorkspacesLayer(NULL);
for (int32 i = 0; i < fWinBorderCount; i++) { for (int32 i = 0; i < fWinBorderCount; i++) {
if (dynamic_cast<class WorkspacesLayer *>(fWinBorderList[i]->TopChild()) != NULL) if (dynamic_cast<class WorkspacesLayer *>(fWinBorderList[i]->FirstChild()) != NULL)
SetWorkspacesLayer(fWinBorderList[i]->TopChild()); SetWorkspacesLayer(fWinBorderList[i]->FirstChild());
} }
// to determine if there was a change in window hierarchy // to determine if there was a change in window hierarchy
@@ -2112,10 +2126,10 @@ RootLayer::empty_visible_regions(Layer *layer)
layer->fFullVisible.MakeEmpty(); layer->fFullVisible.MakeEmpty();
layer->fVisible.MakeEmpty(); layer->fVisible.MakeEmpty();
Layer* child = layer->BottomChild(); Layer* child = layer->LastChild();
while (child) { while (child) {
empty_visible_regions(child); empty_visible_regions(child);
child = layer->UpperSibling(); child = layer->PreviousChild();
} }
} }
#endif #endif
+4 -4
View File
@@ -77,10 +77,10 @@ public:
} }
// For the active workspaces // For the active workspaces
virtual Layer* TopChild(void) const; virtual Layer* FirstChild() const;
virtual Layer* LowerSibling(void) const; virtual Layer* NextChild() const;
virtual Layer* UpperSibling(void) const; virtual Layer* PreviousChild() const;
virtual Layer* BottomChild(void) const; virtual Layer* LastChild() const;
void HideWinBorder(WinBorder* winBorder); void HideWinBorder(WinBorder* winBorder);
void ShowWinBorder(WinBorder* winBorder); void ShowWinBorder(WinBorder* winBorder);