taskswitcher/taskswitcherui/taskswitcherapp/src/tsappui.cpp
branchRCL_3
changeset 102 ba63c83f4716
parent 93 b01126ce0bec
equal deleted inserted replaced
93:b01126ce0bec 102:ba63c83f4716
   153     // our application ( so that it represent our app )
   153     // our application ( so that it represent our app )
   154     //iApplicationTask.SetWgId( iCoeEnv->RootWin().Identifier() );
   154     //iApplicationTask.SetWgId( iCoeEnv->RootWin().Identifier() );
   155     iApplicationTask.SetWgId( iWg.Identifier() );
   155     iApplicationTask.SetWgId( iWg.Identifier() );
   156 
   156 
   157     // And finally, go to background.
   157     // And finally, go to background.
   158     iForeground = ETrue;
       
   159     MoveAppToBackground( ENoneTransition );
   158     MoveAppToBackground( ENoneTransition );
   160     
   159     
   161     iEikonEnv->RootWin().SetOrdinalPosition(-1, ECoeWinPriorityNeverAtFront);
   160     iEikonEnv->RootWin().SetOrdinalPosition(-1, ECoeWinPriorityNeverAtFront);
   162     iEikonEnv->RootWin().EnableReceiptOfFocus(EFalse);
   161     iEikonEnv->RootWin().EnableReceiptOfFocus(EFalse);
   163     
   162     
   177 // -----------------------------------------------------------------------------
   176 // -----------------------------------------------------------------------------
   178 // CTsAppUi::CTsAppUi()
   177 // CTsAppUi::CTsAppUi()
   179 // Perform the first phase of two phase construction
   178 // Perform the first phase of two phase construction
   180 // -----------------------------------------------------------------------------
   179 // -----------------------------------------------------------------------------
   181 //
   180 //
   182 CTsAppUi::CTsAppUi(): iForeground( EFalse ),
   181 CTsAppUi::CTsAppUi(): iForeground( ETrue ),
   183                                       iApplicationTask( iCoeEnv->WsSession() )
   182                                       iApplicationTask( iCoeEnv->WsSession() )
   184     {
   183     {
   185     // no implementation required
   184     // no implementation required
   186     }
   185     }
   187 
   186 
   190 // Destructor
   189 // Destructor
   191 // -----------------------------------------------------------------------------
   190 // -----------------------------------------------------------------------------
   192 //
   191 //
   193 CTsAppUi::~CTsAppUi()
   192 CTsAppUi::~CTsAppUi()
   194     {
   193     {
   195     if( iAppView && GfxTransEffect::IsRegistered( iAppView ) )
   194     if( GfxTransEffect::IsRegistered( iAppView ) )
   196         {
   195         {
   197         GfxTransEffect::Deregister(iAppView);
   196         GfxTransEffect::Deregister(iAppView);
   198         
   197         
   199         }
   198         }
   200     GfxTransEffect::SetTransitionObserver(0);
   199     GfxTransEffect::SetTransitionObserver(0);
   264                                 TBool aVisibility,
   263                                 TBool aVisibility,
   265                                 TBool /*aLayers*/, 
   264                                 TBool /*aLayers*/, 
   266                                 TUint aSubCom )
   265                                 TUint aSubCom )
   267     {
   266     {
   268     const TDesC8* ptr = reinterpret_cast<const TDesC8*>(iAppView);
   267     const TDesC8* ptr = reinterpret_cast<const TDesC8*>(iAppView);
   269     GfxTransEffect::AbortFullScreen();
       
   270     GfxTransEffect::Abort(iAppView);
   268     GfxTransEffect::Abort(iAppView);
   271     GfxTransEffect::Begin( iAppView, aTranstionId );
   269     GfxTransEffect::Begin( iAppView, aTranstionId );
   272     GfxTransEffect::SetDemarcation( iAppView, iAppView->Rect() );
   270     GfxTransEffect::SetDemarcation( iAppView, iAppView->Rect() );
   273     GfxTransEffect::NotifyExternalState( ECaptureComponentsBegin, ptr );
   271     GfxTransEffect::NotifyExternalState( ECaptureComponentsBegin, ptr );
   274     iAppView->MakeVisible( aVisibility );
   272     iAppView->MakeVisible( aVisibility );
   296         }
   294         }
   297     else
   295     else
   298         {
   296         {
   299         // App start animation
   297         // App start animation
   300         const TDesC8* ptr = reinterpret_cast<const TDesC8*>(iAppView);
   298         const TDesC8* ptr = reinterpret_cast<const TDesC8*>(iAppView);
   301         GfxTransEffect::AbortFullScreen();
       
   302         GfxTransEffect::Abort(iAppView);
   299         GfxTransEffect::Abort(iAppView);
   303         TInt groupId = GfxTransEffect::BeginGroup();
   300         TInt groupId = GfxTransEffect::BeginGroup();
   304         GfxTransEffect::BeginFullScreen(
   301         GfxTransEffect::BeginFullScreen(
   305                  EActivationAppShowTransition, ApplicationRect(),
   302                  EActivationAppShowTransition, ApplicationRect(),
   306                  AknTransEffect::EParameterType,
   303                  AknTransEffect::EParameterType,
   534 // CTsAppUi::GoToBackgroundTimerCallback
   531 // CTsAppUi::GoToBackgroundTimerCallback
   535 // -----------------------------------------------------------------------------
   532 // -----------------------------------------------------------------------------
   536 //
   533 //
   537 TInt CTsAppUi::GoToBackgroundTimerCallback( TAny* aParam )
   534 TInt CTsAppUi::GoToBackgroundTimerCallback( TAny* aParam )
   538     {
   535     {
   539     TSLOG_STATIC_CONTEXT( GoToBackgroundTimerCallback, TSLOG_LOCAL, RThread().Id() );
       
   540     TSLOG_IN();
       
   541     CTsAppUi* self = static_cast<CTsAppUi*>( aParam );
   536     CTsAppUi* self = static_cast<CTsAppUi*>( aParam );
   542     if ( self->iGoToBackgroundTimer )
   537     if ( self->iGoToBackgroundTimer )
   543         {
   538         {
   544         self->iGoToBackgroundTimer->Cancel();
   539         self->iGoToBackgroundTimer->Cancel();
   545         }
   540         }
   548     // to background
   543     // to background
   549     self->iApplicationTask.SendToBackground();
   544     self->iApplicationTask.SendToBackground();
   550 
   545 
   551     // Notify
   546     // Notify
   552     self->HandleSwitchToBackgroundEvent();
   547     self->HandleSwitchToBackgroundEvent();
   553     TSLOG_OUT();
   548 
   554     return 0;
   549     return 0;
   555     }
   550     }
   556 
   551 
   557 // -----------------------------------------------------------------------------
   552 // -----------------------------------------------------------------------------
   558 // CTsAppUi::DelayedForegroundCallback
   553 // CTsAppUi::DelayedForegroundCallback
   582 void CTsAppUi::MoveAppToForeground( TUint  /*aTransitionType*/ )
   577 void CTsAppUi::MoveAppToForeground( TUint  /*aTransitionType*/ )
   583     {
   578     {
   584     TSLOG_CONTEXT( MoveAppToForeground, TSLOG_LOCAL );
   579     TSLOG_CONTEXT( MoveAppToForeground, TSLOG_LOCAL );
   585     TSLOG_IN();
   580     TSLOG_IN();
   586 
   581 
   587     TRAP_IGNORE( iUnderAppWgId = WgIdOfUnderlyingAppL(EFalse) );
       
   588     
       
   589     iUiStarted = ETrue;
   582     iUiStarted = ETrue;
   590     
   583     
   591     // Request window server to bring our application
   584     // Request window server to bring our application
   592     // to foreground
   585     // to foreground
   593     iApplicationTask.BringToForeground();
   586     iApplicationTask.BringToForeground();
   626     
   619     
   627     if( iForeground  )  
   620     if( iForeground  )  
   628         {
   621         {
   629         iForeground = EFalse;
   622         iForeground = EFalse;
   630         SetTaskswitcherStateProperty( KTaskswitcherBackgroundValue );
   623         SetTaskswitcherStateProperty( KTaskswitcherBackgroundValue );
   631         
   624 
   632         iAppView->MakeVisible( EFalse );
       
   633         // notify view
   625         // notify view
   634         iAppView->HandleSwitchToBackgroundEvent();
   626         iAppView->HandleSwitchToBackgroundEvent();
   635         
   627         
   636         iWg.SetOrdinalPosition(-1, ECoeWinPriorityNormal);
   628         iWg.SetOrdinalPosition(-1, ECoeWinPriorityNormal);
   637         
   629         
   801 // -----------------------------------------------------------------------------
   793 // -----------------------------------------------------------------------------
   802 //
   794 //
   803 void CTsAppUi::HandleWsEventL(const TWsEvent& aEvent,
   795 void CTsAppUi::HandleWsEventL(const TWsEvent& aEvent,
   804         CCoeControl* aDestination)
   796         CCoeControl* aDestination)
   805     {
   797     {
   806     TSLOG_CONTEXT( CTsAppUi::HandleWsEventL, TSLOG_LOCAL );
       
   807     CAknAppUi::HandleWsEventL(aEvent, aDestination);
   798     CAknAppUi::HandleWsEventL(aEvent, aDestination);
   808     TInt eventType = aEvent.Type();
   799     TInt eventType = aEvent.Type();
   809     if ( eventType == EEventWindowGroupListChanged )
   800     if ( eventType == EEventWindowGroupListChanged )
   810         {
   801         {
   811         TInt wgId = WgIdOfUnderlyingAppL(EFalse); 
   802         TInt wgId = WgIdOfUnderlyingAppL(EFalse); 
   812         TSLOG2( TSLOG_INFO, "WgIdOfUnderlyingAppL: %d appId: %d",
       
   813                 wgId, GetAppIdL( wgId ).iUid );
       
   814         if ( iForeground &&
   803         if ( iForeground &&
   815              wgId &&
       
   816              wgId != iUnderAppWgId &&
   804              wgId != iUnderAppWgId &&
   817              !iAppView->AppCloseInProgress(iUnderAppWgId) &&
   805              !iAppView->AppCloseInProgress(iUnderAppWgId) &&
   818              !iAppView->WgOnTaskList(wgId) )
   806              !iAppView->WgOnTaskList(wgId) )
   819             {
   807             {
   820             MoveAppToBackground( ENoneTransition );
   808             MoveAppToBackground( ENoneTransition );
   823             {
   811             {
   824             HandleResourceChangeL(KEikDynamicLayoutVariantSwitch);
   812             HandleResourceChangeL(KEikDynamicLayoutVariantSwitch);
   825             }
   813             }
   826         iUnderAppWgId = wgId;
   814         iUnderAppWgId = wgId;
   827         }
   815         }
   828     TSLOG_OUT();
       
   829     }
   816     }
   830 
   817 
   831 
   818 
   832 // -----------------------------------------------------------------------------
   819 // -----------------------------------------------------------------------------
   833 // CTsAppUi::WgIdOfUnderlyingApp
   820 // CTsAppUi::WgIdOfUnderlyingApp
   834 // -----------------------------------------------------------------------------
   821 // -----------------------------------------------------------------------------
   835 //
   822 //
   836 TInt CTsAppUi::WgIdOfUnderlyingAppL( TBool aIgnoreParentChild )
   823 TInt CTsAppUi::WgIdOfUnderlyingAppL( TBool aIgnoreParentChild )
   837     {
   824     {
   838     TSLOG_CONTEXT( CTsAppUi::WgIdOfUnderlyingAppL, TSLOG_LOCAL );
       
   839     TInt retVal(0);
   825     TInt retVal(0);
   840     TInt underlyingWg = CheckForUnderlyingHiddenAppsL();
   826     TInt underlyingWg = CheckForUnderlyingHiddenAppsL();
   841     if ( !underlyingWg )
   827     if ( !underlyingWg )
   842         {
   828         {
   843         TApaTaskList taskList(iEikonEnv->WsSession());
   829         TApaTaskList taskList( iEikonEnv->WsSession() );
   844         underlyingWg = taskList.FindByPos(0).WgId();
   830         underlyingWg = taskList.FindByPos(0).WgId();
   845         if ( !(GetAppIdL(underlyingWg).iUid) )
       
   846             {
       
   847             TSLOG1 (TSLOG_INFO, "Incorrect  underlying window group: %d.", underlyingWg );
       
   848             TSLOG0 (TSLOG_INFO, "No association to appId, nor special handling for underlying hidden apps.Change return value into 0.");
       
   849             underlyingWg = 0;
       
   850             }
       
   851         }
   831         }
   852     
   832     
   853     if ( aIgnoreParentChild )
   833     if ( aIgnoreParentChild )
   854         {
   834         {
   855         retVal = underlyingWg;
   835         retVal = underlyingWg;
   857     else
   837     else
   858         {
   838         {
   859         TInt parentWg = GetTopParentWg( underlyingWg );
   839         TInt parentWg = GetTopParentWg( underlyingWg );
   860         retVal = parentWg ? parentWg : underlyingWg;
   840         retVal = parentWg ? parentWg : underlyingWg;
   861         }
   841         }
   862     TSLOG_OUT();
       
   863     return retVal;
   842     return retVal;
   864     }
   843     }
   865 
   844 
   866 // -----------------------------------------------------------------------------
   845 // -----------------------------------------------------------------------------
   867 // CTsAppUi::GetTopParentWg
   846 // CTsAppUi::GetTopParentWg
   928     CleanupClosePushL(allWgIds);
   907     CleanupClosePushL(allWgIds);
   929     User::LeaveIfError(iEikonEnv->WsSession().WindowGroupList(0, &allWgIds));
   908     User::LeaveIfError(iEikonEnv->WsSession().WindowGroupList(0, &allWgIds));
   930     TInt underlyingWg(allWgIds[0].iId);
   909     TInt underlyingWg(allWgIds[0].iId);
   931     CleanupStack::PopAndDestroy(&allWgIds);
   910     CleanupStack::PopAndDestroy(&allWgIds);
   932     
   911     
   933     TUid appUid = GetAppIdL( underlyingWg );
   912     CApaWindowGroupName* windowName =
       
   913         CApaWindowGroupName::NewLC( iEikonEnv->WsSession(), underlyingWg );
       
   914     TUid appUid = windowName->AppUid();
       
   915     CleanupStack::PopAndDestroy( windowName );
   934     if( appUid == KTsCameraUid ||
   916     if( appUid == KTsCameraUid ||
   935         appUid == KTsTelephoneUid )
   917         appUid == KTsTelephoneUid )
   936         {
   918         {
   937         wgId = underlyingWg;
   919         wgId = underlyingWg;
   938         }
   920         }
   948     TBool retVal(EFalse);
   930     TBool retVal(EFalse);
   949     
   931     
   950     TApaTaskList taskList( iEikonEnv->WsSession() );
   932     TApaTaskList taskList( iEikonEnv->WsSession() );
   951     TInt underlyingWg = taskList.FindByPos(0).WgId();
   933     TInt underlyingWg = taskList.FindByPos(0).WgId();
   952     
   934     
   953     TUid appUid = GetAppIdL( underlyingWg );
   935     CApaWindowGroupName* windowName =
       
   936         CApaWindowGroupName::NewLC( iEikonEnv->WsSession(), underlyingWg );
       
   937     TUid appUid = windowName->AppUid();
       
   938     CleanupStack::PopAndDestroy( windowName );
   954     if ( appUid == KTsCameraUid )
   939     if ( appUid == KTsCameraUid )
   955         {
   940         {
   956         retVal = ETrue;
   941         retVal = ETrue;
   957         }
   942         }
   958     
   943     
   967 TBool CTsAppUi::DelayedForegroundLaunched()
   952 TBool CTsAppUi::DelayedForegroundLaunched()
   968     {
   953     {
   969     return iDelayedForegroundInProgress;
   954     return iDelayedForegroundInProgress;
   970     }
   955     }
   971 
   956 
   972 // -----------------------------------------------------------------------------
       
   973 // CTsAppUi::GetAppIdL
       
   974 // -----------------------------------------------------------------------------
       
   975 //
       
   976 TUid CTsAppUi::GetAppIdL( TInt aWgId )
       
   977     {
       
   978     TUid retVal;
       
   979     CApaWindowGroupName* windowName =
       
   980         CApaWindowGroupName::NewLC( iEikonEnv->WsSession(), aWgId );
       
   981     retVal = windowName->AppUid();
       
   982     CleanupStack::PopAndDestroy( windowName );
       
   983     return retVal;
       
   984     }
       
   985 
       
   986 // End of file
   957 // End of file