From 5604d3c9ce05669fb26f5f3a4a858c5269b14994 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Thu, 24 Nov 2005 16:25:41 +0000 Subject: [PATCH] * _DetermineTarget() will now return fLastMouseMovedView in case there was no valid "_view_token" in the mouse event. * _SanitizeMessage() will now only add the "be:transit" field for B_MOUSE_MOVED messages. It will also now only update fLastMouseMovedView for B_MOUSE_MOVED messages, and not for all mouse messages. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15124 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/Window.cpp | 65 +++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 29 deletions(-) diff --git a/src/kits/interface/Window.cpp b/src/kits/interface/Window.cpp index de4176b566..4158923abf 100644 --- a/src/kits/interface/Window.cpp +++ b/src/kits/interface/Window.cpp @@ -2454,6 +2454,11 @@ BWindow::_DetermineTarget(BMessage *message, BHandler *target) return view; } } + + // if there is no valid token in the message, we try our + // luck with the last target, if available + if (fLastMouseMovedView != NULL) + return fLastMouseMovedView; break; case B_PULSE: @@ -2582,38 +2587,40 @@ BWindow::_SanitizeMessage(BMessage* message, BHandler* target, bool usePreferred // add local view coordinates message->AddPoint("be:view_where", view->ConvertFromScreen(where)); - // is there a token of the view that is currently under the mouse? - BView* viewUnderMouse = NULL; - int32 token; - if (message->FindInt32("_view_token", &token) == B_OK) { - BHandler* handler; - if (gDefaultTokens.GetToken(token, B_HANDLER_TOKEN, - (void**)&handler) == B_OK) - viewUnderMouse = dynamic_cast(handler); - } - - // add transit information - int32 transit; - if (message->FindInt32("be:transit", &transit) != B_OK) { - if (viewUnderMouse == view) { - // the mouse is over the target view - if (fLastMouseMovedView != view) - transit = B_ENTERED_VIEW; - else - transit = B_INSIDE_VIEW; - } else { - // the mouse is not over the target view - if (view == fLastMouseMovedView) - transit = B_EXITED_VIEW; - else - transit = B_OUTSIDE_VIEW; + if (message->what == B_MOUSE_MOVED) { + // is there a token of the view that is currently under the mouse? + BView* viewUnderMouse = NULL; + int32 token; + if (message->FindInt32("_view_token", &token) == B_OK) { + BHandler* handler; + if (gDefaultTokens.GetToken(token, B_HANDLER_TOKEN, + (void**)&handler) == B_OK) + viewUnderMouse = dynamic_cast(handler); + } + + // add transit information + int32 transit; + if (message->FindInt32("be:transit", &transit) != B_OK) { + if (viewUnderMouse == view) { + // the mouse is over the target view + if (fLastMouseMovedView != view) + transit = B_ENTERED_VIEW; + else + transit = B_INSIDE_VIEW; + } else { + // the mouse is not over the target view + if (view == fLastMouseMovedView) + transit = B_EXITED_VIEW; + else + transit = B_OUTSIDE_VIEW; + } + + message->AddInt32("be:transit", transit); } - message->AddInt32("be:transit", transit); + if (usePreferred || viewUnderMouse == NULL) + fLastMouseMovedView = viewUnderMouse; } - - if (usePreferred || viewUnderMouse == NULL) - fLastMouseMovedView = viewUnderMouse; } break; }