textinput/peninputarc/src/peninputanim/peninputanim.cpp
branchRCL_3
changeset 16 857bebeecec0
parent 12 5e18d8c489d6
child 19 ac7e4d1d9209
--- a/textinput/peninputarc/src/peninputanim/peninputanim.cpp	Wed Jun 09 10:03:19 2010 +0300
+++ b/textinput/peninputarc/src/peninputanim/peninputanim.cpp	Mon Jun 21 16:02:35 2010 +0300
@@ -42,10 +42,10 @@
 
 #include <avkondomainpskeys.h>
 //CONSTANT
-const TInt KMsgSlot1 = 1;	//msg slot 2 in IPC
-const TInt KMsgSlot2 = 2; 	//msg slot 2 in IPC
-const TInt KFlushTimerPeriod = 1000 * 10;		//1/100 second
-const TInt KResponseQueueWaitTime = 100000;		//1/10 second
+const TInt KMsgSlot1 = 1;     //msg slot 2 in IPC
+const TInt KMsgSlot2 = 2;     //msg slot 2 in IPC
+const TInt KFlushTimerPeriod = 1000 * 10;          //1/100 second
+const TInt KResponseQueueWaitTime = 100000;        //1/10 second
 
 // ======== GLOBAL FUNCTIONS ========
 
@@ -57,7 +57,7 @@
 //
 EXPORT_C CAnimDll *CreateCAnimDllL()
     {
-	return(new (ELeave) CPeninputAnimDll()); 
+    return(new (ELeave) CPeninputAnimDll()); 
     }
 
 // ======== MEMBER FUNCTIONS ========
@@ -71,7 +71,7 @@
 //
 CAnim* CPeninputAnimDll::CreateInstanceL(TInt /*aType*/)
     {
-	return new(ELeave) CPeninputAnim();
+    return new(ELeave) CPeninputAnim();
     }
 
 // class CPeninputAnim
@@ -83,28 +83,28 @@
 //
 CPeninputAnim::CPeninputAnim()
     {
-	iIsActive = EFalse;
-	//iSpritePosition and iSpriteSize are initialized to 0 by default constructor
-	//iSpritePosition = TPoint(0, 0);
-	//iSpriteSize = TSize(0, 0);
-	iIsPointerCaptured = EFalse;
-	iIsPenDown = EFalse;
-	
-	iPrimaryTouchPtNum = 0;
-	iPrimaryTouchPtDetected = EFalse;
+    iIsActive = EFalse;
+    //iSpritePosition and iSpriteSize are initialized to 0 by default constructor
+    //iSpritePosition = TPoint(0, 0);
+    //iSpriteSize = TSize(0, 0);
+    iIsPointerCaptured = EFalse;
+    iIsPenDown = EFalse;
+    
+    iPrimaryTouchPtNum = 0;
+    iPrimaryTouchPtDetected = EFalse;
 
-	
-#ifdef RD_TACTILE_FEEDBACK	
-	TRAPD( err, FeatureManager::InitializeLibL() );
+    
+#ifdef RD_TACTILE_FEEDBACK    
+    TRAPD( err, FeatureManager::InitializeLibL() );
     if( err == KErrNone )
         {
         iTactileSupported =  FeatureManager::FeatureSupported( KFeatureIdTactileFeedback );
         }
-	iFeedback = MTactileFeedbackServer::Instance();
-#endif // RD_TACTILE_FEEDBACK	
+    iFeedback = MTactileFeedbackServer::Instance();
+#endif // RD_TACTILE_FEEDBACK    
     
-    iEnableSprite = ETrue;	
-    iDSAState = EFalse;	
+    iEnableSprite = ETrue;    
+    iDSAState = EFalse;    
     }
 
 // ---------------------------------------------------------------------------
@@ -114,19 +114,19 @@
 //
 CPeninputAnim::~CPeninputAnim()
     {
-	Deactivate();
+    Deactivate();
 
-	iMsgBufQueue.Close();
-	iKeyMsgResponseQueue.Close();
-	iResponseQueueSemaphore.Close();
-	
-	delete iFlushTimer;
-#ifdef RD_TACTILE_FEEDBACK	
-	FeatureManager::UnInitializeLib();
-	iTactileControl.Close();
-	iBackupTactileControl.Close();
-#endif // RD_TACTILE_FEEDBACK	
-	delete iPointerEventSuppressor;
+    iMsgBufQueue.Close();
+    iKeyMsgResponseQueue.Close();
+    iResponseQueueSemaphore.Close();
+    
+    delete iFlushTimer;
+#ifdef RD_TACTILE_FEEDBACK    
+    FeatureManager::UnInitializeLib();
+    iTactileControl.Close();
+    iBackupTactileControl.Close();
+#endif // RD_TACTILE_FEEDBACK    
+    delete iPointerEventSuppressor;
     }
 
 // ---------------------------------------------------------------------------
@@ -136,10 +136,10 @@
 //
 void CPeninputAnim::ConstructL(TAny* /*aParameters*/)
     {
-	// the animation feature is not used
-	iFunctions->SetInterval(0);
-	iFlushTimer = CPeriodic::NewL(CActive::EPriorityStandard);
-	
+    // the animation feature is not used
+    iFunctions->SetInterval(0);
+    iFlushTimer = CPeriodic::NewL(CActive::EPriorityStandard);
+    
     iFunctions->RegisterForNotifications(EDirectScreenAccess);
     iPointerEventSuppressor = CPenPointerEventSuppressor::NewL();
     }
@@ -199,7 +199,7 @@
     {
     if( iIsSimulatedEvent )
         {
-    	return EFalse;
+        return EFalse;
         }
     
     // Suppress multi-touch events
@@ -228,7 +228,7 @@
         }
 
     
-	// Suppress unexpected drag events
+    // Suppress unexpected drag events
     TPointerEvent pointerEvent;
     switch ( aRawEvent.Type() )
         {
@@ -260,30 +260,39 @@
         }
 
     
-	switch(aRawEvent.Type())
-	    {
-		case TRawEvent::EKeyUp:
-		case TRawEvent::EKeyDown:
-		    {
-			return OnRawKeyEvent(aRawEvent);        	
-		    }
-		case TRawEvent::EButton1Down:
-		    {
-			return OnRawButton1Down(aRawEvent);
-		    }
-		case TRawEvent::EButton1Up:
-		    {
-			return OnRawButton1Up(aRawEvent);
-		    }
-		case TRawEvent::EPointerMove:
-		    {
-			return OnRawPointerMove(aRawEvent);
-		    }
-		default:
-		    {
-			return EFalse;
-		    }            
-	    }	
+    switch(aRawEvent.Type())
+        {
+        case TRawEvent::EKeyUp:
+        case TRawEvent::EKeyDown:
+            {
+            return OnRawKeyEvent(aRawEvent);            
+            }
+        case TRawEvent::EButton1Down:
+            {
+            TBool used = OnRawButton1Down(aRawEvent);
+            
+            if ( used )
+                {
+                StartTimer();
+                }
+            
+            return used;
+            }
+        case TRawEvent::EButton1Up:
+            {
+            TBool used = OnRawButton1Up(aRawEvent);
+            StopTimer();
+            return used;
+            }
+        case TRawEvent::EPointerMove:
+            {
+            return OnRawPointerMove(aRawEvent);
+            }
+        default:
+            {
+            return EFalse;
+            }            
+        }    
     }
 
 // ---------------------------------------------------------------------------
@@ -296,7 +305,7 @@
     {
     switch(aOpcode)
         {
-		case EPeninputOpActivate:
+        case EPeninputOpActivate:
             {
             Activate();
             break;
@@ -308,16 +317,16 @@
             }        
         case EPeninputOpLayoutUpdateArea:
             {
-            PanicClientIfNoParam(aParams);	                
-			TUpdateDataArea* area = static_cast<TUpdateDataArea*>(aParams);
-			iSpriteFunctions->UpdateMember( 0, area->iRect, area->iUpdateFlag );
-			break;
-		    }			
+            PanicClientIfNoParam(aParams);                    
+            TUpdateDataArea* area = static_cast<TUpdateDataArea*>(aParams);
+            iSpriteFunctions->UpdateMember( 0, area->iRect, area->iUpdateFlag );
+            break;
+            }            
         case EPeninputOpCapturePointer:
             {
             PanicClientIfNoParam(aParams);            
-	        iIsPointerCaptured = *(static_cast<TBool*>(aParams));
-	        break;
+            iIsPointerCaptured = *(static_cast<TBool*>(aParams));
+            break;
             }
         case EPeninputOpSimulateEvent:
             {
@@ -356,7 +365,7 @@
                 }
             TTactileControlInfo controlitem(area.iId, area.iNewRect, area.iTactileType);
             TInt idx = iTactileControl.Find(controlitem, 
-            		TIdentityRelation<TTactileControlInfo>(CPeninputAnim::MatchItemByControlID));
+                    TIdentityRelation<TTactileControlInfo>(CPeninputAnim::MatchItemByControlID));
             if(idx != KErrNotFound)
                 {  
                 iTactileControl.Remove(idx);
@@ -378,18 +387,18 @@
             }
             break; 
         case EPeninputOpChangeFeedbackType:
-        	{
-        	PanicClientIfNoParam(aParams);
+            {
+            PanicClientIfNoParam(aParams);
             TTactileFeedbackArea area = *(static_cast<TTactileFeedbackArea*>(aParams));
             TTactileControlInfo controlitem(area.iId, area.iNewRect, area.iTactileType);
             TInt idx = iTactileControl.Find(controlitem,                    
-					TIdentityRelation<TTactileControlInfo>(CPeninputAnim::MatchItemByControlID));
+                    TIdentityRelation<TTactileControlInfo>(CPeninputAnim::MatchItemByControlID));
             if(idx != KErrNotFound)
                 {                                
                 //change the tactile type
                 iTactileControl[idx].iTactileType = area.iTactileType;
-                }        	
-        	}
+                }            
+            }
             break;
 #endif // RD_TACTILE_FEEDBACK
         case EPeninputOpEnalbeSprite:
@@ -406,7 +415,7 @@
             iFunctions->Panic();
             break;
             }
-	    }
+        }
     }
 
 
@@ -432,7 +441,7 @@
             iKeyMsgResponseQueue.OpenGlobal(KMsgEventResponseQueue);
             iResponseQueueSemaphore.OpenGlobal(KAnimKeyEventSemaphore);
 
-			break;
+            break;
             }
 
         case EPeninputOpActivate:
@@ -448,19 +457,19 @@
             }       
             
         case EPeninputOpLayoutUpdateArea:
-        	{
-        	//TUpdateDataArea s;
-			//TPckg<TUpdateDataArea> pkg(s);        	
-			TRect rect;
-			TBool flag;
-		    TPckg<TRect> rectMsg(rect);			
-		    TPckg<TBool> flagMsg(flag);    
-			
-			msg->ReadL(KMsgSlot1,rectMsg);
-			msg->ReadL(KMsgSlot2,flagMsg);
-			iSpriteFunctions->UpdateMember(0, rect,flag);			
-        	  }
-        	  break;
+            {
+            //TUpdateDataArea s;
+            //TPckg<TUpdateDataArea> pkg(s);            
+            TRect rect;
+            TBool flag;
+            TPckg<TRect> rectMsg(rect);            
+            TPckg<TBool> flagMsg(flag);    
+            
+            msg->ReadL(KMsgSlot1,rectMsg);
+            msg->ReadL(KMsgSlot2,flagMsg);
+            iSpriteFunctions->UpdateMember(0, rect,flag);            
+              }
+              break;
         case EPeninputOpLayoutUpdateAreaRegion:
             {
             TInt num;
@@ -481,8 +490,8 @@
                 }
 
             CleanupStack::PopAndDestroy( buf );
-        	}
-        	break;
+            }
+            break;
         case EPeninputOpSetLayoutPos:
             {
             TPoint pt;
@@ -495,55 +504,55 @@
         case EPeninputOpCapturePointer:
             {
             TInt captureCtrlID;
-			TPckg<TBool> msgData(iIsPointerCaptured);
-			TPckg<TInt> msgCaptureCtrlIDData(captureCtrlID);
+            TPckg<TBool> msgData(iIsPointerCaptured);
+            TPckg<TInt> msgCaptureCtrlIDData(captureCtrlID);
             
             msg->ReadL(KMsgSlot1,msgData);
             msg->ReadL(KMsgSlot2,msgCaptureCtrlIDData);
 #ifdef RD_TACTILE_FEEDBACK
-			// When pointer is captured by some ctrl,
-			// only the captured ctrl has tactile feedback ablity,
-			// disable all other one's.
+            // When pointer is captured by some ctrl,
+            // only the captured ctrl has tactile feedback ablity,
+            // disable all other one's.
             if (iIsPointerCaptured)
-            	{
-            	// Back up all the tactile area
-            	iBackupTactileControl.Reset();        	
-		        TInt count = iTactileControl.Count();
-		        for(TInt i = 0; i < count; ++i)
-		            {
-		            iBackupTactileControl.Append(iTactileControl[i]);
-		            }
-		        
-		        // Clean up the original tactile area
-		        iTactileControl.Reset();		       
-		        
-		        // Find the captured ctrl, restore its tactile ablity
-		        for(TInt i = 0; i < count; ++i)
-		            {
-		            if (iBackupTactileControl[i].iId == captureCtrlID)
-		            	{
-		            	iTactileControl.Append(iBackupTactileControl[i]);
-		            	}
-		            }
+                {
+                // Back up all the tactile area
+                iBackupTactileControl.Reset();            
+                TInt count = iTactileControl.Count();
+                for(TInt i = 0; i < count; ++i)
+                    {
+                    iBackupTactileControl.Append(iTactileControl[i]);
+                    }
+                
+                // Clean up the original tactile area
+                iTactileControl.Reset();               
+                
+                // Find the captured ctrl, restore its tactile ablity
+                for(TInt i = 0; i < count; ++i)
+                    {
+                    if (iBackupTactileControl[i].iId == captureCtrlID)
+                        {
+                        iTactileControl.Append(iBackupTactileControl[i]);
+                        }
+                    }
 
-            	}
+                }
             // When pointer released captured, 
             // restore all original tactile area.
             else 
-            	{
-            	if (iBackupTactileControl.Count() != 0)
-            		{
-            		iTactileControl.Reset();			       
-	            	
-			        TInt count = iBackupTactileControl.Count();
-			        for(TInt i = 0; i < count; ++i)
-			            {
-			            iTactileControl.Append(iBackupTactileControl[i]);
-			            }
-			        iBackupTactileControl.Reset();
-            		}
-            	}
-#endif            	
+                {
+                if (iBackupTactileControl.Count() != 0)
+                    {
+                    iTactileControl.Reset();                   
+                    
+                    TInt count = iBackupTactileControl.Count();
+                    for(TInt i = 0; i < count; ++i)
+                        {
+                        iTactileControl.Append(iBackupTactileControl[i]);
+                        }
+                    iBackupTactileControl.Reset();
+                    }
+                }
+#endif                
             }
             break;
         case EPeninputOpLayoutSizeChangedWithSize:
@@ -567,7 +576,7 @@
             
 #ifdef RD_TACTILE_FEEDBACK             
         case EPeninputOpRegisterFeedbackArea:
-            {						
+            {                        
             GetFeedbackAreaDataL(iTactileControl,msg);            
             }
             break;
@@ -583,7 +592,7 @@
             //remove all registered feedback area
             const TInt KRemoveAllId = -1;           
             if(controlarray.Count() && controlarray[0].iId == KRemoveAllId && 
-										controlarray[0].iArea == TRect(0,0,0,0))
+                                        controlarray[0].iArea == TRect(0,0,0,0))
                 {
                 //remove all
                 iTactileControl.Reset();
@@ -595,7 +604,7 @@
                     {
                     //find id first
                     TInt idx = iTactileControl.Find(controlarray[i], 
-								TIdentityRelation<TTactileControlInfo>(CPeninputAnim::MatchItemByControlID));
+                                TIdentityRelation<TTactileControlInfo>(CPeninputAnim::MatchItemByControlID));
                     
                     if(idx != KErrNotFound)
                         {
@@ -624,7 +633,7 @@
                 {
                 //find id first
                 TInt idx = iTactileControl.Find(controlarray[i], 
-                		   TIdentityRelation<TTactileControlInfo>(CPeninputAnim::MatchItemByControlID));
+                           TIdentityRelation<TTactileControlInfo>(CPeninputAnim::MatchItemByControlID));
                                     
                 if(idx != KErrNotFound)
                     {
@@ -654,12 +663,12 @@
             for(TInt i = 0; i < controlarray.Count(); ++i)
                 {
                 //find id first
-                TInt idx = iTactileControl.Find(controlarray[i],                 		   
-						   TIdentityRelation<TTactileControlInfo>(CPeninputAnim::MatchItemByControlID));
+                TInt idx = iTactileControl.Find(controlarray[i],                            
+                           TIdentityRelation<TTactileControlInfo>(CPeninputAnim::MatchItemByControlID));
                 if(idx != KErrNotFound)
                     {
                     //change the tactile feedback type
-					iTactileControl[idx].iTactileType = controlarray[i].iTactileType;
+                    iTactileControl[idx].iTactileType = controlarray[i].iTactileType;
                     break;
                     }
                 }
@@ -672,20 +681,20 @@
 #endif // RD_TACTILE_FEEDBACK 
         case EPeninputOpRequestDSAState:                        
             {
-		    TPckgC<TBool> flagMsg(iDSAState);    
-			
-			msg->WriteL(KMsgSlot1,flagMsg);
+            TPckgC<TBool> flagMsg(iDSAState);    
+            
+            msg->WriteL(KMsgSlot1,flagMsg);
             
             }
             break;
         case EPeninputOpSetDiscreeptPop:
-        	{
+            {
             TRect area;
             TPckg<TRect> msgData(area);
             msg->ReadL(KMsgSlot1,msgData);
             SetDiscreeptPop(area); 
-        	}
-        	break;
+            }
+            break;
         default:
             // unsupported opcode, panic the client
             {                
@@ -705,16 +714,14 @@
 //
 void CPeninputAnim::Activate()
     {
-	if(!iIsActive)
-	    {
-		iSpriteFunctions->SetPosition(iSpritePosition);
-		if(iEnableSprite)
-		    iSpriteFunctions->Activate(ETrue);
-		iFunctions->GetRawEvents(ETrue);
-		iIsActive = ETrue;		
-
-		StartTimer();
-	    }        
+    if(!iIsActive)
+        {
+        iSpriteFunctions->SetPosition(iSpritePosition);
+        if(iEnableSprite)
+            iSpriteFunctions->Activate(ETrue);
+        iFunctions->GetRawEvents(ETrue);
+        iIsActive = ETrue;        
+        }        
     }
 
 // ---------------------------------------------------------------------------
@@ -724,15 +731,15 @@
 //
 void CPeninputAnim::Deactivate()
     {
-	if(iIsActive)
-	    {
-	    if(iEnableSprite)
-		    iSpriteFunctions->Activate(EFalse);
-		iFunctions->GetRawEvents(EFalse);        
-		iIsActive = EFalse;
-		
-		StopTimer();
-	    }        
+    if(iIsActive)
+        {
+        if(iEnableSprite)
+            iSpriteFunctions->Activate(EFalse);
+        iFunctions->GetRawEvents(EFalse);        
+        iIsActive = EFalse;
+        
+        StopTimer();
+        }        
     }
     
 #ifdef RD_TACTILE_FEEDBACK
@@ -740,7 +747,7 @@
 // CPeninputAnim::DoTactileFeedBack
 // Give tactile feedback
 // ---------------------------------------------------------------------------
-//						
+//                        
 void CPeninputAnim::DoTactileFeedBack(const TPoint& aPos)
     {
     if ( iFeedback ) 
@@ -753,7 +760,7 @@
                 iFeedback->InstantFeedback((TTouchLogicalFeedback)iTactileControl[i].iTactileType);
                 return;
                 }                 
-        	}           
+            }           
         }
     }
 #endif // RD_TACTILE_FEEDBACK
@@ -768,65 +775,65 @@
 
 TBool CPeninputAnim::OnRawButton1Down(const TRawEvent& aRawEvent)
     {
-	if(iIsSimulatedEvent)
-	    {
-		return EFalse;
-	    }
-		
+    if(iIsSimulatedEvent)
+        {
+        return EFalse;
+        }
+        
     
-	if(iDiscreetPoped && iDiscreetPopArea.Contains(aRawEvent.Pos()))
-		{
-		iDiscreetPopedCapture = ETrue;
-		return EFalse;
-		}
-	TRect rect(iSpritePosition, iSpriteSize);        
-	if(rect.Contains(aRawEvent.Pos()))
-	    {                
-#ifdef RD_TACTILE_FEEDBACK		    
-	    //give tactile feedback	    
-	    if(iTactileSupported)
+    if(iDiscreetPoped && iDiscreetPopArea.Contains(aRawEvent.Pos()))
+        {
+        iDiscreetPopedCapture = ETrue;
+        return EFalse;
+        }
+    TRect rect(iSpritePosition, iSpriteSize);        
+    if(rect.Contains(aRawEvent.Pos()))
+        {                
+#ifdef RD_TACTILE_FEEDBACK            
+        //give tactile feedback        
+        if(iTactileSupported)
             DoTactileFeedBack(aRawEvent.Pos() - rect.iTl);
-#endif // RD_TACTILE_FEEDBACK	
-		iIsPenDown = ETrue;
+#endif // RD_TACTILE_FEEDBACK    
+        iIsPenDown = ETrue;
 
         // When button downing event is happened, iIsMove is reset to EFalse
-	    iIsMove = EFalse;              
+        iIsMove = EFalse;              
 
         // Recording pointer that button is pressing down in at this time
-	    iPointerDown = aRawEvent.Pos();  
+        iPointerDown = aRawEvent.Pos();  
         //
 
-		PostRawEvent(aRawEvent); 
-		return ETrue;
-	    }
+        PostRawEvent(aRawEvent); 
+        return ETrue;
+        }
 
-	if(iIsPointerCaptured)
-	    {                    
-		PostRawEvent(aRawEvent);
-		return ETrue;
-	    }
+    if(iIsPointerCaptured)
+        {                    
+        PostRawEvent(aRawEvent);
+        return ETrue;
+        }
 
-	//pointer outside of input area,inform layout
-	SendRawEvent(aRawEvent);
+    //pointer outside of input area,inform layout
+    SendRawEvent(aRawEvent);
 
-	return EFalse;
+    return EFalse;
     }
 
 TBool CPeninputAnim::OnRawButton1Up(const TRawEvent& aRawEvent)
     {
-	if(iIsSimulatedEvent)
-	    {
-		return EFalse;
-	    }
+    if(iIsSimulatedEvent)
+        {
+        return EFalse;
+        }
 
-	//For discreetPop
-	if(iDiscreetPopedCapture )
-		{
-		iDiscreetPopedCapture = EFalse;
-		return EFalse;
-		}
-	if(iIsPenDown)
-	    {      
+    //For discreetPop
+    if(iDiscreetPopedCapture )
+        {
+        iDiscreetPopedCapture = EFalse;
+        return EFalse;
+        }
+    if(iIsPenDown)
+        {      
   
         // When the control key pressing down in is different with the control key pressing up 
         // and pointer moving event isn¡¯t happened,
@@ -839,69 +846,69 @@
           }
         //
 
-		iIsPenDown = EFalse;
-		
-		TRect rect(iSpritePosition, iSpriteSize);        
-		if(rect.Contains(aRawEvent.Pos()))
-		    {
-			//send pen up event immediately
-			SendRawEvent(aRawEvent);
+        iIsPenDown = EFalse;
+        
+        TRect rect(iSpritePosition, iSpriteSize);        
+        if(rect.Contains(aRawEvent.Pos()))
+            {
+            //send pen up event immediately
+            SendRawEvent(aRawEvent);
             
             // When key pressing up event is completed, iIsMove is reset to EFalse.
             iIsMove = EFalse;   
             //
 
-			return ETrue;                    
-		    }
-	    }
-	
-	if(iIsPointerCaptured)
-	    {                    
-		PostRawEvent(aRawEvent);
-		return ETrue;
-	    }
+            return ETrue;                    
+            }
+        }
     
-	//pointer outside of input area,inform layout
-	SendRawEvent(aRawEvent);
+    if(iIsPointerCaptured)
+        {                    
+        PostRawEvent(aRawEvent);
+        return ETrue;
+        }
+    
+    //pointer outside of input area,inform layout
+    SendRawEvent(aRawEvent);
 
-	return EFalse;	
+    return EFalse;    
     }
 
 TBool CPeninputAnim::OnRawPointerMove(const TRawEvent& aRawEvent)
     {
-	if(iIsSimulatedEvent)
-	    {
-		return EFalse;
-	    }
-	if(iDiscreetPopedCapture)
-	    {
-	    return EFalse;
-	    }
-#ifdef RD_TACTILE_FEEDBACK		    
-	TRect rect(iSpritePosition, iSpriteSize);        
-	if( iIsPenDown && iIsPointerCaptured)
-	    {                
-	    //give tactile feedback	    
+    if(iIsSimulatedEvent)
+        {
+        return EFalse;
+        }
+    if(iDiscreetPopedCapture)
+        {
+        return EFalse;
+        }
+#ifdef RD_TACTILE_FEEDBACK            
+    TRect rect(iSpritePosition, iSpriteSize);        
+    if( iIsPenDown && iIsPointerCaptured)
+        {                
+        //give tactile feedback        
         // When pointer moving event is happened, iIsMove is set to ETrue
         iIsMove = ETrue;        
         //
 
-		PostRawEvent(aRawEvent); 
-		return ETrue;
-	    }
-#endif // RD_TACTILE_FEEDBACK	
+        PostRawEvent(aRawEvent); 
+        return ETrue;
+        }
+#endif // RD_TACTILE_FEEDBACK    
 
-	if(iIsPointerCaptured || iIsPenDown)
-	    {                    
+    if(iIsPointerCaptured || iIsPenDown)
+        {                    
         // When pointer moving event is happened, iIsMove is set to ETrue
         iIsMove = ETrue;        
         //
 
-		PostRawEvent(aRawEvent);
-		return ETrue;
-	    }
-	
-	return EFalse;
+        PostRawEvent(aRawEvent);
+        return ETrue;
+        }
+    
+    return EFalse;
     }
 
 // ---------------------------------------------------------------------------
@@ -912,12 +919,12 @@
 
 TPoint CPeninputAnim::SetPosition(const TPoint& aNewPos)
     {
-	if(aNewPos != iSpritePosition)
-	    {
-		iSpritePosition = aNewPos;
-		iSpriteFunctions->SetPosition(iSpritePosition);	
-	    }
-	return iSpritePosition;
+    if(aNewPos != iSpritePosition)
+        {
+        iSpritePosition = aNewPos;
+        iSpriteFunctions->SetPosition(iSpritePosition);    
+        }
+    return iSpritePosition;
     }
 
 // ---------------------------------------------------------------------------
@@ -927,11 +934,11 @@
 //
 void CPeninputAnim::UpdateArea(const TRect& aRect, TBool aFullUpdate)
     {
-	if(iIsActive)
+    if(iIsActive)
         {
-	    // if function is called without specifying the parameter aRect
-	    // (using default param value) the whole area drawn to is updated
-	    iSpriteFunctions->UpdateMember(0, aRect, aFullUpdate);
+        // if function is called without specifying the parameter aRect
+        // (using default param value) the whole area drawn to is updated
+        iSpriteFunctions->UpdateMember(0, aRect, aFullUpdate);
         }
     }
 
@@ -971,8 +978,8 @@
     if(iEventBuffer.iNum >= KMaxEvent)
         {
         FlushRawEventBuffer();
-	    }
-	
+        }
+    
     iEventBuffer.iEvent[iEventBuffer.iNum] = aRawEvent;
     iEventBuffer.iNum++;
     }
@@ -984,12 +991,12 @@
 //
 TInt CPeninputAnim::FlushRawEventBuffer()
     {
-	TInt ret = KErrNone;
-	
+    TInt ret = KErrNone;
+    
     if(iEventBuffer.iNum > 0)
-	    {
+        {
         ret = iMsgBufQueue.Send(iEventBuffer);
-       	iEventBuffer.iNum = 0;        	
+           iEventBuffer.iNum = 0;            
         }
     
     return ret;
@@ -1003,21 +1010,21 @@
 //    
 TBool CPeninputAnim::OnRawKeyEvent(const TRawEvent& aRawEvent)
     {
-	TInt ret = KErrNone;
-	
-	//first sends all buffered event out
+    TInt ret = KErrNone;
+    
+    //first sends all buffered event out
     FlushRawEventBuffer();
     
     //clear the signal and the response msg queue
     TBool isHandled = EFalse;
     ret = iKeyMsgResponseQueue.Receive(isHandled);
     while(ret == KErrNone)
-	    {
+        {
         iResponseQueueSemaphore.Wait();
         ret = iKeyMsgResponseQueue.Receive(isHandled);
         }
 
-	//send the event directly        
+    //send the event directly        
     iEventBuffer.iNum = 1;
     iEventBuffer.iEvent[0] = aRawEvent;
     ret = FlushRawEventBuffer();
@@ -1025,13 +1032,13 @@
     isHandled = EFalse;
     if(ret == KErrNone) 
         {
-	    //wait for the key event processed.    
-	    ret = iResponseQueueSemaphore.Wait(KResponseQueueWaitTime);
-	    if(ret == KErrNone)
-	        {        
-	        //read the response from msg queue
-	        iKeyMsgResponseQueue.Receive(isHandled);
-	        }
+        //wait for the key event processed.    
+        ret = iResponseQueueSemaphore.Wait(KResponseQueueWaitTime);
+        if(ret == KErrNone)
+            {        
+            //read the response from msg queue
+            iKeyMsgResponseQueue.Receive(isHandled);
+            }
         }
 
     return isHandled;
@@ -1044,12 +1051,15 @@
 // 
 void CPeninputAnim::StartTimer()
     {
-	iFlushTimer->Start(
-		KFlushTimerPeriod, 
-		KFlushTimerPeriod, 
-		TCallBack(FlushTimerCallBack, this));	
+    if ( iIsActive )
+        {
+        iFlushTimer->Start(
+            KFlushTimerPeriod, 
+            KFlushTimerPeriod, 
+            TCallBack(FlushTimerCallBack, this));
+        }
     }
-	
+    
 // ---------------------------------------------------------------------------
 // CPeninputAnim::StopTimer
 // Cancel timer
@@ -1057,12 +1067,13 @@
 // 
 void CPeninputAnim::StopTimer()
     {
-	iFlushTimer->Cancel();	
+    iFlushTimer->Cancel();
+    FlushRawEventBuffer();
     }
 
 #ifdef RD_TACTILE_FEEDBACK
 void CPeninputAnim::GetFeedbackAreaDataL(RArray<TTactileControlInfo>& aTactileControlArray,
-										 const RMessagePtr2* msg, 
+                                         const RMessagePtr2* msg, 
                                          RArray<TRect>* aPrevRectArray)
     {
     TInt num;
@@ -1079,7 +1090,7 @@
         {
         //Advanced Tactile feedback REQ417-47932
         aTactileControlArray.Append(TTactileControlInfo(area[i].iId,
-									area[i].iNewRect,area[i].iTactileType));      
+                                    area[i].iNewRect,area[i].iTactileType));      
         //aRectArray.Append(area[i].iNewRect);                
         if(aPrevRectArray)
             aPrevRectArray->Append(area[i].iPrevRect);                    
@@ -1094,11 +1105,11 @@
 // ---------------------------------------------------------------------------
 // 
 TBool CPeninputAnim::MatchItemByControlID (const TTactileControlInfo& aFirst, const TTactileControlInfo& aSecond)
-	{
-	if (aFirst.iId == aSecond.iId)
-		return ETrue;
-	return EFalse;
-	}
+    {
+    if (aFirst.iId == aSecond.iId)
+        return ETrue;
+    return EFalse;
+    }
 
 // ---------------------------------------------------------------------------
 // CPeninputAnim::MatchItemByControlIDAndArea
@@ -1106,16 +1117,16 @@
 // ---------------------------------------------------------------------------
 // 
 TBool CPeninputAnim::MatchItemByControlIDAndArea (const TTactileControlInfo& aFirst, const TTactileControlInfo& aSecond)
-	{
-	if ((aFirst.iId == aSecond.iId) && (aFirst.iArea == aSecond.iArea))
-		return ETrue;
-	return EFalse;
-	}
+    {
+    if ((aFirst.iId == aSecond.iId) && (aFirst.iArea == aSecond.iArea))
+        return ETrue;
+    return EFalse;
+    }
 #endif // RD_TACTILE_FEEDBACK    
 
 void CPeninputAnim::SetDiscreeptPop(TRect aArea)
-	{
-	iDiscreetPopArea = aArea;
+    {
+    iDiscreetPopArea = aArea;
     if(iDiscreetPopArea.Size().iWidth > 0)
         {
         iDiscreetPoped = ETrue;
@@ -1125,5 +1136,5 @@
         iDiscreetPoped = EFalse;
         iDiscreetPopedCapture = EFalse;
         }
-	}
+    }
 // End of File