From fa36f85b007a124c418fd8cfc0e836cc7fdc86cf Mon Sep 17 00:00:00 2001
From: PavelK ProductEngine <pavelkproductengine@lindenlab.com>
Date: Tue, 9 Apr 2013 20:50:54 +0300
Subject: [PATCH] CHUI-797 FIXED Only one separated conversation window is
 shown after exiting from mouselook view Added all separated conversation
 floaters to skip list used in gFloaterView->popVisibleAll(skip_list) in
 llagent.cpp since LLFloaterIMContainer::setVisible() takes control of them by
 itself.

---
 indra/llui/llfloater.cpp               |  5 +++++
 indra/llui/llfloater.h                 |  1 +
 indra/newview/llagent.cpp              | 13 ++++++++++++-
 indra/newview/llconversationview.cpp   | 14 +++++++++-----
 indra/newview/llconversationview.h     |  2 ++
 indra/newview/llfloaterimcontainer.cpp | 18 ++++++++++++++++++
 indra/newview/llfloaterimcontainer.h   |  2 ++
 7 files changed, 49 insertions(+), 6 deletions(-)

diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp
index 5873df51690..6816137e523 100644
--- a/indra/llui/llfloater.cpp
+++ b/indra/llui/llfloater.cpp
@@ -3258,6 +3258,11 @@ bool LLFloater::isShown() const
     return ! isMinimized() && isInVisibleChain();
 }
 
+bool LLFloater::isDetachedAndNotMinimized()
+{
+	return !getHost() && !isMinimized();
+}
+
 /* static */
 bool LLFloater::isShown(const LLFloater* floater)
 {
diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h
index 4dba1e645f5..26ac4a98adc 100644
--- a/indra/llui/llfloater.h
+++ b/indra/llui/llfloater.h
@@ -238,6 +238,7 @@ class LLFloater : public LLPanel, public LLInstanceTracker<LLFloater>
 	void			center();
 
 	LLMultiFloater* getHost();
+	bool isDetachedAndNotMinimized();
 
 	void			applyTitle();
 	std::string		getCurrentTitle() const;
diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp
index 094d5020786..e0ab70bac71 100755
--- a/indra/newview/llagent.cpp
+++ b/indra/newview/llagent.cpp
@@ -45,6 +45,7 @@
 #include "llenvmanager.h"
 #include "llfirstuse.h"
 #include "llfloatercamera.h"
+#include "llfloaterimcontainer.h"
 #include "llfloaterreg.h"
 #include "llfloatertools.h"
 #include "llgroupactions.h"
@@ -90,6 +91,7 @@
 #include "llworld.h"
 #include "llworldmap.h"
 #include "stringize.h"
+#include "boost/foreach.hpp"
 
 using namespace LLVOAvatarDefines;
 
@@ -2002,7 +2004,16 @@ void LLAgent::endAnimationUpdateUI()
 			{
 				skip_list.insert(LLFloaterReg::findInstance("mini_map"));
 			}
-		
+
+			LLFloaterIMContainer* im_box = LLFloaterReg::getTypedInstance<LLFloaterIMContainer>("im_container");
+			LLFloaterIMContainer::floater_list_t conversations;
+			im_box->getDetachedConversationFloaters(conversations);
+			BOOST_FOREACH(LLFloater* conversation, conversations)
+			{
+				llinfos << "skip_list.insert(session_floater): " << conversation->getTitle() << llendl;
+				skip_list.insert(conversation);
+			}
+
 			gFloaterView->popVisibleAll(skip_list);
 #endif
 			mViewsPushed = FALSE;
diff --git a/indra/newview/llconversationview.cpp b/indra/newview/llconversationview.cpp
index b6c53e5e30f..911e14bcd53 100755
--- a/indra/newview/llconversationview.cpp
+++ b/indra/newview/llconversationview.cpp
@@ -340,16 +340,20 @@ void LLConversationViewSession::setVisibleIfDetached(BOOL visible)
 {
 	// Do this only if the conversation floater has been torn off (i.e. no multi floater host) and is not minimized
 	// Note: minimized dockable floaters are brought to front hence unminimized when made visible and we don't want that here
-	LLFolderViewModelItem* item = mViewModelItem;
-	LLUUID session_uuid = dynamic_cast<LLConversationItem*>(item)->getUUID();
-	LLFloater* session_floater = LLFloaterIMSessionTab::getConversation(session_uuid);
-	
-	if (session_floater && !session_floater->getHost() && !session_floater->isMinimized())
+	LLFloater* session_floater = getSessionFloater();
+	if (session_floater && session_floater->isDetachedAndNotMinimized())
 	{
 		session_floater->setVisible(visible);
 	}
 }
 
+LLFloater* LLConversationViewSession::getSessionFloater()
+{
+	LLFolderViewModelItem* item = mViewModelItem;
+	LLUUID session_uuid = dynamic_cast<LLConversationItem*>(item)->getUUID();
+	return LLFloaterIMSessionTab::getConversation(session_uuid);
+}
+
 LLConversationViewParticipant* LLConversationViewSession::findParticipant(const LLUUID& participant_id)
 {
 	// This is *not* a general tree parsing algorithm. We search only in the mItems list
diff --git a/indra/newview/llconversationview.h b/indra/newview/llconversationview.h
index 3eb2e63792d..7e432804d03 100755
--- a/indra/newview/llconversationview.h
+++ b/indra/newview/llconversationview.h
@@ -87,6 +87,8 @@ class LLConversationViewSession : public LLFolderViewFolder
 
 	/*virtual*/ void setFlashState(bool flash_state);
 
+	LLFloater* getSessionFloater();
+
 private:
 
 	void onCurrentVoiceSessionChanged(const LLUUID& session_id);
diff --git a/indra/newview/llfloaterimcontainer.cpp b/indra/newview/llfloaterimcontainer.cpp
index f89e818928f..8575f6f0558 100644
--- a/indra/newview/llfloaterimcontainer.cpp
+++ b/indra/newview/llfloaterimcontainer.cpp
@@ -54,6 +54,7 @@
 #include "llworld.h"
 #include "llsdserialize.h"
 #include "llviewerobjectlist.h"
+#include "boost/foreach.hpp"
 
 //
 // LLFloaterIMContainer
@@ -660,6 +661,23 @@ void LLFloaterIMContainer::setVisible(BOOL visible)
 	LLMultiFloater::setVisible(visible);
 }
 
+void LLFloaterIMContainer::getDetachedConversationFloaters(floater_list_t& floaters)
+{
+	typedef conversations_widgets_map::value_type conv_pair;
+	BOOST_FOREACH(conv_pair item, mConversationsWidgets)
+	{
+		LLConversationViewSession* widget = dynamic_cast<LLConversationViewSession*>(item.second);
+		if (widget)
+		{
+			LLFloater* session_floater = widget->getSessionFloater();
+			if (session_floater && session_floater->isDetachedAndNotMinimized())
+			{
+				floaters.push_back(session_floater);
+			}
+		}
+	}
+}
+
 void LLFloaterIMContainer::setVisibleAndFrontmost(BOOL take_focus, const LLSD& key)
 {
 	LLMultiFloater::setVisibleAndFrontmost(take_focus, key);
diff --git a/indra/newview/llfloaterimcontainer.h b/indra/newview/llfloaterimcontainer.h
index f6c716e2cfb..5ea1a38c635 100644
--- a/indra/newview/llfloaterimcontainer.h
+++ b/indra/newview/llfloaterimcontainer.h
@@ -194,6 +194,8 @@ class LLFloaterIMContainer
 	bool isScrolledOutOfSight(LLConversationViewSession* conversation_item_widget);
 	boost::signals2::connection mMicroChangedSignal;
 	S32 getConversationListItemSize() { return mConversationsWidgets.size(); }
+	typedef std::list<LLFloater*> floater_list_t;
+	void getDetachedConversationFloaters(floater_list_t& floaters);
 
 private:
 	LLConversationViewSession* createConversationItemWidget(LLConversationItem* item);
-- 
GitLab