From 95e29889f4ada13620594a84eb23df831c128345 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Mon, 6 Feb 2006 19:34:36 +0000 Subject: [PATCH] This fixes the update problems that I could observe. The client might have been not in sync with the server regarding window position and size, which in turn messed up the ConvertFromScreen() functions and also the view Bounds(). Therefor the current window geometry is also added to the information the client gets when starting an update session. I think the problem was there before my previous changes, just maybe less likely to be observed. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16258 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/Window.cpp | 51 +++++++++++++++++++++++++++------ src/servers/app/WindowLayer.cpp | 15 ++++++++-- 2 files changed, 55 insertions(+), 11 deletions(-) diff --git a/src/kits/interface/Window.cpp b/src/kits/interface/Window.cpp index 80678a5328..24a0e9d545 100644 --- a/src/kits/interface/Window.cpp +++ b/src/kits/interface/Window.cpp @@ -776,11 +776,15 @@ BWindow::DispatchMessage(BMessage *msg, BHandler *target) MessageQueue()->RemoveMessage(pendingMessage); } } - fFrame.right = fFrame.left + width; - fFrame.bottom = fFrame.top + height; - - _AdoptResize(); - FrameResized(width, height); + if (width != fFrame.Width() || height != fFrame.Height()) { + // NOTE: we might have already handled the resize + // in an _UPDATE_ message + fFrame.right = fFrame.left + width; + fFrame.bottom = fFrame.top + height; + + _AdoptResize(); + FrameResized(width, height); + } } break; } @@ -789,9 +793,13 @@ BWindow::DispatchMessage(BMessage *msg, BHandler *target) { BPoint origin; if (msg->FindPoint("where", &origin) == B_OK) { - fFrame.OffsetTo(origin); + if (fFrame.LeftTop() != origin) { + // NOTE: we might have already handled the move + // in an _UPDATE_ message + fFrame.OffsetTo(origin); - FrameMoved(origin); + FrameMoved(origin); + } } break; } @@ -953,7 +961,34 @@ BWindow::DispatchMessage(BMessage *msg, BHandler *target) int32 code; if (fLink->FlushWithReply(code) == B_OK && code == B_OK) { - // read culmulated update rect + // read current window position and size first, + // the update rect is in screen coordinates... + // so we need to be up to date + BPoint origin; + fLink->Read(&origin); + float width; + float height; + fLink->Read(&width); + fLink->Read(&height); + if (origin != fFrame.LeftTop()) { + // TODO: remove code duplicatation with + // B_WINDOW_MOVED case... +//printf("window position was not up to date\n"); + fFrame.OffsetTo(origin); + FrameMoved(origin); + } + if (width != fFrame.Width() || height != fFrame.Height()) { + // TODO: remove code duplicatation with + // B_WINDOW_RESIZED case... +//printf("window size was not up to date\n"); + fFrame.right = fFrame.left + width; + fFrame.bottom = fFrame.top + height; + + _AdoptResize(); + FrameResized(width, height); + } + + // read culmulated update rect (is in screen coords) fLink->Read(&updateRect); // read tokens for views that need to be drawn diff --git a/src/servers/app/WindowLayer.cpp b/src/servers/app/WindowLayer.cpp index 8fe7fd1eec..ad470d8c92 100644 --- a/src/servers/app/WindowLayer.cpp +++ b/src/servers/app/WindowLayer.cpp @@ -1596,7 +1596,7 @@ WindowLayer::_ShiftPartOfRegion(BRegion* region, BRegion* regionToShift, if (common.CountRects() > 0) { // cut the common part from the region, // offset that to destination and include again -// region->Exclude(&common); + region->Exclude(&common); common.OffsetBy(xOffset, yOffset); region->Include(&common); } @@ -1751,10 +1751,18 @@ WindowLayer::BeginUpdate(BPrivate::PortLink& link) BRegion dirty(fCurrentUpdateSession.DirtyRegion()); dirty.IntersectWith(&VisibleContentRegion()); +//fDrawingEngine->FillRegion(dirty, RGBColor(255, 0, 0, 255)); + + link.StartMessage(B_OK); + // append the current window geometry to the + // message, the client will need it + link.Attach(fFrame.LeftTop()); + link.Attach(fFrame.Width()); + link.Attach(fFrame.Height()); + // append he update rect in screen coords + link.Attach(dirty.Frame()); // find and attach all views that intersect with // the dirty region - link.StartMessage(B_OK); - link.Attach(dirty.Frame()); fTopLayer->AddTokensForLayersInRegion(link, dirty, &fContentRegion); // mark the end of the token "list" link.Attach(B_NULL_TOKEN); @@ -1767,6 +1775,7 @@ WindowLayer::BeginUpdate(BPrivate::PortLink& link) &fContentRegion, true); #endif } else { +printf("BeginUpdate() but no update requested!!\n"); link.StartMessage(B_ERROR); link.Flush(); fprintf(stderr, "WindowLayer::BeginUpdate() - no update requested!\n");