Fixed a bad bug in the app_server:
fCurrentLayer was used to determine to which layer a new one would be added to, but BView::AddChild() would only set this correctly for the current view, ie. all children of the new child were added to the wrong layer in the app_server. Now, AS_LAYER_CREATE sends the parent's token to the server, and the server relies on this to build the layer hierarchy. All of a sudden a lot of hidden views are visible now. I noticed the bug while refactoring the task manager, but a lot of apps were affected. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13164 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
6a6ab9b2e2
commit
53442520cc
@ -3558,7 +3558,7 @@ BView::setOwner(BWindow *theOwner)
|
||||
if (fShelf)
|
||||
owner->RemoveHandler(fShelf);
|
||||
}
|
||||
|
||||
|
||||
if (theOwner && theOwner != owner) {
|
||||
theOwner->AddHandler(this);
|
||||
if (fShelf)
|
||||
@ -3662,17 +3662,17 @@ BView::removeSelf()
|
||||
|
||||
|
||||
void
|
||||
BView::callDetachHooks(BView *aView)
|
||||
BView::callDetachHooks(BView *view)
|
||||
{
|
||||
aView->DetachedFromWindow();
|
||||
view->DetachedFromWindow();
|
||||
|
||||
BView *child = aView->first_child;
|
||||
BView *child = view->first_child;
|
||||
while (child != NULL) {
|
||||
aView->callDetachHooks(child);
|
||||
view->callDetachHooks(child);
|
||||
child = child->next_sibling;
|
||||
}
|
||||
|
||||
aView->AllDetached();
|
||||
view->AllDetached();
|
||||
}
|
||||
|
||||
|
||||
@ -3695,9 +3695,9 @@ BView::removeFromList()
|
||||
|
||||
|
||||
bool
|
||||
BView::addToList(BView *aView, BView *before)
|
||||
BView::addToList(BView *view, BView *before)
|
||||
{
|
||||
if (!aView)
|
||||
if (!view)
|
||||
return false;
|
||||
|
||||
BView *current = first_child;
|
||||
@ -3714,47 +3714,48 @@ BView::addToList(BView *aView, BView *before)
|
||||
// we're at begining of the list, OR between two elements
|
||||
if (current) {
|
||||
if (current == first_child) {
|
||||
aView->next_sibling = current;
|
||||
current->prev_sibling = aView;
|
||||
first_child = aView;
|
||||
view->next_sibling = current;
|
||||
current->prev_sibling = view;
|
||||
first_child = view;
|
||||
} else {
|
||||
aView->next_sibling = current;
|
||||
aView->prev_sibling = current->prev_sibling;
|
||||
current->prev_sibling->next_sibling = aView;
|
||||
current->prev_sibling = aView;
|
||||
view->next_sibling = current;
|
||||
view->prev_sibling = current->prev_sibling;
|
||||
current->prev_sibling->next_sibling = view;
|
||||
current->prev_sibling = view;
|
||||
}
|
||||
} else {
|
||||
// we have reached the end of the list
|
||||
|
||||
// if last!=NULL then we add to the end. Otherwise, aView is the
|
||||
// if last!=NULL then we add to the end. Otherwise, view is the
|
||||
// first chiild in the list
|
||||
if (last) {
|
||||
last->next_sibling = aView;
|
||||
aView->prev_sibling = last;
|
||||
last->next_sibling = view;
|
||||
view->prev_sibling = last;
|
||||
} else
|
||||
first_child = aView;
|
||||
first_child = view;
|
||||
}
|
||||
|
||||
aView->parent = this;
|
||||
view->parent = this;
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
BView::callAttachHooks(BView *aView)
|
||||
BView::callAttachHooks(BView *view)
|
||||
{
|
||||
aView->AttachedToWindow();
|
||||
view->AttachedToWindow();
|
||||
|
||||
BView *child= aView->first_child;
|
||||
BView *child = view->first_child;
|
||||
while (child != NULL) {
|
||||
aView->callAttachHooks(child);
|
||||
view->callAttachHooks(child);
|
||||
child = child->next_sibling;
|
||||
}
|
||||
|
||||
aView->AllAttached();
|
||||
view->AllAttached();
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
BView::attachView(BView *aView)
|
||||
BView::attachView(BView *view)
|
||||
{
|
||||
// LEAVE the following line commented!!!
|
||||
// check_lock();
|
||||
@ -3768,30 +3769,30 @@ BView::attachView(BView *aView)
|
||||
are made.
|
||||
*/
|
||||
|
||||
if (aView->top_level_view)
|
||||
if (view->top_level_view)
|
||||
owner->fLink->StartMessage(AS_LAYER_CREATE_ROOT);
|
||||
else
|
||||
owner->fLink->StartMessage(AS_LAYER_CREATE);
|
||||
|
||||
owner->fLink->Attach<int32>(_get_object_token_( aView ));
|
||||
owner->fLink->AttachString(aView->Name());
|
||||
owner->fLink->Attach<BRect>(aView->Frame());
|
||||
owner->fLink->Attach<uint32>(aView->ResizingMode());
|
||||
owner->fLink->Attach<uint32>(aView->fEventMask);
|
||||
owner->fLink->Attach<uint32>(aView->fEventOptions);
|
||||
owner->fLink->Attach<uint32>(aView->Flags());
|
||||
owner->fLink->Attach<bool>(aView->IsHidden(aView));
|
||||
owner->fLink->Attach<rgb_color>(aView->fState->viewColor);
|
||||
owner->fLink->Attach<int32>(aView->CountChildren());
|
||||
owner->fLink->Attach<int32>(_get_object_token_(view));
|
||||
owner->fLink->AttachString(view->Name());
|
||||
owner->fLink->Attach<BRect>(view->Frame());
|
||||
owner->fLink->Attach<uint32>(view->ResizingMode());
|
||||
owner->fLink->Attach<uint32>(view->fEventMask);
|
||||
owner->fLink->Attach<uint32>(view->fEventOptions);
|
||||
owner->fLink->Attach<uint32>(view->Flags());
|
||||
owner->fLink->Attach<bool>(view->IsHidden(view));
|
||||
owner->fLink->Attach<rgb_color>(view->fState->viewColor);
|
||||
owner->fLink->Attach<int32>(_get_object_token_(this));
|
||||
owner->fLink->Flush();
|
||||
|
||||
aView->setCachedState();
|
||||
|
||||
view->setCachedState();
|
||||
|
||||
// we attach all its children
|
||||
|
||||
BView *child= aView->first_child;
|
||||
BView *child = view->first_child;
|
||||
while (child != NULL) {
|
||||
aView->attachView(child);
|
||||
view->attachView(child);
|
||||
child = child->next_sibling;
|
||||
}
|
||||
|
||||
@ -3802,26 +3803,26 @@ BView::attachView(BView *aView)
|
||||
|
||||
|
||||
void
|
||||
BView::deleteView( BView* aView)
|
||||
BView::deleteView(BView* view)
|
||||
{
|
||||
BView *child = aView->first_child;
|
||||
BView *child = view->first_child;
|
||||
while (child != NULL) {
|
||||
BView *nextChild = child->next_sibling;
|
||||
deleteView(child);
|
||||
child = nextChild;
|
||||
}
|
||||
|
||||
delete aView;
|
||||
delete view;
|
||||
}
|
||||
|
||||
|
||||
BView *
|
||||
BView::findView(const BView *aView, const char *viewName) const
|
||||
BView::findView(const BView *view, const char *viewName) const
|
||||
{
|
||||
if (!strcmp(viewName, aView->Name()))
|
||||
return const_cast<BView *>(aView);
|
||||
if (!strcmp(viewName, view->Name()))
|
||||
return const_cast<BView *>(view);
|
||||
|
||||
BView *child = aView->first_child;
|
||||
BView *child = view->first_child;
|
||||
while (child != NULL) {
|
||||
BView *view;
|
||||
if ((view = findView(child, viewName)) != NULL)
|
||||
|
@ -313,7 +313,7 @@ ServerWindow::SetLayerState(Layer *layer, BPrivate::LinkReceiver &link)
|
||||
|
||||
|
||||
inline Layer*
|
||||
ServerWindow::CreateLayerTree(Layer *localRoot, BPrivate::LinkReceiver &link)
|
||||
ServerWindow::CreateLayerTree(BPrivate::LinkReceiver &link, Layer **_parent)
|
||||
{
|
||||
// NOTE: no need to check for a lock. This is a private method.
|
||||
|
||||
@ -324,7 +324,7 @@ ServerWindow::CreateLayerTree(Layer *localRoot, BPrivate::LinkReceiver &link)
|
||||
uint32 eventOptions;
|
||||
uint32 flags;
|
||||
bool hidden;
|
||||
int32 childCount;
|
||||
int32 parentToken;
|
||||
char *name = NULL;
|
||||
rgb_color viewColor;
|
||||
|
||||
@ -336,10 +336,11 @@ ServerWindow::CreateLayerTree(Layer *localRoot, BPrivate::LinkReceiver &link)
|
||||
link.Read<uint32>(&eventOptions);
|
||||
link.Read<uint32>(&flags);
|
||||
link.Read<bool>(&hidden);
|
||||
link.Read<rgb_color>(&viewColor );
|
||||
link.Read<int32>(&childCount);
|
||||
link.Read<rgb_color>(&viewColor);
|
||||
link.Read<int32>(&parentToken);
|
||||
|
||||
STRACE(("ServerWindow(%s)::CreateLayerTree()-> layer %s, token %ld\n", fName,name,token));
|
||||
STRACE(("ServerWindow(%s)::CreateLayerTree()-> layer %s, token %ld\n",
|
||||
fName, name, token));
|
||||
|
||||
Layer *newLayer = new Layer(frame, name, token, resizeMask,
|
||||
flags, gDesktop->GetDisplayDriver());
|
||||
@ -353,9 +354,13 @@ ServerWindow::CreateLayerTree(Layer *localRoot, BPrivate::LinkReceiver &link)
|
||||
newLayer->fEventOptions = eventOptions;
|
||||
newLayer->fOwner = fWinBorder;
|
||||
|
||||
// add the new Layer to the tree structure.
|
||||
if (localRoot)
|
||||
localRoot->AddChild(newLayer, NULL);
|
||||
if (_parent) {
|
||||
Layer *parent = fWinBorder->FindLayer(parentToken);
|
||||
if (parent == NULL)
|
||||
CRITICAL("View token not found!\n");
|
||||
|
||||
*_parent = parent;
|
||||
}
|
||||
|
||||
return newLayer;
|
||||
}
|
||||
@ -364,7 +369,7 @@ ServerWindow::CreateLayerTree(Layer *localRoot, BPrivate::LinkReceiver &link)
|
||||
void
|
||||
ServerWindow::DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
|
||||
{
|
||||
if (fCurrentLayer == NULL && code != AS_LAYER_CREATE_ROOT) {
|
||||
if (fCurrentLayer == NULL && code != AS_LAYER_CREATE_ROOT && code != AS_LAYER_CREATE) {
|
||||
printf("ServerWindow %s received unexpected code - message offset %ld before top_view attached.\n",fName, code - SERVER_TRUE);
|
||||
return;
|
||||
}
|
||||
@ -431,22 +436,19 @@ ServerWindow::DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
|
||||
int32 token;
|
||||
|
||||
link.Read<int32>(&token);
|
||||
|
||||
// Layer *current = FindLayer(fWinBorder->fTopLayer, token);
|
||||
|
||||
Layer *current = fWinBorder->FindLayer(token);
|
||||
if(current)
|
||||
{
|
||||
if (current) {
|
||||
DTRACE(("ServerWindow %s: Message AS_SET_CURRENT_LAYER: %s, token %ld\n", fName, current->fName->String(), token));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
DTRACE(("ServerWindow %s: Message AS_SET_CURRENT_LAYER: layer not found, token %ld\n", fName, token));
|
||||
}
|
||||
|
||||
if (current)
|
||||
fCurrentLayer=current;
|
||||
fCurrentLayer = current;
|
||||
else // hope this NEVER happens! :-)
|
||||
CRITICAL("Server PANIC: window cannot find Layer with ID\n");
|
||||
// ToDo: if this happens, we probably want to kill the app and clean up
|
||||
break;
|
||||
}
|
||||
|
||||
@ -458,9 +460,8 @@ ServerWindow::DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
|
||||
// This should be the *only* place where this happens.
|
||||
if (fCurrentLayer != NULL)
|
||||
break;
|
||||
|
||||
// fWinBorder->fTopLayer = CreateLayerTree(NULL);
|
||||
fWinBorder->fTopLayer = CreateLayerTree(NULL, link);
|
||||
|
||||
fWinBorder->fTopLayer = CreateLayerTree(link, NULL);
|
||||
fWinBorder->fTopLayer->SetAsTopLayer(true);
|
||||
fCurrentLayer = fWinBorder->fTopLayer;
|
||||
|
||||
@ -472,19 +473,15 @@ ServerWindow::DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
|
||||
case AS_LAYER_CREATE:
|
||||
{
|
||||
STRACE(("ServerWindow %s: Message AS_LAYER_CREATE: Layer name: %s\n", fName, fCurrentLayer->fName->String()));
|
||||
Layer *newLayer;
|
||||
|
||||
if (fCurrentLayer == NULL)
|
||||
break;
|
||||
|
||||
// newLayer = CreateLayerTree(NULL);
|
||||
newLayer = CreateLayerTree(NULL, link);
|
||||
fCurrentLayer->AddChild(newLayer, this);
|
||||
Layer* parent = NULL;
|
||||
Layer* newLayer = CreateLayerTree(link, &parent);
|
||||
if (parent != NULL)
|
||||
parent->AddChild(newLayer, this);
|
||||
|
||||
if (!(newLayer->IsHidden())){
|
||||
if (!newLayer->IsHidden()) {
|
||||
myRootLayer->GoInvalidate(newLayer, newLayer->fFull);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case AS_LAYER_DELETE:
|
||||
@ -512,7 +509,7 @@ ServerWindow::DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
|
||||
|
||||
delete fCurrentLayer;
|
||||
|
||||
fCurrentLayer=parent;
|
||||
fCurrentLayer = parent;
|
||||
break;
|
||||
}
|
||||
case AS_LAYER_SET_STATE:
|
||||
|
@ -117,9 +117,8 @@ public:
|
||||
FMWList fWinFMWList;
|
||||
|
||||
private:
|
||||
|
||||
// methods for retrieving and creating a tree strcture of Layers.
|
||||
Layer* CreateLayerTree(Layer *localRoot, BPrivate::LinkReceiver &link);
|
||||
Layer* CreateLayerTree(BPrivate::LinkReceiver &link, Layer **_parent);
|
||||
void SetLayerState(Layer *layer, BPrivate::LinkReceiver &link);
|
||||
void SetLayerFontState(Layer *layer, BPrivate::LinkReceiver &link);
|
||||
void ClientDied(bool crashed);
|
||||
|
Loading…
Reference in New Issue
Block a user