From 1317cdbf8f691b229a12ad5fb9b6ae8dd477d587 Mon Sep 17 00:00:00 2001
From: Dmitry Zaporozhan <dzaporozhan@productengine.com>
Date: Thu, 14 Jan 2010 18:29:00 +0200
Subject: [PATCH] Fixed low bug EXT-4146 - IM window appears after double click
 on "i" button.

--HG--
branch : product-engine
---
 indra/newview/llavatarlist.cpp     | 12 ++++++++++++
 indra/newview/llavatarlist.h       |  4 ++++
 indra/newview/llavatarlistitem.cpp | 15 +++++++++++++++
 indra/newview/llavatarlistitem.h   |  2 ++
 indra/newview/llpanelpeople.cpp    | 19 +++++++++++--------
 indra/newview/llpanelpeople.h      |  2 +-
 6 files changed, 45 insertions(+), 9 deletions(-)

diff --git a/indra/newview/llavatarlist.cpp b/indra/newview/llavatarlist.cpp
index 19e9e52ddfd..6784e6693b0 100644
--- a/indra/newview/llavatarlist.cpp
+++ b/indra/newview/llavatarlist.cpp
@@ -320,6 +320,11 @@ boost::signals2::connection LLAvatarList::setRefreshCompleteCallback(const commi
 	return mRefreshCompleteSignal.connect(cb);
 }
 
+boost::signals2::connection LLAvatarList::setItemDoubleClickCallback(const mouse_signal_t::slot_type& cb)
+{
+	return mItemDoubleClickSignal.connect(cb);
+}
+
 void LLAvatarList::addNewItem(const LLUUID& id, const std::string& name, BOOL is_online, EAddPosition pos)
 {
 	LLAvatarListItem* item = new LLAvatarListItem();
@@ -333,6 +338,8 @@ void LLAvatarList::addNewItem(const LLUUID& id, const std::string& name, BOOL is
 	item->setShowProfileBtn(mShowProfileBtn);
 	item->showSpeakingIndicator(mShowSpeakingIndicator);
 
+	item->setDoubleClickCallback(boost::bind(&LLAvatarList::onItemDoucleClicked, this, _1, _2, _3, _4));
+
 	addItem(item, id, pos);
 }
 
@@ -400,6 +407,11 @@ void LLAvatarList::updateLastInteractionTimes()
 	}
 }
 
+void LLAvatarList::onItemDoucleClicked(LLUICtrl* ctrl, S32 x, S32 y, MASK mask)
+{
+	mItemDoubleClickSignal(ctrl, x, y, mask);
+}
+
 bool LLAvatarItemComparator::compare(const LLPanel* item1, const LLPanel* item2) const
 {
 	const LLAvatarListItem* avatar_item1 = dynamic_cast<const LLAvatarListItem*>(item1);
diff --git a/indra/newview/llavatarlist.h b/indra/newview/llavatarlist.h
index 0d2ce884ae7..a58a5623786 100644
--- a/indra/newview/llavatarlist.h
+++ b/indra/newview/llavatarlist.h
@@ -92,6 +92,8 @@ class LLAvatarList : public LLFlatListView
 
 	boost::signals2::connection setRefreshCompleteCallback(const commit_signal_t::slot_type& cb);
 
+	boost::signals2::connection setItemDoubleClickCallback(const mouse_signal_t::slot_type& cb);
+
 protected:
 	void refresh();
 
@@ -101,6 +103,7 @@ class LLAvatarList : public LLFlatListView
 		std::vector<LLUUID>& vadded,
 		std::vector<LLUUID>& vremoved);
 	void updateLastInteractionTimes();
+	void onItemDoucleClicked(LLUICtrl* ctrl, S32 x, S32 y, MASK mask);
 
 private:
 
@@ -120,6 +123,7 @@ class LLAvatarList : public LLFlatListView
 	LLAvatarListItem::ContextMenu* mContextMenu;
 
 	commit_signal_t mRefreshCompleteSignal;
+	mouse_signal_t mItemDoubleClickSignal;
 };
 
 /** Abstract comparator for avatar items */
diff --git a/indra/newview/llavatarlistitem.cpp b/indra/newview/llavatarlistitem.cpp
index 1043858373c..66ab32f3e88 100644
--- a/indra/newview/llavatarlistitem.cpp
+++ b/indra/newview/llavatarlistitem.cpp
@@ -258,6 +258,21 @@ void LLAvatarListItem::onProfileBtnClick()
 	LLAvatarActions::showProfile(mAvatarId);
 }
 
+BOOL LLAvatarListItem::handleDoubleClick(S32 x, S32 y, MASK mask)
+{
+	if(mInfoBtn->getRect().pointInRect(x, y))
+	{
+		onInfoBtnClick();
+		return TRUE;
+	}
+	if(mProfileBtn->getRect().pointInRect(x, y))
+	{
+		onProfileBtnClick();
+		return TRUE;
+	}
+	return LLPanel::handleDoubleClick(x, y, mask);
+}
+
 void LLAvatarListItem::setValue( const LLSD& value )
 {
 	if (!value.isMap()) return;;
diff --git a/indra/newview/llavatarlistitem.h b/indra/newview/llavatarlistitem.h
index f76ffb391d4..479a4833cb9 100644
--- a/indra/newview/llavatarlistitem.h
+++ b/indra/newview/llavatarlistitem.h
@@ -103,6 +103,8 @@ class LLAvatarListItem : public LLPanel, public LLFriendObserver
 	void onInfoBtnClick();
 	void onProfileBtnClick();
 
+	/*virtual*/ BOOL handleDoubleClick(S32 x, S32 y, MASK mask);
+
 protected:
 	/**
 	 * Contains indicator to show voice activity. 
diff --git a/indra/newview/llpanelpeople.cpp b/indra/newview/llpanelpeople.cpp
index 03cc870a595..c14b282488c 100644
--- a/indra/newview/llpanelpeople.cpp
+++ b/indra/newview/llpanelpeople.cpp
@@ -532,10 +532,10 @@ BOOL LLPanelPeople::postBuild()
 	friends_panel->childSetAction("add_btn",	boost::bind(&LLPanelPeople::onAddFriendWizButtonClicked,	this));
 	friends_panel->childSetAction("del_btn",	boost::bind(&LLPanelPeople::onDeleteFriendButtonClicked,	this));
 
-	mOnlineFriendList->setDoubleClickCallback(boost::bind(&LLPanelPeople::onAvatarListDoubleClicked, this, mOnlineFriendList));
-	mAllFriendList->setDoubleClickCallback(boost::bind(&LLPanelPeople::onAvatarListDoubleClicked, this, mAllFriendList));
-	mNearbyList->setDoubleClickCallback(boost::bind(&LLPanelPeople::onAvatarListDoubleClicked, this, mNearbyList));
-	mRecentList->setDoubleClickCallback(boost::bind(&LLPanelPeople::onAvatarListDoubleClicked, this, mRecentList));
+	mOnlineFriendList->setItemDoubleClickCallback(boost::bind(&LLPanelPeople::onAvatarListDoubleClicked, this, _1));
+	mAllFriendList->setItemDoubleClickCallback(boost::bind(&LLPanelPeople::onAvatarListDoubleClicked, this, _1));
+	mNearbyList->setItemDoubleClickCallback(boost::bind(&LLPanelPeople::onAvatarListDoubleClicked, this, _1));
+	mRecentList->setItemDoubleClickCallback(boost::bind(&LLPanelPeople::onAvatarListDoubleClicked, this, _1));
 
 	mOnlineFriendList->setCommitCallback(boost::bind(&LLPanelPeople::onAvatarListCommitted, this, mOnlineFriendList));
 	mAllFriendList->setCommitCallback(boost::bind(&LLPanelPeople::onAvatarListCommitted, this, mAllFriendList));
@@ -1005,12 +1005,15 @@ void LLPanelPeople::onTabSelected(const LLSD& param)
 		mFilterEditor->setLabel(getString("people_filter_label"));
 }
 
-void LLPanelPeople::onAvatarListDoubleClicked(LLAvatarList* list)
+void LLPanelPeople::onAvatarListDoubleClicked(LLUICtrl* ctrl)
 {
-	LLUUID clicked_id = list->getSelectedUUID();
-
-	if (clicked_id.isNull())
+	LLAvatarListItem* item = dynamic_cast<LLAvatarListItem*>(ctrl);
+	if(!item)
+	{
 		return;
+	}
+
+	LLUUID clicked_id = item->getAvatarId();
 	
 #if 0 // SJB: Useful for testing, but not currently functional or to spec
 	LLAvatarActions::showProfile(clicked_id);
diff --git a/indra/newview/llpanelpeople.h b/indra/newview/llpanelpeople.h
index da2c0e368ca..7580fdbeeff 100644
--- a/indra/newview/llpanelpeople.h
+++ b/indra/newview/llpanelpeople.h
@@ -109,7 +109,7 @@ class LLPanelPeople : public LLPanel
 	void					onNearbyViewSortButtonClicked();
 	void					onFriendsViewSortButtonClicked();
 	void					onGroupsViewSortButtonClicked();
-	void					onAvatarListDoubleClicked(LLAvatarList* list);
+	void					onAvatarListDoubleClicked(LLUICtrl* ctrl);
 	void					onAvatarListCommitted(LLAvatarList* list);
 	void					onGroupPlusButtonClicked();
 	void					onGroupMinusButtonClicked();
-- 
GitLab