Refactor HAS_MOUSE flag handling

Now each widget is responsible to enable/disable its own HAS_MOUSE flag
in response to the kMouseEnter/Leave message received. Also there is no
need to iterate over the parents since these messages are propagated
to the parent
This commit is contained in:
Martín Capello 2024-10-28 17:59:37 -03:00 committed by David Capello
parent f67643a24e
commit 9e396227c2
3 changed files with 9 additions and 15 deletions

View File

@ -1012,13 +1012,6 @@ void Manager::setMouse(Widget* widget)
msg->setPropagateToParent(true);
msg->setCommonAncestor(commonAncestor);
enqueueMessage(msg);
// Remove HAS_MOUSE from all the hierarchy
auto a = mouse_widget;
while (a && a != commonAncestor) {
a->disableFlags(HAS_MOUSE);
a = a->parent();
}
}
// If the mouse is captured, we can just put the HAS_MOUSE flag in
@ -1049,13 +1042,6 @@ void Manager::setMouse(Widget* widget)
mousePos,
kKeyUninitializedModifier,
PointerType::Unknown);
// Add HAS_MOUSE to all the hierarchy
auto a = mouse_widget;
while (a && a != commonAncestor) {
a->enableFlags(HAS_MOUSE);
a = a->parent();
}
}
}

View File

@ -85,7 +85,7 @@ bool TooltipManager::onProcessMessage(Message* msg)
m_timer->start();
}
}
break;
return false;
}
case kKeyDownMessage:

View File

@ -1620,6 +1620,14 @@ bool Widget::onProcessMessage(Message* msg)
else
break;
case kMouseEnterMessage:
enableFlags(HAS_MOUSE);
return true;
case kMouseLeaveMessage:
disableFlags(HAS_MOUSE);
return true;
case kSetCursorMessage:
// Propagate the message to the parent.
if (parent())