diff --git a/src/servers/app/Layer.cpp b/src/servers/app/Layer.cpp index 30ce12901c..adfbfb3acd 100644 --- a/src/servers/app/Layer.cpp +++ b/src/servers/app/Layer.cpp @@ -103,7 +103,6 @@ Layer::Layer(BRect frame, const char *name, int32 token, uint32 resize, fHidden = false; fEventMask = 0UL; fEventOptions = 0UL; - fInUpdate = false; fIsTopLayer = false; fLevel = -100; @@ -539,7 +538,7 @@ void Layer::RequestDraw(const BRegion ®, Layer *startFrom) { // calculate the minimum region/rectangle to be updated with // a single message to the client. - fUpdateReg = fFullVisible; + BRegion updateReg(fFullVisible); if (fFlags & B_FULL_UPDATE_ON_RESIZE && fFrameAction == B_LAYER_ACTION_RESIZE) { @@ -547,78 +546,43 @@ void Layer::RequestDraw(const BRegion ®, Layer *startFrom) } else { - fUpdateReg.IntersectWith(®); + updateReg.IntersectWith(®); } - if (fUpdateReg.CountRects() > 0) + if (updateReg.CountRects() > 0) { + fOwner->zUpdateReg.Include(&updateReg); if (!fOwner->fInUpdate) { - fOwner->prevInvalid = fUpdateReg; - SendUpdateMsg(); - } - else - { - fOwner->zUpdateReg.Include(&fUpdateReg); +// TODO: WHAT if 2 or more update requests are sent before we start to processing the first one. + fOwner->fUpdateReg = fOwner->zUpdateReg; +//fOwner->cnt++; +//if (fOwner->cnt != 1) +// debugger("Adi: Not Allowed!"); + fOwner->zUpdateReg.MakeEmpty(); + SendUpdateMsg(fOwner->fUpdateReg); } } } if (fVisible.CountRects() > 0) { - // client side drawing. Send only one UPDATE message! - if (HasClient()) + BRegion updateReg(fVisible); + // calculate the update region + if (fFlags & B_FULL_UPDATE_ON_RESIZE + && fFrameAction == B_LAYER_ACTION_RESIZE) { - // calculate the update region - fUpdateReg = fVisible; - if (fFlags & B_FULL_UPDATE_ON_RESIZE - && fFrameAction == B_LAYER_ACTION_RESIZE) - { - // do nothing - } - else - { - fUpdateReg.IntersectWith(®); - } - - if (fUpdateReg.CountRects() > 0) - { - // clear background with viewColor. - fDriver->ConstrainClippingRegion(&fUpdateReg); -// RGBColor c(rand()%255,rand()%255,rand()%255); -// fDriver->FillRect(fUpdateReg.Frame(), c); - fDriver->FillRect(fUpdateReg.Frame(), fLayerData->viewcolor); - fDriver->ConstrainClippingRegion(NULL); - fUpdateReg.MakeEmpty(); - } + // do nothing } else { - // server drawings are immediate. - // No IPC is needed so this is done in place. - if (fClassID == AS_WINBORDER_CLASS) - { - WinBorder *wb = (WinBorder*)this; - wb->zUpdateReg.Include(®); - } + updateReg.IntersectWith(®); + } - fUpdateReg = fVisible; - if (fFlags & B_FULL_UPDATE_ON_RESIZE - && fFrameAction == B_LAYER_ACTION_RESIZE) - { - // do nothing - } - else - { - fUpdateReg.IntersectWith(®); - } - - if (fUpdateReg.CountRects() > 0) - { - fDriver->ConstrainClippingRegion(&fUpdateReg); - Draw(fUpdateReg.Frame()); - fDriver->ConstrainClippingRegion(NULL); - fUpdateReg.MakeEmpty(); - } + if (updateReg.CountRects() > 0) + { + fDriver->ConstrainClippingRegion(&updateReg); + Draw(updateReg.Frame()); + fDriver->ConstrainClippingRegion(NULL); } } @@ -646,7 +610,7 @@ void Layer::Draw(const BRect &r) // TODO/NOTE: this should be an empty method! the next lines are for testing only #ifdef DEBUG_LAYER - printf("Layer::Draw: "); + printf("Layer(%s)::Draw: ", GetName()); r.PrintToStream(); #endif @@ -660,36 +624,38 @@ void Layer::Draw(const BRect &r) void Layer::UpdateStart() { // During updates we only want to draw what's in the update region - fInUpdate = true; if (fClassID == AS_WINBORDER_CLASS) { // NOTE: don't worry, RooLayer is locked here. WinBorder *wb = (WinBorder*)this; - wb->yUpdateReg = wb->prevInvalid; + + wb->fInUpdate = true; +// TODO: wb->fUpdateReg seems to be invalid from time to time. Fix that! [See TODO in RequestDraw] + wb->yUpdateReg = wb->fUpdateReg; + wb->fUpdateReg.MakeEmpty(); +//wb->cnt--; +//if (wb->cnt != 0) +// debugger("Adi2: Not Allowed!"); } - fClipReg = &fUpdateReg; } void Layer::UpdateEnd() { // The usual case. Drawing is permitted in the whole visible area. - fUpdateReg.MakeEmpty(); if (fClassID == AS_WINBORDER_CLASS) { WinBorder *wb = (WinBorder*)this; + wb->yUpdateReg.MakeEmpty(); - wb->zUpdateReg.Exclude(&wb->prevInvalid); + + wb->fInUpdate = false; + if (wb->zUpdateReg.CountRects() > 0) { BRegion reg(wb->zUpdateReg); wb->RequestDraw(reg, NULL); - wb->zUpdateReg.MakeEmpty(); } - else - wb->prevInvalid.MakeEmpty(); } - - fInUpdate = false; } /*! @@ -760,7 +726,7 @@ void Layer::RebuildFullRegion(void) fFull.Set(fParent->ConvertToTop(fFrame )); else fFull.Set(fFrame); - + // TODO: restrict to screen coordinates // TODO: Convert to screen coordinates @@ -1157,7 +1123,9 @@ void Layer::move_layer(float x, float y) if (fClassID == AS_WINBORDER_CLASS) { WinBorder *wb = (WinBorder*)this; - wb->prevInvalid.OffsetBy(x, y); + wb->zUpdateReg.OffsetBy(x, y); + wb->yUpdateReg.OffsetBy(x, y); + wb->fUpdateReg.OffsetBy(x, y); } fParent->StartRebuildRegions(BRegion(rect), this, B_LAYER_MOVE, pt); @@ -1369,6 +1337,12 @@ BRegion Layer::ConvertToParent(BRegion *reg) return newreg; } +//! Converts the passed rectangle from parent coordinates +BPoint Layer::ConvertFromParent(BPoint pt) +{ + return (pt - fFrame.LeftTop()); +} + //! Converts the passed rectangle from parent coordinates BRect Layer::ConvertFromParent(BRect rect) { @@ -1480,16 +1454,15 @@ void Layer::SendViewMovedMsg() } //! Sends an _UPDATE_ message to the client BWindow -void Layer::SendUpdateMsg() +void Layer::SendUpdateMsg(BRegion ®) { BMessage msg; msg.what = _UPDATE_; - msg.AddRect("_rect", ConvertFromTop(fUpdateReg.Frame()) ); - msg.AddRect("debug_rect", fUpdateReg.Frame() ); - msg.AddInt32("_token",fViewToken); + msg.AddRect("_rect", ConvertFromTop(reg.Frame()) ); + msg.AddRect("debug_rect", reg.Frame() ); +// msg.AddInt32("_token",fViewToken); fOwner->Window()->SendMessageToClient(&msg); - //fServerWin->SendMessageToClient( &msg ); } Layer *Layer::VirtualTopChild() const diff --git a/src/servers/app/Layer.h b/src/servers/app/Layer.h index 9478e11191..ee6d721008 100644 --- a/src/servers/app/Layer.h +++ b/src/servers/app/Layer.h @@ -114,6 +114,7 @@ public: BRect ConvertToParent(BRect rect); BRegion ConvertToParent(BRegion *reg); + BPoint ConvertFromParent(BPoint pt); BRect ConvertFromParent(BRect rect); BRegion ConvertFromParent(BRegion *reg); @@ -147,7 +148,6 @@ public: void UpdateStart(); void UpdateEnd(); - bool InUpdate() const { return fInUpdate; } BRegion* ClippingRegion() const { return fClipReg; } protected: @@ -177,7 +177,6 @@ protected: BRegion fVisible; BRegion fFullVisible; BRegion fFull; - BRegion fUpdateReg; BRegion *fClipReg; BRegion *clipToPicture; @@ -192,7 +191,6 @@ protected: uint32 fEventMask; uint32 fEventOptions; bool fHidden; - bool fInUpdate; bool fIsTopLayer; uint16 fAdFlags; int8 fClassID; @@ -208,7 +206,7 @@ private: void RequestDraw(const BRegion ®, Layer *startFrom); ServerWindow *SearchForServerWindow(void); - void Layer::SendUpdateMsg(); + void SendUpdateMsg(BRegion ®); void SendViewMovedMsg(void); void SendViewResizedMsg(void); diff --git a/src/servers/app/ServerWindow.cpp b/src/servers/app/ServerWindow.cpp index 3e13e81f27..ea9266f15d 100644 --- a/src/servers/app/ServerWindow.cpp +++ b/src/servers/app/ServerWindow.cpp @@ -925,10 +925,17 @@ void ServerWindow::DispatchMessage(int32 code, LinkMsgReader &link) case AS_LAYER_GET_COORD: { STRACE(("ServerWindow %s: Message AS_LAYER_GET_COORD: Layer: %s\n",fTitle.String(), cl->fName->String())); +printf("Adi: %s\n", cl->GetName()); +cl->fFrame.PrintToStream(); +cl->fBoundsLeftTop.PrintToStream(); fMsgSender->StartMessage(SERVER_TRUE); - fMsgSender->Attach(cl->fFrame.left); - fMsgSender->Attach(cl->fFrame.top); + BPoint pt(cl->ConvertFromParent(cl->fFrame.LeftTop())); + fMsgSender->Attach(pt.x); + fMsgSender->Attach(pt.y); +// fMsgSender->Attach(cl->fFrame.left); +// fMsgSender->Attach(cl->fFrame.top); fMsgSender->Attach(cl->fFrame.OffsetToCopy(cl->fBoundsLeftTop)); +// fMsgSender->Attach(cl->ConvertFromTop(cl->fFrame.OffsetToCopy(cl->fBoundsLeftTop))); fMsgSender->Flush(); break; @@ -1437,6 +1444,7 @@ void ServerWindow::DispatchMessage(int32 code, LinkMsgReader &link) { STRACE(("ServerWindow %s: Message AS_SHOW_WINDOW\n",fTitle.String())); Show(); +printf("Adi: %s shown\n", fTitle.String()); break; } case AS_HIDE_WINDOW: @@ -1651,13 +1659,18 @@ void ServerWindow::DispatchGraphicsMessage(int32 code, LinkMsgReader &link) { fWinBorder->GetRootLayer()->Lock(); BRegion rreg(cl->fVisible); - rreg.IntersectWith(&fWinBorder->yUpdateReg); - + if (fWinBorder->fInUpdate) + rreg.IntersectWith(&fWinBorder->yUpdateReg); +//if (!fWinBorder->yUpdateReg.Frame().IsValid() && fWinBorder->fInUpdate) +//{ +// printf("ADi: FRAME INVALID!!!!\n"); +// fWinBorder->yUpdateReg.PrintToStream(); +//} desktop->GetDisplayDriver()->ConstrainClippingRegion(&rreg); // rgb_color rrr = cl->fLayerData->viewcolor.GetColor32(); // RGBColor c(rand()%255,rand()%255,rand()%255); // desktop->GetDisplayDriver()->FillRect(BRect(0,0,639,479), c); - +// snooze(500000); switch (code) { case AS_LAYER_SET_HIGH_COLOR: diff --git a/src/servers/app/WinBorder.cpp b/src/servers/app/WinBorder.cpp index 8d03dfa0d5..38e3d41a3a 100644 --- a/src/servers/app/WinBorder.cpp +++ b/src/servers/app/WinBorder.cpp @@ -83,9 +83,10 @@ WinBorder::WinBorder(const BRect &r, const char *name, const int32 look, const i { // unlike BViews, windows start off as hidden fHidden = true; + fInUpdate = false; fServerWin = win; fClassID = AS_WINBORDER_CLASS; - +cnt = 0; fMouseButtons = 0; fKeyModifiers = 0; fDecorator = NULL; @@ -311,7 +312,7 @@ void WinBorder::Draw(const BRect &r) fDecorator->SetFocus(true); else fDecorator->SetFocus(false); - fDecorator->Draw(fUpdateReg.Frame()); + fDecorator->Draw(r); } } diff --git a/src/servers/app/WinBorder.h b/src/servers/app/WinBorder.h index d2367e46c9..060ac3b87e 100644 --- a/src/servers/app/WinBorder.h +++ b/src/servers/app/WinBorder.h @@ -114,7 +114,7 @@ protected: BRegion zUpdateReg; BRegion yUpdateReg; - BRegion prevInvalid; + BRegion fUpdateReg; int32 fMouseButtons; int32 fKeyModifiers; @@ -123,7 +123,9 @@ protected: bool fIsClosing; bool fIsMinimizing; bool fIsZooming; - + + bool fInUpdate; + int cnt; float fMinWidth, fMaxWidth; float fMinHeight, fMaxHeight; };