From 1596a167c0c7cd591f8817db58c6ef0d02f9375e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Thu, 28 Apr 2005 23:56:40 +0000 Subject: [PATCH] work around for layers not being moved that have not yet been added to the tree. See WinBorder::MoveTo for the explaination. The same problem should be at other places and most likely for normal views as well. This fixes BWindow::MoveXX() when it is not yet Show()n git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12500 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/Window.cpp | 1 - src/servers/app/Layer.cpp | 16 ++++++++++++---- src/servers/app/Layer.h | 4 ++++ src/servers/app/RootLayer.cpp | 28 ++++++++++------------------ src/servers/app/WinBorder.cpp | 31 ++++++++++++++++++++++++++++++- 5 files changed, 56 insertions(+), 24 deletions(-) diff --git a/src/kits/interface/Window.cpp b/src/kits/interface/Window.cpp index 433475d9e7..9350c82ace 100644 --- a/src/kits/interface/Window.cpp +++ b/src/kits/interface/Window.cpp @@ -1911,7 +1911,6 @@ void BWindow::MoveBy(float dx, float dy) void BWindow::MoveTo( BPoint point ) { -printf("BWindow::MoveTo(%.1f, %.1f)\n", point.x, point.y); Lock(); if (fFrame.left != point.x || fFrame.top != point.y) { diff --git a/src/servers/app/Layer.cpp b/src/servers/app/Layer.cpp index 294fa45459..5a71b2a36e 100644 --- a/src/servers/app/Layer.cpp +++ b/src/servers/app/Layer.cpp @@ -559,11 +559,13 @@ Layer::RebuildRegions( const BRegion& reg, uint32 action, BPoint pt, BPoint ptOf switch(action) { case B_LAYER_NONE: { RBTRACE(("1) Layer(%s): Action B_LAYER_NONE\n", GetName())); + STRACE(("1) Layer(%s): Action B_LAYER_NONE\n", GetName())); oldRegion = fVisible; break; } case B_LAYER_MOVE: { RBTRACE(("1) Layer(%s): Action B_LAYER_MOVE\n", GetName())); + STRACE(("1) Layer(%s): Action B_LAYER_MOVE\n", GetName())); oldRegion = fFullVisible; fFrame.OffsetBy(pt.x, pt.y); fFull.OffsetBy(pt.x, pt.y); @@ -576,12 +578,14 @@ Layer::RebuildRegions( const BRegion& reg, uint32 action, BPoint pt, BPoint ptOf } case B_LAYER_SIMPLE_MOVE: { RBTRACE(("1) Layer(%s): Action B_LAYER_SIMPLE_MOVE\n", GetName())); + STRACE(("1) Layer(%s): Action B_LAYER_SIMPLE_MOVE\n", GetName())); fFull.OffsetBy(pt.x, pt.y); break; } case B_LAYER_RESIZE: { RBTRACE(("1) Layer(%s): Action B_LAYER_RESIZE\n", GetName())); + STRACE(("1) Layer(%s): Action B_LAYER_RESIZE\n", GetName())); oldRegion = fVisible; fFrame.right += pt.x; @@ -596,6 +600,7 @@ Layer::RebuildRegions( const BRegion& reg, uint32 action, BPoint pt, BPoint ptOf } case B_LAYER_MASK_RESIZE: { RBTRACE(("1) Layer(%s): Action B_LAYER_MASK_RESIZE\n", GetName())); + STRACE(("1) Layer(%s): Action B_LAYER_MASK_RESIZE\n", GetName())); oldRegion = fVisible; BPoint offset, rSize; @@ -1265,20 +1270,23 @@ Layer::move_layer(float x, float y) { fFrameAction = B_LAYER_ACTION_MOVE; - BPoint pt(x,y); - BRect rect(fFull.Frame().OffsetByCopy(pt)); - if (fClassID == AS_WINBORDER_CLASS) { +/* if (fClassID == AS_WINBORDER_CLASS) { WinBorder *wb = (WinBorder*)this; wb->zUpdateReg.OffsetBy(x, y); wb->yUpdateReg.OffsetBy(x, y); wb->fUpdateReg.OffsetBy(x, y); - } + }*/ + BPoint pt(x, y); + BRect rect(fFull.Frame().OffsetByCopy(pt)); + fParent->StartRebuildRegions(BRegion(rect), this, B_LAYER_MOVE, pt); + fDriver->CopyRegionList(&fRootLayer->fCopyRegList, &fRootLayer->fCopyList, fRootLayer->fCopyRegList.CountItems(), &fFullVisible); + fParent->Redraw(fRootLayer->fRedrawReg, this); EmptyGlobals(); diff --git a/src/servers/app/Layer.h b/src/servers/app/Layer.h index 9fc5588a5f..aca3104dbb 100644 --- a/src/servers/app/Layer.h +++ b/src/servers/app/Layer.h @@ -199,6 +199,10 @@ class Layer { void Invalidate(const BRegion& region); BRect fFrame; +// TODO: should be removed or reused in a similar fashion +// to hold the accumulated origins from the graphics state stack. +// The same needs to be done for "scale". (Keeping an accumulated +// value.) // BPoint fBoundsLeftTop; WinBorder* fOwner; Layer* fParent; diff --git a/src/servers/app/RootLayer.cpp b/src/servers/app/RootLayer.cpp index 3c78d104bb..2215344bfe 100644 --- a/src/servers/app/RootLayer.cpp +++ b/src/servers/app/RootLayer.cpp @@ -1227,17 +1227,13 @@ void RootLayer::MouseEventHandler(int32 code, BPortLink& msg) } } - if (winBorderUnder) - { - BPoint pt = evt.where; - pt -= fLastMousePossition; + if (winBorderUnder) { - if (fMovingWindow) - { - if(winBorderUnder->fDecorator) - winBorderUnder->fDecorator->MoveBy(pt.x, pt.y); + BPoint delta = evt.where - fLastMousePossition; - winBorderUnder->move_layer(pt.x, pt.y); + if (fMovingWindow) { + + winBorderUnder->MoveBy(delta.x, delta.y); // I know the way we get BWindow's new location it's not nice :-), // but I don't see another way. fTopLayer.Frame().LeftTop() does not change, ever. @@ -1245,22 +1241,18 @@ void RootLayer::MouseEventHandler(int32 code, BPortLink& msg) BMessage msg(B_WINDOW_MOVED); msg.AddPoint("where", location); winBorderUnder->Window()->SendMessageToClient(&msg, B_NULL_TOKEN, false); - } - else if (fResizingWindow) - { - if(winBorderUnder->fDecorator) - winBorderUnder->fDecorator->ResizeBy(pt.x, pt.y); - winBorderUnder->resize_layer(pt.x, pt.y); + } else if (fResizingWindow) { + + winBorderUnder->ResizeBy(delta.x, delta.y); BRect frame(winBorderUnder->fTopLayer->Frame()); BMessage msg(B_WINDOW_RESIZED); msg.AddInt32("width", frame.Width()); msg.AddInt32("height", frame.Height()); winBorderUnder->Window()->SendMessageToClient(&msg, B_NULL_TOKEN, false); - } - else - { + + } else { winBorderUnder->MouseMoved(winBorderUnder->TellWhat(evt)); } } diff --git a/src/servers/app/WinBorder.cpp b/src/servers/app/WinBorder.cpp index 0e0bd9fca5..46761fbb52 100644 --- a/src/servers/app/WinBorder.cpp +++ b/src/servers/app/WinBorder.cpp @@ -313,7 +313,36 @@ void WinBorder::MoveBy(float x, float y) if(fDecorator) fDecorator->MoveBy(x,y); - move_layer(x,y); +// NOTE: I moved this here from Layer::move_layer() +// Should this have any bad consequences I'm not aware of? +zUpdateReg.OffsetBy(x, y); +yUpdateReg.OffsetBy(x, y); +fUpdateReg.OffsetBy(x, y); + + if (IsHidden()) { +// TODO: This is a work around for a design issue: +// The actual movement of a layer is done during +// the region rebuild. The mechanism is somewhat +// complicated and scheduled for refractoring... +// The problem here for hidden layers is that +// they seem *not* to be part of the layer tree. +// I don't think this is wrong as such, but of +// course the rebuilding of regions does not take +// place then. I don't understand yet the consequences +// for normal views, but this here fixes at least +// BWindows being MoveTo()ed before they are Show()n. +// In Layer::move_to, StartRebuildRegions() is called +// on fParent. But the rest of the this layers tree +// has not been added to fParent apperantly. So now +// you ask why fParent is even valid? Me too. + fFrame.OffsetBy(x, y); + fFull.OffsetBy(x, y); + fTopLayer->move_layer(x, y); + // ...and here we get really hacky... + fTopLayer->fFrame.OffsetTo(0.0, 0.0); + } else { + move_layer(x, y); + } } //! Resizes the winborder with redraw