[haiku-commits] r42280 - haiku/trunk/src/add-ons/decorators/SATDecorator

  • From: clemens.zeidler@xxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 22 Jun 2011 07:22:04 +0200 (CEST)

Author: czeidler
Date: 2011-06-22 07:22:04 +0200 (Wed, 22 Jun 2011)
New Revision: 42280
Changeset: https://dev.haiku-os.org/changeset/42280

Modified:
   haiku/trunk/src/add-ons/decorators/SATDecorator/SATGroup.cpp
   haiku/trunk/src/add-ons/decorators/SATDecorator/SATGroup.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
Log:
- Use soft inequality constraints to describe the window max size. This means 
the max size of a window is only violated when it is really necessary. In this 
case the affected windows get a temporary sufficient large max size limit.
- When resizing a window the window size constraint stays soft when solving the 
layout. This makes sure that the layout constraints can be fulfilled. Fixes 
r41759.
- Some other refactoring.

S&T should work much better now. Sorry that I wasn't able to finish it before 
a3.



Modified: haiku/trunk/src/add-ons/decorators/SATDecorator/SATGroup.cpp
===================================================================
--- haiku/trunk/src/add-ons/decorators/SATDecorator/SATGroup.cpp        
2011-06-21 22:59:54 UTC (rev 42279)
+++ haiku/trunk/src/add-ons/decorators/SATDecorator/SATGroup.cpp        
2011-06-22 05:22:04 UTC (rev 42280)
@@ -78,31 +78,6 @@
 }
 
 
-void
-WindowArea::UpdateSizeLimits()
-{
-       int32 minWidth, maxWidth, minHeight, maxHeight;
-       minWidth = minHeight = 1;
-       maxWidth = maxHeight = 1;
-
-       for (int i = 0; i < fWindowList.CountItems(); i++) {
-               int32 minW, maxW, minH, maxH;
-               fWindowList.ItemAt(i)->GetSizeLimits(&minW, &maxW, &minH, 
&maxH);
-               if (minW > minWidth)
-                       minWidth = minW;
-               if (maxW > maxWidth)
-                       maxWidth = maxW;
-               if (minH > minHeight)
-                       minHeight = minH;
-               if (maxH > maxHeight)
-                       maxHeight = maxH;
-       }
-       for (int i = 0; i < fWindowList.CountItems(); i++)
-               fWindowList.ItemAt(i)->SetSizeLimits(minWidth, maxWidth, 
minHeight,
-                       maxHeight);
-}
-
-
 bool
 WindowArea::_AddWindow(SATWindow* window, SATWindow* after)
 {
@@ -719,10 +694,13 @@
        if (area)
                area->_RemoveWindow(window);
 
-       for (int i = 0; i < CountItems(); i++)
-               WindowAt(i)->DoGroupLayout();
+       int32 windowCount = CountItems();
 
        window->RemovedFromGroup(this, stayBelowMouse);
+
+       if (windowCount >= 2)
+               WindowAt(0)->DoGroupLayout();
+
        // Do nothing after removing the window from the group because this
        // could have released the last reference and destroyed ourself.
        return true;

Modified: haiku/trunk/src/add-ons/decorators/SATDecorator/SATGroup.h
===================================================================
--- haiku/trunk/src/add-ons/decorators/SATDecorator/SATGroup.h  2011-06-21 
22:59:54 UTC (rev 42279)
+++ haiku/trunk/src/add-ons/decorators/SATDecorator/SATGroup.h  2011-06-22 
05:22:04 UTC (rev 42280)
@@ -105,6 +105,7 @@
                        float                           Position() const;
                        void                            SetPosition(float 
position);
                        orientation_t           Orientation() const;
+                       Variable*                       Var() { return 
fVariable;       }
 
                        //! Caller takes ownership of the constraint.
                        Constraint*                     Connect(Variable* 
variable);
@@ -143,7 +144,6 @@
        const   SATWindowList&          LayerOrder() { return 
fWindowLayerOrder; }
                        bool                            
MoveWindowToPosition(SATWindow* window,
                                                                        int32 
index);
-                       void                            UpdateSizeLimits();
 
                        Crossing*                       LeftTopCrossing()
                                                                        { 
return fLeftTopCrossing.Get(); }

Modified: haiku/trunk/src/add-ons/decorators/SATDecorator/SATWindow.cpp
===================================================================
--- haiku/trunk/src/add-ons/decorators/SATDecorator/SATWindow.cpp       
2011-06-21 22:59:54 UTC (rev 42279)
+++ haiku/trunk/src/add-ons/decorators/SATDecorator/SATWindow.cpp       
2011-06-22 05:22:04 UTC (rev 42280)
@@ -22,7 +22,9 @@
 using namespace LinearProgramming;
 
 
-const uint32 kExtentPenalty = 10;
+const float kExtentPenalty = 1;
+const float kHighPenalty = 10;
+const float kInequalityPenalty = 10000;
 
 
 GroupCookie::GroupCookie(SATWindow* satWindow)
@@ -36,15 +38,10 @@
        fRightBorder(NULL),
        fBottomBorder(NULL),
 
-       fLeftBorderConstraint(NULL),
-       fTopBorderConstraint(NULL),
-       fRightBorderConstraint(NULL),
-       fBottomBorderConstraint(NULL),
-
-       fLeftConstraint(NULL),
-       fTopConstraint(NULL),
        fMinWidthConstraint(NULL),
        fMinHeightConstraint(NULL),
+       fMaxWidthConstraint(NULL),
+       fMaxHeightConstraint(NULL),
        fWidthConstraint(NULL),
        fHeightConstraint(NULL)
 {
@@ -58,12 +55,12 @@
 
 
 void
-GroupCookie::DoGroupLayout(SATWindow* triggerWindow)
+GroupCookie::DoGroupLayout()
 {
        if (!fSATGroup.Get())
                return;
 
-       BRect frame = triggerWindow->CompleteWindowFrame();
+       BRect frame = fSATWindow->CompleteWindowFrame();
        // Make it also work for solver which don't support negative variables
        frame.OffsetBy(kMakePositiveOffset, kMakePositiveOffset);
 
@@ -72,17 +69,16 @@
        fHeightConstraint->SetRightSide(frame.Height());
 
        LinearSpec* linearSpec = fSATGroup->GetLinearSpec();
-       fLeftConstraint = linearSpec->AddConstraint(1.0, fLeftBorder, kEQ,
-               frame.left);
-       fTopConstraint  = linearSpec->AddConstraint(1.0, fTopBorder, kEQ,
+       Constraint* leftConstraint = linearSpec->AddConstraint(1.0, fLeftBorder,
+               kEQ, frame.left);
+       Constraint* topConstraint = linearSpec->AddConstraint(1.0, fTopBorder, 
kEQ,
                frame.top);
 
-       // adjust window position soft constraints
-       // (a bit more penalty for them so they take precedence)
-       fWidthConstraint->SetPenaltyNeg(-1);
-       fWidthConstraint->SetPenaltyPos(-1);
-       fHeightConstraint->SetPenaltyNeg(-1);
-       fHeightConstraint->SetPenaltyPos(-1);
+       // give soft constraints a high penalty
+       fWidthConstraint->SetPenaltyNeg(kHighPenalty);
+       fWidthConstraint->SetPenaltyPos(kHighPenalty);
+       fHeightConstraint->SetPenaltyNeg(kHighPenalty);
+       fHeightConstraint->SetPenaltyPos(kHighPenalty);
 
        // After we set the new parameter solve and apply the new layout.
        ResultType result;
@@ -93,8 +89,7 @@
                        break;
                }
                if (result == kOptimal) {
-                       fSATGroup->AdjustWindows(triggerWindow);
-                       _UpdateWindowSize(frame);
+                       fSATGroup->AdjustWindows(fSATWindow);
                        break;
                }
        }
@@ -105,10 +100,8 @@
        fHeightConstraint->SetPenaltyNeg(kExtentPenalty);
        fHeightConstraint->SetPenaltyPos(kExtentPenalty);
 
-       linearSpec->RemoveConstraint(fLeftConstraint);
-       fLeftConstraint = NULL;
-       linearSpec->RemoveConstraint(fTopConstraint);
-       fTopConstraint = NULL;
+       linearSpec->RemoveConstraint(leftConstraint);
+       linearSpec->RemoveConstraint(topConstraint);
 }
 
 
@@ -124,6 +117,7 @@
                fRightBorder->Value() - kMakePositiveOffset,
                fBottomBorder->Value() - kMakePositiveOffset);
 
+       fSATWindow->AdjustSizeLimits(frameSAT);
        desktop->MoveWindowBy(window, round(frameSAT.left - frame.left),
                round(frameSAT.top - frame.top), workspace);
 
@@ -133,7 +127,7 @@
        desktop->ResizeWindowBy(window, round(frameSAT.right - frame.right),
                round(frameSAT.bottom - frame.bottom));
 
-       _UpdateWindowSize(frame);
+       UpdateSizeConstaints(frameSAT);
 }
 
 
@@ -143,9 +137,22 @@
 {
        fMinWidthConstraint->SetRightSide(minWidth);
        fMinHeightConstraint->SetRightSide(minHeight);
+       fMaxWidthConstraint->SetRightSide(maxWidth);
+       fMaxHeightConstraint->SetRightSide(maxHeight);
 }
 
 
+void
+GroupCookie::UpdateSizeConstaints(const BRect& frame)
+{
+       // adjust window size soft constraints
+       if (fSATWindow->IsHResizeable() == true)
+               fWidthConstraint->SetRightSide(frame.Width());
+       if (fSATWindow->IsVResizeable() == true)
+               fHeightConstraint->SetRightSide(frame.Height());
+}
+
+
 bool
 GroupCookie::Init(SATGroup* group, WindowArea* area)
 {
@@ -156,56 +163,44 @@
 
        LinearSpec* linearSpec = group->GetLinearSpec();
        // create variables
-       fLeftBorder = linearSpec->AddVariable();
-       fTopBorder = linearSpec->AddVariable();
-       fRightBorder = linearSpec->AddVariable();
-       fBottomBorder = linearSpec->AddVariable();
+       fLeftBorder = area->LeftTab()->Var();
+       fTopBorder = area->TopTab()->Var();
+       fRightBorder = area->RightTab()->Var();
+       fBottomBorder = area->BottomTab()->Var();
 
-       if (!fLeftBorder || !fTopBorder || !fRightBorder || !fBottomBorder) {
-               // clean up
-               Uninit();
-               return false;
-       }
+       // size limit constraints
+       int32 minWidth, maxWidth;
+       int32 minHeight, maxHeight;
+       fSATWindow->GetSizeLimits(&minWidth, &maxWidth, &minHeight, &maxHeight);
+       fSATWindow->AddDecorator(&minWidth, &maxWidth, &minHeight, &maxHeight);
 
-       // create constraints
-       BRect frame = fSATWindow->CompleteWindowFrame();
-
-       int32 minWidth, maxWidth, minHeight, maxHeight;
-       fSATWindow->GetSizeLimits(&minWidth, &maxWidth, &minHeight,
-               &maxHeight);
        fMinWidthConstraint = linearSpec->AddConstraint(1.0, fRightBorder, -1.0,
                fLeftBorder, kGE, minWidth);
        fMinHeightConstraint = linearSpec->AddConstraint(1.0, fBottomBorder, 
-1.0,
                fTopBorder, kGE, 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, kEQ, frame.Width(), kExtentPenalty,
+       fMaxWidthConstraint = linearSpec->AddConstraint(1.0, fRightBorder, -1.0,
+               fLeftBorder, kLE, maxWidth, kInequalityPenalty, 
kInequalityPenalty);
+       fMaxHeightConstraint = linearSpec->AddConstraint(1.0, fBottomBorder, 
-1.0,
+               fTopBorder, kLE, maxHeight, kInequalityPenalty, 
kInequalityPenalty);
+
+       // Width and height have soft constraints
+       BRect frame = fSATWindow->CompleteWindowFrame();
+       fWidthConstraint = linearSpec->AddConstraint(1.0, fRightBorder, -1.0,
+               fLeftBorder, kEQ, frame.Width(), kExtentPenalty,
                kExtentPenalty);
        fHeightConstraint = linearSpec->AddConstraint(-1.0, fTopBorder, 1.0,
                fBottomBorder, kEQ, frame.Height(), kExtentPenalty,
                kExtentPenalty);
 
-       if (!fMinWidthConstraint
-               || !fMinHeightConstraint || !fWidthConstraint || 
!fHeightConstraint) {
+       if (!fMinWidthConstraint || !fMinHeightConstraint || !fWidthConstraint
+               || !fHeightConstraint || !fMaxWidthConstraint
+               || !fMaxHeightConstraint) {
                // clean up
                Uninit();
                return false;
        }
 
-       fLeftBorderConstraint = area->LeftTab()->Connect(fLeftBorder);
-       fTopBorderConstraint = area->TopTab()->Connect(fTopBorder);
-       fRightBorderConstraint = area->RightTab()->Connect(fRightBorder);
-       fBottomBorderConstraint = area->BottomTab()->Connect(fBottomBorder);
-
-       if (!fLeftBorderConstraint || !fTopBorderConstraint
-               || !fRightBorderConstraint || !fBottomBorderConstraint) {
-               Uninit();
-               return false;
-       }
-
        return true;
 }
 
@@ -213,34 +208,21 @@
 void
 GroupCookie::Uninit()
 {
-       delete fLeftBorder;
-       delete fTopBorder;
-       delete fRightBorder;
-       delete fBottomBorder;
        fLeftBorder = NULL;
        fTopBorder = NULL;
        fRightBorder = NULL;
        fBottomBorder = NULL;
 
-       delete fLeftBorderConstraint;
-       delete fTopBorderConstraint;
-       delete fRightBorderConstraint;
-       delete fBottomBorderConstraint;
-       fLeftBorderConstraint = NULL;
-       fTopBorderConstraint = NULL;
-       fRightBorderConstraint = NULL;
-       fBottomBorderConstraint = NULL;
-
-       delete fLeftConstraint;
-       delete fTopConstraint;
        delete fMinWidthConstraint;
        delete fMinHeightConstraint;
+       delete fMaxWidthConstraint;
+       delete fMaxHeightConstraint;
        delete fWidthConstraint;
        delete fHeightConstraint;
-       fLeftConstraint = NULL;
-       fTopConstraint = NULL;
        fMinWidthConstraint = NULL;
        fMinHeightConstraint = NULL;
+       fMaxWidthConstraint = NULL;
+       fMaxHeightConstraint = NULL;
        fWidthConstraint = NULL;
        fHeightConstraint = NULL;
 
@@ -268,15 +250,6 @@
 }
 
 
-void
-GroupCookie::_UpdateWindowSize(const BRect& frame)
-{
-       // adjust window size soft constraints
-       fWidthConstraint->SetRightSide(frame.Width());
-       fHeightConstraint->SetRightSide(frame.Height());
-}
-
-
 // #pragma mark -
 
 
@@ -297,16 +270,18 @@
 
        fDesktop = fWindow->Desktop();
 
+       // read initial limit values
+       fWindow->GetSizeLimits(&fOriginalMinWidth, &fOriginalMaxWidth,
+               &fOriginalMinHeight, &fOriginalMaxHeight);
+       BRect frame = fWindow->Frame();
+       fOriginalWidth = frame.Width();
+       fOriginalHeight = frame.Height();
+
        fGroupCookie = &fOwnGroupCookie;
        _InitGroup();
 
        fSATSnappingBehaviourList.AddItem(&fSATStacking);
        fSATSnappingBehaviourList.AddItem(&fSATTiling);
-
-       // read initial limit values
-       fWindow->GetSizeLimits(&fOriginalMinWidth, &fOriginalMaxWidth,
-               &fOriginalMinHeight, &fOriginalMaxHeight);
-       Resized();
 }
 
 
@@ -392,11 +367,6 @@
                return false;
        }
 
-       if (group->CountItems() > 1)
-               area->UpdateSizeLimits();
-
-       if (group->CountItems() == 2)
-               group->WindowAt(0)->_UpdateSizeLimits();
        return true;
 }
 
@@ -408,8 +378,6 @@
                fWindow->Title());
 
        _RestoreOriginalSize(stayBelowMouse);
-       if (group->CountItems() == 1)
-               group->WindowAt(0)->_RestoreOriginalSize(false);
 
        if (fShutdown) {
                fGroupCookie->Uninit();
@@ -507,72 +475,174 @@
        if (!PositionManagedBySAT())
                return;
 
-       fGroupCookie->DoGroupLayout(this);
+       fGroupCookie->DoGroupLayout();
 
        DoWindowLayout();
 }
 
 
 void
-SATWindow::SetSizeLimits(int32 minWidth, int32 maxWidth, int32 minHeight,
-       int32 maxHeight)
+SATWindow::AdjustSizeLimits(BRect targetFrame)
 {
-       _UpdateSizeLimits();
+       SATDecorator* decorator = GetDecorator();
+       if (decorator == NULL)
+               return;
+
+       targetFrame.right -= 2 * (int32)decorator->BorderWidth();
+       targetFrame.bottom -= 2 * (int32)decorator->BorderWidth()
+               + (int32)decorator->TabHeight() + 1;
+
+       int32 minWidth, maxWidth;
+       int32 minHeight, maxHeight;
+       GetSizeLimits(&minWidth, &maxWidth, &minHeight, &maxHeight);
+
+       if (maxWidth < targetFrame.Width())
+               maxWidth = targetFrame.IntegerWidth();
+       if (maxHeight < targetFrame.Height())
+               maxHeight = targetFrame.IntegerHeight();
+
+       fWindow->SetSizeLimits(minWidth, maxWidth, minHeight, maxHeight);
 }
 
 
 void
-SATWindow::Resized()
+SATWindow::GetSizeLimits(int32* minWidth, int32* maxWidth, int32* minHeight,
+       int32* maxHeight) const
 {
-       BRect frame = fWindow->Frame();
-       fOriginalWidth = frame.Width();
-       fOriginalHeight = frame.Height();
+       *minWidth = fOriginalMinWidth;
+       *minHeight = fOriginalMinHeight;
+       *maxWidth = fOriginalMaxWidth;
+       *maxHeight = fOriginalMaxHeight;
+
+       SATDecorator* decorator = GetDecorator();
+       if (decorator == NULL)
+               return;
+
+       int32 minDecorWidth = 1, maxDecorWidth = 1;
+       int32 minDecorHeight = 1, maxDecorHeight = 1;
+       decorator->GetSizeLimits(&minDecorWidth, &minDecorHeight,
+               &maxDecorWidth, &maxDecorHeight);
+
+       // if no size limit is set but the window is not resizeable choose the
+       // current size as limit
+       if (IsHResizeable() == false && fOriginalMinWidth <= minDecorWidth)
+               *minWidth = (int32)fOriginalWidth;
+       if (IsVResizeable() == false && fOriginalMinHeight <= minDecorHeight)
+               *minHeight = (int32)fOriginalHeight;
+
+       if (*minWidth > *maxWidth)
+               *maxWidth = *minWidth;
+       if (*minHeight > *maxHeight)
+               *maxHeight = *minHeight;
 }
 
 
-BRect
-SATWindow::CompleteWindowFrame()
+void
+SATWindow::AddDecorator(int32* minWidth, int32* maxWidth, int32* minHeight,
+       int32* maxHeight)
 {
-       BRect frame = fWindow->Frame();
-       if (fDesktop
-               && fDesktop->CurrentWorkspace() != fWindow->CurrentWorkspace()) 
{
-               window_anchor& anchor = 
fWindow->Anchor(fWindow->CurrentWorkspace());
-               if (anchor.position != kInvalidWindowPosition)
-                       frame.OffsetTo(anchor.position);
-       }
+       SATDecorator* decorator = GetDecorator();
+       if (decorator == NULL)
+               return;
 
+       *minWidth += 2 * (int32)decorator->BorderWidth();
+       *minHeight += 2 * (int32)decorator->BorderWidth()
+               + (int32)decorator->TabHeight() + 1;
+       *maxWidth += 2 * (int32)decorator->BorderWidth();
+       *maxHeight += 2 * (int32)decorator->BorderWidth()
+               + (int32)decorator->TabHeight() + 1;
+}
+
+
+void
+SATWindow::AddDecorator(BRect& frame)
+{
        SATDecorator* decorator = GetDecorator();
        if (!decorator)
-               return frame;
+               return;
        frame.left -= decorator->BorderWidth();
        frame.right += decorator->BorderWidth() + 1;
        frame.top -= decorator->BorderWidth() + decorator->TabHeight() + 1;
        frame.bottom += decorator->BorderWidth();
+}
 
-       return frame;
+
+void
+SATWindow::SetOriginalSizeLimits(int32 minWidth, int32 maxWidth,
+       int32 minHeight, int32 maxHeight)
+{
+       fOriginalMinWidth = minWidth;
+       fOriginalMaxWidth = maxWidth;
+       fOriginalMinHeight = minHeight;
+       fOriginalMaxHeight = maxHeight;
+
+       GetSizeLimits(&minWidth, &maxWidth, &minHeight, &maxHeight);
+       AddDecorator(&minWidth, &maxWidth, &minHeight, &maxHeight);
+       fGroupCookie->SetSizeLimits(minWidth, maxWidth, minHeight, maxHeight);
 }
 
 
 void
-SATWindow::GetSizeLimits(int32* minWidth, int32* maxWidth, int32* minHeight,
-       int32* maxHeight) const
+SATWindow::Resized()
 {
-       fWindow->GetSizeLimits(minWidth, maxWidth, minHeight, maxHeight);
-
-       SATDecorator* decorator = GetDecorator();
-       if (decorator == NULL)
+       bool hResizeable = IsHResizeable();
+       bool vResizeable = IsVResizeable();
+       if (hResizeable == false && vResizeable == false)
                return;
 
-       *minWidth += 2 * (int32)decorator->BorderWidth() + 1;
-       *minHeight += 2 * (int32)decorator->BorderWidth()
-               + (int32)decorator->TabHeight() + 1;
-       *maxWidth += 2 * (int32)decorator->BorderWidth() + 1;
-       *maxHeight += 2 * (int32)decorator->BorderWidth()
-               + (int32)decorator->TabHeight() + 1;
+       BRect frame = fWindow->Frame();
+       if (hResizeable)
+               fOriginalWidth = frame.Width();
+       if (vResizeable)
+               fOriginalHeight = frame.Height();
+
+       fGroupCookie->UpdateSizeConstaints(CompleteWindowFrame());
 }
 
 
 bool
+SATWindow::IsHResizeable() const
+{
+       if (fWindow->Look() == B_MODAL_WINDOW_LOOK
+               || fWindow->Look() == B_BORDERED_WINDOW_LOOK
+               || fWindow->Look() == B_NO_BORDER_WINDOW_LOOK
+               || (fWindow->Flags() & B_NOT_RESIZABLE) != 0
+               || (fWindow->Flags() & B_NOT_H_RESIZABLE) != 0)
+               return false;
+       return true;
+}
+
+
+bool
+SATWindow::IsVResizeable() const
+{
+       if (fWindow->Look() == B_MODAL_WINDOW_LOOK
+               || fWindow->Look() == B_BORDERED_WINDOW_LOOK
+               || fWindow->Look() == B_NO_BORDER_WINDOW_LOOK
+               || (fWindow->Flags() & B_NOT_RESIZABLE) != 0
+               || (fWindow->Flags() & B_NOT_V_RESIZABLE) != 0)
+               return false;
+       return true;
+}
+
+
+BRect
+SATWindow::CompleteWindowFrame()
+{
+       BRect frame = fWindow->Frame();
+       if (fDesktop
+               && fDesktop->CurrentWorkspace() != fWindow->CurrentWorkspace()) 
{
+               window_anchor& anchor = 
fWindow->Anchor(fWindow->CurrentWorkspace());
+               if (anchor.position != kInvalidWindowPosition)
+                       frame.OffsetTo(anchor.position);
+       }
+
+       AddDecorator(frame);
+       return frame;
+}
+
+
+bool
 SATWindow::PositionManagedBySAT()
 {
        if (fGroupCookie->GetGroup() && fGroupCookie->GetGroup()->CountItems() 
== 1)
@@ -711,53 +781,6 @@
 }
 
 
-void
-SATWindow::_UpdateSizeLimits()
-{
-       int32 minWidth, minHeight;
-       int32 maxWidth, maxHeight;
-       fWindow->GetSizeLimits(&fOriginalMinWidth, &maxWidth,
-               &fOriginalMinHeight, &maxHeight);
-       minWidth = fOriginalMinWidth;
-       minHeight = fOriginalMinHeight;
-       if (maxWidth != B_SIZE_UNLIMITED)
-               fOriginalMaxWidth = maxWidth;
-       if (maxHeight != B_SIZE_UNLIMITED)
-               fOriginalMaxHeight = maxHeight;
-       SATDecorator* decorator = GetDecorator();
-       // if no size limit is set but the window is not resizeable choose the
-       // current size as limit
-       if (fWindow->Look() == B_MODAL_WINDOW_LOOK
-               || fWindow->Look() == B_BORDERED_WINDOW_LOOK
-               || fWindow->Look() == B_NO_BORDER_WINDOW_LOOK
-               || (fWindow->Flags() & B_NOT_RESIZABLE) != 0
-               || (fWindow->Flags() & B_NOT_H_RESIZABLE) != 0
-               || (fWindow->Flags() & B_NOT_V_RESIZABLE) != 0) {
-               int32 minDecorWidth = 1, maxDecorWidth = 1;
-               int32 minDecorHeight = 1, maxDecorHeight = 1;
-               if (decorator)
-                       decorator->GetSizeLimits(&minDecorWidth, 
&minDecorHeight,
-                               &maxDecorWidth, &maxDecorHeight);
-               BRect frame = fWindow->Frame();
-               if (fOriginalMinWidth <= minDecorWidth)
-                       minWidth = frame.IntegerWidth();
-               if (fOriginalMinHeight <= minDecorHeight)
-                       minHeight = frame.IntegerHeight();
-       }
-       fWindow->SetSizeLimits(minWidth, B_SIZE_UNLIMITED,
-               minHeight, B_SIZE_UNLIMITED);
-
-
-       if (decorator) {
-               minWidth += 2 * (int32)decorator->BorderWidth();
-               minHeight += 2 * (int32)decorator->BorderWidth()
-                       + (int32)decorator->TabHeight() + 1;
-       }
-       fGroupCookie->SetSizeLimits(minWidth, B_SIZE_UNLIMITED, minHeight,
-               B_SIZE_UNLIMITED);
-}
-
-
 uint64
 SATWindow::_GenerateId()
 {
@@ -767,6 +790,7 @@
        return (time & ~0xFFFF) | randNumber;
 }
 
+
 void
 SATWindow::_RestoreOriginalSize(bool stayBelowMouse)
 {
@@ -775,18 +799,10 @@
                fOriginalMinHeight, fOriginalMaxHeight);
        BRect frame = fWindow->Frame();
        float x = 0, y = 0;
-       if (fWindow->Look() == B_MODAL_WINDOW_LOOK
-               || fWindow->Look() == B_BORDERED_WINDOW_LOOK
-               || fWindow->Look() == B_NO_BORDER_WINDOW_LOOK
-               || (fWindow->Flags() & B_NOT_RESIZABLE) != 0) {
+       if (IsHResizeable() == false)
                x = fOriginalWidth - frame.Width();
+       if (IsVResizeable() == false)
                y = fOriginalHeight - frame.Height();
-       } else {
-               if ((fWindow->Flags() & B_NOT_H_RESIZABLE) != 0)
-                       x = fOriginalWidth - frame.Width();
-               if ((fWindow->Flags() & B_NOT_V_RESIZABLE) != 0)
-                       y = fOriginalHeight - frame.Height();
-       }
        fDesktop->ResizeWindowBy(fWindow, x, y);
 
        if (!stayBelowMouse)

Modified: haiku/trunk/src/add-ons/decorators/SATDecorator/SATWindow.h
===================================================================
--- haiku/trunk/src/add-ons/decorators/SATDecorator/SATWindow.h 2011-06-21 
22:59:54 UTC (rev 42279)
+++ haiku/trunk/src/add-ons/decorators/SATDecorator/SATWindow.h 2011-06-22 
05:22:04 UTC (rev 42280)
@@ -30,10 +30,11 @@
                        bool                            Init(SATGroup* group, 
WindowArea* area);
                        void                            Uninit();
 
-                       void                            
DoGroupLayout(SATWindow* triggerWindow);
+                       void                            DoGroupLayout();
                        void                            MoveWindow(int32 
workspace);
                        void                            SetSizeLimits(int32 
minWidth, int32 maxWidth,
                                                                        int32 
minHeight, int32 maxHeight);
+                       void                            
UpdateSizeConstaints(const BRect& frame);
 
                        SATGroup*                       GetGroup() { return 
fSATGroup.Get(); }
 
@@ -43,8 +44,6 @@
                                                                        
WindowArea* area);
 
 private:
-                       void                            _UpdateWindowSize(const 
BRect& frame);
-
                        SATWindow*                      fSATWindow;
 
                        BReference<SATGroup>    fSATGroup;
@@ -56,15 +55,12 @@
                        Variable*                       fRightBorder;
                        Variable*                       fBottomBorder;
 
-                       Constraint*                     fLeftBorderConstraint;
-                       Constraint*                     fTopBorderConstraint;
-                       Constraint*                     fRightBorderConstraint;
-                       Constraint*                     fBottomBorderConstraint;
-
-                       Constraint*                     fLeftConstraint;
-                       Constraint*                     fTopConstraint;
                        Constraint*                     fMinWidthConstraint;
                        Constraint*                     fMinHeightConstraint;
+                       Constraint*                     fMaxWidthConstraint;
+                       Constraint*                     fMaxHeightConstraint;
+                       Constraint*                     fKeepMaxWidthConstraint;
+                       Constraint*                     
fKeepMaxHeightConstraint;
                        Constraint*                     fWidthConstraint;
                        Constraint*                     fHeightConstraint;
 };
@@ -107,15 +103,23 @@
                        void                            DoWindowLayout();
                        void                            DoGroupLayout();
 
-                       void                            SetSizeLimits(int32 
minWidth, int32 maxWidth,
-                                                                       int32 
minHeight, int32 maxHeight);
+                       void                            AdjustSizeLimits(BRect 
targetFrame);
+                       void                            
SetOriginalSizeLimits(int32 minWidth,
+                                                                       int32 
maxWidth, int32 minHeight,
+                                                                       int32 
maxHeight);
+                       void                            GetSizeLimits(int32* 
minWidth, int32* maxWidth,
+                                                                       int32* 
minHeight, int32* maxHeight) const;
+                       void                            AddDecorator(int32* 
minWidth, int32* maxWidth,
+                                                                       int32* 
minHeight, int32* maxHeight);
+                       void                            AddDecorator(BRect& 
frame);
+
                        // hook called when window has been resized form the 
outside
                        void                            Resized();
+                       bool                            IsHResizeable() const;
+                       bool                            IsVResizeable() const;
 
                        //! \return the complete window frame including the 
Decorator
                        BRect                           CompleteWindowFrame();
-                       void                            GetSizeLimits(int32* 
minWidth, int32* maxWidth,
-                                                                       int32* 
minHeight, int32* maxHeight) const;
 
                        //! \return true if window is in a group with a least 
another window
                        bool                            PositionManagedBySAT();
@@ -137,9 +141,9 @@
                        void                            GetSettings(BMessage& 
message);
 private:
                        void                            _InitGroup();
-                       void                            _UpdateSizeLimits();
                        uint64                          _GenerateId();
 
+                       void                            _UpdateSizeLimits();
                        void                            _RestoreOriginalSize(
                                                                        bool 
stayBelowMouse = true);
 

Modified: haiku/trunk/src/add-ons/decorators/SATDecorator/StackAndTile.cpp
===================================================================
--- haiku/trunk/src/add-ons/decorators/SATDecorator/StackAndTile.cpp    
2011-06-21 22:59:54 UTC (rev 42279)
+++ haiku/trunk/src/add-ons/decorators/SATDecorator/StackAndTile.cpp    
2011-06-22 05:22:04 UTC (rev 42280)
@@ -397,10 +397,10 @@
        SATWindow* satWindow = GetSATWindow(window);
        if (!satWindow)
                return;
-       WindowArea* area = satWindow->GetWindowArea();
-       if (!area)
-               return;
-       area->UpdateSizeLimits();
+       satWindow->SetOriginalSizeLimits(minWidth, maxWidth, minHeight, 
maxHeight);
+
+       // trigger a relayout
+       WindowMoved(window);
 }
 
 


Other related posts: