change the way the _UPDATE_ message is used: it is now a mere notification that some views need updating. The BWindow will then pull data from the server which views exactly and the update rect. Therefor, the server can append regions to the current update session even if an _UPDATE_ message has already been sent to the client. If multiple views are invalidated in the client, only one update session will be triggered instead of two with the old implementation. Some drawing defects can be observed, but I know how to reproduce them so I hope to fix them soon.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16245 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2006-02-06 10:28:30 +00:00
parent 585c5a0042
commit bb160ab5f6
6 changed files with 88 additions and 34 deletions
+28 -6
View File
@@ -946,16 +946,38 @@ BWindow::DispatchMessage(BMessage *msg, BHandler *target)
{
STRACE(("info:BWindow handling _UPDATE_.\n"));
BRect updateRect;
msg->FindRect("_rect", &updateRect);
updateRect.OffsetBy(fFrame.LeftTop());
fLink->StartMessage(AS_BEGIN_UPDATE);
fInTransaction = true;
int32 token;
for (int32 i = 0; msg->FindInt32("_token", i, &token) == B_OK; i++) {
if (BView* view = _FindView(token))
view->_Draw(updateRect);
int32 code;
if (fLink->FlushWithReply(code) == B_OK
&& code == B_OK) {
// read culmulated update rect
fLink->Read<BRect>(&updateRect);
// read tokens for views that need to be drawn
// NOTE: we need to read the tokens completely
// first, or other calls would likely mess up the
// data in the link.
BList tokens(20);
int32 token;
status_t error = fLink->Read<int32>(&token);
while (error >= B_OK && token != B_NULL_TOKEN) {
tokens.AddItem((void*)token);
error = fLink->Read<int32>(&token);
}
// draw
int32 count = tokens.CountItems();
for (int32 i = 0; i < count; i++) {
if (BView* view = _FindView((int32)tokens.ItemAtFast(i)))
view->_Draw(updateRect);
}
// TODO: the tokens are actually hirachically sorted,
// so traversing the list in revers and calling
// child->DrawAfterChildren would actually work correctly,
// only that drawing outside a view is not yet supported
// in the app_server.
}
fLink->StartMessage(AS_END_UPDATE);