From d4bbf5c221f103c292fb93167b559469982f7e04 Mon Sep 17 00:00:00 2001 From: Clemens Zeidler Date: Thu, 2 Sep 2010 23:58:26 +0000 Subject: [PATCH] Clean up. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38515 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../decorators/SATDecorator/SATWindow.cpp | 65 +++++++------------ .../decorators/SATDecorator/SATWindow.h | 6 +- .../decorators/SATDecorator/StackAndTile.cpp | 3 - 3 files changed, 26 insertions(+), 48 deletions(-) diff --git a/src/add-ons/decorators/SATDecorator/SATWindow.cpp b/src/add-ons/decorators/SATDecorator/SATWindow.cpp index cbe749662f..cc6693069a 100644 --- a/src/add-ons/decorators/SATDecorator/SATWindow.cpp +++ b/src/add-ons/decorators/SATDecorator/SATWindow.cpp @@ -51,6 +51,9 @@ GroupCookie::~GroupCookie() } +const uint32 kExtentPenalty = 10; + + void GroupCookie::DoGroupLayout(SATWindow* triggerWindow) { @@ -89,12 +92,13 @@ GroupCookie::DoGroupLayout(SATWindow* triggerWindow) break; } } + _UpdateWindowSize(frame); // set penalties back to normal - fWidthConstraint->SetPenaltyNeg(10); - fWidthConstraint->SetPenaltyPos(10); - fHeightConstraint->SetPenaltyNeg(10); - fHeightConstraint->SetPenaltyPos(10); + fWidthConstraint->SetPenaltyNeg(kExtentPenalty); + fWidthConstraint->SetPenaltyPos(kExtentPenalty); + fHeightConstraint->SetPenaltyNeg(kExtentPenalty); + fHeightConstraint->SetPenaltyPos(kExtentPenalty); fLeftConstraint->SetPenaltyNeg(1); fLeftConstraint->SetPenaltyPos(1); @@ -118,17 +122,8 @@ GroupCookie::MoveWindow(int32 workspace) fTopBorder->Value() - frame.top); desktop->ResizeWindowBy(window, fRightBorder->Value() - frame.right, fBottomBorder->Value() - frame.bottom); -} - -void -GroupCookie::UpdateWindowSize() -{ - BRect frame = fSATWindow->CompleteWindowFrame(); - - // adjust window size soft constraints - fWidthConstraint->SetRightSide(frame.Width()); - fHeightConstraint->SetRightSide(frame.Height()); + _UpdateWindowSize(frame); } @@ -167,15 +162,17 @@ GroupCookie::Init(SATGroup* group, WindowArea* area) fRightBorder, OperatorType(LE), -minWidth); fMinHeightConstraint = linearSpec->AddConstraint(1.0, fTopBorder, -1.0, fBottomBorder, OperatorType(LE), -minHeight); - + // The width and height constraints have higher penalties than the // position constraints (left, top), so a window will keep its size // unless explicitly resized. fWidthConstraint = linearSpec->AddConstraint(-1.0, fLeftBorder, 1.0, - fRightBorder, OperatorType(EQ), frame.Width(), 10, 10); + fRightBorder, OperatorType(EQ), frame.Width(), kExtentPenalty, + kExtentPenalty); fHeightConstraint = linearSpec->AddConstraint(-1.0, fTopBorder, 1.0, - fBottomBorder, OperatorType(EQ), frame.Height(), 10, 10); - + fBottomBorder, OperatorType(EQ), frame.Height(), kExtentPenalty, + kExtentPenalty); + if (!fLeftConstraint || !fTopConstraint || !fMinWidthConstraint || !fMinHeightConstraint || !fWidthConstraint || !fHeightConstraint) { // clean up @@ -256,6 +253,15 @@ GroupCookie::PropagateToGroup(SATGroup* group, WindowArea* area) } +void +GroupCookie::_UpdateWindowSize(const BRect& frame) +{ + // adjust window size soft constraints + fWidthConstraint->SetRightSide(frame.Width()); + fHeightConstraint->SetRightSide(frame.Height()); +} + + SATWindow::SATWindow(StackAndTile* sat, Window* window) : fWindow(window), @@ -327,29 +333,6 @@ SATWindow::PropagateToGroup(SATGroup* group, WindowArea* area) } -void -SATWindow::UpdateGroupWindowsSize() -{ - SATGroup* group = GetGroup(); - if (!group) - return; - - for (int i = 0; i < group->CountItems(); i++) { - SATWindow* window = group->WindowAt(i); - if (window == this) - continue; - window->UpdateWindowSize(); - } -} - - -void -SATWindow::UpdateWindowSize() -{ - fGroupCookie->UpdateWindowSize(); -} - - void SATWindow::MoveWindowToSAT(int32 workspace) { diff --git a/src/add-ons/decorators/SATDecorator/SATWindow.h b/src/add-ons/decorators/SATDecorator/SATWindow.h index 086914f595..8b9c556e83 100644 --- a/src/add-ons/decorators/SATDecorator/SATWindow.h +++ b/src/add-ons/decorators/SATDecorator/SATWindow.h @@ -32,7 +32,6 @@ public: void DoGroupLayout(SATWindow* triggerWindow); void MoveWindow(int32 workspace); - void UpdateWindowSize(); SATGroup* GetGroup() { return fSATGroup.Get(); } @@ -41,6 +40,8 @@ public: bool PropagateToGroup(SATGroup* group, WindowArea* area); private: + void _UpdateWindowSize(const BRect& frame); + SATWindow* fSATWindow; BReference fSATGroup; @@ -85,9 +86,6 @@ public: bool PropagateToGroup(SATGroup* group, WindowArea* area); - void UpdateGroupWindowsSize(); - void UpdateWindowSize(); - //! Move the window to the tab's position. void MoveWindowToSAT(int32 workspace); diff --git a/src/add-ons/decorators/SATDecorator/StackAndTile.cpp b/src/add-ons/decorators/SATDecorator/StackAndTile.cpp index 43156e5b2c..47cf0d47fe 100644 --- a/src/add-ons/decorators/SATDecorator/StackAndTile.cpp +++ b/src/add-ons/decorators/SATDecorator/StackAndTile.cpp @@ -182,9 +182,6 @@ StackAndTile::WindowResized(Window* window) satWindow->FindSnappingCandidates(); else { satWindow->DoGroupLayout(); - // after solve the layout update the size constraints of all windows in - // the group - satWindow->UpdateGroupWindowsSize(); // Do a window layout for all windows. TODO: mybe do it a bit more // efficient