* changed the way a message is forwarded to the focus view (instead of adding

a suspend focus field to the message, there is now a "feed focus" field in
  case the message should be forwarded).
* added a comment to the BPoint version of _FindView() (since it's broken)
* _DistributeMessage() is now called after _DetermineTarget() - so that it
  can prevent sending the message twice to the focus view.
* removed BWindow::DoUpdate() as it's no longer used.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15066 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2005-11-22 12:49:35 +00:00
parent 8e51bdd43f
commit b095201503
4 changed files with 57 additions and 16 deletions
+1 -3
View File
@@ -267,7 +267,7 @@ private:
void AddShortcut(uint32 key, uint32 modifiers,
BMenuItem* item);
BHandler* _DetermineTarget(BMessage* message, BHandler* target);
bool _DistributeMessage(BMessage* message);
bool _DistributeMessage(BMessage* message, BHandler* target);
bool InUpdate();
void _DequeueAll();
@@ -293,8 +293,6 @@ private:
bool _HandleKeyDown(char key, uint32 modifiers);
void _KeyboardNavigation();
void DoUpdate(BView* view, BRect& area);
// Debug (TODO: to be removed)
void PrintToStream() const;
+31 -10
View File
@@ -2241,11 +2241,11 @@ BWindow::task_looper()
B_HANDLER_TOKEN, (void **)&handler);
}
if (!usePreferred || _DistributeMessage(fLastMessage)) {
// if a target was given, and we should not use the preferred
// handler, we can just use that one
if (handler == NULL || usePreferred)
handler = _DetermineTarget(fLastMessage, handler);
// if a target was given, and we should not use the preferred
// handler, we can just use that one
if (handler == NULL || usePreferred)
handler = _DetermineTarget(fLastMessage, handler);
if (!usePreferred || _DistributeMessage(fLastMessage, handler)) {
if (handler == NULL)
handler = this;
@@ -2471,15 +2471,19 @@ BWindow::_DetermineTarget(BMessage *message, BHandler *target)
Returns \c true in case the message should still be dispatched
*/
bool
BWindow::_DistributeMessage(BMessage* message)
BWindow::_DistributeMessage(BMessage* message, BHandler* focus)
{
bool suspend;
if (message->FindBool("_suspend_focus", &suspend) != B_OK)
suspend = false;
bool foundFocus = false;
int32 focusToken = B_NULL_TOKEN;
if (focus != NULL)
focusToken = _get_object_token_(focus);
int32 index = 0;
int32 token;
for (; message->FindInt32("_token", index, &token) == B_OK; index++) {
if (token == focusToken)
foundFocus = true;
BView* target = _FindView(token);
if (target == NULL)
continue;
@@ -2488,7 +2492,20 @@ BWindow::_DistributeMessage(BMessage* message)
messenger.SendMessage(message);
}
return !suspend;
if (index > 0) {
if (foundFocus) {
// the focus view already got this message
return false;
}
// should this message still be dispatched by the focus view?
bool feedFocus;
if (message->FindBool("_feed_focus", &feedFocus) != B_OK
|| feedFocus == false)
return false;
}
return true;
}
@@ -2629,6 +2646,10 @@ BWindow::_FindView(int32 token)
BView *
BWindow::_FindView(BView *view, BPoint point) const
{
// TODO: this is totally broken (bounds vs. frame) - since
// BView::Bounds() potentially queries the app_server
// anyway, we could just let the app_server answer this
// query directly.
if (view->Bounds().Contains(point) && !view->fFirstChild)
return view;
+22 -3
View File
@@ -496,6 +496,21 @@ EventDispatcher::_SetToken(BMessage* message, int32 token)
}
void
EventDispatcher::_SetFeedFocus(BMessage* message)
{
if (message->ReplaceBool("_feed_focus", true) != B_OK)
message->AddBool("_feed_focus", true);
}
void
EventDispatcher::_UnsetFeedFocus(BMessage* message)
{
message->RemoveName("_feed_focus");
}
void
EventDispatcher::_EventLoop()
{
@@ -563,6 +578,8 @@ EventDispatcher::_EventLoop()
if (fHasFocus) {
addedTokens |= _AddTokens(event, fFocusTokens);
if (addedTokens)
_SetFeedFocus(event);
_SendMessage(fFocus, event, event->what == B_MOUSE_MOVED
? kMouseMovedImportance : kStandardImportance);
}
@@ -585,8 +602,8 @@ EventDispatcher::_EventLoop()
// forwarded to the target
addedTokens = true;
if (fSuspendFocus)
event->AddBool("_suspend_focus", true);
if (!fSuspendFocus)
_SetFeedFocus(event);
}
// supposed to fall through
@@ -600,8 +617,10 @@ EventDispatcher::_EventLoop()
if (keyboardEvent || pointerEvent) {
// send the event to the additional listeners
if (addedTransit)
if (addedTransit) {
_UnsetTransit(event);
_UnsetFeedFocus(event);
}
if (addedTokens)
_RemoveTokens(event);
+3
View File
@@ -49,11 +49,14 @@ class EventDispatcher : public BLocker {
void _Unset();
bool _SendMessage(BMessenger& messenger, BMessage* message, float importance);
void _SetTransit(BMessage* message, int32 transit);
void _UnsetTransit(BMessage* message);
bool _AddTokens(BMessage* message, BList& tokens);
void _RemoveTokens(BMessage* message);
void _SetToken(BMessage* message, int32 token);
void _SetFeedFocus(BMessage* message);
void _UnsetFeedFocus(BMessage* message);
event_target* _FindListener(const BMessenger& messenger, int32 token,
int32* _index = NULL);