From a36e94757e6cd0ebca9e47c19ef4afa712184e28 Mon Sep 17 00:00:00 2001 From: Ansariel Date: Fri, 8 Jul 2016 18:32:13 +0200 Subject: [PATCH] FIRE-16744: Speculative shot-into-the-blue fix for new IM tabs stealing focus --- indra/newview/fsfloaterim.cpp | 15 ++++----- indra/newview/fsfloaterimcontainer.cpp | 42 +++++++++++++++++--------- indra/newview/fsfloaterimcontainer.h | 4 +++ 3 files changed, 37 insertions(+), 24 deletions(-) diff --git a/indra/newview/fsfloaterim.cpp b/indra/newview/fsfloaterim.cpp index b51852f42a..a641ee626e 100644 --- a/indra/newview/fsfloaterim.cpp +++ b/indra/newview/fsfloaterim.cpp @@ -2068,21 +2068,18 @@ void FSFloaterIM::sRemoveTypingIndicator(const LLSD& data) floater->removeTypingIndicator(); } -void FSFloaterIM::onNewIMReceived( const LLUUID& session_id ) +void FSFloaterIM::onNewIMReceived(const LLUUID& session_id) { - if (isChatMultiTab()) { - FSFloaterIMContainer* im_box = FSFloaterIMContainer::getInstance(); - if (!im_box) return; - - if (FSFloaterIM::findInstance(session_id)) return; + if (FSFloaterIM::findInstance(session_id)) + { + return; + } FSFloaterIM* new_tab = FSFloaterIM::getInstance(session_id); - - im_box->addFloater(new_tab, FALSE, LLTabContainer::END); + FSFloaterIMContainer::getInstance()->addNewSession(new_tab); } - } void FSFloaterIM::onClickCloseBtn(bool app_quitting) diff --git a/indra/newview/fsfloaterimcontainer.cpp b/indra/newview/fsfloaterimcontainer.cpp index 99de89ce32..b9c81f5fcf 100644 --- a/indra/newview/fsfloaterimcontainer.cpp +++ b/indra/newview/fsfloaterimcontainer.cpp @@ -49,7 +49,8 @@ FSFloaterIMContainer::FSFloaterIMContainer(const LLSD& seed) : LLMultiFloater(seed), mActiveVoiceFloater(NULL), mCurrentVoiceState(VOICE_STATE_NONE), - mForceVoiceStateUpdate(false) + mForceVoiceStateUpdate(false), + mIsAddingNewSession(false) { mAutoResize = FALSE; LLTransientFloaterMgr::getInstance()->addControlView(LLTransientFloaterMgr::IM, this); @@ -233,31 +234,34 @@ void FSFloaterIMContainer::addFloater(LLFloater* floaterp, { // [SL:KB] - Patch: UI-TabRearrange | Checked: 2012-06-22 (Catznip-3.3.0) // If we're redocking a torn off IM floater, return it back to its previous place - if ( (floaterp->isTornOff()) && (LLTabContainer::END == insertion_point) ) + if (!mIsAddingNewSession && (floaterp->isTornOff()) && (LLTabContainer::END == insertion_point) ) { LLChicletPanel* pChicletPanel = LLChicletBar::instance().getChicletPanel(); LLIMChiclet* pChiclet = pChicletPanel->findChiclet(floaterp->getKey()); - S32 idxChiclet = pChicletPanel->getChicletIndex(pChiclet); - if ( (idxChiclet > 0) && (idxChiclet < pChicletPanel->getChicletCount()) ) + if (pChiclet) { - // Look for the first IM session to the left of this one - while (--idxChiclet >= 0) + S32 idxChiclet = pChicletPanel->getChicletIndex(pChiclet); + if ((idxChiclet > 0) && (idxChiclet < pChicletPanel->getChicletCount())) { - if (pChiclet = dynamic_cast(pChicletPanel->getChiclet(idxChiclet))) + // Look for the first IM session to the left of this one + while (--idxChiclet >= 0) { - FSFloaterIM* pFloater = FSFloaterIM::findInstance(pChiclet->getSessionId()); - if (pFloater) + if (pChiclet = dynamic_cast(pChicletPanel->getChiclet(idxChiclet))) { - insertion_point = (LLTabContainer::eInsertionPoint)(mTabContainer->getIndexForPanel(pFloater) + 1); - break; + FSFloaterIM* pFloater = FSFloaterIM::findInstance(pChiclet->getSessionId()); + if (pFloater) + { + insertion_point = (LLTabContainer::eInsertionPoint)(mTabContainer->getIndexForPanel(pFloater) + 1); + break; + } } } } - } - else - { - insertion_point = (0 == idxChiclet) ? LLTabContainer::START : LLTabContainer::END; + else + { + insertion_point = (0 == idxChiclet) ? LLTabContainer::START : LLTabContainer::END; + } } } // [/SL:KB] @@ -270,6 +274,14 @@ void FSFloaterIMContainer::addFloater(LLFloater* floaterp, floaterp->mCloseSignal.connect(boost::bind(&FSFloaterIMContainer::onCloseFloater, this, session_id)); } +void FSFloaterIMContainer::addNewSession(LLFloater* floaterp) +{ + // Make sure we don't do some strange re-arranging if we add a new IM floater due to a new session + mIsAddingNewSession = true; + addFloater(floaterp, FALSE, LLTabContainer::END); + mIsAddingNewSession = false; +} + // [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-12-11 (Catznip-3.2.0d) | Added: Catznip-3.2.0d void FSFloaterIMContainer::removeFloater(LLFloater* floaterp) { diff --git a/indra/newview/fsfloaterimcontainer.h b/indra/newview/fsfloaterimcontainer.h index 608d66c06a..4d11da1993 100644 --- a/indra/newview/fsfloaterimcontainer.h +++ b/indra/newview/fsfloaterimcontainer.h @@ -55,6 +55,8 @@ public: // [/SL:KB] bool hasFloater(LLFloater* floaterp); + void addNewSession(LLFloater* floaterp); + static FSFloaterIMContainer* findInstance(); static FSFloaterIMContainer* getInstance(); @@ -99,6 +101,8 @@ private: void checkFlashing(); uuid_vec_t mFlashingSessions; + bool mIsAddingNewSession; + // [SL:KB] - Patch: UI-TabRearrange | Checked: 2012-05-05 (Catznip-3.3.0) protected: void onIMTabRearrange(S32 tab_index, LLPanel* tab_panel);