Author: czeidler Date: 2010-05-20 08:18:50 +0200 (Thu, 20 May 2010) New Revision: 36873 Changeset: http://dev.haiku-os.org/changeset/36873/haiku Modified: haiku/branches/features/stack-and-tile/src/servers/app/StackAndTile.cpp Log: Fix snapping detection + smaller fixes. Modified: haiku/branches/features/stack-and-tile/src/servers/app/StackAndTile.cpp =================================================================== --- haiku/branches/features/stack-and-tile/src/servers/app/StackAndTile.cpp 2010-05-20 03:51:01 UTC (rev 36872) +++ haiku/branches/features/stack-and-tile/src/servers/app/StackAndTile.cpp 2010-05-20 06:18:50 UTC (rev 36873) @@ -11,7 +11,7 @@ using namespace std; -// #define DEBUG_STACK_AND_TILE +#define DEBUG_STACK_AND_TILE #ifdef DEBUG_STACK_AND_TILE @@ -43,8 +43,7 @@ void StackAndTile::WindowAdded(Window* window) { - SATWindow* satWindow = new (std::nothrow)SATWindow( - window); + SATWindow* satWindow = new (std::nothrow)SATWindow(window); if (!satWindow) return; @@ -56,8 +55,7 @@ void StackAndTile::WindowRemoved(Window* window) { - SATWindowMap::iterator it = fSATWindowMap.find( - window); + SATWindowMap::iterator it = fSATWindowMap.find(window); if (it == fSATWindowMap.end()) return; @@ -657,7 +655,7 @@ float deltaX = 0; float deltaY = 0; - BRect windowFrame = window->fWindow->Frame(); + BRect windowFrame = window->GetWindow()->Frame(); BList* windowsToRight = window->Right2LeftSnappingWindowIds(); BList* windowsToLeft = window->Left2RightSnappingWindowIds(); @@ -994,17 +992,17 @@ // align this window with the stack fWindow->Desktop()->MoveWindowBy(fWindow, - fWindowUnder->fWindow->Frame().left - fWindow->Frame().left, - fWindowUnder->fWindow->Frame().top - fWindow->Frame().top); + fWindowUnder->GetWindow()->Frame().left - fWindow->Frame().left, + fWindowUnder->GetWindow()->Frame().top - fWindow->Frame().top); fWindow->Desktop()->ResizeWindowBy(fWindow, - fWindowUnder->fWindow->Frame().right - fWindow->Frame().right, - fWindowUnder->fWindow->Frame().bottom - fWindow->Frame().bottom); + fWindowUnder->GetWindow()->Frame().right - fWindow->Frame().right, + fWindowUnder->GetWindow()->Frame().bottom - fWindow->Frame().bottom); // make sure there is a stacked window list BList* stack = fWindowUnder->fStackedWindows; if (!stack) { stack = new BList(); - stack->AddItem(fWindowUnder); + stack->AddItem(fWindowUnder->GetWindow()); fWindowUnder->fStackedWindows = stack; } @@ -1034,7 +1032,7 @@ // add this window to the stack before the windowUnder, // rearrange the window tabs and initialize constraints - stack->AddItem(fWindow, stack->IndexOf(fWindowUnder->fWindow)); + stack->AddItem(fWindow, stack->IndexOf(fWindowUnder->GetWindow())); fStackedWindows = stack; _ArrangeStackedWindowTabs(); _InitStackingAndSnapping(); @@ -1178,9 +1176,10 @@ // go through all windows and look for snapping candidates for (Window* window = fWindow->Desktop()->CurrentWindows().LastWindow(); window; window = window->PreviousWindow(fWindow->CurrentWorkspace())) { + Window* windowUnder = fWindowUnder != NULL ? fWindowUnder->fWindow : NULL; if (!window->IsHidden() && fWindow != window // don't snap window to itself - && fWindowUnder && window != fWindowUnder->fWindow + && window != windowUnder // don't snap with stacking candidate && !(strcmp(window->Title(), "Deskbar")==0) && !(strcmp(window->Title(), "Desktop")==0)) { @@ -1189,39 +1188,39 @@ BRect thisLeft(fWindow->Frame().left - 12, fWindow->Frame().top + 12, fWindow->Frame().left + 6, fWindow->Frame().bottom - 12); - BRect window2Right(window->Frame().right - 6, + BRect windowRight(window->Frame().right - 6, window->Frame().top + 12, window->Frame().right + 12, window->Frame().bottom - 12); - if (thisLeft.Intersects(window2Right)) + if (thisLeft.Intersects(windowRight)) fLeftAdjacentWindows->AddItem(window); - // is window2 adjacent on the top of this window? + // is window adjacent on the top of this window? BRect thisTop(fWindow->Frame().left + 12, fWindow->Frame().top - 22, fWindow->Frame().right - 12, fWindow->Frame().top + 6); - BRect window2Bottom(window->Frame().left + 12, + BRect windowBottom(window->Frame().left + 12, window->Frame().bottom - 6, window->Frame().right - 12, window->Frame().bottom + 12); - if (thisTop.Intersects(window2Bottom)) + if (thisTop.Intersects(windowBottom)) fTopAdjacentWindows->AddItem(window); - // is window2 adjacent on the right of this window? + // is window adjacent on the right of this window? BRect thisRight(fWindow->Frame().right - 6, fWindow->Frame().top + 12, fWindow->Frame().right + 12, fWindow->Frame().bottom - 12); - BRect window2Left(window->Frame().left - 12, + BRect windowLeft(window->Frame().left - 12, window->Frame().top + 12, window->Frame().left + 6, window->Frame().bottom - 12); - if (thisRight.Intersects(window2Left)) + if (thisRight.Intersects(windowLeft)) fRightAdjacentWindows->AddItem(window); - // is window2 adjacent on the bottom of this window? + // is window adjacent on the bottom of this window? BRect thisBottom(fWindow->Frame().left + 12, fWindow->Frame().bottom - 6, fWindow->Frame().right - 12, fWindow->Frame().bottom + 12); - BRect window2Top(window->Frame().left + 12, + BRect windowTop(window->Frame().left + 12, window->Frame().top - 22, window->Frame().right - 12, window->Frame().top + 6); - if (thisBottom.Intersects(window2Top)) + if (thisBottom.Intersects(windowTop)) fBottomAdjacentWindows->AddItem(window); } } @@ -2050,7 +2049,8 @@ _ArrangeStackedWindowTabs(); - #ifdef DEBUG_STACK_AND_TILE + #if 0 + //#ifdef DEBUG_STACK_AND_TILE // debug_printf crashes if given too large strings // therefore we cut our specification string up into smaller chunks BString* specStr = fStackAndTile->GetLinearSpec()->ToBString();