Fix keyboard shortcuts dialog items: don't create/dsetroy children widgets continuously inside KeyItem

Don't send a leave message (e.g. kMouseLeaveMessage) if the old
focused widget (mouse_widget) if an ancestor of the new focused
widget.
This commit is contained in:
David Capello 2018-12-13 14:47:19 -03:00
parent c0fcef0240
commit 7e638cddcc

View File

@ -743,7 +743,7 @@ void Manager::setFocus(Widget* widget)
Widget* commonAncestor = findLowestCommonAncestor(focus_widget, widget);
// Fetch the focus
if (focus_widget) {
if (focus_widget && focus_widget != commonAncestor) {
auto msg = new Message(kFocusLeaveMessage);
msg->setRecipient(focus_widget);
msg->setPropagateToParent(true);
@ -797,10 +797,9 @@ void Manager::setMouse(Widget* widget)
Widget* commonAncestor = findLowestCommonAncestor(mouse_widget, widget);
// Fetch the mouse
if (mouse_widget) {
if (mouse_widget && mouse_widget != commonAncestor) {
auto msg = new Message(kMouseLeaveMessage);
msg->setRecipient(mouse_widget);
msg->setCommonAncestor(commonAncestor);
msg->setPropagateToParent(true);
msg->setCommonAncestor(commonAncestor);
enqueueMessage(msg);
@ -1584,9 +1583,6 @@ Widget* Manager::findLowestCommonAncestor(Widget* a, Widget* b)
if (!a || !b)
return nullptr;
a = a->parent();
b = b->parent();
Widget* u = a;
Widget* v = b;
int aDepth = 0;