Author: czeidler Date: 2011-07-25 03:10:02 +0200 (Mon, 25 Jul 2011) New Revision: 42479 Changeset: https://dev.haiku-os.org/changeset/42479 Modified: haiku/trunk/src/add-ons/decorators/SATDecorator/SATDecorator.cpp haiku/trunk/src/add-ons/decorators/SATDecorator/SATDecorator.h haiku/trunk/src/add-ons/decorators/SATDecorator/SATWindow.cpp haiku/trunk/src/add-ons/decorators/SATDecorator/SATWindow.h haiku/trunk/src/add-ons/decorators/SATDecorator/StackAndTile.cpp haiku/trunk/src/add-ons/decorators/SATDecorator/StackAndTile.h haiku/trunk/src/add-ons/decorators/SATDecorator/Stacking.cpp haiku/trunk/src/add-ons/decorators/SATDecorator/Stacking.h haiku/trunk/src/add-ons/decorators/SATDecorator/Tiling.cpp haiku/trunk/src/add-ons/decorators/SATDecorator/Tiling.h Log: Fix the SATDecorator. Much of the stacking part is handled by the DefaultDecorator now. Modified: haiku/trunk/src/add-ons/decorators/SATDecorator/SATDecorator.cpp =================================================================== --- haiku/trunk/src/add-ons/decorators/SATDecorator/SATDecorator.cpp 2011-07-25 01:09:26 UTC (rev 42478) +++ haiku/trunk/src/add-ons/decorators/SATDecorator/SATDecorator.cpp 2011-07-25 01:10:02 UTC (rev 42479) @@ -85,362 +85,32 @@ SATDecorator::SATDecorator(DesktopSettings& settings, BRect frame, window_look look, uint32 flags) : - DefaultDecorator(settings, frame, look, flags), - - fStackedMode(false), - fStackedTabLength(0) + DefaultDecorator(settings, frame, look, flags) { - fStackedDrawZoom = IsFocus(); -} - -void -SATDecorator::SetStackedMode(bool stacked, BRegion* dirty) -{ - fStackedMode = stacked; - - dirty->Include(fTabRect); - _DoLayout(); - _InvalidateFootprint(); - dirty->Include(fTabRect); } void -SATDecorator::SetStackedTabLength(float length, BRegion* dirty) -{ - fStackedTabLength = length; - - dirty->Include(fTabRect); - _DoLayout(); - _InvalidateFootprint(); - dirty->Include(fTabRect); -} - - -void -SATDecorator::_DoLayout() -{ - STRACE(("DefaultDecorator: Do Layout\n")); - // Here we determine the size of every rectangle that we use - // internally when we are given the size of the client rectangle. - - bool hasTab = false; - - switch ((int)Look()) { - case B_MODAL_WINDOW_LOOK: - fBorderWidth = 5; - break; - - case B_TITLED_WINDOW_LOOK: - case B_DOCUMENT_WINDOW_LOOK: - hasTab = true; - fBorderWidth = 5; - break; - case B_FLOATING_WINDOW_LOOK: - case kLeftTitledWindowLook: - hasTab = true; - fBorderWidth = 3; - break; - - case B_BORDERED_WINDOW_LOOK: - fBorderWidth = 1; - break; - - default: - fBorderWidth = 0; - } - - // calculate our tab rect - if (hasTab) { - // distance from one item of the tab bar to another. - // In this case the text and close/zoom rects - fTextOffset = (fLook == B_FLOATING_WINDOW_LOOK - || fLook == kLeftTitledWindowLook) ? 10 : 18; - - font_height fontHeight; - fDrawState.Font().GetHeight(fontHeight); - - if (fLook != kLeftTitledWindowLook) { - fTabRect.Set(fFrame.left - fBorderWidth, - fFrame.top - fBorderWidth - - ceilf(fontHeight.ascent + fontHeight.descent + 7.0), - ((fFrame.right - fFrame.left) < 35.0 ? - fFrame.left + 35.0 : fFrame.right) + fBorderWidth, - fFrame.top - fBorderWidth); - } else { - fTabRect.Set(fFrame.left - fBorderWidth - - ceilf(fontHeight.ascent + fontHeight.descent + 5.0), - fFrame.top - fBorderWidth, fFrame.left - fBorderWidth, - fFrame.bottom + fBorderWidth); - } - - // format tab rect for a floating window - make the rect smaller - if (fLook == B_FLOATING_WINDOW_LOOK) { - fTabRect.InsetBy(0, 2); - fTabRect.OffsetBy(0, 2); - } - - if (fStackedMode) - fTabRect.right = fTabRect.left + fStackedTabLength; - - float offset; - float size; - float inset; - _GetButtonSizeAndOffset(fTabRect, &offset, &size, &inset); - - // fMinTabSize contains just the room for the buttons - fMinTabSize = inset * 2 + fTextOffset; - if ((fFlags & B_NOT_CLOSABLE) == 0) - fMinTabSize += offset + size; - if ((fFlags & B_NOT_ZOOMABLE) == 0) - fMinTabSize += offset + size; - - // fMaxTabSize contains fMinWidth + the width required for the title - fMaxTabSize = fDrawingEngine - ? ceilf(fDrawingEngine->StringWidth(Title(), strlen(Title()), - fDrawState.Font())) : 0.0; - if (fMaxTabSize > 0.0) - fMaxTabSize += fTextOffset; - fMaxTabSize += fMinTabSize; - - float tabSize = (fLook != kLeftTitledWindowLook - ? fFrame.Width() : fFrame.Height()) + fBorderWidth * 2; - - if (fStackedMode) { - tabSize = fStackedTabLength; - fMaxTabSize = tabSize; - } - else { - if (tabSize < fMinTabSize) - tabSize = fMinTabSize; - if (tabSize > fMaxTabSize) - tabSize = fMaxTabSize; - } - // layout buttons and truncate text - if (fLook != kLeftTitledWindowLook) - fTabRect.right = fTabRect.left + tabSize; - else - fTabRect.bottom = fTabRect.top + tabSize; - } else { - // no tab - fMinTabSize = 0.0; - fMaxTabSize = 0.0; - fTabRect.Set(0.0, 0.0, -1.0, -1.0); - fCloseRect.Set(0.0, 0.0, -1.0, -1.0); - fZoomRect.Set(0.0, 0.0, -1.0, -1.0); - } - - // calculate left/top/right/bottom borders - if (fBorderWidth > 0) { - // NOTE: no overlapping, the left and right border rects - // don't include the corners! - fLeftBorder.Set(fFrame.left - fBorderWidth, fFrame.top, - fFrame.left - 1, fFrame.bottom); - - fRightBorder.Set(fFrame.right + 1, fFrame.top , - fFrame.right + fBorderWidth, fFrame.bottom); - - fTopBorder.Set(fFrame.left - fBorderWidth, fFrame.top - fBorderWidth, - fFrame.right + fBorderWidth, fFrame.top - 1); - - fBottomBorder.Set(fFrame.left - fBorderWidth, fFrame.bottom + 1, - fFrame.right + fBorderWidth, fFrame.bottom + fBorderWidth); - } else { - // no border - fLeftBorder.Set(0.0, 0.0, -1.0, -1.0); - fRightBorder.Set(0.0, 0.0, -1.0, -1.0); - fTopBorder.Set(0.0, 0.0, -1.0, -1.0); - fBottomBorder.Set(0.0, 0.0, -1.0, -1.0); - } - - // calculate resize rect - if (fBorderWidth > 1) { - fResizeRect.Set(fBottomBorder.right - kResizeKnobSize, - fBottomBorder.bottom - kResizeKnobSize, fBottomBorder.right, - fBottomBorder.bottom); - } else { - // no border or one pixel border (menus and such) - fResizeRect.Set(0, 0, -1, -1); - } - - if (hasTab) { - // make sure fTabOffset is within limits and apply it to - // the fTabRect - if (fTabOffset < 0) - fTabOffset = 0; - if (fTabLocation != 0.0 - && fTabOffset > (fRightBorder.right - fLeftBorder.left - - fTabRect.Width())) - fTabOffset = uint32(fRightBorder.right - fLeftBorder.left - - fTabRect.Width()); - fTabRect.OffsetBy(fTabOffset, 0); - - // finally, layout the buttons and text within the tab rect - _LayoutTabItems(fTabRect); - } -} - - -void -SATDecorator::_LayoutTabItems(const BRect& tabRect) -{ - float offset; - float size; - float inset; - _GetButtonSizeAndOffset(tabRect, &offset, &size, &inset); - - // calulate close rect based on the tab rectangle - if (fLook != kLeftTitledWindowLook) { - fCloseRect.Set(tabRect.left + offset, tabRect.top + offset, - tabRect.left + offset + size, tabRect.top + offset + size); - - fZoomRect.Set(tabRect.right - offset - size, tabRect.top + offset, - tabRect.right - offset, tabRect.top + offset + size); - - // hidden buttons have no width - if ((Flags() & B_NOT_CLOSABLE) != 0) - fCloseRect.right = fCloseRect.left - offset; - if ((Flags() & B_NOT_ZOOMABLE) != 0) - fZoomRect.left = fZoomRect.right + offset; - } else { - fCloseRect.Set(tabRect.left + offset, tabRect.top + offset, - tabRect.left + offset + size, tabRect.top + offset + size); - - fZoomRect.Set(tabRect.left + offset, tabRect.bottom - offset - size, - tabRect.left + size + offset, tabRect.bottom - offset); - - // hidden buttons have no height - if ((Flags() & B_NOT_CLOSABLE) != 0) - fCloseRect.bottom = fCloseRect.top - offset; - if ((Flags() & B_NOT_ZOOMABLE) != 0) - fZoomRect.top = fZoomRect.bottom + offset; - } - - // calculate room for title - // TODO: the +2 is there because the title often appeared - // truncated for no apparent reason - OTOH the title does - // also not appear perfectly in the middle - if (fLook != kLeftTitledWindowLook) - size = (fZoomRect.left - fCloseRect.right) - fTextOffset * 2 + inset; - else - size = (fZoomRect.top - fCloseRect.bottom) - fTextOffset * 2 + inset; - - if (fStackedMode && !fStackedDrawZoom) { - fZoomRect.Set(0, 0, 0, 0); - size = (fTabRect.right - fCloseRect.right) - fTextOffset * 2 + inset; - } - uint8 truncateMode = B_TRUNCATE_MIDDLE; - - if (fStackedMode) { - if (fStackedTabLength < 100) - truncateMode = B_TRUNCATE_END; - float titleWidth = fDrawState.Font().StringWidth(Title(), - BString(Title()).Length()); - if (size < titleWidth) { - float oldTextOffset = fTextOffset; - fTextOffset -= (titleWidth - size) / 2; - const float kMinTextOffset = 5.; - if (fTextOffset < kMinTextOffset) - fTextOffset = kMinTextOffset; - size += oldTextOffset * 2; - size -= fTextOffset * 2; - } - } - - fTruncatedTitle = Title(); - fDrawState.Font().TruncateString(&fTruncatedTitle, truncateMode, size); - fTruncatedTitleLength = fTruncatedTitle.Length(); -} - - -bool -SATDecorator::_SetTabLocation(float location, BRegion* updateRegion) -{ - STRACE(("DefaultDecorator: Set Tab Location(%.1f)\n", location)); - if (!fTabRect.IsValid()) - return false; - - if (location < 0) - location = 0; - - float maxLocation = 0.; - if (fStackedMode) - maxLocation = fRightBorder.right - fLeftBorder.left - fStackedTabLength; - else - maxLocation = fRightBorder.right - fLeftBorder.left - fTabRect.Width(); - if (location > maxLocation) - location = maxLocation; - - float delta = location - fTabOffset; - if (delta == 0.0) - return false; - - // redraw old rect (1 pix on the border also must be updated) - BRect trect(fTabRect); - trect.bottom++; - updateRegion->Include(trect); - - fTabRect.OffsetBy(delta, 0); - fTabOffset = (int32)location; - _LayoutTabItems(fTabRect); - - fTabLocation = maxLocation > 0.0 ? fTabOffset / maxLocation : 0.0; - - // redraw new rect as well - trect = fTabRect; - trect.bottom++; - updateRegion->Include(trect); - return true; -} - - -void -SATDecorator::_SetFocus() -{ - DefaultDecorator::_SetFocus(); - - if (!fStackedMode) - return; - - if (IsFocus()) - fStackedDrawZoom = true; - else - fStackedDrawZoom = false; - - _DoLayout(); - -} - - -void -SATDecorator::DrawButtons(const BRect& invalid) -{ - // Draw the buttons if we're supposed to - if (!(fFlags & B_NOT_CLOSABLE) && invalid.Intersects(fCloseRect)) - _DrawClose(fCloseRect); - - if (fStackedMode) { - // TODO: This should be solved differently. We don't just want to not - // draw the button, we actually want it removed. So rather add extra - // flags to remove the individual buttons to DefaultDecorator. - if (fStackedDrawZoom && invalid.Intersects(fZoomRect)) - _DrawZoom(fZoomRect); - } else if (!(fFlags & B_NOT_ZOOMABLE) && invalid.Intersects(fZoomRect)) - _DrawZoom(fZoomRect); -} - - -void SATDecorator::GetComponentColors(Component component, uint8 highlight, - ComponentColors _colors) + ComponentColors _colors, Decorator::Tab* _tab) { + DefaultDecorator::Tab* tab = static_cast<DefaultDecorator::Tab*>(_tab); // we handle only our own highlights if (highlight != HIGHLIGHT_STACK_AND_TILE) { - DefaultDecorator::GetComponentColors(component, highlight, _colors); + DefaultDecorator::GetComponentColors(component, highlight, + _colors, tab); return; } + if (tab && tab->isHighlighted == false + && (component == COMPONENT_TAB || component == COMPONENT_CLOSE_BUTTON + || component == COMPONENT_ZOOM_BUTTON)) { + DefaultDecorator::GetComponentColors(component, highlight, + _colors, tab); + return; + } + switch (component) { case COMPONENT_TAB: _colors[COLOR_TAB_FRAME_LIGHT] = kFrameColors[0]; Modified: haiku/trunk/src/add-ons/decorators/SATDecorator/SATDecorator.h =================================================================== --- haiku/trunk/src/add-ons/decorators/SATDecorator/SATDecorator.h 2011-07-25 01:09:26 UTC (rev 42478) +++ haiku/trunk/src/add-ons/decorators/SATDecorator/SATDecorator.h 2011-07-25 01:10:02 UTC (rev 42479) @@ -42,35 +42,10 @@ BRect frame, window_look look, uint32 flags); - /*! Indicates that window is stacked */ - void SetStackedMode(bool stacked, BRegion* dirty); - bool StackedMode() const - { return fStackedMode; } - - /*! Set the tab length if the decorator is in stacked mode and if - the tab is the last one in the tab bar. */ - void SetStackedTabLength(float length, - BRegion* dirty); - float StackedTabLength() const - { return fStackedTabLength; } - protected: - void _DoLayout(); - void _LayoutTabItems(const BRect& tabRect); - - bool _SetTabLocation(float location, - BRegion* updateRegion = NULL); - void _SetFocus(); - - virtual void DrawButtons(const BRect& invalid); virtual void GetComponentColors(Component component, - uint8 highlight, ComponentColors _colors); - -private: - bool fStackedMode; - bool fStackedDrawZoom; - float fStackedTabLength; - bool fStackedTabShifting; + uint8 highlight, ComponentColors _colors, + Decorator::Tab* tab = NULL); }; Modified: haiku/trunk/src/add-ons/decorators/SATDecorator/SATWindow.cpp =================================================================== --- haiku/trunk/src/add-ons/decorators/SATDecorator/SATWindow.cpp 2011-07-25 01:09:26 UTC (rev 42478) +++ haiku/trunk/src/add-ons/decorators/SATDecorator/SATWindow.cpp 2011-07-25 01:10:02 UTC (rev 42479) @@ -403,15 +403,17 @@ if (!group || !area) return false; - bool status = group->AddWindow(child, area, this); + if (group->AddWindow(child, area, this) == false) + return false; - if (status) { - area->WindowList().ItemAt(0)->SetStackedMode(true); - // for the case we are the first added window - child->SetStackedMode(true); + DoGroupLayout(); + + if (fWindow->AddWindowToStack(child->GetWindow()) == false) { + group->RemoveWindow(child); + DoGroupLayout(); + return false; } - DoGroupLayout(); return true; } @@ -419,6 +421,7 @@ void SATWindow::RemovedFromArea(WindowArea* area) { + fWindow->DetachFromWindowStack(true); for (int i = 0; i < fSATSnappingBehaviourList.CountItems(); i++) fSATSnappingBehaviourList.ItemAt(i)->RemovedFromArea(area); } @@ -462,22 +465,12 @@ void -SATWindow::DoWindowLayout() -{ - for (int i = 0; i < fSATSnappingBehaviourList.CountItems(); i++) - fSATSnappingBehaviourList.ItemAt(i)->DoWindowLayout(); -} - - -void SATWindow::DoGroupLayout() { if (!PositionManagedBySAT()) return; fGroupCookie->DoGroupLayout(); - - DoWindowLayout(); } @@ -659,15 +652,17 @@ if (!decorator) return false; + int32 tabIndex = fWindow->PositionInStack(); BRegion dirty; uint8 highlight = active ? SATDecorator::HIGHLIGHT_STACK_AND_TILE : 0; - decorator->SetRegionHighlight(SATDecorator::REGION_TAB, highlight, &dirty); - decorator->SetRegionHighlight(SATDecorator::REGION_CLOSE_BUTTON, highlight, - &dirty); - decorator->SetRegionHighlight(SATDecorator::REGION_ZOOM_BUTTON, highlight, - &dirty); + decorator->SetRegionHighlight(Decorator::REGION_TAB, highlight, &dirty, + tabIndex); + decorator->SetRegionHighlight(Decorator::REGION_CLOSE_BUTTON, highlight, + &dirty, tabIndex); + decorator->SetRegionHighlight(Decorator::REGION_ZOOM_BUTTON, highlight, + &dirty, tabIndex); - fWindow->ProcessDirtyRegion(dirty); + fWindow->TopLayerStackWindow()->ProcessDirtyRegion(dirty); return true; } @@ -688,55 +683,6 @@ } -bool -SATWindow::SetStackedMode(bool stacked) -{ - SATDecorator* decorator = GetDecorator(); - if (!decorator) - return false; - BRegion dirty; - decorator->SetStackedMode(stacked, &dirty); - fDesktop->RebuildAndRedrawAfterWindowChange(fWindow, dirty); - return true; -} - - -bool -SATWindow::SetStackedTabLength(float length) -{ - SATDecorator* decorator = GetDecorator(); - if (!decorator) - return false; - BRegion dirty; - decorator->SetStackedTabLength(length, &dirty); - fDesktop->RebuildAndRedrawAfterWindowChange(fWindow, dirty); - return true; -} - - -bool -SATWindow::SetStackedTabMoving(bool moving) -{ - SATDecorator* decorator = GetDecorator(); - if (!decorator) - return false; - - if (!moving) - DoGroupLayout(); - - return true; -} - - -void -SATWindow::TabLocationMoved(float location, bool shifting) -{ - for (int i = 0; i < fSATSnappingBehaviourList.CountItems(); i++) - fSATSnappingBehaviourList.ItemAt(i)->TabLocationMoved(location, - shifting); -} - - uint64 SATWindow::Id() { @@ -814,7 +760,7 @@ SATDecorator* decorator = GetDecorator(); if (decorator == NULL) return; - BRect tabRect = decorator->TabRect(); + BRect tabRect = decorator->TitleBarRect(); if (mousePosition.y < tabRect.bottom && mousePosition.y > tabRect.top && mousePosition.x <= frame.right + decorator->BorderWidth() +1 && mousePosition.x >= frame.left + decorator->BorderWidth()) { Modified: haiku/trunk/src/add-ons/decorators/SATDecorator/SATWindow.h =================================================================== --- haiku/trunk/src/add-ons/decorators/SATDecorator/SATWindow.h 2011-07-25 01:09:26 UTC (rev 42478) +++ haiku/trunk/src/add-ons/decorators/SATDecorator/SATWindow.h 2011-07-25 01:10:02 UTC (rev 42479) @@ -104,7 +104,6 @@ void FindSnappingCandidates(); bool JoinCandidates(); - void DoWindowLayout(); void DoGroupLayout(); void AdjustSizeLimits(BRect targetFrame); @@ -134,11 +133,6 @@ bool IsTabHighlighted(); bool IsBordersHighlighted(); - bool SetStackedMode(bool stacked = true); - bool SetStackedTabLength(float length); - bool SetStackedTabMoving(bool moving = true); - void TabLocationMoved(float location, bool shifting); - uint64 Id(); bool SetSettings(const BMessage& message); Modified: haiku/trunk/src/add-ons/decorators/SATDecorator/StackAndTile.cpp =================================================================== --- haiku/trunk/src/add-ons/decorators/SATDecorator/StackAndTile.cpp 2011-07-25 01:09:26 UTC (rev 42478) +++ haiku/trunk/src/add-ons/decorators/SATDecorator/StackAndTile.cpp 2011-07-25 01:10:02 UTC (rev 42479) @@ -26,8 +26,7 @@ : fDesktop(NULL), fSATKeyPressed(false), - fCurrentSATWindow(NULL), - fTabIsShifting(false) + fCurrentSATWindow(NULL) { } @@ -218,7 +217,8 @@ if (message->FindInt32("clicks") == 2) return; - switch (satWindow->GetDecorator()->RegionAt(where)) { + int32 tab; + switch (satWindow->GetDecorator()->RegionAt(where, tab)) { case Decorator::REGION_TAB: case Decorator::REGION_LEFT_BORDER: case Decorator::REGION_RIGHT_BORDER: @@ -247,15 +247,6 @@ void StackAndTile::MouseUp(Window* window, BMessage* message, const BPoint& where) { - if (fTabIsShifting) { - SATWindow* satWindow = GetSATWindow(window); - if (satWindow) { - fTabIsShifting = false; - satWindow->TabLocationMoved(satWindow->GetWindow()->TabLocation(), - fTabIsShifting); - } - } - if (fSATKeyPressed) _StopSAT(); @@ -287,20 +278,8 @@ if (SATKeyPressed() && fCurrentSATWindow) satWindow->FindSnappingCandidates(); - else { + else satWindow->DoGroupLayout(); - - // Do a window layout for all windows. TODO: maybe do it a bit more - // efficient - SATGroup* group = satWindow->GetGroup(); - if (!group) - return; - for (int i = 0; i < group->CountItems(); i++) { - SATWindow* listWindow = group->WindowAt(i); - if (listWindow != satWindow) - listWindow->DoWindowLayout(); - } - } } @@ -379,14 +358,10 @@ void -StackAndTile::WindowTabLocationChanged(Window* window, float location) +StackAndTile::WindowTabLocationChanged(Window* window, float location, + bool isShifting) { - SATWindow* satWindow = GetSATWindow(window); - if (!satWindow) - return; - fTabIsShifting = true; - satWindow->TabLocationMoved(location, fTabIsShifting); } Modified: haiku/trunk/src/add-ons/decorators/SATDecorator/StackAndTile.h =================================================================== --- haiku/trunk/src/add-ons/decorators/SATDecorator/StackAndTile.h 2011-07-25 01:09:26 UTC (rev 42478) +++ haiku/trunk/src/add-ons/decorators/SATDecorator/StackAndTile.h 2011-07-25 01:10:02 UTC (rev 42479) @@ -74,7 +74,7 @@ virtual void WindowMinimized(Window* window, bool minimize); virtual void WindowTabLocationChanged(Window* window, - float location); + float location, bool isShifting); virtual void SizeLimitsChanged(Window* window, int32 minWidth, int32 maxWidth, int32 minHeight, int32 maxHeight); @@ -107,8 +107,6 @@ SATWindowList fGrouplessWindows; SATWindow* fCurrentSATWindow; - - bool fTabIsShifting; }; @@ -167,7 +165,6 @@ virtual bool JoinCandidates() = 0; /*! Update the window tab values, solve the layout and move all windows in the group accordantly. */ - virtual void DoWindowLayout() = 0; virtual void RemovedFromArea(WindowArea* area) {} virtual void TabLocationMoved(float location, bool shifting) {} Modified: haiku/trunk/src/add-ons/decorators/SATDecorator/Stacking.cpp =================================================================== --- haiku/trunk/src/add-ons/decorators/SATDecorator/Stacking.cpp 2011-07-25 01:09:26 UTC (rev 42478) +++ haiku/trunk/src/add-ons/decorators/SATDecorator/Stacking.cpp 2011-07-25 01:10:02 UTC (rev 42479) @@ -227,11 +227,11 @@ BPoint mousePosition; int32 buttons; fSATWindow->GetDesktop()->GetLastMouseState(&mousePosition, &buttons); - if (!window->Decorator()->TabRect().Contains(mousePosition)) + if (!window->Decorator()->TitleBarRect().Contains(mousePosition)) return false; // use the upper edge of the candidate window to find the parent window - mousePosition.y = window->Decorator()->TabRect().top; + mousePosition.y = window->Decorator()->TitleBarRect().top; for (int i = 0; i < group->CountItems(); i++) { SATWindow* satWindow = group->WindowAt(i); @@ -239,7 +239,10 @@ Window* win = satWindow->GetWindow(); if (win == window || !win->Decorator()) continue; - if (win->Decorator()->TabRect().Contains(mousePosition)) { + Decorator::Tab* tab = win->Decorator()->TabAt(win->PositionInStack()); + if (tab == NULL) + continue; + if (tab->tabRect.Contains(mousePosition)) { // remember window as the parent for stacking fStackingParent = satWindow; _HighlightWindows(true); @@ -265,67 +268,15 @@ void -SATStacking::DoWindowLayout() -{ - _AdjustWindowTabs(); -} - - -void SATStacking::RemovedFromArea(WindowArea* area) { const SATWindowList& list = area->WindowList(); - if (list.CountItems() == 1) - list.ItemAt(0)->SetStackedMode(false); - else if (list.CountItems() > 0) + if (list.CountItems() > 0) list.ItemAt(0)->DoGroupLayout(); - - fSATWindow->SetStackedMode(false); } void -SATStacking::TabLocationMoved(float location, bool shifting) -{ - if (!shifting) { - _AdjustWindowTabs(); - return; - } - - SATDecorator* decorator = fSATWindow->GetDecorator(); - Desktop* desktop = fSATWindow->GetWindow()->Desktop(); - WindowArea* area = fSATWindow->GetWindowArea(); - if (!desktop || !area || ! decorator) - return; - - const SATWindowList& stackedWindows = area->WindowList(); - ASSERT(stackedWindows.CountItems() > 0); - int32 windowIndex = stackedWindows.IndexOf(fSATWindow); - ASSERT(windowIndex >= 0); - float tabLength = stackedWindows.ItemAt(0)->GetDecorator() - ->StackedTabLength(); - - float oldTabPosition = windowIndex * (tabLength + 1); - if (fabs(oldTabPosition - location) < tabLength / 2) - return; - - int32 neighbourIndex = windowIndex; - if (oldTabPosition > location) - neighbourIndex--; - else - neighbourIndex++; - - SATWindow* neighbour = stackedWindows.ItemAt(neighbourIndex); - if (!neighbour) - return; - - float newNeighbourPosition = windowIndex * (tabLength + 1); - area->MoveWindowToPosition(fSATWindow, neighbourIndex); - desktop->SetWindowTabLocation(neighbour->GetWindow(), newNeighbourPosition); -} - - -void SATStacking::_ClearSearchResult() { if (!fStackingParent) @@ -345,46 +296,3 @@ fStackingParent->HighlightTab(highlight); fSATWindow->HighlightTab(highlight); } - - -bool -SATStacking::_AdjustWindowTabs() -{ - SATDecorator* decorator = fSATWindow->GetDecorator(); - Desktop* desktop = fSATWindow->GetWindow()->Desktop(); - WindowArea* area = fSATWindow->GetWindowArea(); - if (!desktop || !area || ! decorator) - return false; - - if (!decorator->StackedMode()) - return false; - - BRect frame = fSATWindow->CompleteWindowFrame(); - - const SATWindowList& stackedWindows = area->WindowList(); - - int stackCount = stackedWindows.CountItems(); - float titleBarLength = frame.Width(); - ASSERT(titleBarLength > 0); - // floor to avoid drawing issues - float tabLength = floorf(titleBarLength / stackCount); - // the part that we lost due to the floor - float roundingError = 0; - if (tabLength > kMaxTabWidth) - tabLength = kMaxTabWidth; - else - roundingError = titleBarLength - stackCount * tabLength; - - float location = 0; - for (int i = 0; i < stackCount; i++) { - SATWindow* window = stackedWindows.ItemAt(i); - if (i == stackCount - 1) - window->SetStackedTabLength(tabLength - 1 + roundingError); - else - window->SetStackedTabLength(tabLength - 1); - - desktop->SetWindowTabLocation(window->GetWindow(), location); - location += tabLength; - } - return true; -} Modified: haiku/trunk/src/add-ons/decorators/SATDecorator/Stacking.h =================================================================== --- haiku/trunk/src/add-ons/decorators/SATDecorator/Stacking.h 2011-07-25 01:09:26 UTC (rev 42478) +++ haiku/trunk/src/add-ons/decorators/SATDecorator/Stacking.h 2011-07-25 01:10:02 UTC (rev 42479) @@ -34,12 +34,10 @@ void DoWindowLayout(); void RemovedFromArea(WindowArea* area); - void TabLocationMoved(float location, bool shifting); private: void _ClearSearchResult(); void _HighlightWindows(bool highlight = true); - bool _AdjustWindowTabs(); SATWindow* fSATWindow; Modified: haiku/trunk/src/add-ons/decorators/SATDecorator/Tiling.cpp =================================================================== --- haiku/trunk/src/add-ons/decorators/SATDecorator/Tiling.cpp 2011-07-25 01:09:26 UTC (rev 42478) +++ haiku/trunk/src/add-ons/decorators/SATDecorator/Tiling.cpp 2011-07-25 01:10:02 UTC (rev 42479) @@ -78,13 +78,6 @@ } -void -SATTiling::DoWindowLayout() -{ - -} - - bool SATTiling::_FindFreeAreaInGroup(SATGroup* group) { Modified: haiku/trunk/src/add-ons/decorators/SATDecorator/Tiling.h =================================================================== --- haiku/trunk/src/add-ons/decorators/SATDecorator/Tiling.h 2011-07-25 01:09:26 UTC (rev 42478) +++ haiku/trunk/src/add-ons/decorators/SATDecorator/Tiling.h 2011-07-25 01:10:02 UTC (rev 42479) @@ -24,7 +24,6 @@ bool FindSnappingCandidates(SATGroup* group); bool JoinCandidates(); - void DoWindowLayout(); private: bool _FindFreeAreaInGroup(SATGroup* group);