Index: abi/src/af/xap/xp/xav_View.cpp
===================================================================
RCS file: /cvsroot/abi/src/af/xap/xp/xav_View.cpp,v
retrieving revision 1.15
diff -u -r1.15 xav_View.cpp
--- abi/src/af/xap/xp/xav_View.cpp	2000/11/12 14:45:19	1.15
+++ abi/src/af/xap/xp/xav_View.cpp	2001/01/25 13:56:45
@@ -21,6 +21,7 @@
 #include "ut_types.h"
 #include "xav_View.h"
 #include "xav_Listener.h"
+#include "xap_Frame.h"
 #include"ut_debugmsg.h"
 
 AV_View::AV_View(XAP_App * pApp, void* pParentData)
@@ -131,6 +132,22 @@
 	}
 
 	return UT_TRUE;
+}
+
+UT_Bool AV_View::isActive(void) const
+{
+	AV_View* pActiveView = NULL;
+	XAP_Frame* lff = getApp()->getLastFocussedFrame();
+	if(lff) 
+	{
+		pActiveView = lff->getCurrentView();
+	}
+	else 
+	{
+		pActiveView = this;
+	}
+	
+	return pActiveView == this;
 }
 
 UT_uint32 AV_View::getTick(void)
Index: abi/src/af/xap/xp/xav_View.h
===================================================================
RCS file: /cvsroot/abi/src/af/xap/xp/xav_View.h,v
retrieving revision 1.29
diff -u -r1.29 xav_View.h
--- abi/src/af/xap/xp/xav_View.h	2001/01/18 14:43:23	1.29
+++ abi/src/af/xap/xp/xav_View.h	2001/01/25 13:56:45
@@ -100,6 +100,9 @@
 
 	UT_Bool			addListener(AV_Listener * pListener, AV_ListenerId * pListenerId);
 	UT_Bool			removeListener(AV_ListenerId listenerId);
+
+	//! returns true iff the current view is the active/focused window
+	UT_Bool			isActive(void) const;
 	virtual UT_Bool	notifyListeners(const AV_ChangeMask hint) = 0;
 
 	virtual UT_Bool	canDo(UT_Bool bUndo) const = 0;
Index: abi/src/text/fmt/xp/fl_BlockLayout.cpp
===================================================================
RCS file: /cvsroot/abi/src/text/fmt/xp/fl_BlockLayout.cpp,v
retrieving revision 1.237
diff -u -r1.237 fl_BlockLayout.cpp
--- abi/src/text/fmt/xp/fl_BlockLayout.cpp	2001/01/24 17:28:29	1.237
+++ abi/src/text/fmt/xp/fl_BlockLayout.cpp	2001/01/25 13:56:46
@@ -371,7 +371,7 @@
 		{ "margin-right",	&m_iRightMargin,	&m_iRightMarginLayoutUnits	},
 		{ "text-indent",	&m_iTextIndent,		&m_iTextIndentLayoutUnits	}
 	};
-	for (int iRg = 0; iRg < NrElements(rgProps); ++iRg)
+	for (UT_uint32 iRg = 0; iRg < NrElements(rgProps); ++iRg)
 	{
 		const MarginAndIndent_t& mai = rgProps[iRg];
 		const char* pszProp = getProperty((XML_Char*)mai.szProp);
@@ -2159,7 +2159,7 @@
 
 				UT_UCSChar theWord[101];
 				// convert smart quote apostrophe to ASCII single quote to be compatible with ispell
-				for (unsigned int ldex=0; ldex<wordLength; ++ldex)
+				for (UT_uint32 ldex=0; ldex<wordLength; ++ldex)
 				{
 					UT_UCSChar currentChar;
 					currentChar = pBlockText[wordBeginning + ldex];
@@ -2251,7 +2251,7 @@
 
 		UT_UCSChar theWord[101];
 		// convert smart quote apostrophe to ASCII single quote to be compatible with ispell
-		for (unsigned int ldex=0; ldex<wordLength; ++ldex)
+		for (UT_uint32 ldex=0; ldex<wordLength; ++ldex)
 		{
 			UT_UCSChar currentChar;
 			currentChar = pBlockText[wordBeginning + ldex];
@@ -2847,11 +2847,13 @@
 	UT_ASSERT(_validateBlockForPoint());
 
 	FV_View* pView = m_pLayout->getView();
-	if (pView)
+	if (pView && pView->isActive())
 	{
-		pView->_setPoint(pcrs->getPosition()+len);
+		pView->_setPoint(pcrs->getPosition() + len);
 		pView->notifyListeners(AV_CHG_FMTCHAR); // TODO verify that this is necessary.
 	}
+	else if(pView && pView->getPoint() > pcrs->getPosition())
+		pView->_setPoint(pView->getPoint() + len);
 
 	if (m_pLayout->hasBackgroundCheckReason(FL_DocLayout::bgcrSmartQuotes))
 	{
@@ -2865,7 +2867,7 @@
 		if (sqcount)
 		{
 			m_pDoc->beginUserAtomicGlob();
-			for (unsigned int sdex=0; sdex<sqcount; ++sdex)
+			for (UT_uint32 sdex=0; sdex<sqcount; ++sdex)
 			{
 				m_pLayout->considerSmartQuoteCandidateAt(this, sqlist[sdex]);
 			}
@@ -3020,10 +3022,16 @@
 	setNeedsReformat();
 
 	FV_View* pView = m_pLayout->getView();
-	if (pView)
+	if (pView && pView->isActive())
 	{
  		pView->_resetSelection();
- 		pView->_setPoint(pcrs->getPosition());
+		pView->_setPoint(pcrs->getPosition());
+	}
+	else if(pView && pView->getPoint() > pcrs->getPosition())
+	{
+		if(pView->getPoint() <= pcrs->getPosition() + len)
+			pView->_setPoint(pcrs->getPosition());
+		else pView->_setPoint(pView->getPoint() - len);
 	}
 
 	if (m_pLayout->getAutoSpellCheck())
@@ -3323,10 +3331,10 @@
 	m_pLayout->dequeueBlockForBackgroundCheck(this);
 
 	FV_View* pView = pSL->getDocLayout()->getView();
-	if (pView)
-	{
+	if (pView && pView->isActive())
 		pView->_setPoint(pcrx->getPosition());
-	}
+	else if(pView && pView->getPoint() > pcrx->getPosition())
+		pView->_setPoint(pView->getPoint() - 1);
 
 	delete this;			// TODO whoa!  this construct is VERY dangerous.
 	
@@ -3400,10 +3408,9 @@
 	setNeedsReformat();
 
 	FV_View* pView = m_pLayout->getView();
-	if (pView)
-	{
+	if (pView && pView->isActive())
 		pView->_setPoint(pcrx->getPosition());
-	}
+	else if (pView) pView->_setPoint(pView->getPoint() + fl_BLOCK_STRUX_OFFSET);
 
 	return UT_TRUE;
 }
@@ -3567,10 +3574,10 @@
 	pNewBL->setNeedsReformat();
 
 	FV_View* pView = m_pLayout->getView();
-	if (pView)
-	{
+	if (pView && pView->isActive())
 		pView->_setPoint(pcrx->getPosition() + fl_BLOCK_STRUX_OFFSET);
-	}
+	else if(pView && pView->getPoint() > pcrx->getPosition())
+		pView->_setPoint(pView->getPoint() + fl_BLOCK_STRUX_OFFSET);
 
 #ifdef FASTSQUIGGLE
 	if (m_pLayout->getAutoSpellCheck() && m_vecSquiggles.getItemCount() > 0)
@@ -3649,10 +3656,14 @@
 	pOldSL->deleteEmptyColumns();
 
 	FV_View* pView = m_pLayout->getView();
-	if (pView)
+	if (pView && pView->isActive())
 	{
 		pView->_setPoint(pcrx->getPosition() + fl_BLOCK_STRUX_OFFSET + fl_BLOCK_STRUX_OFFSET);
 	}
+	else if(pView && pView->getPoint() > pcrx->getPosition())
+	{
+		pView->_setPoint(pView->getPoint() + fl_BLOCK_STRUX_OFFSET + fl_BLOCK_STRUX_OFFSET);
+	}
 
 	return UT_TRUE;
 }
@@ -3772,11 +3783,10 @@
 	setNeedsReformat();
 
 	FV_View* pView = m_pLayout->getView();
-	if (pView)
-	{
-		pView->_resetSelection();
+	if (pView && pView->isActive())
 		pView->_setPoint(pcro->getPosition() + 1);
-	}
+	else if(pView && pView->getPoint() > pcro->getPosition())
+		pView->_setPoint(pView->getPoint() + 1);
 
 	if (m_pLayout->getAutoSpellCheck())
 		_insertSquiggles(blockOffset, 1);	// TODO: are objects always one wide?
@@ -3826,11 +3836,13 @@
 	setNeedsReformat();
 
 	FV_View* pView = m_pLayout->getView();
-	if (pView)
+	if (pView && pView->isActive())
 	{
 		pView->_resetSelection();
 		pView->_setPoint(pcro->getPosition());
 	}
+	else if(pView && pView->getPoint() > pcro->getPosition())
+		pView->_setPoint(pView->getPoint() - 1);
 
 	if (m_pLayout->getAutoSpellCheck())
 		_deleteSquiggles(blockOffset, 1);	// TODO: are objects always one wide?
@@ -3883,7 +3895,7 @@
 done:
 	setNeedsReformat();
 
-	if (pView)
+	if (pView && pView->isActive())
 	{
 		pView->_resetSelection();
 		pView->_setPoint(pcroc->getPosition());
@@ -4125,10 +4137,12 @@
 	setNeedsReformat();
 
 	FV_View* pView = m_pLayout->getView();
+	if (pView && pView->isActive())
+		pView->_setPoint(pcrfm->getPosition());
+
 	if (pView)
 	{
 		pView->_resetSelection();
-		pView->_setPoint(pcrfm->getPosition());
 		pView->notifyListeners(AV_CHG_FMTCHAR);
 	}
 
@@ -4153,7 +4167,7 @@
 	setNeedsReformat();
 
 	FV_View* pView = m_pLayout->getView();
-	if (pView)
+	if (pView && pView->isActive())
 	{
 		pView->_resetSelection();
 		pView->_setPoint(pcrfm->getPosition());
@@ -4249,7 +4263,7 @@
 	setNeedsReformat();
 
 	FV_View* pView = m_pLayout->getView();
-	if (pView)
+	if (pView && pView->isActive())
 	{
 		pView->_resetSelection();
 		pView->_setPoint(pcrfmc->getPosition());
@@ -4313,7 +4327,7 @@
 		if (wordLength < 100)
 		{
 			// convert smart quote apostrophe to ASCII single quote to be compatible with ispell
-			for (unsigned int ldex=0; ldex<wordLength; ++ldex)
+			for (UT_uint32 ldex=0; ldex<wordLength; ++ldex)
 			{
 				UT_UCSChar currentChar;
 				currentChar = pBlockText[wordBeginning + ldex];
Index: abi/src/text/fmt/xp/fl_DocListener.cpp
===================================================================
RCS file: /cvsroot/abi/src/text/fmt/xp/fl_DocListener.cpp,v
retrieving revision 1.93
diff -u -r1.93 fl_DocListener.cpp
--- abi/src/text/fmt/xp/fl_DocListener.cpp	2001/01/20 15:49:47	1.93
+++ abi/src/text/fmt/xp/fl_DocListener.cpp	2001/01/25 13:56:46
@@ -610,7 +610,7 @@
 	case PX_ChangeRecord::PXT_ChangePoint:
 	{
 		FV_View* pView = m_pLayout->getView();
-		if (pView)
+		if (pView && pView->isActive())
 			pView->_setPoint(pcr->getPosition());
 		goto finish_up;
 	}