diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2024-08-13 15:32:47 -0400 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2024-08-13 15:32:47 -0400 |
commit | 23f2631d598b6e07450a96ed1ec00670c8867cdd (patch) | |
tree | 20195c1688ad8cb7e8631c97fa5920624f10972c /indra/llui/llfocusmgr.cpp | |
parent | 54334ff6e377e35c97df3a0fe2a859795ec07b21 (diff) | |
parent | 8ce3323269d95f54e2b768c4c5aa154d4afbbb6b (diff) |
Merge branch 'develop' into nat/edu-channel
Diffstat (limited to 'indra/llui/llfocusmgr.cpp')
-rw-r--r-- | indra/llui/llfocusmgr.cpp | 70 |
1 files changed, 40 insertions, 30 deletions
diff --git a/indra/llui/llfocusmgr.cpp b/indra/llui/llfocusmgr.cpp index 2331b34c43..0d7c98294f 100644 --- a/indra/llui/llfocusmgr.cpp +++ b/indra/llui/llfocusmgr.cpp @@ -41,21 +41,21 @@ LLFocusableElement::LLFocusableElement() } // virtual -BOOL LLFocusableElement::handleKey(KEY key, MASK mask, BOOL called_from_parent) +bool LLFocusableElement::handleKey(KEY key, MASK mask, bool called_from_parent) { - return FALSE; + return false; } // virtual -BOOL LLFocusableElement::handleKeyUp(KEY key, MASK mask, BOOL called_from_parent) +bool LLFocusableElement::handleKeyUp(KEY key, MASK mask, bool called_from_parent) { - return FALSE; + return false; } // virtual -BOOL LLFocusableElement::handleUnicodeChar(llwchar uni_char, BOOL called_from_parent) +bool LLFocusableElement::handleUnicodeChar(llwchar uni_char, bool called_from_parent) { - return FALSE; + return false; } // virtual @@ -73,10 +73,20 @@ bool LLFocusableElement::wantsReturnKey() const // virtual LLFocusableElement::~LLFocusableElement() { - delete mFocusLostCallback; - delete mFocusReceivedCallback; - delete mFocusChangedCallback; - delete mTopLostCallback; + auto free_signal = [&](focus_signal_t*& signal) + { + if (signal) + { + signal->disconnect_all_slots(); + delete signal; + signal = nullptr; + } + }; + + free_signal(mFocusLostCallback); + free_signal(mFocusReceivedCallback); + free_signal(mFocusChangedCallback); + free_signal(mTopLostCallback); } void LLFocusableElement::onFocusReceived() @@ -96,12 +106,12 @@ void LLFocusableElement::onTopLost() if (mTopLostCallback) (*mTopLostCallback)(this); } -BOOL LLFocusableElement::hasFocus() const +bool LLFocusableElement::hasFocus() const { return gFocusMgr.getKeyboardFocus() == this; } -void LLFocusableElement::setFocus(BOOL b) +void LLFocusableElement::setFocus(bool b) { } @@ -149,9 +159,9 @@ LLFocusMgr::LLFocusMgr() mKeyboardFocus( NULL ), mLastKeyboardFocus( NULL ), mDefaultKeyboardFocus( NULL ), - mKeystrokesOnly(FALSE), + mKeystrokesOnly(false), mTopCtrl( NULL ), - mAppHasFocus(TRUE), // Macs don't seem to notify us that we've gotten focus, so default to true + mAppHasFocus(true), // Macs don't seem to notify us that we've gotten focus, so default to true mImpl(new LLFocusMgr::Impl) { } @@ -183,10 +193,10 @@ void LLFocusMgr::releaseFocusIfNeeded( LLView* view ) } } - LLUI::getInstance()->removePopup(view); + if(LLUI::instanceExists()) LLUI::getInstance()->removePopup(view); } -void LLFocusMgr::setKeyboardFocus(LLFocusableElement* new_focus, BOOL lock, BOOL keystrokes_only) +void LLFocusMgr::setKeyboardFocus(LLFocusableElement* new_focus, bool lock, bool keystrokes_only) { // notes if keyboard focus is changed again (by onFocusLost/onFocusReceived) // making the rest of our processing unnecessary since it will already be @@ -269,7 +279,7 @@ void LLFocusMgr::setKeyboardFocus(LLFocusableElement* new_focus, BOOL lock, BOOL // releasing keyboard focus, move to the default. if (mDefaultKeyboardFocus != NULL && mKeyboardFocus == NULL) { - mDefaultKeyboardFocus->setFocus(TRUE); + mDefaultKeyboardFocus->setFocus(true); } LLView* focus_subtree = dynamic_cast<LLView*>(mKeyboardFocus); @@ -301,23 +311,23 @@ void LLFocusMgr::setKeyboardFocus(LLFocusableElement* new_focus, BOOL lock, BOOL } -// Returns TRUE is parent or any descedent of parent has keyboard focus. -BOOL LLFocusMgr::childHasKeyboardFocus(const LLView* parent ) const +// Returns true is parent or any descedent of parent has keyboard focus. +bool LLFocusMgr::childHasKeyboardFocus(const LLView* parent ) const { LLView* focus_view = dynamic_cast<LLView*>(mKeyboardFocus); while( focus_view ) { if( focus_view == parent ) { - return TRUE; + return true; } focus_view = focus_view->getParent(); } - return FALSE; + return false; } -// Returns TRUE is parent or any descedent of parent is the mouse captor. -BOOL LLFocusMgr::childHasMouseCapture( const LLView* parent ) const +// Returns true is parent or any descedent of parent is the mouse captor. +bool LLFocusMgr::childHasMouseCapture( const LLView* parent ) const { if( mMouseCaptor && dynamic_cast<LLView*>(mMouseCaptor) != NULL ) { @@ -326,12 +336,12 @@ BOOL LLFocusMgr::childHasMouseCapture( const LLView* parent ) const { if( captor_view == parent ) { - return TRUE; + return true; } captor_view = captor_view->getParent(); } } - return FALSE; + return false; } void LLFocusMgr::removeKeyboardFocusWithoutCallback( const LLFocusableElement* focus ) @@ -400,18 +410,18 @@ void LLFocusMgr::removeMouseCaptureWithoutCallback( const LLMouseHandler* captor } -BOOL LLFocusMgr::childIsTopCtrl( const LLView* parent ) const +bool LLFocusMgr::childIsTopCtrl( const LLView* parent ) const { LLView* top_view = (LLView*)mTopCtrl; while( top_view ) { if( top_view == parent ) { - return TRUE; + return true; } top_view = top_view->getParent(); } - return FALSE; + return false; } @@ -471,7 +481,7 @@ void LLFocusMgr::triggerFocusFlash() mFocusFlashTimer.reset(); } -void LLFocusMgr::setAppHasFocus(BOOL focus) +void LLFocusMgr::setAppHasFocus(bool focus) { if (!mAppHasFocus && focus) { @@ -481,7 +491,7 @@ void LLFocusMgr::setAppHasFocus(BOOL focus) // release focus from "top ctrl"s, which generally hides them if (!focus) { - LLUI::getInstance()->clearPopups(); + if(LLUI::instanceExists()) LLUI::getInstance()->clearPopups(); } mAppHasFocus = focus; } |