From e0c538ed7d3e6995e5071b76cbf6f17485748c25 Mon Sep 17 00:00:00 2001 From: Clemens Zeidler Date: Sun, 19 Sep 2010 21:08:47 +0000 Subject: [PATCH] A decorator can change during the lifetime of a window so get a fresh decorator every time. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38729 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../decorators/SATDecorator/SATWindow.cpp | 41 ++++++++++++------- .../decorators/SATDecorator/SATWindow.h | 3 +- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/src/add-ons/decorators/SATDecorator/SATWindow.cpp b/src/add-ons/decorators/SATDecorator/SATWindow.cpp index 54f3422e35..8a7f223385 100644 --- a/src/add-ons/decorators/SATDecorator/SATWindow.cpp +++ b/src/add-ons/decorators/SATDecorator/SATWindow.cpp @@ -297,7 +297,6 @@ SATWindow::SATWindow(StackAndTile* sat, Window* window) fSATTiling(this), fShutdown(false) { - fDecorator = dynamic_cast(fWindow->Decorator()); fDesktop = fWindow->Desktop(); fGroupCookie = &fOwnGroupCookie; @@ -319,6 +318,13 @@ SATWindow::~SATWindow() } +SATDecorator* +SATWindow::GetDecorator() +{ + return static_cast(fWindow->Decorator()); +} + + SATGroup* SATWindow::GetGroup() { @@ -540,14 +546,15 @@ SATWindow::PositionManagedBySAT() bool SATWindow::HighlightTab(bool active) { - if (!fDecorator) + SATDecorator* decorator = GetDecorator(); + if (!decorator) return false; if (IsTabHighlighted() == active) return false; BRegion dirty; - fDecorator->HighlightTab(active, &dirty); + decorator->HighlightTab(active, &dirty); fWindow->ProcessDirtyRegion(dirty); return true; @@ -557,14 +564,15 @@ SATWindow::HighlightTab(bool active) bool SATWindow::HighlightBorders(bool active) { - if (!fDecorator) + SATDecorator* decorator = GetDecorator(); + if (!decorator) return false; if (IsBordersHighlighted() == active) return false; BRegion dirty; - fDecorator->HighlightBorders(active, &dirty); + decorator->HighlightBorders(active, &dirty); fWindow->ProcessDirtyRegion(dirty); return true; } @@ -573,8 +581,9 @@ SATWindow::HighlightBorders(bool active) bool SATWindow::IsTabHighlighted() { - if (fDecorator) - return fDecorator->IsTabHighlighted(); + SATDecorator* decorator = GetDecorator(); + if (decorator) + return decorator->IsTabHighlighted(); return false; } @@ -582,8 +591,9 @@ SATWindow::IsTabHighlighted() bool SATWindow::IsBordersHighlighted() { - if (fDecorator) - return fDecorator->IsBordersHighlighted(); + SATDecorator* decorator = GetDecorator(); + if (decorator) + return decorator->IsBordersHighlighted(); return false; } @@ -591,10 +601,11 @@ SATWindow::IsBordersHighlighted() bool SATWindow::SetStackedMode(bool stacked) { - if (!fDecorator) + SATDecorator* decorator = GetDecorator(); + if (!decorator) return false; BRegion dirty; - fDecorator->SetStackedMode(stacked, &dirty); + decorator->SetStackedMode(stacked, &dirty); fDesktop->RebuildAndRedrawAfterWindowChange(fWindow, dirty); return true; } @@ -603,10 +614,11 @@ SATWindow::SetStackedMode(bool stacked) bool SATWindow::SetStackedTabLength(float length) { - if (!fDecorator) + SATDecorator* decorator = GetDecorator(); + if (!decorator) return false; BRegion dirty; - fDecorator->SetStackedTabLength(length, &dirty); + decorator->SetStackedTabLength(length, &dirty); fDesktop->RebuildAndRedrawAfterWindowChange(fWindow, dirty); return true; } @@ -615,7 +627,8 @@ SATWindow::SetStackedTabLength(float length) bool SATWindow::SetStackedTabMoving(bool moving) { - if (!fDecorator) + SATDecorator* decorator = GetDecorator(); + if (!decorator) return false; if (!moving) diff --git a/src/add-ons/decorators/SATDecorator/SATWindow.h b/src/add-ons/decorators/SATDecorator/SATWindow.h index 16a4acb5b2..0ce7ff0ca4 100644 --- a/src/add-ons/decorators/SATDecorator/SATWindow.h +++ b/src/add-ons/decorators/SATDecorator/SATWindow.h @@ -77,7 +77,7 @@ public: ~SATWindow(); Window* GetWindow() { return fWindow; } - SATDecorator* GetDecorator() { return fDecorator; } + SATDecorator* GetDecorator(); StackAndTile* GetStackAndTile() { return fStackAndTile; } Desktop* GetDesktop() { return fDesktop; } //! Can be NULL if memory allocation failed! @@ -130,7 +130,6 @@ private: void _InitGroup(); Window* fWindow; - SATDecorator* fDecorator; StackAndTile* fStackAndTile; Desktop* fDesktop;