From 3231b95ed8a7198e138840cd068424ba012cf47b Mon Sep 17 00:00:00 2001 From: DarkWyrm Date: Wed, 17 Sep 2003 17:14:22 +0000 Subject: [PATCH] Un-kludged Decorator::GetFootprint. Much more elegant now. :) git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4732 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/app/server/Decorator.cpp | 9 ++------- src/servers/app/server/DefaultDecorator.cpp | 9 +++++---- src/servers/app/server/DefaultDecorator.h | 2 +- src/servers/app/server/DesktopClasses.cpp | 10 +++++++--- src/servers/app/server/WinBorder.cpp | 19 +++++++------------ 5 files changed, 22 insertions(+), 27 deletions(-) diff --git a/src/servers/app/server/Decorator.cpp b/src/servers/app/server/Decorator.cpp index e3fffe6fbe..15f8ca289a 100644 --- a/src/servers/app/server/Decorator.cpp +++ b/src/servers/app/server/Decorator.cpp @@ -541,17 +541,12 @@ void Decorator::_SetColors(void) /*! \brief Returns the "footprint" of the entire window, including decorator - \return Region representing the window's screen footprint - - This function should generate a new BRegion allocated on the heap which represents - the entire area occupied by the window decorator on the screen. For example, a BeOS - decorator would return _tabrect + _borderrect. + \param region Region to be changed to represent the window's screen footprint This function is required by all subclasses. */ -BRegion *Decorator::GetFootprint(void) +void Decorator::GetFootprint(BRegion *region) { - return NULL; } /*! diff --git a/src/servers/app/server/DefaultDecorator.cpp b/src/servers/app/server/DefaultDecorator.cpp index 070d844781..69fd110785 100644 --- a/src/servers/app/server/DefaultDecorator.cpp +++ b/src/servers/app/server/DefaultDecorator.cpp @@ -293,16 +293,17 @@ STRACE(("DefaultDecorator: Move By (%.1f, %.1f)\n",pt.x,pt.y)); bottomborder.OffsetBy(pt); } -BRegion * DefaultDecorator::GetFootprint(void) +void DefaultDecorator::GetFootprint(BRegion *region) { STRACE(("DefaultDecorator: Get Footprint\n")); // This function calculates the decorator's footprint in coordinates // relative to the layer. This is most often used to set a WinBorder // object's visible region. + if(!region) + return; - BRegion *reg=new BRegion(_borderrect); - reg->Include(_tabrect); - return reg; + region->Set(_borderrect); + region->Include(_tabrect); } BRect DefaultDecorator::SlideTab(float dx, float dy=0){ diff --git a/src/servers/app/server/DefaultDecorator.h b/src/servers/app/server/DefaultDecorator.h index b2cfe04735..85eff545e2 100644 --- a/src/servers/app/server/DefaultDecorator.h +++ b/src/servers/app/server/DefaultDecorator.h @@ -40,7 +40,7 @@ public: virtual void MoveBy(BPoint pt); virtual void Draw(BRect r); virtual void Draw(void); - virtual BRegion *GetFootprint(void); + virtual void GetFootprint(BRegion *region); virtual BRect SlideTab(float dx, float dy); virtual click_type Clicked(BPoint pt, int32 buttons, int32 modifiers); protected: diff --git a/src/servers/app/server/DesktopClasses.cpp b/src/servers/app/server/DesktopClasses.cpp index 89516da829..32f193b73b 100644 --- a/src/servers/app/server/DesktopClasses.cpp +++ b/src/servers/app/server/DesktopClasses.cpp @@ -436,10 +436,14 @@ WinBorder* Screen::GetWindowAt( BPoint pt ){ { if(child->_hidden) continue; - wb = dynamic_cast( child ); - if (wb) - if(wb->GetDecorator()->GetFootprint()->Contains(pt)) + wb = dynamic_cast(child); + if(wb) + { + BRegion reg; + wb->GetDecorator()->GetFootprint(®); + if(reg.Contains(pt)) return wb; + } } return NULL; } diff --git a/src/servers/app/server/WinBorder.cpp b/src/servers/app/server/WinBorder.cpp index 5cd101ec57..529e5fc9da 100644 --- a/src/servers/app/server/WinBorder.cpp +++ b/src/servers/app/server/WinBorder.cpp @@ -110,13 +110,8 @@ WinBorder::WinBorder(const BRect &r, const char *name, const int32 look, const i _vresizewin = false; _driver = GetGfxDriver(ActiveScreen()); _decorator = new_decorator(r,name,look,feel,flags,GetGfxDriver(ActiveScreen())); + _decorator->GetFootprint(_visible); - // We need to do this because GetFootprint is supposed to generate a new BRegion. - // I suppose the call probably ought to be void GetFootprint(BRegion *recipient), but we can - // change that later. - - delete _visible; // it was initialized in Layer's constructor. - _visible = _decorator->GetFootprint(); *_full = *_visible; *_invalid = *_visible; _frame = _visible->Frame(); @@ -314,21 +309,22 @@ STRACE_CLICK(("ClickMove: Drag\n")); // by the new location so we know what areas to invalidate. // The original location - BRegion *reg=_decorator->GetFootprint(); + BRegion reg; + _decorator->GetFootprint(®); // The new location - BRegion reg2(*reg); + BRegion reg2(reg); reg2.OffsetBy((int32)dx, (int32)dy); MoveBy(dx,dy); _decorator->MoveBy(BPoint(dx, dy)); // 3) quickly move the window - _driver->CopyRegion(reg,reg2.Frame().LeftTop()); + _driver->CopyRegion(®,reg2.Frame().LeftTop()); // 4) Invalidate only the areas which we can't redraw directly for(int32 i=0; iExclude(reg2.RectAt(i)); + reg.Exclude(reg2.RectAt(i)); // TODO: DW's notes to self // As of right now, dragging the window is extremely slow despite the use @@ -344,12 +340,11 @@ STRACE_CLICK(("ClickMove: Drag\n")); // layer's coordinates, etc) and set things right. Secondly, nuke the invalid region // in this call so that when RequestDraw is called, this WinBorder doesn't redraw itself - _parent->Invalidate(*reg); + _parent->Invalidate(reg); _parent->RebuildRegions(); _parent->RequestDraw(); - delete reg; unlock_layers(); } }