diff --git a/src/servers/app/server/DefaultDecorator.cpp b/src/servers/app/server/DefaultDecorator.cpp index dbff476e3f..a55aa189d8 100644 --- a/src/servers/app/server/DefaultDecorator.cpp +++ b/src/servers/app/server/DefaultDecorator.cpp @@ -35,6 +35,7 @@ #include "RectUtils.h" #include + #define USE_VIEW_FILL_HACK //#define DEBUG_DECORATOR @@ -355,7 +356,7 @@ printf("DefaultDecorator: Move By (%.1f, %.1f)\n",pt.x,pt.y); topborder.OffsetBy(pt); bottomborder.OffsetBy(pt); - Draw( _borderrect ); +// Draw( _borderrect ); } BRegion * DefaultDecorator::GetFootprint(void) @@ -372,6 +373,11 @@ printf("DefaultDecorator: Get Footprint\n"); return reg; } +BRect DefaultDecorator::SlideTab(float dx, float dy=0){ + //return Decorator::SlideTab(dx,dy); + return _tabrect; +} + void DefaultDecorator::_DrawTitle(BRect r) { printf("_DrawTitle(%f,%f,%f,%f)\n", r.left, r.top, r.right, r.bottom); @@ -446,9 +452,9 @@ void DefaultDecorator::Draw(void) // _driver->FillRect(_borderrect,&_layerdata,pat_solidhigh); - DrawFrame(); + _DrawFrame(_borderrect); - DrawTab(); + _DrawTab(_tabrect); } void DefaultDecorator::_DrawZoom(BRect r) @@ -602,7 +608,8 @@ void DefaultDecorator::_DrawFrame(BRect invalid) // we must clip the lines drawn by this function to the invalid rectangle we are given #ifdef USE_VIEW_FILL_HACK - _driver->FillRect(_frame,&_layerdata,pat_solidhigh); + _layerdata.highcolor = RGBColor( 255, 255, 255 ); + _driver->FillRect(_frame,&_layerdata,pat_solidhigh); #endif if(!borderwidth){ diff --git a/src/servers/app/server/DefaultDecorator.h b/src/servers/app/server/DefaultDecorator.h index d310702560..b2cfe04735 100644 --- a/src/servers/app/server/DefaultDecorator.h +++ b/src/servers/app/server/DefaultDecorator.h @@ -36,21 +36,22 @@ public: DefaultDecorator(BRect frame, int32 wlook, int32 wfeel, int32 wflags); ~DefaultDecorator(void); - void MoveBy(float x, float y); - void MoveBy(BPoint pt); - void Draw(BRect r); - void Draw(void); - BRegion *GetFootprint(void); - click_type Clicked(BPoint pt, int32 buttons, int32 modifiers); + virtual void MoveBy(float x, float y); + virtual void MoveBy(BPoint pt); + virtual void Draw(BRect r); + virtual void Draw(void); + virtual BRegion *GetFootprint(void); + virtual BRect SlideTab(float dx, float dy); + virtual click_type Clicked(BPoint pt, int32 buttons, int32 modifiers); protected: - void _DrawClose(BRect r); - void _DrawFrame(BRect r); - void _DrawTab(BRect r); - void _DrawTitle(BRect r); - void _DrawZoom(BRect r); - void _DoLayout(void); - void _SetFocus(void); - void _SetColors(void); + virtual void _DrawClose(BRect r); + virtual void _DrawFrame(BRect r); + virtual void _DrawTab(BRect r); + virtual void _DrawTitle(BRect r); + virtual void _DrawZoom(BRect r); + virtual void _DoLayout(void); + virtual void _SetFocus(void); + virtual void _SetColors(void); void DrawBlendedRect(BRect r, bool down); uint32 taboffset; diff --git a/src/servers/app/server/Layer.cpp b/src/servers/app/server/Layer.cpp index bd99d168b0..00b1562bd7 100644 --- a/src/servers/app/server/Layer.cpp +++ b/src/servers/app/server/Layer.cpp @@ -34,6 +34,7 @@ #include "PortLink.h" #include "TokenHandler.h" #include "RectUtils.h" +#include "RootLayer.h" //! TokenHandler object used to provide IDs for all Layers and, thus, BViews TokenHandler view_token_handler; @@ -132,11 +133,19 @@ printf("Layer::AddChild lacks before support\n"); layer->_parent=this; if(layer->_visible && layer->_hidecount==0 && _visible) { - // Technically, we could safely take the address of ConvertToParent(BRegion) - // but we don't just to avoid a compiler nag - BRegion *reg=new BRegion(layer->ConvertToParent(layer->_visible)); - _visible->Exclude(reg); - delete reg; + RootLayer *rl; + rl = dynamic_cast(this); + if ( rl ){ + // RootLayer enters here. It does not need to exclude WinBorder's + // visible area! + } + else{ + // Technically, we could safely take the address of ConvertToParent(BRegion) + // but we don't just to avoid a compiler nag + BRegion *reg=new BRegion(layer->ConvertToParent(layer->_visible)); + _visible->Exclude(reg); + delete reg; + } } // we need to change this to a loop for each _lowersibling of the layer @@ -342,7 +351,7 @@ Layer *Layer::FindLayer(int32 token) All children of the layer also receive this call, so only 1 Invalidate call is needed to set a section as invalid on the screen. */ -void Layer::Invalidate(BRegion region) +void Layer::Invalidate(BRegion& region) { int32 i; BRect r; @@ -379,6 +388,7 @@ void Layer::Invalidate(BRegion region) delete reg; } } + } /*! @@ -461,7 +471,8 @@ void Layer::RequestDraw(void) */ bool Layer::IsDirty(void) const { - return (!_invalid)?true:false; + //return (!_invalid)?true:false; + return _is_dirty; } /*! @@ -614,33 +625,40 @@ uint32 Layer::CountChildren(void) */ void Layer::MoveBy(float x, float y) { - BRect oldframe(_frame); _frame.OffsetBy(x,y); + BRegion oldVisible( *_visible ); + _visible->OffsetBy( x, y ); + _full->OffsetBy( x, y ); + if(_parent) { - BRegion *i=new BRegion(oldframe); - if(TestRectIntersection(oldframe,_frame)) - i->Exclude(_frame); - - if(_parent->_invalid==NULL) - _parent->_invalid=i; + BRegion exclude(oldVisible); + exclude.Exclude(_visible); + + if(_parent->_invalid == NULL) + _parent->_invalid = new BRegion( exclude ); else - { - _parent->_invalid->Include(i); - delete i; - } - _parent->_is_dirty=true; + _parent->_invalid->Include( &exclude ); + + _parent->_is_dirty = true; // if _uppersibling is non-NULL, we have other layers which we may have been // covering up. If we did cover up some siblings, they need to be redrawn for(Layer *sib=_uppersibling;sib!=NULL;sib=sib->_uppersibling) { - if(TestRectIntersection(oldframe,sib->_frame)) + BRegion exclude2(oldVisible); + exclude2.Exclude(sib->_visible); + + if( exclude2.CountRects() != 0 ) { // The boundaries intersect on screen, so invalidate the area that // was hidden - sib->Invalidate(oldframe & sib->_frame); + // a new region, becase we do not want to modify 'oldVisible' + BRegion exclude3(oldVisible); + exclude3.IntersectWith(sib->_visible); + + sib->Invalidate( exclude3 ); sib->_is_dirty=true; } } diff --git a/src/servers/app/server/Layer.h b/src/servers/app/server/Layer.h index 1c5bd11006..e5e51432ad 100644 --- a/src/servers/app/server/Layer.h +++ b/src/servers/app/server/Layer.h @@ -73,7 +73,7 @@ public: LayerData *GetLayerData(void) { return _layerdata; } void Invalidate(BRect rect); - void Invalidate(BRegion region); + void Invalidate(BRegion& region); void RebuildRegions(bool include_children=true); virtual void RequestDraw(const BRect &r); virtual void RequestDraw(void); diff --git a/src/servers/app/server/RootLayer.cpp b/src/servers/app/server/RootLayer.cpp index c4c910e4d2..4dd1fcb302 100644 --- a/src/servers/app/server/RootLayer.cpp +++ b/src/servers/app/server/RootLayer.cpp @@ -33,6 +33,7 @@ #include "PatternHandler.h" // for pattern_union #include "ServerConfig.h" +#include /*! \brief Sets up internal variables needed by the RootLayer @@ -44,7 +45,8 @@ RootLayer::RootLayer(BRect rect, const char *layername, DisplayDriver *gfxdriver : Layer(rect,layername,B_FOLLOW_NONE,0, NULL) { _driver=gfxdriver; - _invalid=new BRegion(Bounds()); + _invalid->MakeEmpty(); + _invalid->Include(Bounds()); _is_dirty=true; _bgcolor=new RGBColor(); } @@ -76,6 +78,9 @@ void RootLayer::RequestDraw(void) // Redraw the base if(_invalid) { + printf("ROOTLAYER: "); + _invalid->PrintToStream(); + printf("===========\n"); for(int32 i=0; _invalid->CountRects();i++) { if(_invalid->RectAt(i).IsValid()) @@ -92,7 +97,7 @@ void RootLayer::RequestDraw(void) for(Layer *lay=_topchild; lay!=NULL; lay=lay->_lowersibling) { if(lay->IsDirty()) - lay->RequestDraw(lay->Bounds()); + lay->RequestDraw(); } _is_dirty=false; diff --git a/src/servers/app/server/RootLayer.h b/src/servers/app/server/RootLayer.h index 19a050d40f..10b3d0888a 100644 --- a/src/servers/app/server/RootLayer.h +++ b/src/servers/app/server/RootLayer.h @@ -45,9 +45,9 @@ class RootLayer : public Layer public: RootLayer(BRect rect, const char *layername, DisplayDriver *gfxdriver); ~RootLayer(); - void RequestDraw(); - void RequestDraw(const BRect &r); - void MoveBy(float x, float y); + virtual void RequestDraw(); + virtual void RequestDraw(const BRect &r); + virtual void MoveBy(float x, float y); void MoveBy(BPoint pt); void ResizeBy(float x, float y); void ResizeBy(BPoint pt); diff --git a/src/servers/app/server/ServerApp.cpp b/src/servers/app/server/ServerApp.cpp index 40fac6caf3..f88adedf4f 100644 --- a/src/servers/app/server/ServerApp.cpp +++ b/src/servers/app/server/ServerApp.cpp @@ -50,7 +50,7 @@ #include "LayerData.h" #include "Utils.h" -//#define DEBUG_SERVERAPP +#define DEBUG_SERVERAPP /*! \brief Constructor diff --git a/src/servers/app/server/ServerWindow.cpp b/src/servers/app/server/ServerWindow.cpp index 983d30ab7c..b499fabae7 100644 --- a/src/servers/app/server/ServerWindow.cpp +++ b/src/servers/app/server/ServerWindow.cpp @@ -665,7 +665,7 @@ void ServerWindow::DispatchGraphicsMessage(int32 msgsize, int8 *msgbuffer) BRegion WindowClipRegion; BRegion LayerClipRegion; Layer *sibling; - int32 numRects; + int32 numRects = 0; if ( !msgsize || !msgbuffer ) return; diff --git a/src/servers/app/server/WinBorder.cpp b/src/servers/app/server/WinBorder.cpp index 075133cc90..0afbbec407 100644 --- a/src/servers/app/server/WinBorder.cpp +++ b/src/servers/app/server/WinBorder.cpp @@ -39,7 +39,7 @@ // TODO: Document this file completely -//#define DEBUG_WINBORDER +#define DEBUG_WINBORDER //#define DEBUG_WINBORDER_MOUSE #define DEBUG_WINBORDER_CLICK @@ -97,8 +97,11 @@ WinBorder::WinBorder(const BRect &r, const char *name, const int32 look, const i // rects - given by _decorator::GetBorderRect() - to be able to draw the borders _frame = _decorator->GetBorderRect(); _visible->Set( _frame ); + _visible->Include( _decorator->GetTabRect() ); _full->Set( _frame ); + _full->Include( _decorator->GetTabRect() ); _invalid->Set( _frame ); + _invalid->Include( _decorator->GetTabRect() ); _decorator->SetDriver(_driver); _decorator->SetTitle(name); @@ -274,16 +277,17 @@ void WinBorder::MouseMoved(int8 *buffer) printf("ClickMove: Slide Tab\n"); #endif float dx=pt.x-_mousepos.x; + float dy=pt.y-_mousepos.y; - if(dx!=0) + if(dx != 0 || dy != 0) { // SlideTab returns how much things were moved, and currently // supports just the x direction, so get the value so // we can invalidate the proper area. lock_layers(); - _parent->Invalidate(_decorator->SlideTab(dx,0)); + _parent->Invalidate(_decorator->SlideTab(dx,dy)); _parent->RequestDraw(); - _decorator->DrawTab(); +// _decorator->DrawTab(); unlock_layers(); } } @@ -309,18 +313,20 @@ printf("ClickMove: Drag\n"); lock_layers(); BRegion *reg=_decorator->GetFootprint(); // TODO: we get an error here!!! - this method is untested + // TODO: we really need to enable this method to avoid lots of drawings. //_driver->CopyRegion(reg,_win->_frame.LeftTop()); - - _decorator->MoveBy(BPoint(dx, dy)); - - MoveBy(dx,dy); + _parent->Invalidate(*reg); + _decorator->MoveBy(BPoint(dx, dy)); + MoveBy(dx,dy); + // ADI: what do those do??? BRegion reg2(oldmoveframe); reg->OffsetBy((int32)dx, (int32)dy); reg2.Exclude(reg); _parent->RebuildRegions(); + printf("WinBorder: calling parent = %s::RequestDraw()\n", _parent->_name->String()); _parent->RequestDraw(); delete reg; @@ -433,17 +439,23 @@ void WinBorder::SetFocus(const bool &active) void WinBorder::RequestDraw(const BRect &r) { #ifdef DEBUG_WINBORDER -printf("WinBorder %s: RequestDraw\n",_title->String()); +printf("WinBorder %s: RequestDraw(BRect)\n",_title->String()); +PrintToStream(); #endif _decorator->Draw(r); + delete _invalid; + _invalid = NULL; } void WinBorder::RequestDraw(void) { #ifdef DEBUG_WINBORDER -printf("WinBorder %s::RequestDraw\n",_title->String()); +printf("WinBorder %s::RequestDraw()\n",_title->String()); +PrintToStream(); #endif _decorator->Draw(); + delete _invalid; + _invalid = NULL; } /* void WinBorder::MoveBy(BPoint pt) diff --git a/src/servers/app/server/WinBorder.h b/src/servers/app/server/WinBorder.h index 73ffe1e536..fcd38b2d26 100644 --- a/src/servers/app/server/WinBorder.h +++ b/src/servers/app/server/WinBorder.h @@ -40,9 +40,9 @@ class WinBorder : public Layer public: WinBorder(const BRect &r, const char *name, const int32 look, const int32 feel, const int32 flags, ServerWindow *win); - ~WinBorder(void); - void RequestDraw(void); - void RequestDraw(const BRect &r); + virtual ~WinBorder(void); + virtual void RequestDraw(void); + virtual void RequestDraw(const BRect &r); // void MoveBy(BPoint pt); // void MoveBy(float x, float y); // void ResizeBy(BPoint pt);