textinput/peninputarc/src/peninputanim/peninputanim.cpp
branchRCL_3
changeset 20 ebd48d2de13c
parent 19 ac7e4d1d9209
child 21 ecbabf52600f
--- a/textinput/peninputarc/src/peninputanim/peninputanim.cpp	Thu Aug 19 10:15:25 2010 +0300
+++ b/textinput/peninputarc/src/peninputanim/peninputanim.cpp	Tue Aug 31 15:31:50 2010 +0300
@@ -31,7 +31,9 @@
 #include "peninputcmdparam.h"
 #include "peninputcmdparamext.h"
 #include "peninputcmd.h"
+// Modify for bug ETMA-7X2C5Y begin
 #include "penpointereventsuppressor.h"
+// Modify for bug ETMA-7X2C5Y end
 // ----------- Touch feedback additions start
 #ifdef RD_TACTILE_FEEDBACK
 #include <coecntrl.h>
@@ -42,10 +44,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;		//1/1000 second
+const TInt KResponseQueueWaitTime = 100000;		//1/10 second
 
 // ======== GLOBAL FUNCTIONS ========
 
@@ -57,7 +59,7 @@
 //
 EXPORT_C CAnimDll *CreateCAnimDllL()
     {
-    return(new (ELeave) CPeninputAnimDll()); 
+	return(new (ELeave) CPeninputAnimDll()); 
     }
 
 // ======== MEMBER FUNCTIONS ========
@@ -71,7 +73,7 @@
 //
 CAnim* CPeninputAnimDll::CreateInstanceL(TInt /*aType*/)
     {
-    return new(ELeave) CPeninputAnim();
+	return new(ELeave) CPeninputAnim();
     }
 
 // class CPeninputAnim
@@ -83,28 +85,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 +116,28 @@
 //
 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	
+	// Modify for bug ETMA-7X2C5Y begin
+	delete iPointerEventSuppressor;
+	// Modify for bug ETMA-7X2C5Y end
+	if (iDiscreetPopSubscriber)
+	    {
+	    iDiscreetPopSubscriber->StopSubscribe();
+	    }
+	iDiscreetPopProperty.Close();
+	delete iDiscreetPopSubscriber;
+	iAknUiSrv.Close();
     }
 
 // ---------------------------------------------------------------------------
@@ -136,12 +147,27 @@
 //
 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);
+	// Modify for bug ETMA-7X2C5Y begin
     iPointerEventSuppressor = CPenPointerEventSuppressor::NewL();
+    // Modify for bug ETMA-7X2C5Y end
+    User::LeaveIfError(iDiscreetPopProperty.Attach(KPSUidAvkonDomain, 
+                                         KAknGlobalDiscreetPopupNumChanged));
+    iDiscreetPopSubscriber = new (ELeave) CSubscriber(
+			TCallBack( DiscreetPopChangeNotification, this), 
+			iDiscreetPopProperty);
+    iDiscreetPopSubscriber->SubscribeL();
+	
+	User::LeaveIfError(iAknUiSrv.Connect());
+	iDiscreetPopArea = iAknUiSrv.GetInUseGlobalDiscreetPopupRect();
+    if(iDiscreetPopArea.Size().iWidth > 0)
+    	{
+		iDiscreetPoped = ETrue;
+    	}
     }
 
 
@@ -199,7 +225,7 @@
     {
     if( iIsSimulatedEvent )
         {
-        return EFalse;
+    	return EFalse;
         }
     
     // Suppress multi-touch events
@@ -228,7 +254,7 @@
         }
 
     
-    // Suppress unexpected drag events
+	// Suppress unexpected drag events, refer to error ETMA-7X2C5Y
     TPointerEvent pointerEvent;
     switch ( aRawEvent.Type() )
         {
@@ -260,39 +286,30 @@
         }
 
     
-    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;
-            }            
-        }    
+	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;
+		    }            
+	    }	
     }
 
 // ---------------------------------------------------------------------------
@@ -305,7 +322,7 @@
     {
     switch(aOpcode)
         {
-        case EPeninputOpActivate:
+		case EPeninputOpActivate:
             {
             Activate();
             break;
@@ -317,16 +334,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:
             {
@@ -365,7 +382,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);
@@ -387,18 +404,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:
@@ -415,7 +432,7 @@
             iFunctions->Panic();
             break;
             }
-        }
+	    }
     }
 
 
@@ -441,7 +458,7 @@
             iKeyMsgResponseQueue.OpenGlobal(KMsgEventResponseQueue);
             iResponseQueueSemaphore.OpenGlobal(KAnimKeyEventSemaphore);
 
-            break;
+			break;
             }
 
         case EPeninputOpActivate:
@@ -457,19 +474,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;
@@ -490,8 +507,8 @@
                 }
 
             CleanupStack::PopAndDestroy( buf );
-            }
-            break;
+        	}
+        	break;
         case EPeninputOpSetLayoutPos:
             {
             TPoint pt;
@@ -504,55 +521,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:
@@ -576,7 +593,7 @@
             
 #ifdef RD_TACTILE_FEEDBACK             
         case EPeninputOpRegisterFeedbackArea:
-            {                        
+            {						
             GetFeedbackAreaDataL(iTactileControl,msg);            
             }
             break;
@@ -592,7 +609,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();
@@ -604,7 +621,7 @@
                     {
                     //find id first
                     TInt idx = iTactileControl.Find(controlarray[i], 
-                                TIdentityRelation<TTactileControlInfo>(CPeninputAnim::MatchItemByControlID));
+								TIdentityRelation<TTactileControlInfo>(CPeninputAnim::MatchItemByControlID));
                     
                     if(idx != KErrNotFound)
                         {
@@ -633,7 +650,7 @@
                 {
                 //find id first
                 TInt idx = iTactileControl.Find(controlarray[i], 
-                           TIdentityRelation<TTactileControlInfo>(CPeninputAnim::MatchItemByControlID));
+                		   TIdentityRelation<TTactileControlInfo>(CPeninputAnim::MatchItemByControlID));
                                     
                 if(idx != KErrNotFound)
                     {
@@ -663,12 +680,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;
                     }
                 }
@@ -681,20 +698,12 @@
 #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;
         default:
             // unsupported opcode, panic the client
             {                
@@ -714,14 +723,16 @@
 //
 void CPeninputAnim::Activate()
     {
-    if(!iIsActive)
-        {
-        iSpriteFunctions->SetPosition(iSpritePosition);
-        if(iEnableSprite)
-            iSpriteFunctions->Activate(ETrue);
-        iFunctions->GetRawEvents(ETrue);
-        iIsActive = ETrue;        
-        }        
+	if(!iIsActive)
+	    {
+		iSpriteFunctions->SetPosition(iSpritePosition);
+		if(iEnableSprite)
+		    iSpriteFunctions->Activate(ETrue);
+		iFunctions->GetRawEvents(ETrue);
+		iIsActive = ETrue;		
+
+		StartTimer();
+	    }        
     }
 
 // ---------------------------------------------------------------------------
@@ -731,15 +742,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
@@ -747,7 +758,7 @@
 // CPeninputAnim::DoTactileFeedBack
 // Give tactile feedback
 // ---------------------------------------------------------------------------
-//                        
+//						
 void CPeninputAnim::DoTactileFeedBack(const TPoint& aPos)
     {
     if ( iFeedback ) 
@@ -760,7 +771,7 @@
                 iFeedback->InstantFeedback((TTouchLogicalFeedback)iTactileControl[i].iTactileType);
                 return;
                 }                 
-            }           
+        	}           
         }
     }
 #endif // RD_TACTILE_FEEDBACK
@@ -775,140 +786,112 @@
 
 TBool CPeninputAnim::OnRawButton1Down(const TRawEvent& aRawEvent)
     {
-    if(iIsSimulatedEvent)
-        {
-        return EFalse;
-        }
-        
-    
-    if(iDiscreetPoped && iDiscreetPopArea.Contains(aRawEvent.Pos()))
+	if(iIsSimulatedEvent)
+	    {
+		return EFalse;
+	    }
+		
+    if(iDirty )
         {
-        iDiscreetPopedCapture = ETrue;
-        return EFalse;
+        Refresh();
         }
-    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;
+		PostRawEvent(aRawEvent); 
+		return ETrue;
+	    }
 
-        // When button downing event is happened, iIsMove is reset to EFalse
-        iIsMove = EFalse;              
-
-        // Recording pointer that button is pressing down in at this time
-        iPointerDown = aRawEvent.Pos();  
-        //
-
-        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;
-        }
-
-    //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,
-        // pointer moving event will is supplied 
-        if(iPointerDown != aRawEvent.Pos() && !iIsMove)
-          {
-          TRawEvent rawEvent = aRawEvent;
-          rawEvent.Set( TRawEvent::EPointerMove );
-          OnRawPointerMove(rawEvent);
-          }
-        //
+	if(iIsSimulatedEvent)
+	    {
+		return EFalse;
+	    }
 
-        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;   
-            //
+	//For discreetPop
+	if(iDiscreetPopedCapture )
+		{
+		iDiscreetPopedCapture = EFalse;
+		return EFalse;
+		}
+	if(iIsPenDown)
+	    {      
+		iIsPenDown = EFalse;
+		
+		TRect rect(iSpritePosition, iSpriteSize);        
+		if(rect.Contains(aRawEvent.Pos()))
+		    {
+			//send pen up event immediately
+			SendRawEvent(aRawEvent);
+			return ETrue;                    
+		    }
+	    }
+	
+	if(iIsPointerCaptured)
+	    {                    
+		PostRawEvent(aRawEvent);
+		return ETrue;
+	    }
+    
+	//pointer outside of input area,inform layout
+	SendRawEvent(aRawEvent);
 
-            return ETrue;                    
-            }
-        }
-    
-    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        
-        // When pointer moving event is happened, iIsMove is set to ETrue
-        iIsMove = ETrue;        
-        //
+	if(iIsSimulatedEvent)
+	    {
+		return EFalse;
+	    }
+	if(iDiscreetPopedCapture)
+	    {
+	    return EFalse;
+	    }
+#ifdef RD_TACTILE_FEEDBACK		    
+	TRect rect(iSpritePosition, iSpriteSize);        
+	if( iIsPenDown && iIsPointerCaptured)
+	    {                
+	    //give tactile feedback	    
 
-        PostRawEvent(aRawEvent); 
-        return ETrue;
-        }
-#endif // RD_TACTILE_FEEDBACK    
+		PostRawEvent(aRawEvent); 
+		return ETrue;
+	    }
+#endif // RD_TACTILE_FEEDBACK	
 
-    if(iIsPointerCaptured || iIsPenDown)
-        {                    
-        // When pointer moving event is happened, iIsMove is set to ETrue
-        iIsMove = ETrue;        
-        //
-
-        PostRawEvent(aRawEvent);
-        return ETrue;
-        }
-    
-    return EFalse;
+	if(iIsPointerCaptured || iIsPenDown)
+	    {                    
+		PostRawEvent(aRawEvent);
+		return ETrue;
+	    }
+	
+	return EFalse;
     }
 
 // ---------------------------------------------------------------------------
@@ -919,12 +902,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;
     }
 
 // ---------------------------------------------------------------------------
@@ -934,11 +917,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);
         }
     }
 
@@ -978,8 +961,8 @@
     if(iEventBuffer.iNum >= KMaxEvent)
         {
         FlushRawEventBuffer();
-        }
-    
+	    }
+	
     iEventBuffer.iEvent[iEventBuffer.iNum] = aRawEvent;
     iEventBuffer.iNum++;
     }
@@ -991,12 +974,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;
@@ -1010,21 +993,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();
@@ -1032,13 +1015,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;
@@ -1051,15 +1034,12 @@
 // 
 void CPeninputAnim::StartTimer()
     {
-    if ( iIsActive && !iFlushTimer->IsActive())
-        {
-        iFlushTimer->Start(
-            KFlushTimerPeriod, 
-            KFlushTimerPeriod, 
-            TCallBack(FlushTimerCallBack, this));
-        }
+	iFlushTimer->Start(
+		KFlushTimerPeriod, 
+		KFlushTimerPeriod, 
+		TCallBack(FlushTimerCallBack, this));	
     }
-    
+	
 // ---------------------------------------------------------------------------
 // CPeninputAnim::StopTimer
 // Cancel timer
@@ -1067,13 +1047,12 @@
 // 
 void CPeninputAnim::StopTimer()
     {
-    iFlushTimer->Cancel();
-    FlushRawEventBuffer();
+	iFlushTimer->Cancel();	
     }
 
 #ifdef RD_TACTILE_FEEDBACK
 void CPeninputAnim::GetFeedbackAreaDataL(RArray<TTactileControlInfo>& aTactileControlArray,
-                                         const RMessagePtr2* msg, 
+										 const RMessagePtr2* msg, 
                                          RArray<TRect>* aPrevRectArray)
     {
     TInt num;
@@ -1090,7 +1069,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);                    
@@ -1105,11 +1084,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
@@ -1117,16 +1096,28 @@
 // ---------------------------------------------------------------------------
 // 
 TBool CPeninputAnim::MatchItemByControlIDAndArea (const TTactileControlInfo& aFirst, const TTactileControlInfo& aSecond)
+	{
+	if ((aFirst.iId == aSecond.iId) && (aFirst.iArea == aSecond.iArea))
+		return ETrue;
+	return EFalse;
+	}
+#endif // RD_TACTILE_FEEDBACK    
+TInt CPeninputAnim::DiscreetPopChangeNotification(TAny* aObj)
     {
-    if ((aFirst.iId == aSecond.iId) && (aFirst.iArea == aSecond.iArea))
-        return ETrue;
-    return EFalse;
+    if (aObj)
+        {
+        static_cast<CPeninputAnim*>(aObj)->HandleDiscreetPopNotification();
+        return KErrNone;
+        }
+    else
+        {
+        return KErrArgument;
+        }
     }
-#endif // RD_TACTILE_FEEDBACK    
 
-void CPeninputAnim::SetDiscreeptPop(TRect aArea)
+void CPeninputAnim::Refresh()
     {
-    iDiscreetPopArea = aArea;
+    iDiscreetPopArea = iAknUiSrv.GetInUseGlobalDiscreetPopupRect();
     if(iDiscreetPopArea.Size().iWidth > 0)
         {
         iDiscreetPoped = ETrue;
@@ -1136,5 +1127,51 @@
         iDiscreetPoped = EFalse;
         iDiscreetPopedCapture = EFalse;
         }
+    iDirty = EFalse;
+    }
+
+void CPeninputAnim::HandleDiscreetPopNotification()
+    {
+    iDirty = ETrue;
+    }
+    
+CSubscriber::CSubscriber(TCallBack aCallBack, RProperty& aProperty)
+    :
+    CActive(EPriorityNormal), iCallBack(aCallBack), iProperty(aProperty)
+    {
+    CActiveScheduler::Add(this);
+    }
+
+CSubscriber::~CSubscriber()
+    {
+    Cancel();
+    }
+
+void CSubscriber::SubscribeL()
+    {
+    if (!IsActive())
+        {
+        iProperty.Subscribe(iStatus);
+        SetActive();
+        }
+    }
+
+void CSubscriber::StopSubscribe()
+    {
+    Cancel();
+    }
+
+void CSubscriber::RunL()
+    {
+    if (iStatus.Int() == KErrNone)
+        {
+        iCallBack.CallBack();
+        SubscribeL();
+        }
+    }
+
+void CSubscriber::DoCancel()
+    {
+    iProperty.Cancel();
     }
 // End of File