From 25500bdfd925317645cdbd9185ba6e47a546b838 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Thu, 19 May 2005 17:20:36 +0000 Subject: [PATCH] Fixed BWindow::UpdateIfNeeded() by moving the code from BView::GetMouse() over. GetMouse() will now just call UpdateIfNeeded(). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12736 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/View.cpp | 25 +++---------------------- src/kits/interface/Window.cpp | 29 ++++++++++++++++++----------- 2 files changed, 21 insertions(+), 33 deletions(-) diff --git a/src/kits/interface/View.cpp b/src/kits/interface/View.cpp index 2ab491b4b0..2239a9e988 100644 --- a/src/kits/interface/View.cpp +++ b/src/kits/interface/View.cpp @@ -1173,33 +1173,14 @@ BView::GetMouse(BPoint *location, uint32 *buttons, bool checkMessageQueue) do_owner_check(); if (checkMessageQueue) { - if (find_thread(NULL) == Window()->Thread()) { - // If the event loop is not running right now (we're blocking it), - // we need to retrieve all messages that are pending on the port. - Window()->DequeueAll(); - } - BMessageQueue *queue = Window()->MessageQueue(); queue->Lock(); - // First process and remove any _UPDATE_ message in the queue - // According to Adi, there can only be one at a time + Window()->UpdateIfNeeded(); + + // Look out for mouse update messages BMessage *msg; - for (int32 i = 0; (msg = queue->FindMessage(i)) != NULL; i++) { - if (msg->what == _UPDATE_) { - Window()->BWindow::DispatchMessage(msg, Window()); - // we need to make sure that no overridden method is called - // here; for BWindow::DispatchMessage() we now exactly what - // will happen - queue->RemoveMessage(msg); - delete msg; - break; - } - } - - // Then look out for mouse update messages - for (int32 i = 0; (msg = queue->FindMessage(i)) != NULL; i++) { switch (msg->what) { case B_MOUSE_UP: diff --git a/src/kits/interface/Window.cpp b/src/kits/interface/Window.cpp index 5fc1b80f7f..abcf1eb05a 100644 --- a/src/kits/interface/Window.cpp +++ b/src/kits/interface/Window.cpp @@ -1270,22 +1270,29 @@ BWindow::UpdateIfNeeded() if (find_thread(NULL) != Thread()) return; + // Since we're blocking the event loop, we need to retrieve + // all messages that are pending on the port. + DequeueAll(); + BMessageQueue *queue = MessageQueue(); queue->Lock(); - // process all _UPDATE_ BMessages in message queue - // we lock the queue because we don't want to be stuck in this - // function if there is a continuous stream of updates - BMessage *msg; - while ((msg = queue->FindMessage(_UPDATE_, 0))) { - // ToDo: combine messages if possible - Lock(); - DispatchMessage(msg, this); - Unlock(); + // First process and remove any _UPDATE_ message in the queue + // According to Adi, there can only be one at a time - queue->RemoveMessage(msg); - delete msg; + BMessage *msg; + for (int32 i = 0; (msg = queue->FindMessage(i)) != NULL; i++) { + if (msg->what == _UPDATE_) { + BWindow::DispatchMessage(msg, this); + // we need to make sure that no overridden method is called + // here; for BWindow::DispatchMessage() we now exactly what + // will happen + queue->RemoveMessage(msg); + delete msg; + break; + } } + queue->Unlock(); }