From 867b420067843a1f33829c74185a64d950e077a4 Mon Sep 17 00:00:00 2001 From: Adi Oanca Date: Sun, 27 Mar 2005 10:51:28 +0000 Subject: [PATCH] get_workspace_windows() new returns true if there was a change in window hierarchy. Improved performance a bit by avoiding an invalidate call. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12072 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/app/RootLayer.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/servers/app/RootLayer.cpp b/src/servers/app/RootLayer.cpp index 579489dd14..35a8e7f929 100644 --- a/src/servers/app/RootLayer.cpp +++ b/src/servers/app/RootLayer.cpp @@ -934,10 +934,12 @@ void RootLayer::MouseEventHandler(int32 code, BPortLink& msg) else invalidate = ActiveWorkspace()->MoveToFront(target); - if (invalidate) + // Performance: MoveToFront() often returns true although it shouldn't do that. + // This is because internaly it calls Workspace::ShowWinBorder() and this imposes + // a small penalty, but we can live with that; it make Workspace code a lot more clear/clean. + + if (invalidate && get_workspace_windows()) { - get_workspace_windows(); - // TODO: should it be improved by calling with region of hidden windows // plus the full regions of new windows??? invalidate_layer(this, fFull); @@ -1731,12 +1733,13 @@ void RootLayer::hide_winBorder(WinBorder *winBorder) } } -void RootLayer::get_workspace_windows() +bool RootLayer::get_workspace_windows() { int32 bufferSize = fWinBorderListLength; int32 exCount = fWinBorderCount; bool present; bool newMemory = false; + bool aChange = false; memcpy(fWinBorderList2, fWinBorderList, fWinBorderCount * sizeof(WinBorder*)); @@ -1753,9 +1756,17 @@ void RootLayer::get_workspace_windows() fWinBorderIndex = 0; + // to determine if there was a change in window hierarchy + if (exCount != fWinBorderCount) + aChange = true; + // clear visible and full visible regions for windows no more visible. for (int32 i = 0; i < exCount; i++) { + // to determine if there was a change in window hierarchy + if (!aChange && fWinBorderList2[i] != fWinBorderList[i]) + aChange = true; + present = false; for (int32 j = 0; j < fWinBorderCount; j++) @@ -1775,6 +1786,7 @@ void RootLayer::get_workspace_windows() // printf("Adi: %ld get_workspace_windows(%p)\n", i, fWinBorderList[i]); //} //printf("Adi: get_workspace_windows DONE\n"); + return aChange; } void RootLayer::draw_window_tab(WinBorder *exFocus, WinBorder *focus)