textinput/peninputarc/src/peninputserverapp/peninputserver.cpp
branchRCL_3
changeset 56 8152b1f1763a
parent 50 5a1685599b76
equal deleted inserted replaced
50:5a1685599b76 56:8152b1f1763a
    43 #include "penuiwndctrl.h"
    43 #include "penuiwndctrl.h"
    44 #include "keyrotator.h"
    44 #include "keyrotator.h"
    45 #include <AknDef.h>
    45 #include <AknDef.h>
    46 #include <aknfeppeninputenums.h>
    46 #include <aknfeppeninputenums.h>
    47 #include <aknappui.h> 
    47 #include <aknappui.h> 
       
    48 #include <peninputcmdparam.h>
    48 
    49 
    49 #include "peninputcrpclient.h"
    50 #include "peninputcrpclient.h"
    50 #include <avkondomainpskeys.h>
    51 #include <avkondomainpskeys.h>
       
    52 #include "penuicandidatewnd.h"
       
    53 #include "penuiwndeventobserver.h"
       
    54 #include "penuiwndeventhandler.h"
    51 //#define __WND_TEST_
    55 //#define __WND_TEST_
    52 
    56 
    53 // CONSTANTS
    57 // CONSTANTS
    54 const TSize KInitialPeninputSize= TSize( 10, 10 );
    58 const TSize KInitialPeninputSize= TSize( 10, 10 );
    55 const TInt KMsgQueueLen = 1000;
    59 const TInt KMsgQueueLen = 1000;
    56 const TInt KMsgResponseQueueLen = 10;
    60 const TInt KMsgResponseQueueLen = 10;
       
    61 const TInt KLiftupPriority = 10;
    57 
    62 
    58 const TInt KWsSessionFlushPerioid = 50000;//50ms
    63 const TInt KWsSessionFlushPerioid = 50000;//50ms
    59 const TInt KInvalidValue = -1;
    64 const TInt KInvalidValue = -1;
    60 // Layout UID for portrait FSQ.  Used for distinguish between 
    65 // Layout UID for portrait FSQ.  Used for distinguish between 
    61 // landscape and portrait FSQ for EPluginInputModeFSQ, which 
    66 // landscape and portrait FSQ for EPluginInputModeFSQ, which 
    62 // is used for both orientation in Pen Input server side code.
    67 // is used for both orientation in Pen Input server side code.
    63 const TInt KPenInputSrvPrtFsqUiId = 0x20026837;
    68 const TInt KPenInputSrvPrtFsqUiId = 0x20026837;
    64 
    69 
    65 // The UID of the PopupClock application
       
    66 const TInt KBigClockUid =  0x2000FDC3;
       
    67 
       
    68 // The UID of the SreenSaver application
       
    69 const TInt KScreenSaverUid =  0x100056CF;
       
    70 
       
    71 // The UID of the AutoLock application
       
    72 const TInt KAutoLockUid = 0x100059B5;
       
    73 
    70 
    74 enum TActivationFlag
    71 enum TActivationFlag
    75 	{
    72 	{
    76 	ECmdDeactivate = EFalse,
    73 	ECmdDeactivate = EFalse,
    77 	ECmdActivate = ETrue,
    74 	ECmdActivate = ETrue,
   224 // ---------------------------------------------------------------------------
   221 // ---------------------------------------------------------------------------
   225 //
   222 //
   226 void CPeninputServer::ConstructL( )
   223 void CPeninputServer::ConstructL( )
   227     {
   224     {
   228 #ifdef RD_TACTILE_FEEDBACK     
   225 #ifdef RD_TACTILE_FEEDBACK     
   229 	FeatureManager::InitializeLibL();
   226     FeatureManager::InitializeLibL();
   230    	iSupportFeedback = FeatureManager::FeatureSupported( KFeatureIdTactileFeedback );
   227     iSupportFeedback = FeatureManager::FeatureSupported( KFeatureIdTactileFeedback );
   231 
   228 
   232 #endif //RD_TACTILE_FEEDBACK   
   229 #endif //RD_TACTILE_FEEDBACK   
   233     
   230     
   234     // start server, leaves if server already running
   231     // start server, leaves if server already running
   235     StartL( KPeninputServerName );            
   232     StartL( KPeninputServerName );            
   248     iSoftwareLayoutChangeWatcher = CAknLayoutChangeWatcher::NewL(this,
   245     iSoftwareLayoutChangeWatcher = CAknLayoutChangeWatcher::NewL(this,
   249                                                    KUikPreferredOrientation);
   246                                                    KUikPreferredOrientation);
   250     iHardwareLayoutChangeWatcher->StartWatching();
   247     iHardwareLayoutChangeWatcher->StartWatching();
   251     iSoftwareLayoutChangeWatcher->StartWatching();
   248     iSoftwareLayoutChangeWatcher->StartWatching();
   252 
   249 
   253 	RWindowGroup& rootWin = CCoeEnv::Static()->RootWin();
   250     RWindowGroup& rootWin = CCoeEnv::Static()->RootWin();
   254 	rootWin.EnableFocusChangeEvents (); // For cover UI/status pane refresh problems
   251     rootWin.EnableFocusChangeEvents (); // For cover UI/status pane refresh problems
   255 	rootWin.EnableGroupListChangeEvents();
   252     rootWin.EnableGroupListChangeEvents();
   256 	rootWin.EnableReceiptOfFocus(EFalse);
   253     rootWin.EnableReceiptOfFocus(EFalse);
   257 	rootWin.AutoForeground(EFalse);
   254     rootWin.AutoForeground(EFalse);
   258 
   255 
   259     ConstructSpriteL();
   256     ConstructSpriteL();
   260     
   257     
   261     //create animation object
   258     //create animation object
   262 	iAnimObj = CPeninputAnimObj::NewL(iSpriteMember);
   259     iAnimObj = CPeninputAnimObj::NewL(iSpriteMember);
   263 	
   260     
   264 	iLayoutOwner = CPeninputUiLayoutOwner::NewL( *this );
   261     iLayoutOwner = CPeninputUiLayoutOwner::NewL( *this );
   265 	iPenUiCtrl = new(ELeave) CPenUiWndCtrl(CCoeEnv::Static()->RootWin(),iSpriteMember.iBitmap);
   262     iPenUiCtrl = new(ELeave) CPenUiWndCtrl(CCoeEnv::Static()->RootWin(),iSpriteMember.iBitmap);
   266 	iInternalBackgroundCtrl = new(ELeave) CInternalBkCtrl(CCoeEnv::Static()->RootWin());
   263     iInternalBackgroundCtrl = new(ELeave) CInternalBkCtrl(CCoeEnv::Static()->RootWin());
   267     iInternalBackgroundCtrl->ConstructL();	
   264     iInternalBackgroundCtrl->ConstructL();    
   268 	iPenUiCtrl->ConstructL();
   265     iPenUiCtrl->ConstructL();
   269 	
   266     iObserver = CPenUiWndEventHandler::NewL( this );
   270 	iCurScreenFocusedWndGrpId = GetFocusAppUid().iUid;
   267     iCandidateWnd = CPenUiCandidateWnd::NewL( iObserver );
       
   268     
       
   269     iCurScreenFocusedWndGrpId = GetFocusAppUid().iUid;
   271 #ifdef __LOG_WNDGROU__    
   270 #ifdef __LOG_WNDGROU__    
   272     iLogFile.Replace(CCoeEnv::Static()->FsSession(),KLogFile,EFileShareAny|EFileWrite);
   271     iLogFile.Replace(CCoeEnv::Static()->FsSession(),KLogFile,EFileShareAny|EFileWrite);
   273     iLogFile.Close();
   272     iLogFile.Close();
   274     
   273     
   275 #endif
   274 #endif
   348 	FeatureManager::UnInitializeLib();
   347 	FeatureManager::UnInitializeLib();
   349     iFeedbackAreaArray.Close();
   348     iFeedbackAreaArray.Close();
   350 #endif // RD_TACTILE_FEEDBACK    
   349 #endif // RD_TACTILE_FEEDBACK    
   351     delete iPenUiCtrl;
   350     delete iPenUiCtrl;
   352     delete iInternalBackgroundCtrl;
   351     delete iInternalBackgroundCtrl;
       
   352     delete iCandidateWnd;
       
   353     delete iObserver;
   353 
   354 
   354     iClientProcess.Close();
   355     iClientProcess.Close();
   355     iClientLayouts.Close();
   356     iClientLayouts.Close();
   356 #ifdef __LOG_WNDGROU__    
   357 #ifdef __LOG_WNDGROU__    
   357     iLogFile.Close();    
   358     iLogFile.Close();    
   789             {
   790             {
   790             RecoverSimulatedKeyEventState();
   791             RecoverSimulatedKeyEventState();
   791             RecoverButtonEventState();
   792             RecoverButtonEventState();
   792             iUiLayout->OnDeActivate(); 
   793             iUiLayout->OnDeActivate(); 
   793             if(iUseWindowCtrl)
   794             if(iUseWindowCtrl)
   794                 iPenUiCtrl->OnDeactivate(); //disable non fading             
   795                 {
       
   796                 iPenUiCtrl->OnDeactivate(); //disable non fading
       
   797                 iCandidateWnd->HideCandidateList();
       
   798                 }
   795             }								    	
   799             }								    	
   796 
   800 
   797         return ETrue;
   801         return ETrue;
   798         }
   802         }
   799     return EFalse;              
   803     return EFalse;              
   846 
   850 
   847     if (DeactivatePenUiLayout(bNeedWait) && bNeedWait)
   851     if (DeactivatePenUiLayout(bNeedWait) && bNeedWait)
   848         iForegroundUiHandler->AddDelayedCmd();
   852         iForegroundUiHandler->AddDelayedCmd();
   849 
   853 
   850     if (iUseWindowCtrl)
   854     if (iUseWindowCtrl)
       
   855         {
   851         iPenUiCtrl->ClosePenUi(aRotation);
   856         iPenUiCtrl->ClosePenUi(aRotation);
       
   857         iCandidateWnd->HideCandidateList();
       
   858         }
   852     
   859     
   853     //save current screen mode
   860     //save current screen mode
   854     iCurScrMode = CCoeEnv::Static()->ScreenDevice()->CurrentScreenMode();    
   861     iCurScrMode = CCoeEnv::Static()->ScreenDevice()->CurrentScreenMode();    
   855     }
   862     }
   856 
   863 
   869     TBool isForeground = IsForegroundSession(
   876     TBool isForeground = IsForegroundSession(
   870                     static_cast<CPeninputServerSession*>(aMessage.Session()));
   877                     static_cast<CPeninputServerSession*>(aMessage.Session()));
   871     //message requests UI attribute is always handled.
   878     //message requests UI attribute is always handled.
   872     switch(aMessage.Function())
   879     switch(aMessage.Function())
   873         {
   880         {
   874         case EPeninputRequestEnableGfxTransEffect:
   881         
   875             {
       
   876             if( iUseWindowCtrl && iPenUiCtrl )
       
   877                 {
       
   878                 TBool enable = EFalse;
       
   879                 TPckg<TBool> msg( enable );
       
   880                 aMessage.ReadL( 0,msg );
       
   881                 iPenUiCtrl->EnableGfxTransEffect( enable );
       
   882                 }
       
   883             }
       
   884             break;
       
   885         case EPeninputRequestUiIsVisible:
   882         case EPeninputRequestUiIsVisible:
   886             {                      
   883             {                      
   887             TPckg<TBool> msg(iActive);
   884             TPckg<TBool> msg(iActive);
   888             
   885             
   889             aMessage.WriteL(0,msg);            
   886             aMessage.WriteL(0,msg);            
  2031 				TUint16* buf = const_cast<TUint16* >( aEventData.Ptr() );    
  2028 				TUint16* buf = const_cast<TUint16* >( aEventData.Ptr() );    
  2032                 TBool* retVal = reinterpret_cast< TBool* > ( buf );
  2029                 TBool* retVal = reinterpret_cast< TBool* > ( buf );
  2033 				iIsLayoutReDrawAllowWhenActive = *retVal;
  2030 				iIsLayoutReDrawAllowWhenActive = *retVal;
  2034 				}
  2031 				}
  2035 				break;	
  2032 				break;	
  2036             case ESignalUpdatePointerSuppressor:
  2033             case ESignalShowServerCandidate:
  2037                 {               
  2034                 {
  2038                 UpdatePointerEventSuppressor( aEventData );
  2035                 if ( iUseWindowCtrl )
       
  2036                     {
       
  2037                     // Lift the priority of candidate list window to higher 
       
  2038                     // than pen ui wnd.
       
  2039                     TInt priority = iPenUiCtrl->WndPriority();
       
  2040                     iCandidateWnd->SetPriority( priority + KLiftupPriority );
       
  2041                 
       
  2042                     TUint16* buf = const_cast<TUint16*>( aEventData.Ptr() );
       
  2043                     TPeninputCandidateData* cmd = 
       
  2044                           reinterpret_cast< TPeninputCandidateData* >( buf );
       
  2045                     iCandidateWnd->SetAlign( 
       
  2046                             CGraphicsContext::TTextAlign ( cmd->iAlign ) );
       
  2047                     iCandidateWnd->SetInitRect( cmd->iInitRect );
       
  2048                     iCandidateWnd->EnableSpell( cmd->iSpellEnabled );
       
  2049                     iCandidateWnd->EnableTextWidth( cmd->iTextWidthEnabled );
       
  2050                     TRAP_IGNORE( iCandidateWnd->ShowCandidateListL( 
       
  2051                                       cmd->iItemArray, cmd->iActiveIndex ) );
       
  2052                     }
       
  2053                 }
       
  2054                 break;
       
  2055             case ESignalHideServerCandidate:
       
  2056                 {
       
  2057                 if ( iUseWindowCtrl )
       
  2058                     {
       
  2059                     iCandidateWnd->HideCandidateList();
       
  2060                     }
  2039                 }
  2061                 }
  2040                 break;
  2062                 break;
  2041         	default:
  2063         	default:
  2042         	    if(iUseWindowCtrl)                    
  2064         	    if(iUseWindowCtrl)                    
  2043         	        {
  2065         	        {
  2146 //    
  2168 //    
  2147 void CPeninputServer::HandleResourceChange(TInt aType)
  2169 void CPeninputServer::HandleResourceChange(TInt aType)
  2148     {
  2170     {
  2149 	// Update the cursor color when resource is changed
  2171 	// Update the cursor color when resource is changed
  2150 	iPenUiCtrl->SetCursorColor();
  2172 	iPenUiCtrl->SetCursorColor();
       
  2173 
       
  2174     // Update candidate window when resource is changed
       
  2175     iCandidateWnd->HandleResourceChange( aType );
  2151 	
  2176 	
  2152 	#ifdef FIX_FOR_NGA 
  2177 	#ifdef FIX_FOR_NGA 
  2153 	// iEnablePriorityChangeOnOriChange will be set to be EFalse, if some dialog in FEP end were opened and 
  2178 	// iEnablePriorityChangeOnOriChange will be set to be EFalse, if some dialog in FEP end were opened and 
  2154 	// not close after rotation for example: Symbol Table, Writing Language list and Match Dialog on ITI
  2179 	// not close after rotation for example: Symbol Table, Writing Language list and Match Dialog on ITI
  2155 	if(iUiLayout && iActive && iEnablePriorityChangeOnOriChange && aType == KEikDynamicLayoutVariantSwitch)
  2180 	if(iUiLayout && iActive && iEnablePriorityChangeOnOriChange && aType == KEikDynamicLayoutVariantSwitch)
  2497         	aEvent.IsTip() 
  2522         	aEvent.IsTip() 
  2498         	&& iCrpService && iCrpService->IsDsaActive() )
  2523         	&& iCrpService && iCrpService->IsDsaActive() )
  2499             {
  2524             {
  2500             SignalOwner( ESignalLayoutClosed, KNullDesC );    
  2525             SignalOwner( ESignalLayoutClosed, KNullDesC );    
  2501             }
  2526             }
  2502                    
  2527         
  2503         TBool handled = iUiLayout ? iUiLayout->HandleEventL(ERawEvent,&aEvent)
  2528         // Candidate window handles raw event firstly.
  2504         		        : EFalse;
  2529         TBool handled = iCandidateWnd->HandleRawEventL( &aEvent );
       
  2530         if( !handled )
       
  2531         	{
       
  2532             handled = iUiLayout ? iUiLayout->HandleEventL( ERawEvent,&aEvent )
       
  2533         		                : EFalse;
       
  2534         	}
  2505 
  2535 
  2506         if (TRawEvent::EButton1Down == aEvent.Type())
  2536         if (TRawEvent::EButton1Down == aEvent.Type())
  2507             {
  2537             {
  2508             iLastRawEvent = aEvent;     
  2538             iLastRawEvent = aEvent;     
  2509             }
  2539             }
  2581                     {
  2611                     {
  2582                     if(iInGlobalNotesState)
  2612                     if(iInGlobalNotesState)
  2583                         {			  
  2613                         {			  
  2584                         //fix for fast swap case
  2614                         //fix for fast swap case
  2585                         iInGlobalNotesState = EFalse;                        
  2615                         iInGlobalNotesState = EFalse;                        
  2586 
  2616                         if(iPreNonGloebalNotesWndGrpId != focusApp.iUid )
  2587                         // Don't handle switching focus group 
       
  2588                         // when current focus of the application is screen saver, auto lock or popup clock.
       
  2589                         if ( iPreNonGloebalNotesWndGrpId != focusApp.iUid && 
       
  2590                              focusApp.iUid != KScreenSaverUid && 
       
  2591                              focusApp.iUid != KAutoLockUid && 
       
  2592                              focusApp.iUid != KBigClockUid )
       
  2593                             {                            
  2617                             {                            
  2594                             iPreNonGloebalNotesWndGrpId = focusApp.iUid;
  2618                             iPreNonGloebalNotesWndGrpId = focusApp.iUid;
  2595                             DeactivateSprite(ETrue);//hide pen ui immediately if switched to another application
  2619                             DeactivateSprite(ETrue);//hide pen ui immediately if switched to another application
  2596                             // Notify FEP to close touch input window.
  2620                             // Notify FEP to close touch input window.
  2597                             // Under this case, touch input window can't be closed without norifying FEP side.
  2621                             // Under this case, touch input window can't be closed without norifying FEP side.
  3057 void CPeninputServer::HandleDiscreetPopNotification()
  3081 void CPeninputServer::HandleDiscreetPopNotification()
  3058     {
  3082     {
  3059 	iDiscreetPopArea = iAknUiSrv.GetInUseGlobalDiscreetPopupRect();
  3083 	iDiscreetPopArea = iAknUiSrv.GetInUseGlobalDiscreetPopupRect();
  3060 	iAnimObj->SetDiscreetPopArea(iDiscreetPopArea);
  3084 	iAnimObj->SetDiscreetPopArea(iDiscreetPopArea);
  3061     }
  3085     }
  3062 
       
  3063 // ---------------------------------------------------------------------------
       
  3064 // CPeninputServer::UpdatePointerEventSuppressor()
       
  3065 // Update parameters of pointer event suppressor.
       
  3066 // ---------------------------------------------------------------------------
       
  3067 //
       
  3068 void CPeninputServer::UpdatePointerEventSuppressor( const TDesC& aData )
       
  3069     {
       
  3070     TUint16* buf = const_cast<TUint16* >( aData.Ptr() );
       
  3071     TPointerEventSuppressorParameters* parameters = 
       
  3072             reinterpret_cast<TPointerEventSuppressorParameters*> ( buf );
       
  3073     
       
  3074     iAnimObj->UpdatePointerEventSuppressor( *parameters );
       
  3075     }
       
  3076 
       
  3077 // ======== class CEventQueue========
  3086 // ======== class CEventQueue========
  3078 //
  3087 //
  3079 // ---------------------------------------------------------------------------
  3088 // ---------------------------------------------------------------------------
  3080 // CEventQueue::CEventQueue
  3089 // CEventQueue::CEventQueue
  3081 // Constructor. Adds the active object to the active scheduler
  3090 // Constructor. Adds the active object to the active scheduler