From 5f05157fb74a6b3c1e20b024055e7fccf434c15c Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Thu, 17 Mar 2011 15:50:51 -0700
Subject: [PATCH] SOCIAL-749 FIX Clicking on world to dismiss context menus
 causes your avatar to walk to click

---
 indra/newview/lltoolpie.cpp    | 17 +++++++++--------
 indra/newview/lltoolpie.h      |  3 ++-
 indra/newview/llviewermenu.cpp |  8 +++++++-
 3 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/indra/newview/lltoolpie.cpp b/indra/newview/lltoolpie.cpp
index 582f50ba37..78df193dc3 100644
--- a/indra/newview/lltoolpie.cpp
+++ b/indra/newview/lltoolpie.cpp
@@ -83,7 +83,7 @@ LLToolPie::LLToolPie()
 	mMouseOutsideSlop( false ),
 	mMouseSteerX(-1),
 	mMouseSteerY(-1),
-	mAbortClickToWalk(false),
+	mBlockClickToWalk(false),
 	mClickAction(0),
 	mClickActionBuyEnabled( gSavedSettings.getBOOL("ClickActionBuyEnabled") ),
 	mClickActionPayEnabled( gSavedSettings.getBOOL("ClickActionPayEnabled") )
@@ -303,7 +303,7 @@ BOOL LLToolPie::handleLeftClickPick()
 	if (gFocusMgr.getKeyboardFocus())
 	{
 		// don't click to walk on attempt to give focus to world
-		mAbortClickToWalk = true;
+		mBlockClickToWalk = true;
 		gFocusMgr.setKeyboardFocus(NULL);
 	}
 
@@ -625,7 +625,7 @@ BOOL LLToolPie::handleMouseUp(S32 x, S32 y, MASK mask)
 	// let media have first pass at click
 	if (handleMediaMouseUp() || LLViewerMediaFocus::getInstance()->getFocus())
 	{
-		mAbortClickToWalk = true;
+		mBlockClickToWalk = true;
 	}
 	stopCameraSteering();
 	mMouseButtonDown = false;
@@ -633,7 +633,7 @@ BOOL LLToolPie::handleMouseUp(S32 x, S32 y, MASK mask)
 	if (click_action == CLICK_ACTION_NONE				// not doing 1-click action
 		&& gSavedSettings.getBOOL("ClickToWalk")		// click to walk enabled
 		&& !gAgent.getFlying()							// don't auto-navigate while flying until that works
-		&& !mAbortClickToWalk							// another behavior hasn't cancelled click to walk
+		&& !mBlockClickToWalk							// another behavior hasn't cancelled click to walk
 		&& !mPick.mPosGlobal.isExactlyZero()			// valid coordinates for pick
 		&& (mPick.mPickType == LLPickInfo::PICK_LAND	// we clicked on land
 			|| mPick.mObjectID.notNull()))				// or on an object
@@ -662,7 +662,7 @@ BOOL LLToolPie::handleMouseUp(S32 x, S32 y, MASK mask)
 		mAutoPilotDestination->setDuration(3.f);
 
 		handle_go_to();
-		mAbortClickToWalk = false;
+		mBlockClickToWalk = false;
 
 		return TRUE;
 	}
@@ -675,7 +675,7 @@ BOOL LLToolPie::handleMouseUp(S32 x, S32 y, MASK mask)
 	LLToolMgr::getInstance()->clearTransientTool();
 	gAgentCamera.setLookAt(LOOKAT_TARGET_CONVERSATION, obj); // maybe look at object/person clicked on
 
-	mAbortClickToWalk = false;
+	mBlockClickToWalk = false;
 	return LLTool::handleMouseUp(x, y, mask);
 }
 
@@ -1298,7 +1298,8 @@ void LLToolPie::VisitHomePage(const LLPickInfo& info)
 
 void LLToolPie::handleSelect()
 {
-	mAbortClickToWalk = true;	
+	// tool is reselected when app gets focus, etc.
+	mBlockClickToWalk = true;	
 }
 
 void LLToolPie::handleDeselect()
@@ -1738,7 +1739,7 @@ bool intersect_ray_with_sphere( const LLVector3& ray_pt, const LLVector3& ray_di
 void LLToolPie::startCameraSteering()
 {
 	mMouseOutsideSlop = true;
-	mAbortClickToWalk = true;
+	mBlockClickToWalk = true;
 
 	if (gAgentCamera.getFocusOnAvatar())
 	{
diff --git a/indra/newview/lltoolpie.h b/indra/newview/lltoolpie.h
index 22e77a3159..22359a6db8 100644
--- a/indra/newview/lltoolpie.h
+++ b/indra/newview/lltoolpie.h
@@ -66,6 +66,7 @@ public:
 	LLViewerObject*		getClickActionObject() { return mClickActionObject; }
 	LLObjectSelection*	getLeftClickSelection() { return (LLObjectSelection*)mLeftClickSelection; }
 	void 				resetSelection();
+	void				blockClickToWalk() { mBlockClickToWalk = true; }
 	
 	static void			selectionPropertiesReceived();
 
@@ -105,7 +106,7 @@ private:
 	LLPointer<LLHUDEffectBlob>	mAutoPilotDestination;
 	LLPointer<LLHUDEffectBlob>	mMouseSteerGrabPoint;
 	bool				mClockwise;			
-	bool				mAbortClickToWalk;
+	bool				mBlockClickToWalk;
 	LLUUID				mMediaMouseCaptureID;
 	LLPickInfo			mPick;
 	LLPickInfo			mHoverPick;
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index 75cf2efc69..3e0363849b 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -7158,7 +7158,13 @@ LLViewerMenuHolderGL::LLViewerMenuHolderGL(const LLViewerMenuHolderGL::Params& p
 
 BOOL LLViewerMenuHolderGL::hideMenus()
 {
-	BOOL handled = LLMenuHolderGL::hideMenus();
+	BOOL handled = FALSE;
+	
+	if (LLMenuHolderGL::hideMenus())
+	{
+		LLToolPie::instance().blockClickToWalk();
+		handled = TRUE;
+	}
 
 	// drop pie menu selection
 	mParcelSelection = NULL;
-- 
GitLab