From 36e605d5f34e9fc0d398b62598b8a350a416b531 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Tue, 20 Dec 2005 22:20:37 +0000 Subject: [PATCH] combine _UPDATE_ and B_WINDOW_RESIZED messages, I left the old code commented, because my combining code might need review. I don't understand why the current message is still in the queue and why passing 1 as index to FindMessage does not seem to work, BMessageQueue::RemoveMessage does not delete the message as documented in the BeBook... everywhere else in the code it seems to be taken as a fact git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15621 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/Window.cpp | 67 +++++++++++++++++++++++++++++++---- 1 file changed, 61 insertions(+), 6 deletions(-) diff --git a/src/kits/interface/Window.cpp b/src/kits/interface/Window.cpp index 1119a54fc2..f99f369c21 100644 --- a/src/kits/interface/Window.cpp +++ b/src/kits/interface/Window.cpp @@ -732,8 +732,38 @@ BWindow::DispatchMessage(BMessage *msg, BHandler *target) case B_WINDOW_RESIZED: { int32 width, height; +// if (msg->FindInt32("width", &width) == B_OK +// && msg->FindInt32("height", &height) == B_OK) { +// fFrame.right = fFrame.left + width; +// fFrame.bottom = fFrame.top + height; +// +// _AdoptResize(); +// FrameResized(width, height); +// } if (msg->FindInt32("width", &width) == B_OK && msg->FindInt32("height", &height) == B_OK) { + + // combine with pending resize notifications + BMessage* pendingMessage; + while ((pendingMessage = MessageQueue()->FindMessage(B_WINDOW_RESIZED, 0))) { + if (pendingMessage != msg) { + int32 nextWidth; + if (pendingMessage->FindInt32("width", &nextWidth) == B_OK) + width = nextWidth; + + int32 nextHeight; + if (pendingMessage->FindInt32("height", &nextHeight) == B_OK) + height = nextHeight; + + MessageQueue()->RemoveMessage(pendingMessage); + // TODO: the BeBook says that MessageQueue::RemoveMessage() deletes the message! + delete pendingMessage; + // this deletes the first *additional* message + // fCurrentMessage is safe + } else { + MessageQueue()->RemoveMessage(pendingMessage); + } + } fFrame.right = fFrame.left + width; fFrame.bottom = fFrame.top + height; @@ -897,14 +927,39 @@ BWindow::DispatchMessage(BMessage *msg, BHandler *target) case _UPDATE_: { STRACE(("info:BWindow handling _UPDATE_.\n")); - BRect updateRect; - int32 token; - msg->FindRect("_rect", &updateRect); - msg->FindInt32("_token", &token); - // TODO: why is "_token" ignored? +// BRect updateRect; +// int32 token; +// msg->FindRect("_rect", &updateRect); +// msg->FindInt32("_token", &token); +// // TODO: why is "_token" ignored? +// +// fLink->StartMessage(AS_BEGIN_UPDATE); +// fTopView->_Draw(updateRect); +// fLink->StartMessage(AS_END_UPDATE); +// fLink->Flush(); + + BRect total; + msg->FindRect("_rect", &total); + + // combine with pending update requests + BRect next; + BMessage* pendingMessage; + while ((pendingMessage = MessageQueue()->FindMessage(_UPDATE_, 0))) { + if (pendingMessage != msg) { + pendingMessage->FindRect("_rect", &next); + total = total | next; + MessageQueue()->RemoveMessage(pendingMessage); + // TODO: the BeBook says that MessageQueue::RemoveMessage() deletes the message! + // this deletes the first *additional* message + // fCurrentMessage is safe + delete pendingMessage; + } else { + MessageQueue()->RemoveMessage(pendingMessage); + } + } fLink->StartMessage(AS_BEGIN_UPDATE); - fTopView->_Draw(updateRect); + fTopView->_Draw(total); fLink->StartMessage(AS_END_UPDATE); fLink->Flush(); break;