diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp
index 63a1706fe45c9b4f3fe2ee2e315adf7f3efa1dae..c34fbcd4f51415d8d02150c0a6caf48438c579d3 100644
--- a/indra/llui/lltoolbar.cpp
+++ b/indra/llui/lltoolbar.cpp
@@ -177,6 +177,7 @@ void LLToolBar::initFromParams(const LLToolBar::Params& p)
 	center_panel_p.rect = getLocalRect();
 	center_panel_p.auto_resize = false;
 	center_panel_p.user_resize = false;
+	center_panel_p.mouse_opaque = false;
 	LLLayoutPanel* center_panel = LLUICtrlFactory::create<LLLayoutPanel>(center_panel_p);
 	mCenteringStack->addChild(center_panel);
 
@@ -557,7 +558,13 @@ void LLToolBar::draw()
 {
 	if (mButtons.empty())
 	{
-		return;
+		mButtonPanel->setVisible(FALSE);
+		mButtonPanel->setMouseOpaque(FALSE);
+	}
+	else
+	{
+		mButtonPanel->setVisible(TRUE);
+		mButtonPanel->setMouseOpaque(TRUE);
 	}
 
 	// Update enable/disable state and highlight state for editable toolbars
@@ -741,7 +748,11 @@ BOOL LLToolBarButton::handleHover(S32 x, S32 y, MASK mask)
 //	llinfos << "Merov debug: handleHover, x = " << x << ", y = " << y << ", mouse = " << hasMouseCapture() << llendl;
 	BOOL handled = FALSE;
 		
-	if (hasMouseCapture() && mStartDragItemCallback && mHandleDragItemCallback)
+	S32 mouse_distance_squared = (x - mMouseDownX) * (x - mMouseDownX) + (y - mMouseDownY) * (y - mMouseDownY);
+	S32 drag_threshold = LLUI::sSettingGroups["config"]->getS32("DragAndDropDistanceThreshold");
+	if (mouse_distance_squared > drag_threshold * drag_threshold
+		&& hasMouseCapture() && 
+		mStartDragItemCallback && mHandleDragItemCallback)
 	{
 		if (!mIsDragged)
 		{
@@ -768,3 +779,8 @@ void LLToolBarButton::onMouseEnter(S32 x, S32 y, MASK mask)
 	// Always highlight toolbar buttons, even if they are disabled
 	mNeedsHighlight = TRUE;
 }
+
+void LLToolBarButton::onMouseCaptureLost()
+{
+	mIsDragged = false;
+}
diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h
index 3fbe5a7703b9a9e86d091d690e758e9f1b280c3b..4fac08113046b16375176c8ed7c850c5c2aa6e32 100644
--- a/indra/llui/lltoolbar.h
+++ b/indra/llui/lltoolbar.h
@@ -68,6 +68,7 @@ class LLToolBarButton : public LLButton
 	void setHandleDragCallback(tool_handledrag_callback_t cb) { mHandleDragItemCallback = cb; }
 
 	void onMouseEnter(S32 x, S32 y, MASK mask);
+	void onMouseCaptureLost();
 
 private:
 	LLCommandId		mId;
diff --git a/indra/newview/lltooldraganddrop.cpp b/indra/newview/lltooldraganddrop.cpp
index a8014b8cde0c3c380fd04fda9340380163d0ce9f..6910b8eced63a39ec0f48a1ec3633edc81f7f000 100644
--- a/indra/newview/lltooldraganddrop.cpp
+++ b/indra/newview/lltooldraganddrop.cpp
@@ -803,7 +803,7 @@ void LLToolDragAndDrop::pick(const LLPickInfo& pick_info)
 
 	LLViewerObject* hit_obj = pick_info.getObject();
 	LLSelectMgr::getInstance()->unhighlightAll();
-
+	bool highlight_object = false;
 	// Treat attachments as part of the avatar they are attached to.
 	if (hit_obj != NULL)
 	{
@@ -845,16 +845,7 @@ void LLToolDragAndDrop::pick(const LLPickInfo& pick_info)
 		{
 			target = DT_OBJECT;
 			hit_face = pick_info.mObjectFace;
-			// if any item being dragged will be applied to the object under our cursor
-			// highlight that object
-			for (S32 i = 0; i < (S32)mCargoIDs.size(); i++)
-			{
-				if (mCargoTypes[i] != DAD_OBJECT || (pick_info.mKeyMask & MASK_CONTROL))
-				{
-					LLSelectMgr::getInstance()->highlightObjectAndFamily(hit_obj);
-					break;
-				}
-			}
+			highlight_object = true;
 		}
 	}
 	else if (pick_info.mPickType == LLPickInfo::PICK_LAND)
@@ -900,6 +891,19 @@ void LLToolDragAndDrop::pick(const LLPickInfo& pick_info)
 		}
 	}
 
+	if (highlight_object && mLastAccept > ACCEPT_NO_LOCKED)
+	{
+		// if any item being dragged will be applied to the object under our cursor
+		// highlight that object
+		for (S32 i = 0; i < (S32)mCargoIDs.size(); i++)
+		{
+			if (mCargoTypes[i] != DAD_OBJECT || (pick_info.mKeyMask & MASK_CONTROL))
+			{
+				LLSelectMgr::getInstance()->highlightObjectAndFamily(hit_obj);
+				break;
+			}
+		}
+	}
 	ECursorType cursor = acceptanceToCursor( mLastAccept );
 	gViewerWindow->getWindow()->setCursor( cursor );