From 7e638cddcc8cf410e17db3cf6821e7e2a2966b6c Mon Sep 17 00:00:00 2001 From: David Capello Date: Thu, 13 Dec 2018 14:47:19 -0300 Subject: [PATCH] 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. --- src/ui/manager.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/ui/manager.cpp b/src/ui/manager.cpp index 9fe5c85a5..2145e0e9b 100644 --- a/src/ui/manager.cpp +++ b/src/ui/manager.cpp @@ -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;