From 25b0ec461d9c522919706a6ddab812e6348696fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Wed, 18 May 2005 15:47:49 +0000 Subject: [PATCH] Now, GetMouse() processes and removes all _UPDATE_ messages, not just those before the first mouse message. This should be more correct and look better. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12715 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/View.cpp | 47 ++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/src/kits/interface/View.cpp b/src/kits/interface/View.cpp index b022a7a415..530d4c3785 100644 --- a/src/kits/interface/View.cpp +++ b/src/kits/interface/View.cpp @@ -765,8 +765,8 @@ BView::SetOrigin(BPoint pt) void BView::SetOrigin(float x, float y) { - if (!(fState->flags & B_VIEW_ORIGIN_BIT) && - x == fState->coordSysOrigin.x && y == fState->coordSysOrigin.y) + if (!(fState->flags & B_VIEW_ORIGIN_BIT) + && x == fState->coordSysOrigin.x && y == fState->coordSysOrigin.y) return; if (do_owner_check()) { @@ -1179,11 +1179,27 @@ BView::GetMouse(BPoint *location, uint32 *buttons, bool checkMessageQueue) if (checkMessageQueue) { BMessageQueue *queue = Window()->MessageQueue(); BMessage *msg; - int32 i = 0; queue->Lock(); - while ((msg = queue->FindMessage(i++)) != NULL) { + // First process and remove all _UPDATE_ messages + // ToDo: it would be great to join them together to one big update message! + + for (int32 i = 0; (msg = queue->FindMessage(i)) != NULL; ) { + 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; + } else + i++; + } + + // Then look out for mouse update messages + + for (int32 i = 0; (msg = queue->FindMessage(i)) != NULL; i++) { switch (msg->what) { case B_MOUSE_UP: case B_MOUSE_DOWN: @@ -1201,27 +1217,14 @@ BView::GetMouse(BPoint *location, uint32 *buttons, bool checkMessageQueue) queue->Unlock(); return; } - - case _UPDATE_: - { - // ToDo: We should even eat *all* _UPDATE_ messages - // in the queue, not only the ones before the current - // mouse message... - 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; - i--; - } } } queue->Unlock(); } - // If B_MOUSE_UP or B_MOUSE_MOVED has not been found in the message queue, - // tell app_server to send us the current mouse coords and buttons. + // If no mouse update message has been found in the message queue, + // we get the current mouse location and buttons from the app_server + owner->fLink->StartMessage(AS_LAYER_GET_MOUSE_COORDS); // This is because BPortLink doesn't automatically attach the reply @@ -1229,12 +1232,12 @@ BView::GetMouse(BPoint *location, uint32 *buttons, bool checkMessageQueue) // TODO: Fix BPortLink synchronous reply code owner->fLink->Attach(owner->fLink->GetReplyPort()); owner->fLink->Flush(); - + int32 rCode = SERVER_FALSE; owner->fLink->GetNextReply(&rCode); if (rCode == SERVER_TRUE) { owner->fLink->Read(location); - owner->fLink->Read((int32 *)buttons,sizeof(int32)); + owner->fLink->Read((int32 *)buttons, sizeof(int32)); } }