From d6eafa1bdbcfa69d60d2d7340c331e34d6915500 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 10 Sep 2024 19:26:16 +0300 Subject: Make updateKeyboardFocus a bit more efficient --- indra/newview/llviewerwindow.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'indra/newview/llviewerwindow.cpp') diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 8ea8fbf905..e24fb35acb 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -3888,7 +3888,9 @@ void LLViewerWindow::updateKeyboardFocus() LLUICtrl* cur_focus = dynamic_cast(gFocusMgr.getKeyboardFocus()); if (cur_focus) { - if (!cur_focus->isInVisibleChain() || !cur_focus->isInEnabledChain()) + bool is_in_visible_chain = cur_focus->isInVisibleChain(); + bool is_in_enabled_chain = cur_focus->isInEnabledChain(); + if (!is_in_visible_chain || !is_in_enabled_chain) { // don't release focus, just reassign so that if being given // to a sibling won't call onFocusLost on all the ancestors @@ -3899,11 +3901,19 @@ void LLViewerWindow::updateKeyboardFocus() bool new_focus_found = false; while(parent) { + if (!is_in_visible_chain) + { + is_in_visible_chain = parent->isInVisibleChain(); + } + if (!is_in_enabled_chain) + { + is_in_enabled_chain = parent->isInEnabledChain(); + } if (parent->isCtrl() && (parent->hasTabStop() || parent == focus_root) && !parent->getIsChrome() - && parent->isInVisibleChain() - && parent->isInEnabledChain()) + && is_in_visible_chain + && is_in_enabled_chain) { if (!parent->focusFirstItem()) { -- cgit v1.2.3