From a62a824efb89aff3056d0659ee2c23ad6d15eeaa Mon Sep 17 00:00:00 2001
From: Mnikolenko ProductEngine <mnikolenko@productengine.com>
Date: Fri, 29 Mar 2013 15:23:17 +0200
Subject: [PATCH] CHUI-903 FIXED Don't show toasts if Session floater is
 torn-off and in focus.

---
 indra/newview/llfloaterimnearbychathandler.cpp | 10 +++++++---
 indra/newview/llimview.cpp                     | 14 ++++++++------
 2 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/indra/newview/llfloaterimnearbychathandler.cpp b/indra/newview/llfloaterimnearbychathandler.cpp
index 0824b264060..9ce5e128977 100644
--- a/indra/newview/llfloaterimnearbychathandler.cpp
+++ b/indra/newview/llfloaterimnearbychathandler.cpp
@@ -605,11 +605,15 @@ void LLFloaterIMNearbyChatHandler::processChat(const LLChat& chat_msg,
 		}
 
 		//Don't show nearby toast, if conversation is visible and selected
-		if (im_box->getSelectedSession().isNull() &&
+		if ((nearby_chat->hasFocus()) ||
+		    ((im_box->getSelectedSession().isNull() &&
 				((LLFloater::isVisible(im_box) && !im_box->isMinimized() && im_box->isFrontmost())
-						|| (LLFloater::isVisible(nearby_chat) && !nearby_chat->isMinimized() && nearby_chat->isFrontmost())))
+						|| (LLFloater::isVisible(nearby_chat) && !nearby_chat->isMinimized() && nearby_chat->isFrontmost())))))
 		{
-			return;
+			if(nearby_chat->isMessagePaneExpanded())
+			{
+				return;
+			}
 		}
 
         //Will show toast when chat preference is set        
diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp
index 4171fa1235f..6cff933de67 100644
--- a/indra/newview/llimview.cpp
+++ b/indra/newview/llimview.cpp
@@ -181,17 +181,16 @@ void on_new_message(const LLSD& msg)
 	{
 		conversations_floater_status = CLOSED;
 	}
-	else if ( !im_box->hasFocus() &&
-			(!session_floater || !LLFloater::isVisible(session_floater)
-	            || session_floater->isMinimized() || !session_floater->hasFocus()))
+	else if (!session_floater || !LLFloater::isVisible(session_floater)
+	            || session_floater->isMinimized() || !session_floater->hasFocus())
 	{
 		conversations_floater_status = NOT_ON_TOP;
 	}
-	else if (im_box->getSelectedSession() != session_id)
+	else if (session_floater->hasFocus())
 	{
 		conversations_floater_status = ON_TOP;
     }
-	else
+	else if((session_floater->hasFocus()) && (im_box->getSelectedSession() == session_id))
 	{
 		conversations_floater_status = ON_TOP_AND_ITEM_IS_SELECTED;
 	}
@@ -297,8 +296,11 @@ void on_new_message(const LLSD& msg)
     }
 
     // 4. Toast
-    if ("toast" == user_preferences
+    if ((("toast" == user_preferences) &&
+    		(CLOSED == conversations_floater_status
+    		    || NOT_ON_TOP == conversations_floater_status))
     		    || !session_floater->isMessagePaneExpanded())
+
     {
         //Show IM toasts (upper right toasts)
         // Skip toasting for system messages and for nearby chat
-- 
GitLab