From 8b4cf1c373c952b9864924f907e34c3a5086a84d Mon Sep 17 00:00:00 2001 From: Adi Oanca Date: Mon, 14 Mar 2005 19:25:15 +0000 Subject: [PATCH] Fixed a problem with floating subset windows not being shown when their main window became active. (Cleared visible regions for it and its children when automatically being removed from workspace) git-svn-id: file:///srv/svn/repos/haiku/trunk/current@11739 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/app/server/RootLayer.cpp | 52 +++++++++++++++++++++++++--- src/servers/app/server/RootLayer.h | 1 + 2 files changed, 49 insertions(+), 4 deletions(-) diff --git a/src/servers/app/server/RootLayer.cpp b/src/servers/app/server/RootLayer.cpp index bd3935928b..899b0db51c 100644 --- a/src/servers/app/server/RootLayer.cpp +++ b/src/servers/app/server/RootLayer.cpp @@ -1633,20 +1633,46 @@ void RootLayer::hide_winBorder(WinBorder *winBorder) void RootLayer::get_workspace_windows() { int32 bufferSize = fWinBorderListLength; + int32 exCount = fWinBorderCount; + bool present; + bool newMemory = false; - memcpy(fWinBorderList2, fWinBorderList, fWinBorderCount); + memcpy(fWinBorderList2, fWinBorderList, fWinBorderCount * sizeof(WinBorder*)); if (!(ActiveWorkspace()->GetWinBorderList((void**)fWinBorderList, &bufferSize))) { - fWinBorderList2 = (WinBorder**)realloc(fWinBorderList2, bufferSize); - fWinBorderList = (WinBorder**)realloc(fWinBorderList, bufferSize); - fWinBorderListLength = bufferSize; + newMemory = true; + // grow by a factor of 8. + fWinBorderListLength = (bufferSize / 8 + 1) * 8; + fWinBorderList = (WinBorder**)realloc(fWinBorderList, fWinBorderListLength); ActiveWorkspace()->GetWinBorderList((void**)fWinBorderList, &bufferSize); } fWinBorderCount = bufferSize; fWinBorderIndex = 0; + + // clear visible and full visible regions for windows no more visible. + for (int32 i = 0; i < exCount; i++) + { + present = false; + + for (int32 j = 0; j < fWinBorderCount; j++) + if (fWinBorderList2[i] == fWinBorderList[j]) + present = true; + + if (!present) + empty_visible_regions(fWinBorderList2[i]); +// { +// fWinBorderList2[i]->fVisible.MakeEmpty(); +// fWinBorderList2[i]->fFullVisible.MakeEmpty(); +// } + } + + // enlarge 2nd buffer also + if (newMemory) + fWinBorderList2 = (WinBorder**)realloc(fWinBorderList2, fWinBorderListLength); + //for (int32 i = 0; i < fWinBorderCount; i++) //{ // printf("Adi: %ld get_workspace_windows(%p)\n", i, fWinBorderList[i]); @@ -1673,3 +1699,21 @@ void RootLayer::draw_window_tab(WinBorder *exFocus, WinBorder *focus) } } } + +inline +void RootLayer::empty_visible_regions(Layer *layer) +{ +// TODO: optimize by avoiding recursion? + // NOTE: first 'layer' must be a WinBorder + Layer *child; + + layer->fFullVisible.MakeEmpty(); + layer->fVisible.MakeEmpty(); + + child = layer->VirtualBottomChild(); + while(child) + { + empty_visible_regions(child); + child = layer->VirtualUpperSibling(); + } +} \ No newline at end of file diff --git a/src/servers/app/server/RootLayer.h b/src/servers/app/server/RootLayer.h index 1cc8940143..9ada33714c 100644 --- a/src/servers/app/server/RootLayer.h +++ b/src/servers/app/server/RootLayer.h @@ -138,6 +138,7 @@ friend class Desktop; void get_workspace_windows(); void draw_window_tab(WinBorder *exFocus, WinBorder *focus); + void empty_visible_regions(Layer *layer); void invalidate_layer(Layer *layer, const BRegion ®ion); void redraw_layer(Layer *layer, const BRegion ®ion);