From 885eed5c442129b3435f464ebe2e3be48af28715 Mon Sep 17 00:00:00 2001 From: Adi Oanca Date: Wed, 2 Jun 2004 20:44:46 +0000 Subject: [PATCH] a little cleanup git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7744 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/app/server/Layer.cpp | 148 +++++++++++++----------- src/servers/app/server/ServerWindow.cpp | 11 +- src/servers/app/server/WinBorder.cpp | 15 ++- 3 files changed, 94 insertions(+), 80 deletions(-) diff --git a/src/servers/app/server/Layer.cpp b/src/servers/app/server/Layer.cpp index d97a07060c..88b4b8f7f4 100644 --- a/src/servers/app/server/Layer.cpp +++ b/src/servers/app/server/Layer.cpp @@ -12,15 +12,22 @@ #include "RootLayer.h" #include "DisplayDriver.h" #include "LayerData.h" +#include //#define DEBUG_LAYER #ifdef DEBUG_LAYER -# include # define STRACE(x) printf x #else # define STRACE(x) ; #endif +//#define DEBUG_LAYER_REBUILD +#ifdef DEBUG_LAYER_REBUILD +# define RBTRACE(x) printf x +#else +# define RBTRACE(x) ; +#endif + BRegion gRedrawReg; BList gCopyRegList; BList gCopyList; @@ -74,7 +81,7 @@ Layer::Layer(BRect frame, const char *name, int32 token, uint32 resize, clipToPicture = NULL; /* NOW all regions (_visible, _fullVisible, _full) are empty */ - printf("Layer(%s) successfuly created\n", GetName()); + STRACE(("Layer(%s) successfuly created\n", GetName())); } //! Destructor frees all allocated heap space @@ -108,7 +115,7 @@ Layer::~Layer(void) void Layer::AddChild(Layer *layer, RootLayer *rootLayer) { -printf("Layer(%s)::AddChild(%s)\n", GetName(), layer->GetName()); +STRACE(("Layer(%s)::AddChild(%s) START\n", GetName(), layer->GetName())); if( layer->_parent != NULL ) { printf("ERROR: AddChild(): Layer already has a _parent\n"); return; @@ -171,11 +178,12 @@ printf("Layer(%s)::AddChild(%s)\n", GetName(), layer->GetName()); if ( !(layer->IsHidden()) && layer->fRootLayer && !IsHidden()){ FullInvalidate( layer->_full ); } -printf("Layer(%s)::AddChild(%s) ENDED\n", GetName(), layer->GetName()); +STRACE(("Layer(%s)::AddChild(%s) END\n", GetName(), layer->GetName())); } void Layer::RemoveChild(Layer *layer) { +STRACE(("Layer(%s)::RemoveChild(%s) START\n", GetName(), layer->GetName())); if( layer->_parent == NULL ){ printf("ERROR: RemoveChild(): Layer doesn't have a _parent\n"); return; @@ -248,7 +256,7 @@ void Layer::RemoveChild(Layer *layer) layer->_full.MakeEmpty(); layer->_fullVisible.MakeEmpty(); layer->_visible.MakeEmpty(); - +STRACE(("Layer(%s)::RemoveChild(%s) END\n", GetName(), layer->GetName())); } void Layer::RemoveSelf() @@ -366,9 +374,11 @@ void Layer::FullInvalidate(const BRect &rect) void Layer::FullInvalidate(const BRegion& region) { -printf("Layer(%s)::FullInvalidate():\n", GetName()); -region.PrintToStream(); -printf("\n"); +STRACE(("Layer(%s)::FullInvalidate():\n", GetName())); +#ifdef DEBUG_LAYER + region.PrintToStream(); + printf("\n"); +#endif BPoint pt(0,0); StartRebuildRegions(region, NULL,/* B_LAYER_INVALIDATE, pt); */B_LAYER_NONE, pt); @@ -380,9 +390,11 @@ printf("\n"); void Layer::Invalidate(const BRegion& region) { -printf("Layer(%s)::Invalidate():\n", GetName()); -region.PrintToStream(); -printf("\n"); +STRACE(("Layer(%s)::Invalidate():\n", GetName())); +#ifdef DEBUG_LAYER + region.PrintToStream(); + printf("\n"); +#endif gRedrawReg = region; @@ -393,7 +405,7 @@ printf("\n"); void Layer::Redraw(const BRegion& reg, Layer *startFrom) { -printf("Layer(%s)::Redraw();\n", GetName()); +STRACE(("Layer(%s)::Redraw();\n", GetName())); BRegion *pReg = const_cast(®); if(_serverwin){ @@ -407,11 +419,11 @@ printf("Layer(%s)::Redraw();\n", GetName()); RequestDraw(reg, startFrom); } } -printf("Layer::Redraw ENDED\n"); +STRACE(("Layer::Redraw ENDED\n")); } void Layer::RequestClientUpdate(const BRegion ®, Layer *startFrom){ -printf("Layer(%s)::RequestClientUpdate();\n", GetName()); +STRACE(("Layer(%s)::RequestClientUpdate()\n", GetName())); if (IsHidden()){ // this layer has nothing visible on screen, so bail out. return; @@ -455,7 +467,7 @@ printf("Layer(%s)::RequestClientUpdate();\n", GetName()); void Layer::RequestDraw(const BRegion ®, Layer *startFrom, bool redraw) { -printf("Layer(%s)::RequestDraw()\n", GetName()); +STRACE(("Layer(%s)::RequestDraw()\n", GetName())); if (_visible.CountRects() > 0 && !IsHidden()){ fUpdateReg = _visible; fUpdateReg.IntersectWith(®); @@ -488,9 +500,8 @@ printf("Layer(%s)::RequestDraw()\n", GetName()); void Layer::Draw(const BRect &r) { - // TODO/NOTE: this should be an empty method! the next lines are for testing only -printf("Layer::Draw() Called\n"); +STRACE(("Layer::Draw() Called\n")); // RGBColor col(152,102,51); // DRIVER->FillRect_(r, 1, col, &fUpdateReg); //snooze(1000000); @@ -502,7 +513,7 @@ printf("Layer::Draw() Called\n"); void Layer::Show(void) { -printf("Layer(%s)::Show()\n", GetName()); +STRACE(("Layer(%s)::Show()\n", GetName())); if( !IsHidden() ) return; @@ -516,7 +527,7 @@ printf("Layer(%s)::Show()\n", GetName()); void Layer::Hide(void) { -printf("\n\nLayer(%s)::Hide()\n", GetName()); +STRACE(("Layer(%s)::Hide()\n", GetName())); if ( IsHidden() ) return; @@ -590,6 +601,7 @@ uint32 Layer::CountChildren(void) const } void Layer::RebuildFullRegion( ){ +STRACE(("Layer(%s)::RebuildFullRegion()\n", GetName())); if (_parent) _full.Set( _parent->ConvertToTop( _frame ) ); else @@ -623,6 +635,7 @@ void Layer::RebuildFullRegion( ){ void Layer::RebuildRegions( const BRegion& reg, uint32 action, BPoint pt, BPoint ptOffset) { +STRACE(("Layer(%s)::RebuildRegions() START\n", GetName())); //NOTE: this method must be executed as fast as possible. // Currently SendView[Moved/Resized]Msg() simply constructs a message and calls // ServerWindow::SendMessageToClient() @@ -642,12 +655,12 @@ void Layer::RebuildRegions( const BRegion& reg, uint32 action, BPoint pt, BPoint RRLabel1: switch(action){ case B_LAYER_NONE:{ -printf("1) Action B_LAYER_NONE\n"); +RBTRACE(("1) Action B_LAYER_NONE\n")); oldRegion = _visible; break; } case B_LAYER_MOVE:{ -printf("1) Action B_LAYER_MOVE\n"); +RBTRACE(("1) Action B_LAYER_MOVE\n")); oldRegion = _fullVisible; _frame.OffsetBy(pt.x, pt.y); _full.OffsetBy(pt.x, pt.y); @@ -658,13 +671,13 @@ printf("1) Action B_LAYER_MOVE\n"); break; } case B_LAYER_SIMPLE_MOVE:{ -printf("1) Action B_LAYER_SIMPLE_MOVE\n"); +RBTRACE(("1) Action B_LAYER_SIMPLE_MOVE\n")); _full.OffsetBy(pt.x, pt.y); break; } case B_LAYER_RESIZE:{ -printf("1) Action B_LAYER_RESIZE\n"); +RBTRACE(("1) Action B_LAYER_RESIZE\n")); oldRegion = _visible; _frame.right += pt.x; @@ -677,7 +690,7 @@ printf("1) Action B_LAYER_RESIZE\n"); break; } case B_LAYER_MASK_RESIZE:{ -printf("1) Action B_LAYER_MASK_RESIZE\n"); +RBTRACE(("1) Action B_LAYER_MASK_RESIZE\n")); oldRegion = _visible; BPoint offset, rSize; @@ -816,19 +829,22 @@ printf("1) Action B_LAYER_MASK_RESIZE\n"); // _fullVisible.MakeEmpty(); // _visible.MakeEmpty(); //} -printf("\n ======= Layer(%s)::RR finals ======\n", GetName()); -oldRegion.PrintToStream(); -_full.PrintToStream(); -_fullVisible.PrintToStream(); -_visible.PrintToStream(); -printf("==========RedrawReg===========\n"); -gRedrawReg.PrintToStream(); -printf("=====================\n"); +#ifdef DEBUG_LAYER_REBUILD + printf("\n ======= Layer(%s)::RR finals ======\n", GetName()); + oldRegion.PrintToStream(); + _full.PrintToStream(); + _fullVisible.PrintToStream(); + _visible.PrintToStream(); + printf("==========RedrawReg===========\n"); + gRedrawReg.PrintToStream(); + printf("=====================\n"); +#endif +STRACE(("Layer(%s)::RebuildRegions() END\n", GetName())); } void Layer::StartRebuildRegions( const BRegion& reg, Layer *target, uint32 action, BPoint& pt) { -printf("Layer(%s)::StartRebuildRegions()\n", GetName()); +STRACE(("Layer(%s)::StartRebuildRegions() START\n", GetName())); if(!_parent) _fullVisible = _full; @@ -846,36 +862,42 @@ printf("Layer(%s)::StartRebuildRegions()\n", GetName()); lay->RebuildRegions(reg, B_LAYER_NONE, pt, BPoint(0.0f, 0.0f)); } } - -printf("\n ===!=== Layer(%s)::SRR finals ===!===\n", GetName()); -_full.PrintToStream(); -_fullVisible.PrintToStream(); -_visible.PrintToStream(); -oldVisible.PrintToStream(); -printf("=====================\n"); -gRedrawReg.PrintToStream(); +#ifdef DEBUG_LAYER_REBUILD + printf("\n ===!=== Layer(%s)::SRR finals ===!===\n", GetName()); + _full.PrintToStream(); + _fullVisible.PrintToStream(); + _visible.PrintToStream(); + oldVisible.PrintToStream(); + printf("=====!=====RedrawReg=====!=====\n"); + gRedrawReg.PrintToStream(); + printf("=====================\n"); +#endif BRegion redrawReg(_visible); // if this is the first time if (oldVisible.CountRects() > 0){ -printf("YES, it happens\n"); redrawReg.Exclude(&oldVisible); } gRedrawReg.Include(&redrawReg); + +#ifdef DEBUG_LAYER_REBUILD + printf("Layer(%s)::StartRebuildREgions() ended! Redraw Region:\n", GetName()); + gRedrawReg.PrintToStream(); + printf("\n"); + printf("Layer(%s)::StartRebuildREgions() ended! Copy Region:\n", GetName()); + for(int32 k=0; kPrintToStream(); + ((BPoint*)(gCopyList.ItemAt(k)))->PrintToStream(); + } + printf("\n"); +#endif - printf("Layer(%s)::StartRebuildREgions() ended! Redraw Region:\n", GetName()); - gRedrawReg.PrintToStream(); - printf("\n"); - printf("Layer(%s)::StartRebuildREgions() ended! Copy Region:\n", GetName()); - for(int32 k=0; kPrintToStream(); - ((BPoint*)(gCopyList.ItemAt(k)))->PrintToStream(); - } - printf("\n"); +STRACE(("Layer(%s)::StartRebuildRegions() END\n", GetName())); } void Layer::MoveBy(float x, float y) { +STRACE(("Layer(%s)::MoveBy() START\n", GetName())); if(!_parent){ debugger("ERROR: in Layer::MoveBy()! - No parent!\n"); return; @@ -891,6 +913,7 @@ void Layer::MoveBy(float x, float y) _parent->Redraw(gRedrawReg, this); EmptyGlobals(); +STRACE(("Layer(%s)::MoveBy() END\n", GetName())); } void Layer::EmptyGlobals(){ @@ -907,7 +930,7 @@ void Layer::EmptyGlobals(){ } uint32 Layer::ResizeOthers(float x, float y, BPoint coords[], BPoint *ptOffset){ -printf("Layer(%s): x=%f y=%f\n", GetName(), x, y); +STRACE(("Layer(%s)::ResizeOthers() START\n", GetName())); uint32 rmask = _resize_mode; // offset coords[0].x = 0.0f; @@ -917,55 +940,43 @@ printf("Layer(%s): x=%f y=%f\n", GetName(), x, y); coords[1].y = 0.0f; if ((rmask & 0x00000f00UL)>>8 == _VIEW_LEFT_ - && (rmask & 0x0000000fUL)>>0 == _VIEW_RIGHT_) - { -printf("Layer(%s) - step 1\n", GetName()); + && (rmask & 0x0000000fUL)>>0 == _VIEW_RIGHT_){ coords[1].x = x; } else if ((rmask & 0x00000f00UL)>>8 == _VIEW_LEFT_){ -printf("Layer(%s) - step 2\n", GetName()); } else if ((rmask & 0x0000000fUL)>>0 == _VIEW_RIGHT_){ -printf("Layer(%s) - step 3\n", GetName()); coords[0].x = x; } else if ((rmask & 0x00000f00UL)>>8 == _VIEW_CENTER_){ -printf("Layer(%s) - step 4\n", GetName()); coords[0].x = x/2; } else { // illegal flag. Do nothing. -printf("Layer(%s) - step 5\n", GetName()); } if ((rmask & 0x0000f000UL)>>12 == _VIEW_TOP_ - && (rmask & 0x000000f0UL)>>4 == _VIEW_BOTTOM_) - { + && (rmask & 0x000000f0UL)>>4 == _VIEW_BOTTOM_){ coords[1].y = y; -printf("Layer(%s) - sstep 1\n", GetName()); } else if ((rmask & 0x0000f000UL)>>12 == _VIEW_TOP_){ -printf("Layer(%s) - sstep 2\n", GetName()); } else if ((rmask & 0x000000f0UL)>>4 == _VIEW_BOTTOM_){ -printf("Layer(%s) - sstep 3\n", GetName()); coords[0].y = y; } else if ((rmask & 0x0000f000UL)>>12 == _VIEW_CENTER_){ -printf("Layer(%s) - sstep 4\n", GetName()); coords[0].y = y/2; } else { // illegal flag. Do nothing. -printf("Layer(%s) - sstep 5\n", GetName()); } -printf("Layer(%s): coord[0].x=%f coord[0].y=%f\n", GetName(), coords[0].x, coords[0].y); -printf("Layer(%s): coord[1].x=%f coord[1].y=%f\n", GetName(), coords[1].x, coords[1].y); +STRACE(("Layer(%s)::ResizeOthers() END\n", GetName())); return 0UL; } void Layer::ResizeBy(float x, float y) { +STRACE(("Layer(%s)::ResizeBy() START\n", GetName())); if(!_parent){ printf("ERROR: in Layer::MoveBy()! - No parent!\n"); return; @@ -983,6 +994,7 @@ void Layer::ResizeBy(float x, float y) _parent->Redraw(gRedrawReg, this); EmptyGlobals(); +STRACE(("Layer(%s)::ResizeBy() END\n", GetName())); } void Layer::PrintToStream(void) diff --git a/src/servers/app/server/ServerWindow.cpp b/src/servers/app/server/ServerWindow.cpp index 4ebe43132a..a7a3fe4859 100644 --- a/src/servers/app/server/ServerWindow.cpp +++ b/src/servers/app/server/ServerWindow.cpp @@ -49,7 +49,7 @@ #include "CursorManager.h" #include "Workspace.h" -#define DEBUG_SERVERWINDOW +//#define DEBUG_SERVERWINDOW //#define DEBUG_SERVERWINDOW_MOUSE //#define DEBUG_SERVERWINDOW_KEYBOARD @@ -916,7 +916,6 @@ void ServerWindow::DispatchMessage(int32 code) cl->MoveBy(x, y); - STRACE(("ServerWindow %s: Message AS_LAYER_MOVETO: Layer: %s\n",fTitle.String(), cl->_name->String())); break; } case AS_LAYER_RESIZETO: @@ -931,7 +930,6 @@ void ServerWindow::DispatchMessage(int32 code) cl->ResizeBy(newWidth, newHeight); - STRACE(("ServerWindow %s: Message AS_LAYER_RESIZETO: Layer: %s\n",fTitle.String(), cl->_name->String())); break; } case AS_LAYER_GET_COORD: @@ -1144,6 +1142,8 @@ void ServerWindow::DispatchMessage(int32 code) fSession->ReadData(&c, sizeof(rgb_color)); cl->_layerdata->viewcolor.SetColor(c); + + cl->Invalidate(cl->_visible); STRACE(("ServerWindow %s: Message AS_LAYER_SET_VIEW_COLOR: Layer: %s\n",fTitle.String(), cl->_name->String())); break; @@ -1562,9 +1562,7 @@ void ServerWindow::DispatchMessage(int32 code) fSession->ReadFloat(&yResizeBy); fWinBorder->ResizeBy(xResizeBy, yResizeBy); -printf("===> ddd = %f %f", xResizeBy, yResizeBy); - // TODO: Implement - STRACE(("ServerWindow %s: Message Resize unimplemented\n",fTitle.String())); + break; } case B_MINIMIZE: @@ -2184,7 +2182,6 @@ int32 ServerWindow::MonitorWin(void *data) { STRACE(("ServerWindow %s received Quit request\n",win->Title())); quitting = true; -printf("Deleting window...\n"); delete win; break; } diff --git a/src/servers/app/server/WinBorder.cpp b/src/servers/app/server/WinBorder.cpp index ad64ac9bc3..9b4077688f 100644 --- a/src/servers/app/server/WinBorder.cpp +++ b/src/servers/app/server/WinBorder.cpp @@ -21,7 +21,7 @@ // // File Name: WinBorder.cpp // Author: DarkWyrm -// Adi Oanca +// Adi Oanca // Description: Layer subclass which handles window management // //------------------------------------------------------------------------------ @@ -48,8 +48,8 @@ //#define DEBUG_WINBORDER // toggle -#define DEBUG_WINBORDER_MOUSE -#define DEBUG_WINBORDER_CLICK +//#define DEBUG_WINBORDER_MOUSE +//#define DEBUG_WINBORDER_CLICK #ifdef DEBUG_WINBORDER # include @@ -119,7 +119,7 @@ WinBorder::WinBorder(const BRect &r, const char *name, const int32 look, const i //--------------------------------------------------------------------------- WinBorder::~WinBorder(void) { -STRACE(("WinBorder %s:~WinBorder()\n",GetName())); +STRACE(("WinBorder(%s):~WinBorder()\n",GetName())); if (fDecorator) { delete fDecorator; fDecorator = NULL; @@ -130,6 +130,7 @@ STRACE(("WinBorder %s:~WinBorder()\n",GetName())); } //--------------------------------------------------------------------------- void WinBorder::RebuildFullRegion(void){ +STRACE(("WinBorder(%s):~RebuildFullRegion()\n",GetName())); BRegion topLayerFull; Layer *topLayer = _serverwin->fTopLayer; topLayerFull.Set( ConvertToTop(*fNewTopLayerFrame) ); @@ -315,7 +316,7 @@ void WinBorder::HighlightDecorator(const bool &active) //--------------------------------------------------------------------------- void WinBorder::Draw(const BRect &r) { -printf("WinBorder(%s)::Draw()\n", GetName()); +STRACE(("WinBorder(%s)::Draw()\n", GetName())); if(fDecorator){ // decorator is allowed to draw in its entire visible region, not just in the update one. fUpdateReg = _visible; @@ -339,6 +340,7 @@ snooze(1000000); //--------------------------------------------------------------------------- void WinBorder::MoveBy(float x, float y) { +STRACE(("WinBorder(%s)::MoveBy()\n", GetName())); if(fDecorator){ fDecorator->MoveBy(x,y); fDecFull->OffsetBy(x,y); @@ -349,6 +351,7 @@ void WinBorder::MoveBy(float x, float y) //--------------------------------------------------------------------------- void WinBorder::ResizeBy(float x, float y) { +STRACE(("WinBorder(%s)::ResizeBy()\n", GetName())); if(fDecorator){ fDecorator->ResizeBy(x,y); } @@ -413,6 +416,7 @@ void WinBorder::SetLevel(){ } //--------------------------------------------------------------------------- void WinBorder::AddToSubsetOf(WinBorder* main){ +STRACE(("WinBorder(%s)::AddToSubsetOf()\n", GetName())); if (!main || (main && !(main->GetRootLayer()))) return; @@ -466,6 +470,7 @@ void WinBorder::AddToSubsetOf(WinBorder* main){ } //--------------------------------------------------------------------------- void WinBorder::RemoveFromSubsetOf(WinBorder* main){ +STRACE(("WinBorder(%s)::RemoveFromSubsetOf()\n", GetName())); RootLayer *rl = main->GetRootLayer(); desktop->fGeneralLock.Lock();