From d1582a5105f01181535fb859c530e45c2efca071 Mon Sep 17 00:00:00 2001
From: Steven Bennetts <steve@lindenlab.com>
Date: Mon, 5 Feb 2007 20:20:42 +0000
Subject: [PATCH] merge -r 57111:57464 maintenance.

---
 indra/llui/llfloater.cpp              | 12 +++-
 indra/llui/llmenugl.cpp               | 97 +++++++++++++++++----------
 indra/llui/llmenugl.h                 |  9 ++-
 indra/llui/llscrolllistctrl.cpp       | 45 ++++++-------
 indra/llui/llscrolllistctrl.h         |  7 +-
 indra/llvfs/llvfs.cpp                 |  2 +-
 indra/llwindow/llkeyboardwin32.cpp    | 11 +--
 indra/llwindow/llwindowwin32.cpp      | 14 ----
 indra/llxml/llcontrol.h               |  6 +-
 indra/newview/licenses-linux.txt      | 33 +++++++++
 indra/newview/lldrawpoolalpha.cpp     | 32 +++------
 indra/newview/llfloaterregioninfo.cpp | 16 +++--
 indra/newview/llfolderview.cpp        |  2 +-
 indra/newview/llnetmap.cpp            |  2 +-
 indra/newview/llpanelavatar.cpp       | 15 +++++
 indra/newview/llpanelavatar.h         |  2 +
 indra/newview/llpanelpermissions.cpp  |  5 ++
 indra/newview/llpreviewnotecard.cpp   |  8 ++-
 indra/newview/llpreviewscript.cpp     | 13 +++-
 indra/newview/llpreviewscript.h       |  5 +-
 indra/newview/llstartup.cpp           | 10 ++-
 indra/newview/lltooldraganddrop.cpp   |  3 +
 indra/newview/lltracker.cpp           |  2 +-
 indra/newview/llviewercontrol.cpp     | 16 +++++
 indra/newview/llviewercontrol.h       |  1 +
 indra/newview/llviewermenu.cpp        | 24 +++++--
 indra/newview/llviewermenu.h          |  1 +
 indra/newview/llviewerwindow.cpp      | 20 +-----
 indra/newview/pipeline.cpp            |  3 +-
 indra/newview/pipeline.h              |  1 -
 30 files changed, 267 insertions(+), 150 deletions(-)

diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp
index b37602093fa..8dc0ce5f668 100644
--- a/indra/llui/llfloater.cpp
+++ b/indra/llui/llfloater.cpp
@@ -506,7 +506,8 @@ void LLFloater::open()	/* Flawfinder: ignore */
 	if (sHostp != NULL && hostp == NULL)
 	{
 		// needs a host
-		sHostp->addFloater(this, TRUE);
+		// only select tabs if window they are hosted in is visible
+		sHostp->addFloater(this, sHostp->getVisible());
 	}
 	else if (hostp != NULL)
 	{
@@ -2578,8 +2579,6 @@ void LLMultiFloater::addFloater(LLFloater* floaterp, BOOL select_added_floater,
 	if ( select_added_floater )
 	{
 		mTabContainer->selectLastTab();
-		// explicitly call tabopen to load preview assets, etc.
-		tabOpen((LLFloater*)mTabContainer->getCurrentPanel(), true);
 	}
 
 	floaterp->setHost(this);
@@ -2702,6 +2701,13 @@ void LLMultiFloater::setVisible(BOOL visible)
 		{
 			cur_floaterp->setVisible(visible);
 		}
+
+		// if no tab selected, and we're being shown,
+		// select last tab to be added
+		if (visible && !cur_floaterp)
+		{
+			mTabContainer->selectLastTab();
+		}
 	}
 }
 
diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp
index b2225aa1a0f..6ec0719ad5e 100644
--- a/indra/llui/llmenugl.cpp
+++ b/indra/llui/llmenugl.cpp
@@ -43,7 +43,7 @@
 #include <boost/tokenizer.hpp>
 
 // static
-LLView *LLMenuGL::sDefaultMenuContainer = NULL;
+LLMenuHolderGL *LLMenuGL::sMenuContainer = NULL;
 
 S32 MENU_BAR_HEIGHT = 0;
 S32 MENU_BAR_WIDTH = 0;
@@ -392,7 +392,7 @@ void LLMenuItemGL::doIt( void )
 		&& !getMenu()->getTornOff() 
 		&& getMenu()->getVisible())
 	{
-		((LLMenuHolderGL*)getMenu()->getParent())->hideMenus();
+		LLMenuGL::sMenuContainer->hideMenus();
 	}
 }
 
@@ -454,18 +454,28 @@ BOOL LLMenuItemGL::handleKeyHere( KEY key, MASK mask, BOOL called_from_parent )
 
 BOOL LLMenuItemGL::handleMouseUp( S32 x, S32 y, MASK )
 {
-	//llinfos << mLabel.c_str() << " handleMouseUp " << x << "," << y
-	//	<< llendl;
 	if (mEnabled)
 	{
 		// switch to mouse navigation mode
 		LLMenuGL::setKeyboardMode(FALSE);
 
 		doIt();
-		setHighlight(FALSE);
 		make_ui_sound("UISndClickRelease");
 		return TRUE;
 	}
+	return FALSE;
+}
+
+BOOL LLMenuItemGL::handleMouseDown( S32 x, S32 y, MASK )
+{
+	if (mEnabled)
+	{
+		// switch to mouse navigation mode
+		LLMenuGL::setKeyboardMode(FALSE);
+
+		setHighlight(TRUE);
+		return TRUE;
+	}
 	else
 	{
 		return FALSE;
@@ -1483,6 +1493,9 @@ void LLMenuItemBranchGL::openMenu()
 	}
 	else if( !mBranch->getVisible() )
 	{
+		// get valid rectangle for menus
+		const LLRect menu_region_rect = LLMenuGL::sMenuContainer->getMenuRect();
+
 		mBranch->arrange();
 
 		LLRect rect = mBranch->getRect();
@@ -1505,13 +1518,13 @@ void LLMenuItemBranchGL::openMenu()
 		mBranch->localPointToOtherView( 0, 0, &x, &y, mBranch->getParent() ); 
 		S32 delta_x = 0;
 		S32 delta_y = 0;
-		if( y < 0 )
+		if( y < menu_region_rect.mBottom )
 		{
-			delta_y = -y;
+			delta_y = menu_region_rect.mBottom - y;
 		}
 
-		S32 window_width = mBranch->getParent()->getRect().getWidth();
-		if( x > window_width - rect.getWidth() )
+		S32 menu_region_width = menu_region_rect.getWidth();
+		if( x - menu_region_rect.mLeft > menu_region_width - rect.getWidth() )
 		{
 			// move sub-menu over to left side
 			delta_x = llmax(-x, (-1 * (rect.getWidth() + mRect.getWidth())));
@@ -1942,9 +1955,9 @@ void LLMenuGL::parseChildXML(LLXMLNodePtr child, LLView *parent, LLUICtrlFactory
 		// SUBMENU
 		LLMenuGL *submenu = (LLMenuGL*)LLMenuGL::fromXML(child, parent, factory);
 		appendMenu(submenu);
-		if (LLMenuGL::sDefaultMenuContainer != NULL)
+		if (LLMenuGL::sMenuContainer != NULL)
 		{
-			submenu->updateParent(LLMenuGL::sDefaultMenuContainer);
+			submenu->updateParent(LLMenuGL::sMenuContainer);
 		}
 		else
 		{
@@ -2331,8 +2344,10 @@ void LLMenuGL::arrange( void )
 
 	if( mItems.size() ) 
 	{
-		U32 max_width = (getParent() != NULL) ? getParent()->getRect().getWidth() : U32_MAX;
-		U32 max_height = (getParent() != NULL) ? getParent()->getRect().getHeight() : U32_MAX;
+		const LLRect menu_region_rect = LLMenuGL::sMenuContainer ? LLMenuGL::sMenuContainer->getMenuRect() : LLRect(0, S32_MAX, S32_MAX, 0);
+
+		U32 max_width = menu_region_rect.getWidth();
+		U32 max_height = menu_region_rect.getHeight();
 		// *FIX: create the item first and then ask for its dimensions?
 		S32 spillover_item_width = PLAIN_PAD_PIXELS + LLFontGL::sSansSerif->getWidth( "More" );
 		S32 spillover_item_height = llround(LLFontGL::sSansSerif->getLineHeight()) + MENU_ITEM_PADDING;
@@ -2453,7 +2468,7 @@ void LLMenuGL::createSpilloverBranch()
 		// technically, you can't tear off spillover menus, but we're passing the handle
 		// along just to be safe
 		mSpilloverMenu = new LLMenuGL("More", "More", mParentFloaterHandle);
-		mSpilloverMenu->updateParent(getParent());
+		mSpilloverMenu->updateParent(LLMenuGL::sMenuContainer);
 		// Inherit colors
 		mSpilloverMenu->setBackgroundColor( mBackgroundColor );
 		mSpilloverMenu->setCanTearOff(FALSE);
@@ -3138,6 +3153,8 @@ void hide_top_view( LLView* view )
 // static
 void LLMenuGL::showPopup(LLView* spawning_view, LLMenuGL* menu, S32 x, S32 y)
 {
+	const LLRect menu_region_rect = LLMenuGL::sMenuContainer->getMenuRect();
+
 	const S32 HPAD = 2;
 	LLRect rect = menu->getRect();
 	//LLView* cur_view = spawning_view;
@@ -3158,13 +3175,15 @@ void LLMenuGL::showPopup(LLView* spawning_view, LLMenuGL* menu, S32 x, S32 y)
 	//									&left, &bottom ); 
 	S32 delta_x = 0;
 	S32 delta_y = 0;
-	if( bottom < 0 )
+	if( bottom < menu_region_rect.mBottom )
 	{
-		delta_y = -bottom;
+		// At this point, we need to move the context menu to the
+		// other side of the mouse.
+		//delta_y = menu_region_rect.mBottom - bottom;
+		delta_y = (rect.getHeight() + 2 * HPAD);
 	}
 
-	S32 parent_width = menu->getParent()->getRect().getWidth();
-	if( left > parent_width - rect.getWidth() )
+	if( left > menu_region_rect.mRight - rect.getWidth() )
 	{
 		// At this point, we need to move the context menu to the
 		// other side of the mouse.
@@ -3536,7 +3555,7 @@ BOOL LLPieMenu::handleMouseUp( S32 x, S32 y, MASK mask )
 	if (!handled && !mUseInfiniteRadius)
 	{
 		// call hidemenus to make sure transient selections get cleared
-		((LLMenuHolderGL*)getParent())->hideMenus();
+		sMenuContainer->hideMenus();
 	}
 
 	if (mFirstMouseDown)
@@ -3847,10 +3866,9 @@ void LLPieMenu::show(S32 x, S32 y, BOOL mouse_down)
 	S32 width = mRect.getWidth();
 	S32 height = mRect.getHeight();
 
-	LLView* parent_view = getParent();
-	S32 menu_region_width = parent_view->getRect().getWidth();
-	S32 menu_region_height = parent_view->getRect().getHeight();
+	const LLRect menu_region_rect = LLMenuGL::sMenuContainer->getMenuRect();
 
+	LLView* parent_view = getParent();
 	BOOL moved = FALSE;
 
 	S32 local_x, local_y;
@@ -3860,36 +3878,36 @@ void LLPieMenu::show(S32 x, S32 y, BOOL mouse_down)
 	arrange();
 
 	// Adjust the pie rectangle to keep it on screen
-	if (mRect.mLeft < 0) 
+	if (mRect.mLeft < menu_region_rect.mLeft) 
 	{
-		//mShiftHoriz = 0 - mRect.mLeft;
+		//mShiftHoriz = menu_region_rect.mLeft - mRect.mLeft;
 		//mRect.translate( mShiftHoriz, 0 );
-		mRect.translate( 0 - mRect.mLeft, 0 );
+		mRect.translate( menu_region_rect.mLeft - mRect.mLeft, 0 );
 		moved = TRUE;
 	}
 
-	if (mRect.mRight > menu_region_width) 
+	if (mRect.mRight > menu_region_rect.mRight) 
 	{
-		//mShiftHoriz = menu_region_width - mRect.mRight;
+		//mShiftHoriz = menu_region_rect.mRight - mRect.mRight;
 		//mRect.translate( mShiftHoriz, 0);
-		mRect.translate( menu_region_width - mRect.mRight, 0 );
+		mRect.translate( menu_region_rect.mRight - mRect.mRight, 0 );
 		moved = TRUE;
 	}
 
-	if (mRect.mBottom < 0)
+	if (mRect.mBottom < menu_region_rect.mBottom)
 	{
-		//mShiftVert = -mRect.mBottom;
+		//mShiftVert = menu_region_rect.mBottom - mRect.mBottom;
 		//mRect.translate( 0, mShiftVert );
-		mRect.translate( 0, 0 - mRect.mBottom );
+		mRect.translate( 0, menu_region_rect.mBottom - mRect.mBottom );
 		moved = TRUE;
 	}
 
 
-	if (mRect.mTop > menu_region_height)
+	if (mRect.mTop > menu_region_rect.mTop)
 	{
-		//mShiftVert = menu_region_height - mRect.mTop;
+		//mShiftVert = menu_region_rect.mTop - mRect.mTop;
 		//mRect.translate( 0, mShiftVert );
-		mRect.translate( 0, menu_region_height - mRect.mTop );
+		mRect.translate( 0, menu_region_rect.mTop - mRect.mTop );
 		moved = TRUE;
 	}
 
@@ -4048,9 +4066,9 @@ LLView* LLMenuBarGL::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory
 				menu->setCanTearOff(TRUE, parent_handle);
 			}
 			menubar->appendMenu(menu);
-			if (LLMenuGL::sDefaultMenuContainer != NULL)
+			if (LLMenuGL::sMenuContainer != NULL)
 			{
-				menu->updateParent(LLMenuGL::sDefaultMenuContainer);
+				menu->updateParent(LLMenuGL::sMenuContainer);
 			}
 			else
 			{
@@ -4411,7 +4429,7 @@ void LLMenuHolderGL::reshape(S32 width, S32 height, BOOL called_from_parent)
 	LLView::reshape(width, height, called_from_parent);
 }
 
-BOOL LLMenuHolderGL::hasVisibleMenu()
+BOOL LLMenuHolderGL::hasVisibleMenu() const
 {
 	for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it)
 	{
@@ -4424,6 +4442,11 @@ BOOL LLMenuHolderGL::hasVisibleMenu()
 	return FALSE;
 }
 
+const LLRect LLMenuHolderGL::getMenuRect() const
+{
+	return getLocalRect();
+}
+
 BOOL LLMenuHolderGL::hideMenus()
 {
 	if (!mCanHide)
diff --git a/indra/llui/llmenugl.h b/indra/llui/llmenugl.h
index b9f7d033ac2..d43b4553c38 100644
--- a/indra/llui/llmenugl.h
+++ b/indra/llui/llmenugl.h
@@ -22,6 +22,7 @@
 #include "llview.h"
 
 class LLMenuItemGL;
+class LLMenuHolderGL;
 
 extern S32 MENU_BAR_HEIGHT;
 extern S32 MENU_BAR_WIDTH;
@@ -144,6 +145,7 @@ class LLMenuItemGL : public LLView
 
 	// LLView Functionality
 	virtual BOOL handleKeyHere( KEY key, MASK mask, BOOL called_from_parent );
+	virtual BOOL handleMouseDown( S32 x, S32 y, MASK mask );
 	virtual BOOL handleMouseUp( S32 x, S32 y, MASK mask );
 	virtual void draw( void );
 
@@ -504,7 +506,8 @@ class LLMenuGL
 	static BOOL getKeyboardMode() { return sKeyboardMode; }
 
 	static void onFocusLost(LLView* old_focus);
-	static LLView *sDefaultMenuContainer;
+
+	static LLMenuHolderGL* sMenuContainer;
 	
 protected:
 	void createSpilloverBranch();
@@ -679,8 +682,10 @@ class LLMenuHolderGL : public LLPanel
 	virtual BOOL handleMouseDown( S32 x, S32 y, MASK mask );
 	virtual BOOL handleRightMouseDown( S32 x, S32 y, MASK mask );
 
+	virtual const LLRect getMenuRect() const;
+	virtual BOOL hasVisibleMenu() const;
+
 	static void setActivatedItem(LLMenuItemGL* item);
-	BOOL hasVisibleMenu();
 
 protected:
 	static LLViewHandle sItemLastSelectedHandle;
diff --git a/indra/llui/llscrolllistctrl.cpp b/indra/llui/llscrolllistctrl.cpp
index 95ea2cbc37e..d263c25c722 100644
--- a/indra/llui/llscrolllistctrl.cpp
+++ b/indra/llui/llscrolllistctrl.cpp
@@ -143,7 +143,8 @@ LLScrollListText::LLScrollListText( const LLString& text, const LLFontGL* font,
 	mFontStyle( font_style ),
 	mWidth( width ),
 	mVisible( visible ),
-	mHighlightChars( 0 )
+	mHighlightCount( 0 ),
+	mHighlightOffset( 0 )
 {
 	if (use_color)
 	{
@@ -197,13 +198,14 @@ void LLScrollListText::drawToWidth(S32 width, const LLColor4& color, const LLCol
 		display_color = &color;
 	}
 
-	if (mHighlightChars > 0)
+	if (mHighlightCount > 0)
 	{
 		mRoundedRectImage->bind();
 		glColor4fv(highlight_color.mV);
-		gl_segmented_rect_2d_tex(-2, 
+		S32 left = mFont->getWidth(mText.getString(), 0, mHighlightOffset);
+		gl_segmented_rect_2d_tex(left - 2, 
 				llround(mFont->getLineHeight()) + 1, 
-				mFont->getWidth(mText.getString(), 0, mHighlightChars) + 1, 
+				left + mFont->getWidth(mText.getString(), mHighlightOffset, mHighlightCount) + 1, 
 				1, 
 				mRoundedRectImage->getWidth(), 
 				mRoundedRectImage->getHeight(), 
@@ -1141,11 +1143,17 @@ BOOL LLScrollListCtrl::selectSimpleItemByPrefix(const LLWString& target, BOOL ca
 			{
 				LLWString::toLower(item_label);
 			}
+			// remove extraneous whitespace from searchable label
+			LLWString trimmed_label = item_label;
+			LLWString::trim(trimmed_label);
 			
-			BOOL select = item->getEnabled() && !item_label.compare(0, target_len, target_trimmed);
+			BOOL select = item->getEnabled() && trimmed_label.compare(0, target_trimmed.size(), target_trimmed) == 0;
 
 			if (select)
 			{
+				// find offset of matching text (might have leading whitespace)
+				S32 offset = item_label.find(target_trimmed);
+				cellp->highlightText(offset, target_trimmed.size());
 				selectItem(item);
 				found = TRUE;
 				break;
@@ -1447,6 +1455,9 @@ BOOL LLScrollListCtrl::handleMouseDown(S32 x, S32 y, MASK mask)
 {
 	BOOL handled = LLView::childrenHandleMouseDown(x, y, mask) != NULL;
 
+	// set keyboard focus first, in case click action wants to move focus elsewhere
+	setFocus(TRUE);
+
 	if( !handled && mCanSelect)
 	{
 		LLScrollListItem* hit_item = hitItem(x, y);
@@ -1539,8 +1550,6 @@ BOOL LLScrollListCtrl::handleMouseDown(S32 x, S32 y, MASK mask)
 		}
 	}
 
-	gFocusMgr.setKeyboardFocus(this, NULL);
-
 	return TRUE;
 }
 
@@ -1739,7 +1748,7 @@ BOOL LLScrollListCtrl::handleKeyHere(KEY key,MASK mask, BOOL called_from_parent
 						LLScrollListCell* cellp = getFirstSelected()->getColumn(mSearchColumn);
 						if (cellp)
 						{
-							cellp->highlightText(0);
+							cellp->highlightText(0, 0);
 						}
 					}
 				}
@@ -1748,13 +1757,6 @@ BOOL LLScrollListCtrl::handleKeyHere(KEY key,MASK mask, BOOL called_from_parent
 					// update search string only on successful match
 					mSearchTimer.reset();
 
-					// highlight current search on matching item
-					LLScrollListCell* cellp = getFirstSelected()->getColumn(mSearchColumn);
-					if (cellp)
-					{
-						cellp->highlightText(mSearchString.size());
-					}
-
 					if (mCommitOnKeyboardMovement
 						&& !mCommitOnSelectionChange) 
 					{
@@ -1794,13 +1796,6 @@ BOOL LLScrollListCtrl::handleUnicodeCharHere(llwchar uni_char, BOOL called_from_
 		mSearchString += uni_char;
 		mSearchTimer.reset();
 
-		// highlight current search on matching item
-		LLScrollListCell* cellp = getFirstSelected()->getColumn(mSearchColumn);
-		if (cellp)
-		{
-			cellp->highlightText(mSearchString.size());
-		}
-
 		if (mCommitOnKeyboardMovement
 			&& !mCommitOnSelectionChange) 
 		{
@@ -1843,7 +1838,7 @@ BOOL LLScrollListCtrl::handleUnicodeCharHere(llwchar uni_char, BOOL called_from_
 				if (item->getEnabled() && LLStringOps::toLower(item_label[0]) == uni_char)
 				{
 					selectItem(item);
-					cellp->highlightText(1);
+					cellp->highlightText(0, 1);
 					mSearchTimer.reset();
 
 					if (mCommitOnKeyboardMovement
@@ -1906,7 +1901,7 @@ void LLScrollListCtrl::selectItem(LLScrollListItem* itemp, BOOL select_single_it
 			LLScrollListCell* cellp = mLastSelected->getColumn(mSearchColumn);
 			if (cellp)
 			{
-				cellp->highlightText(0);
+				cellp->highlightText(0, 0);
 			}
 		}
 		if (select_single_item)
@@ -1934,7 +1929,7 @@ void LLScrollListCtrl::deselectItem(LLScrollListItem* itemp)
 		LLScrollListCell* cellp = itemp->getColumn(mSearchColumn);
 		if (cellp)
 		{
-			cellp->highlightText(0);
+			cellp->highlightText(0, 0);
 		}
 		mSelectionChanged = TRUE;
 	}
diff --git a/indra/llui/llscrolllistctrl.h b/indra/llui/llscrolllistctrl.h
index 805efe8679b..985ccc12a57 100644
--- a/indra/llui/llscrolllistctrl.h
+++ b/indra/llui/llscrolllistctrl.h
@@ -38,7 +38,7 @@ class LLScrollListCell
 	virtual const LLString&	getTextLower() const { return LLString::null; }
 	virtual const BOOL		getVisible() const { return TRUE; }
 	virtual void			setWidth(S32 width) = 0;
-	virtual void			highlightText(S32 num_chars) {}
+	virtual void			highlightText(S32 offset, S32 num_chars) {}
 
 	virtual BOOL	handleClick() { return FALSE; }
 	virtual	void	setEnabled(BOOL enable) { }
@@ -57,7 +57,7 @@ class LLScrollListText : public LLScrollListCell
 	virtual S32		getHeight() const			{ return llround(mFont->getLineHeight()); }
 	virtual const LLString&		getText() const		{ return mText.getString(); }
 	virtual const BOOL			getVisible() const  { return mVisible; }
-	virtual void	highlightText(S32 num_chars) {mHighlightChars = num_chars;}
+	virtual void	highlightText(S32 offset, S32 num_chars) {mHighlightOffset = offset; mHighlightCount = num_chars;}
 	void			setText(const LLString& text);
 
 private:
@@ -68,7 +68,8 @@ class LLScrollListText : public LLScrollListCell
 	S32				mWidth;
 	S32				mEllipsisWidth;	// in pixels, of "..."
 	BOOL			mVisible;
-	S32				mHighlightChars;
+	S32				mHighlightCount;
+	S32				mHighlightOffset;
 
 	LLPointer<LLImageGL> mRoundedRectImage;
 };
diff --git a/indra/llvfs/llvfs.cpp b/indra/llvfs/llvfs.cpp
index e57e56aaf04..f907fcab451 100644
--- a/indra/llvfs/llvfs.cpp
+++ b/indra/llvfs/llvfs.cpp
@@ -1254,7 +1254,7 @@ void LLVFS::eraseBlockLength(LLVFSBlock *block)
 	}
 	if (iter == end)
 	{
-		llerrs << "eraseBlock could not find block" << llendl;
+		llwarns << "eraseBlock could not find block" << llendl;
 	}
 }
 
diff --git a/indra/llwindow/llkeyboardwin32.cpp b/indra/llwindow/llkeyboardwin32.cpp
index b168c1aed8b..448345eeebc 100644
--- a/indra/llwindow/llkeyboardwin32.cpp
+++ b/indra/llwindow/llkeyboardwin32.cpp
@@ -195,7 +195,6 @@ BOOL LLKeyboardWin32::handleKeyDown(const U16 key, MASK mask)
 	return handled;
 }
 
-
 // mask is ignored, except for extended flag -- we poll the modifier keys for the other flags
 BOOL LLKeyboardWin32::handleKeyUp(const U16 key, MASK mask)
 {
@@ -229,10 +228,14 @@ MASK LLKeyboardWin32::currentMask(BOOL)
 void LLKeyboardWin32::scanKeyboard()
 {
 	S32 key;
+	MSG	msg;
+	BOOL pending_key_events = PeekMessage(&msg, NULL, WM_KEYFIRST, WM_KEYLAST, PM_NOREMOVE | PM_NOYIELD);
 	for (key = 0; key < KEY_COUNT; key++)
 	{
 		// On Windows, verify key down state. JC
-		if (mKeyLevel[key])
+		// RN: only do this if we don't have further key events in the queue
+		// as otherwise there might be key repeat events still waiting for this key we are now dumping
+		if (!pending_key_events && mKeyLevel[key])
 		{
 			// *TODO: I KNOW there must be a better way of
 			// interrogating the key state than this, using async key
@@ -243,9 +246,9 @@ void LLKeyboardWin32::scanKeyboard()
 				// ...translate back to windows key
 				U16 virtual_key = inverseTranslateExtendedKey(key);
 				// keydown in highest bit
-				if (!(GetAsyncKeyState(virtual_key) & 0x8000))
+				if (!pending_key_events && !(GetAsyncKeyState(virtual_key) & 0x8000))
 				{
-					//llinfos << "Key up event missed, resetting" << llendl;
+ 					//llinfos << "Key up event missed, resetting" << llendl;
 					mKeyLevel[key] = FALSE;
 				}
 			}
diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp
index 535f94d8553..c79a39c513e 100644
--- a/indra/llwindow/llwindowwin32.cpp
+++ b/indra/llwindow/llwindowwin32.cpp
@@ -1961,20 +1961,6 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_
 						<< " key " << S32(w_param) 
 						<< llendl;
 				}
-				// lower 15 bits hold key repeat count
-				S32 key_repeat_count = l_param & 0x7fff;
-				if (key_repeat_count > 1)
-				{
-					KEY translated_key;
-					gKeyboard->translateKey(w_param, &translated_key);
-					if (!gKeyboard->getKeyDown(translated_key))
-					{
-						//RN: hack for handling key repeats when we no longer recognize the key as being down
-						//This is necessary because we sometimes ignore the message queue and use getAsyncKeyState
-						// to clear key level flags before we've processed all key repeat messages
-						return 0;
-					}
-				}
 				if(gKeyboard->handleKeyDown(w_param, mask) && eat_keystroke)
 				{
 					return 0;
diff --git a/indra/llxml/llcontrol.h b/indra/llxml/llcontrol.h
index b88f388a0b7..871d8871364 100644
--- a/indra/llxml/llcontrol.h
+++ b/indra/llxml/llcontrol.h
@@ -48,6 +48,7 @@ friend class LLControlGroup;
 	BOOL			mHasRange;
 	BOOL			mPersist;
 	BOOL            mIsDefault;
+
 	static	std::set<LLControlBase*>	mChangedControls;
 	static	std::list<S32>				mFreeIDs;//These lists are used to store the ID's of registered event listeners.
 	static	std::list<S32>				mUsedIDs;
@@ -152,7 +153,10 @@ friend class LLControlGroup;
 		}
 	}
 
-	/*virtual*/ void resetToDefault() { mCurrent = mDefault; mIsDefault = TRUE;}
+	/*virtual*/ void resetToDefault() 
+	{ 
+		setValue(mDefault);
+	}
 
 	virtual	~LLControl()
 	{
diff --git a/indra/newview/licenses-linux.txt b/indra/newview/licenses-linux.txt
index f7ccf27a128..57df413ae0f 100644
--- a/indra/newview/licenses-linux.txt
+++ b/indra/newview/licenses-linux.txt
@@ -404,6 +404,39 @@ Subject to the following 3 conditions, Epinions, Inc. permits you, free of charg
 3) IN NO EVENT SHALL EPINIONS, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE (HOWEVER ARISING, INCLUDING NEGLIGENCE), EVEN IF EPINIONS, INC. IS AWARE OF THE POSSIBILITY OF SUCH DAMAGES. 
 
 
+===============
+libuuid License
+===============
+
+Copyright (C) 1999, 2000, 2003, 2004 by Theodore Ts'o
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, and the entire permission notice in its entirety,
+   including the disclaimer of warranties.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+3. The name of the author may not be used to endorse or promote
+   products derived from this software without specific prior
+   written permission.
+
+THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF
+WHICH ARE HEREBY DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGE.
+
+
 ============
 zlib License
 ============
diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp
index d34695a7be2..8c520f66385 100644
--- a/indra/newview/lldrawpoolalpha.cpp
+++ b/indra/newview/lldrawpoolalpha.cpp
@@ -443,7 +443,14 @@ void LLDrawPoolAlpha::renderForSelect()
 	LLGLSObjectSelectAlpha gls_alpha;
 
 	glBlendFunc(GL_ONE, GL_ZERO);
-	glAlphaFunc(gPickTransparent ? GL_GEQUAL : GL_GREATER, 0.f);
+	if (gPickTransparent)
+	{
+		glAlphaFunc(GL_GEQUAL, 0.f);
+	}
+	else
+	{
+		glAlphaFunc(GL_GEQUAL, gPickAlphaThreshold);
+	}
 
 	bindGLVertexPointer();
 	bindGLTexCoordPointer();
@@ -464,27 +471,10 @@ void LLDrawPoolAlpha::renderForSelect()
 	LLDynamicArray<LLFace*>* distance_bins;
 	distance_bins = mDistanceBins;
 
-	S32 j;
-	S32 num_bins_no_alpha_test = (gPickAlphaThreshold != 0.f) ? 
-		(NUM_ALPHA_BINS - llmax(2, (S32)(ALPHA_FALLOFF_START_DISTANCE * mInvBinSize))) : 
-		NUM_ALPHA_BINS;
-
 	S32 i;
-	for (i = 0; i < num_bins_no_alpha_test; i++)
-	{
-		S32 distance_bin_size = distance_bins[i].count();
-		for (j = 0; j < distance_bin_size; j++)
-		{
-			const LLFace &face = *distance_bins[i][j];
-			if (face.getDrawable() && !face.getDrawable()->isDead() && (face.getViewerObject()->mGLName))
-			{
-				face.bindTexture();
-				face.renderForSelect();
-			}
-		}
-	}
+	S32 j;
 
-	for (i = num_bins_no_alpha_test; i < NUM_ALPHA_BINS; i++)
+	for (i = 0; i < NUM_ALPHA_BINS; i++)
 	{
 		S32 distance_bin_size = distance_bins[i].count();
 		if (distance_bin_size)
@@ -493,8 +483,6 @@ void LLDrawPoolAlpha::renderForSelect()
 			{
 				const LLFace &face = *distance_bins[i][j];
 
-				glAlphaFunc(GL_GEQUAL, face.mAlphaFade * gPickAlphaTargetThreshold);
-
 				if (face.getDrawable() && !face.getDrawable()->isDead() && (face.getViewerObject()->mGLName))
 				{
 					face.bindTexture();
diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp
index 1ad724024b1..55b3ee185bf 100644
--- a/indra/newview/llfloaterregioninfo.cpp
+++ b/indra/newview/llfloaterregioninfo.cpp
@@ -305,12 +305,20 @@ void LLFloaterRegionInfo::processRegionInfo(LLMessageSystem* msg)
 	panel->childSetValue("restrict_pushobject", (region_flags & REGION_FLAGS_RESTRICT_PUSHOBJECT) ? TRUE : FALSE );
 	panel->childSetValue("allow_land_resell_check", (region_flags & REGION_FLAGS_BLOCK_LAND_RESELL) ? FALSE : TRUE );
 	panel->childSetValue("allow_parcel_changes_check", (region_flags & REGION_FLAGS_ALLOW_PARCEL_CHANGES) ? TRUE : FALSE );
-
 	panel->childSetValue("agent_limit_spin", LLSD((F32)agent_limit) );
 	panel->childSetValue("object_bonus_spin", LLSD(object_bonus_factor) );
-
 	panel->childSetValue("access_combo", LLSD(LLViewerRegion::accessToString(sim_access)) );
 
+
+	// detect teen grid for maturity
+	LLViewerRegion* region = gAgent.getRegion();
+
+	U32 parent_estate_id;
+	msg->getU32("RegionInfo", "ParentEstateID", parent_estate_id);
+	BOOL teen_grid = (parent_estate_id == 5);  // *TODO add field to estate table and test that
+	panel->childSetEnabled("access_combo", gAgent.isGodlike() || (region && region->canManageEstate() && !teen_grid));
+	
+
 	// DEBUG PANEL
 	panel = LLUICtrlFactory::getPanelByName(tab, "Debug");
 	if(!panel) return;
@@ -330,7 +338,6 @@ void LLFloaterRegionInfo::processRegionInfo(LLMessageSystem* msg)
 	panel->childSetValue("terrain_lower_spin", LLSD(terrain_lower_limit));
 	panel->childSetValue("use_estate_sun_check", LLSD(use_estate_sun));
 
-	LLViewerRegion* region = gAgent.getRegion();
 	BOOL allow_modify = gAgent.isGodlike() || (region && region->canManageEstate());
 	panel->childSetValue("fixed_sun_check", LLSD((BOOL)(region_flags & REGION_FLAGS_SUN_FIXED)));
 	panel->childSetEnabled("fixed_sun_check", allow_modify && !use_estate_sun);
@@ -506,7 +513,8 @@ bool LLPanelRegionGeneralInfo::refreshFromRegion(LLViewerRegion* region)
 	setCtrlsEnabled(allow_modify);
 	childDisable("apply_btn");
 	childSetEnabled("access_text", allow_modify);
-	childSetEnabled("access_combo", allow_modify);
+	// childSetEnabled("access_combo", allow_modify);
+	// now set in processRegionInfo for teen grid detection
 	childSetEnabled("kick_btn", allow_modify);
 	childSetEnabled("kick_all_btn", allow_modify);
 	childSetEnabled("im_btn", allow_modify);
diff --git a/indra/newview/llfolderview.cpp b/indra/newview/llfolderview.cpp
index b3585fdfafa..39cf48c5c96 100644
--- a/indra/newview/llfolderview.cpp
+++ b/indra/newview/llfolderview.cpp
@@ -4059,7 +4059,7 @@ BOOL LLFolderView::handleRightMouseDown( S32 x, S32 y, MASK mask )
 		}
 
 		menu->arrange();
-		menu->updateParent(gMenuHolder);
+		menu->updateParent(LLMenuGL::sMenuContainer);
 		LLMenuGL::showPopup(this, menu, x, y);
 	}
 	else
diff --git a/indra/newview/llnetmap.cpp b/indra/newview/llnetmap.cpp
index 26f4a2fb5b7..b03996d460a 100644
--- a/indra/newview/llnetmap.cpp
+++ b/indra/newview/llnetmap.cpp
@@ -772,7 +772,7 @@ BOOL LLNetMap::handleRightMouseDown(S32 x, S32 y, MASK mask)
 	if (menu)
 	{
 		menu->buildDrawLabels();
-		menu->updateParent(gMenuHolder);
+		menu->updateParent(LLMenuGL::sMenuContainer);
 		LLMenuGL::showPopup(this, menu, x, y);
 	}
 	return TRUE;
diff --git a/indra/newview/llpanelavatar.cpp b/indra/newview/llpanelavatar.cpp
index dda28020cd5..50586b3649f 100644
--- a/indra/newview/llpanelavatar.cpp
+++ b/indra/newview/llpanelavatar.cpp
@@ -359,6 +359,20 @@ void LLPanelAvatarSecondLife::onClickPublishHelp(void *)
 	gViewerWindow->alertXml("ClickPublishHelpAvatar");
 }
 
+// static
+void LLPanelAvatarSecondLife::onClickPartnerHelp(void *)
+{
+    gViewerWindow->alertXml("ClickPartnerHelpAvatar", onClickPartnerHelpLoadURL, (void*) NULL);
+}
+
+// static 
+void LLPanelAvatarSecondLife::onClickPartnerHelpLoadURL(S32 option, void* userdata)
+{
+  if (option == 0)
+    LLWeb::loadURL("http://secondlife.com/partner");
+}
+
+
 //-----------------------------------------------------------------------------
 // LLPanelAvatarFirstLife()
 //-----------------------------------------------------------------------------
@@ -388,6 +402,7 @@ BOOL LLPanelAvatarSecondLife::postBuild(void)
 {
 	childSetEnabled("born", FALSE);
 	childSetEnabled("partner_edit", FALSE);
+	childSetAction("partner_help",onClickPartnerHelp,this);
 	
 	childSetAction("?",onClickPublishHelp,this);
 	BOOL own_avatar = (mPanelAvatar->getAvatarID() == gAgent.getID() );
diff --git a/indra/newview/llpanelavatar.h b/indra/newview/llpanelavatar.h
index 713750ad06a..1f4ed7e8299 100644
--- a/indra/newview/llpanelavatar.h
+++ b/indra/newview/llpanelavatar.h
@@ -69,6 +69,8 @@ class LLPanelAvatarSecondLife
 	static void onClickFriends(			void *userdata);
 	static void onDoubleClickGroup(void* userdata);
 	static void onClickPublishHelp(void *userdata);
+	static void onClickPartnerHelp(void *userdata);
+	static void onClickPartnerHelpLoadURL(S32 option, void* userdata);
 
 	// Clear out the controls anticipating new network data.
 	void clearControls();
diff --git a/indra/newview/llpanelpermissions.cpp b/indra/newview/llpanelpermissions.cpp
index adcf17febf8..332d22ade62 100644
--- a/indra/newview/llpanelpermissions.cpp
+++ b/indra/newview/llpanelpermissions.cpp
@@ -710,6 +710,11 @@ void LLPanelPermissions::refresh()
 	{
 		RadioSaleType->setSelectedIndex((S32)sale_type - 1);
 	}
+	else
+	{
+		// default option is sell copy, determined to be safest
+		RadioSaleType->setSelectedIndex((S32)LLSaleInfo::FS_COPY - 1);
+	}
 
 	if (is_for_sale)
 	{
diff --git a/indra/newview/llpreviewnotecard.cpp b/indra/newview/llpreviewnotecard.cpp
index a37ed692b1c..6b8cc626ee4 100644
--- a/indra/newview/llpreviewnotecard.cpp
+++ b/indra/newview/llpreviewnotecard.cpp
@@ -91,8 +91,12 @@ LLPreviewNotecard::LLPreviewNotecard(const std::string& name,
 		}
 	}	
 
-	reshape(curRect.getWidth(), curRect.getHeight(), TRUE);
-	setRect(curRect);
+	// only assert shape if not hosted in a multifloater
+	if (!getHost())
+	{
+		reshape(curRect.getWidth(), curRect.getHeight(), TRUE);
+		setRect(curRect);
+	}
 			
 	childSetVisible("lock", FALSE);	
 	
diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp
index f7e063b412f..f6b9f0e0182 100644
--- a/indra/newview/llpreviewscript.cpp
+++ b/indra/newview/llpreviewscript.cpp
@@ -1268,7 +1268,7 @@ LLLiveLSLEditor::LLLiveLSLEditor(const std::string& name,
 								 const std::string& title,
 								 const LLUUID& object_id,
 								 const LLUUID& item_id) :
-	LLFloater(name, rect, title, TRUE, SCRIPT_MIN_WIDTH, SCRIPT_MIN_HEIGHT),
+	LLPreview(name, rect, title, item_id, object_id, TRUE, SCRIPT_MIN_WIDTH, SCRIPT_MIN_HEIGHT),
 	mObjectID(object_id),
 	mItemID(item_id),
 	mScriptEd(NULL),
@@ -1327,6 +1327,11 @@ LLLiveLSLEditor::~LLLiveLSLEditor()
 	LLLiveLSLEditor::sInstances.removeData(mItemID ^ mObjectID);
 }
 
+// this is called via LLPreview::loadAsset() virtual method
+void LLLiveLSLEditor::loadAsset()
+{
+	loadAsset(FALSE);
+}
 
 void LLLiveLSLEditor::loadAsset(BOOL is_new)
 {
@@ -1358,6 +1363,7 @@ void LLLiveLSLEditor::loadAsset(BOOL is_new)
 				mScriptEd->mEditor->setText("You are not allowed to view this script.");
 				mScriptEd->mEditor->makePristine();
 				mScriptEd->mEditor->setEnabled(FALSE);
+				mAssetStatus = PREVIEW_ASSET_LOADED;
 			}
 			else if(mItem.notNull())
 			{
@@ -1381,11 +1387,13 @@ void LLLiveLSLEditor::loadAsset(BOOL is_new)
 				msg->addUUIDFast(_PREHASH_ItemID, mItemID);
 				msg->sendReliable(object->getRegion()->getHost());
 				mAskedForRunningInfo = TRUE;
+				mAssetStatus = PREVIEW_ASSET_LOADING;
 			}
 			else
 			{
 				mScriptEd->mEditor->setText("");
 				mScriptEd->mEditor->makePristine();
+				mAssetStatus = PREVIEW_ASSET_LOADED;
 			}
 
 			if(item
@@ -1429,6 +1437,7 @@ void LLLiveLSLEditor::loadAsset(BOOL is_new)
 									LLSaleInfo::DEFAULT,
 									LLInventoryItem::II_FLAGS_NONE,
 									time_corrected());
+		mAssetStatus = PREVIEW_ASSET_LOADED;
 	}
 }
 
@@ -1448,6 +1457,7 @@ void LLLiveLSLEditor::onLoadComplete(LLVFS *vfs, const LLUUID& asset_id,
 		{
 			instance = LLLiveLSLEditor::sInstances[*xored_id];
 			instance->loadScriptText(vfs, asset_id, type);
+			instance->mAssetStatus = PREVIEW_ASSET_LOADED;
 		}
 		else
 		{
@@ -1469,6 +1479,7 @@ void LLLiveLSLEditor::onLoadComplete(LLVFS *vfs, const LLUUID& asset_id,
 			{
 				LLNotifyBox::showXml("UnableToLoadScript");
 			}
+			instance->mAssetStatus = PREVIEW_ASSET_ERROR;
 		}
 	}
 
diff --git a/indra/newview/llpreviewscript.h b/indra/newview/llpreviewscript.h
index ead9d8e334d..9b2beb9ce93 100644
--- a/indra/newview/llpreviewscript.h
+++ b/indra/newview/llpreviewscript.h
@@ -147,7 +147,7 @@ class LLPreviewLSL : public LLPreview
 
 
 // Used to view and edit an LSL that is attached to an object.
-class LLLiveLSLEditor : public LLFloater
+class LLLiveLSLEditor : public LLPreview
 {
 public: 
 	LLLiveLSLEditor(const std::string& name, const LLRect& rect,
@@ -166,7 +166,8 @@ class LLLiveLSLEditor : public LLFloater
 	virtual void draw();
 	virtual void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
 
-	void loadAsset(BOOL is_new = FALSE);
+	virtual void loadAsset();
+	void loadAsset(BOOL is_new);
 	void saveIfNeeded();
 
 	static void onLoad(void* userdata);
diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp
index 5e7b3377d9b..cf80a722820 100644
--- a/indra/newview/llstartup.cpp
+++ b/indra/newview/llstartup.cpp
@@ -377,9 +377,17 @@ BOOL idle_startup()
 		{
 			fclose(found_template);
 
+			U32 port = gAgent.mViewerPort;
+
+			if ((NET_USE_OS_ASSIGNED_PORT == port) &&   // if nothing specified on command line (-port)
+			    (gSavedSettings.getBOOL("ConnectionPortEnabled")))
+			  {
+			    port = gSavedSettings.getU32("ConnectionPort");
+			  }
+
 			if(!start_messaging_system(
 				   message_template_path,
-				   gAgent.mViewerPort,
+				   port,
 				   LL_VERSION_MAJOR,
 				   LL_VERSION_MINOR,
 				   LL_VERSION_PATCH,
diff --git a/indra/newview/lltooldraganddrop.cpp b/indra/newview/lltooldraganddrop.cpp
index 7e01b185305..ea1284117df 100644
--- a/indra/newview/lltooldraganddrop.cpp
+++ b/indra/newview/lltooldraganddrop.cpp
@@ -1461,6 +1461,9 @@ void LLToolDragAndDrop::dropObject(LLViewerObject* raycast_target,
 		// since it's coming from the library or trash, we want to not
 		// 'take' it back to the same place.
 		item->setParent(LLUUID::null);
+		// *TODO this code isn't working - the parent (FolderID) is still
+		// set when the object is "taken".  so code on the "take" side is
+		// checking for trash and library as well (llviewermenu.cpp)
 	}
 	if (mSource == SOURCE_NOTECARD)
 	{
diff --git a/indra/newview/lltracker.cpp b/indra/newview/lltracker.cpp
index d3d7fd528de..42ef25ac4e2 100644
--- a/indra/newview/lltracker.cpp
+++ b/indra/newview/lltracker.cpp
@@ -245,7 +245,7 @@ void LLTracker::render3D()
 			else 
 			{
 				const LLRelationship* buddy = av_tracker.getBuddyInfo(avatar_id);
-				if(buddy && !buddy->isOnline())
+				if(buddy && !buddy->isOnline() && !gAgent.isGodlike())
 				{
 					stop_tracking = TRUE;
 				}
diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp
index 6069945725c..99cae9979c1 100644
--- a/indra/newview/llviewercontrol.cpp
+++ b/indra/newview/llviewercontrol.cpp
@@ -198,6 +198,20 @@ void LLFloaterSettingsDebug::onCommitSettings(LLUICtrl* ctrl, void* user_data)
 	}
 }
 
+// static
+void LLFloaterSettingsDebug::onClickDefault(void* user_data)
+{
+	LLFloaterSettingsDebug* floaterp = (LLFloaterSettingsDebug*)user_data;
+	LLComboBox* settings_combo = (LLComboBox*)floaterp->getChildByName("settings_combo");
+	LLControlBase* controlp = (LLControlBase*)settings_combo->getCurrentUserdata();
+
+	if (controlp)
+	{
+		controlp->resetToDefault();
+		floaterp->updateControl(controlp);
+	}
+}
+
 // we've switched controls, or doing per-frame update, so update spinners, etc.
 void LLFloaterSettingsDebug::updateControl(LLControlBase* controlp)
 {
@@ -421,6 +435,8 @@ void LLFloaterSettingsDebug::updateControl(LLControlBase* controlp)
 			if (!spinner4->hasFocus())
 			{
 				spinner4->setPrecision(3);
+				spinner4->setMinValue(0.0);
+				spinner4->setMaxValue(1.f);
 				spinner4->setValue(clr.mV[VALPHA]);
 			}
 			break;
diff --git a/indra/newview/llviewercontrol.h b/indra/newview/llviewercontrol.h
index e86f961b3a7..55d92c2d7ad 100644
--- a/indra/newview/llviewercontrol.h
+++ b/indra/newview/llviewercontrol.h
@@ -27,6 +27,7 @@ class LLFloaterSettingsDebug : public LLFloater
 	static void show(void*);
 	static void onSettingSelect(LLUICtrl* ctrl, void* user_data);
 	static void onCommitSettings(LLUICtrl* ctrl, void* user_data);
+	static void onClickDefault(void* user_data);
 
 protected:
 	static LLFloaterSettingsDebug* sInstance;
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index ef7027876a4..7ef1fd82c63 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -44,6 +44,7 @@
 
 // newview includes
 #include "llagent.h"
+
 #include "llagentpilot.h"
 #include "llbox.h"
 #include "llcallingcard.h"
@@ -546,10 +547,10 @@ void init_menus()
 	// Main menu bar
 	//
 	gMenuHolder = new LLViewerMenuHolderGL();
-	gMenuHolder->setRect(LLRect(0, top - MENU_BAR_HEIGHT, width, STATUS_BAR_HEIGHT));
+	gMenuHolder->setRect(LLRect(0, top, width, 0));
 	gMenuHolder->setFollowsAll();
 
-	LLMenuGL::sDefaultMenuContainer = gMenuHolder;
+	LLMenuGL::sMenuContainer = gMenuHolder;
 
 	// Initialize actions
 	initialize_menu_actions();
@@ -583,12 +584,12 @@ void init_menus()
 	menu = new LLMenuGL(CLIENT_MENU_NAME);
 	init_client_menu(menu);
 	gMenuBarView->appendMenu( menu );
-	menu->updateParent(gMenuHolder);
+	menu->updateParent(LLMenuGL::sMenuContainer);
 
 	menu = new LLMenuGL(SERVER_MENU_NAME);
 	init_server_menu(menu);
 	gMenuBarView->appendMenu( menu );
-	menu->updateParent(gMenuHolder);
+	menu->updateParent(LLMenuGL::sMenuContainer);
 
 	gMenuBarView->createJumpKeys();
 
@@ -4145,7 +4146,7 @@ void handle_take()
 	if(category_id.notNull())
 	{
 		// there is an unambiguous destination. See if this agent has
-		// such a location and it is not in the trash.
+		// such a location and it is not in the trash or library
 		if(!gInventory.getCategory(category_id))
 		{
 			// nope, set to NULL.
@@ -4153,12 +4154,20 @@ void handle_take()
 		}
 		if(category_id.notNull())
 		{
+		        // check trash
 			LLUUID trash;
 			trash = gInventory.findCategoryUUIDForType(LLAssetType::AT_TRASH);
 			if(category_id == trash || gInventory.isObjectDescendentOf(category_id, trash))
 			{
 				category_id.setNull();
 			}
+
+			// check library
+			if(gInventory.isObjectDescendentOf(category_id, gInventoryLibraryRoot))
+			{
+				category_id.setNull();
+			}
+
 		}
 	}
 	if(category_id.isNull())
@@ -8277,6 +8286,11 @@ BOOL LLViewerMenuHolderGL::hideMenus()
 	return handled;
 }
 
+const LLRect LLViewerMenuHolderGL::getMenuRect() const
+{
+	return LLRect(0, mRect.getHeight() - MENU_BAR_HEIGHT, mRect.getWidth(), STATUS_BAR_HEIGHT);
+}
+
 void handle_save_to_xml(void*)
 {
 	LLFloater* frontmost = gFloaterView->getFrontmost();
diff --git a/indra/newview/llviewermenu.h b/indra/newview/llviewermenu.h
index 37a7f0fa13f..182190ccdf2 100644
--- a/indra/newview/llviewermenu.h
+++ b/indra/newview/llviewermenu.h
@@ -129,6 +129,7 @@ class LLViewerMenuHolderGL : public LLMenuHolderGL
 	LLViewerMenuHolderGL() : LLMenuHolderGL() {};
 
 	virtual BOOL hideMenus();
+	virtual const LLRect getMenuRect() const;
 	//virtual BOOL handleKey(KEY key, MASK mask, BOOL called_from_parent);
 };
 
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 07739980234..871dfcbdead 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -1615,6 +1615,9 @@ void LLViewerWindow::initWorldUI()
 	gStatusBar->translate(0, root_rect.getHeight() - gStatusBar->getRect().getHeight());
 
 	gViewerWindow->getRootView()->addChild(gStatusBar);
+
+	// menu holder appears on top to get first pass at all mouse events
+	gViewerWindow->getRootView()->sendChildToFront(gMenuHolder);
 }
 
 
@@ -2944,8 +2947,6 @@ void LLViewerWindow::hitObjectOrLandGlobalAsync(S32 x, S32 y_from_bot, MASK mask
 	S32 scaled_x = llround((F32)x * mDisplayScale.mV[VX]);
 	S32 scaled_y = llround((F32)y_from_bot * mDisplayScale.mV[VY]);
 
-	F32 delta_time = gAlphaFadeTimer.getElapsedTimeAndResetF32();
-
 	BOOL in_build_mode = gFloaterTools && gFloaterTools->getVisible();
 	if (in_build_mode || LLDrawPoolAlpha::sShowDebugAlpha)
 	{
@@ -2955,17 +2956,6 @@ void LLViewerWindow::hitObjectOrLandGlobalAsync(S32 x, S32 y_from_bot, MASK mask
 	}
 	gPickTransparent = pick_transparent;
 
-	if (gPickTransparent)
-	{
-		gPickAlphaTargetThreshold = 0.f;
-		gPickAlphaThreshold = llmax(gPickAlphaTargetThreshold, gPickAlphaThreshold - (delta_time * 0.7f));
-	}
-	else
-	{
-		gPickAlphaTargetThreshold = 1.f;
-		gPickAlphaThreshold = llmin(gPickAlphaTargetThreshold, gPickAlphaThreshold + (delta_time * 0.7f));
-	}
-
 	gUseGLPick = FALSE;
 	mPickCallback = callback;
 
@@ -4014,7 +4004,6 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei
 				setupViewport();
 				BOOL first_time_through = (subimage_x + subimage_y == 0);
 				gPickTransparent = FALSE;
-				gPickAlphaThreshold = 0.1f;
 				gObjectList.renderObjectsForSelect(*gCamera, FALSE, !first_time_through);
 			}
 			else
@@ -4368,8 +4357,6 @@ void LLViewerWindow::stopGL(BOOL save_state)
 		LLDynamicTexture::destroyGL();
 		stop_glerror();
 
-		if(gParcelMgr) gParcelMgr->destroyGL();
-
 		gPipeline.destroyGL();
 		
 		gCone.cleanupGL();
@@ -4405,7 +4392,6 @@ void LLViewerWindow::restoreGL(const LLString& progress_message)
 		gPipeline.setUseAGP(gSavedSettings.getBOOL("RenderUseAGP"));
 		LLDynamicTexture::restoreGL();
 		LLVOAvatar::restoreGL();
-		if (gParcelMgr) gParcelMgr->restoreGL();
 
 		if (gFloaterCustomize && gFloaterCustomize->getVisible())
 		{
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 25aea4c4b39..0962d3e479e 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -107,8 +107,7 @@ S32		gTrivialAccepts = 0;
 BOOL	gRenderForSelect = FALSE;
 
 BOOL	gUsePickAlpha = TRUE;
-F32		gPickAlphaThreshold = 0.f;
-F32		gPickAlphaTargetThreshold = 0.f;
+F32		gPickAlphaThreshold = 0.2f;
 
 //glsl parameter tables
 const char* LLPipeline::sReservedAttribs[] =
diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h
index 4dada886cb5..f4144b6afae 100644
--- a/indra/newview/pipeline.h
+++ b/indra/newview/pipeline.h
@@ -653,7 +653,6 @@ void render_bbox(const LLVector3 &min, const LLVector3 &max);
 extern LLPipeline gPipeline;
 extern BOOL gRenderForSelect;
 extern F32 gPickAlphaThreshold;
-extern F32 gPickAlphaTargetThreshold;
 extern BOOL gUsePickAlpha;
 
 #endif
-- 
GitLab