taskswitcher/taskswitcherui/taskswitcherapp/src/tsappui.cpp
branchRCL_3
changeset 18 d05a55b217df
parent 17 b8fae6b8a148
child 19 79311d856354
--- a/taskswitcher/taskswitcherui/taskswitcherapp/src/tsappui.cpp	Wed Mar 31 21:17:19 2010 +0300
+++ b/taskswitcher/taskswitcherui/taskswitcherapp/src/tsappui.cpp	Wed Apr 14 15:47:59 2010 +0300
@@ -60,7 +60,9 @@
 
 // time to wait before sending the task to background
 // (must give time to animation)
-const TInt KWaitBeforeGoingToBackground = 175000;
+const TInt KWaitBeforeGoingToBackground = 200000;
+
+const TUid KTsAppUid = { KTsAppUidValue };
 
 // -----------------------------------------------------------------------------
 // CTsAppUi::ConstructL()
@@ -118,6 +120,7 @@
     // Create custom window group
     iWg = RWindowGroup(CCoeEnv::Static()->WsSession());
     iWg.Construct((TUint32)&iWg, ETrue);
+    iWg.EnableScreenChangeEvents(); 
     
     // Create UI
     iAppView = CTsAppView::NewL( ApplicationRect(), *iDeviceState, iWg );
@@ -147,6 +150,9 @@
     iEikonEnv->RootWin().SetOrdinalPosition(-1, ECoeWinPriorityNeverAtFront);
     iEikonEnv->RootWin().EnableReceiptOfFocus(EFalse);
     
+    RWindowGroup& windowGroup = CCoeEnv::Static()->RootWin();
+    windowGroup.EnableGroupListChangeEvents();
+    
     iIsPopUpShown = EFalse;
     iUiStarted = EFalse;
     iDisableAppKeyHandling = EFalse;
@@ -209,7 +215,7 @@
 // CTsAppUi::StartTransion
 // -----------------------------------------------------------------------------
 //
-void CTsAppUi::StartTransion( TUint aTransitionType )
+void CTsAppUi::StartTransion( TUint aTransitionType, TUid aNextAppUid, TInt aWgId )
     {
     if( !EffectsEnabled() )
         {
@@ -230,10 +236,7 @@
                          CAknTransitionUtils::EForceInvisible );
         break;
     case EActivationTransition:
-        StartTransition( aTransitionType, 
-                         EFalse, 
-                         ETrue, 
-                         CAknTransitionUtils::EForceInvisible );
+        StartAppActivateTransition( aNextAppUid, aWgId );
         break;
         }
     }
@@ -262,6 +265,46 @@
     }
 
 // -----------------------------------------------------------------------------
+// CTsAppUi::StartAppActivateTransition
+// -----------------------------------------------------------------------------
+//
+void CTsAppUi::StartAppActivateTransition( TUid aNextAppUid, TInt aWgId )
+    {
+    // Check what type of transition will be trigerred
+    if ( aWgId == iUnderAppWgId )
+        {
+        // App under task switcher was launched
+        StartTransition( EActivationTransition, 
+                         EFalse, 
+                         ETrue, 
+                         CAknTransitionUtils::EForceInvisible );
+        }
+    else
+        {
+        // App start animation
+        TRAP_IGNORE( RequestPopUpL() );
+        const TDesC8* ptr = reinterpret_cast<const TDesC8*>(iAppView);
+        GfxTransEffect::Abort(iAppView);
+        TInt groupId = GfxTransEffect::BeginGroup();
+        GfxTransEffect::BeginFullScreen(
+                 EActivationAppShowTransition, ApplicationRect(),
+                 AknTransEffect::EParameterType,
+                 AknTransEffect::GfxTransParam( aNextAppUid , KTsAppUid ) );
+        GfxTransEffect::Begin( iAppView, EActivationTransition );
+        GfxTransEffect::SetDemarcation( iAppView, iAppView->Rect() );
+        GfxTransEffect::NotifyExternalState( ECaptureComponentsBegin, ptr );
+        iAppView->MakeVisible( EFalse );
+        CAknTransitionUtils::MakeVisibleSubComponents( 
+            iAppView,
+            static_cast<CAknTransitionUtils::TMakeVisibleSubComponentsInfo>(CAknTransitionUtils::EForceInvisible) );
+        GfxTransEffect::NotifyExternalState( ECaptureComponentsEnd, ptr );
+        GfxTransEffect::End( iAppView );
+        GfxTransEffect::EndFullScreen();
+        GfxTransEffect::EndGroup(groupId);
+        }
+    }
+
+// -----------------------------------------------------------------------------
 // CTsAppUi::TransitionFinished
 // -----------------------------------------------------------------------------
 //
@@ -446,7 +489,7 @@
 // CTsAppUi::MoveAppToBackground()
 // -----------------------------------------------------------------------------
 //
-void CTsAppUi::MoveAppToBackground( TUint aTransitionType )
+void CTsAppUi::MoveAppToBackground( TUint aTransitionType, TUid aAppUid, TInt aWgId )
     {
     TSLOG_CONTEXT( MoveAppToBackground, TSLOG_LOCAL );
     TSLOG_IN();
@@ -457,7 +500,7 @@
         }
     else
         {
-        StartTransion(aTransitionType);
+        StartTransion(aTransitionType, aAppUid, aWgId);
         iGoToBackgroundTimer->Cancel();
         iGoToBackgroundTimer->Start( 
                 KWaitBeforeGoingToBackground, 
@@ -698,4 +741,98 @@
     return retVal;  
     }
 
+
+// -----------------------------------------------------------------------------
+// CTsAppUi::HandleWsEventL
+// -----------------------------------------------------------------------------
+//
+void CTsAppUi::HandleWsEventL(const TWsEvent& aEvent,
+        CCoeControl* aDestination)
+    {
+    CAknAppUi::HandleWsEventL(aEvent, aDestination);
+    TInt eventType = aEvent.Type();
+    if ( eventType == EEventWindowGroupListChanged )
+        {
+        TInt wgId = WgIdOfUnderlyingApp(EFalse);
+        if ( iForeground &&
+             wgId != iUnderAppWgId &&
+             !iAppView->AppCloseInProgress(iUnderAppWgId) )
+            {
+            MoveAppToBackground( ENoneTransition );
+            }
+        if ( WgIdOfUnderlyingApp(ETrue) != iUnderAppWgId )
+            {
+            HandleResourceChangeL(KEikDynamicLayoutVariantSwitch);
+            }
+        iUnderAppWgId = wgId;
+        }
+    }
+
+
+// -----------------------------------------------------------------------------
+// CTsAppUi::WgIdOfUnderlyingApp
+// -----------------------------------------------------------------------------
+//
+TInt CTsAppUi::WgIdOfUnderlyingApp( TBool aIgnoreParentChild )
+    {
+    TInt retVal(0);
+    TApaTaskList taskList( iEikonEnv->WsSession() );
+    TInt underlyingWg = taskList.FindByPos(0).WgId();
+    if ( aIgnoreParentChild )
+        {
+        retVal = underlyingWg;
+        }
+    else
+        {
+        TInt parentWg = GetTopParentWg( underlyingWg );
+        retVal = parentWg ? parentWg : underlyingWg;
+        }
+    return retVal;
+    }
+
+// -----------------------------------------------------------------------------
+// CTsAppUi::GetTopParentWg
+// -----------------------------------------------------------------------------
+//
+TInt CTsAppUi::GetTopParentWg( TInt aChildWg )
+	{
+	TInt parentWg = GetParentWg( aChildWg );
+	if( parentWg )
+		{
+		TInt topParentWg = GetTopParentWg( parentWg );
+		if( topParentWg )
+			{
+			parentWg = topParentWg; 
+			}
+		}
+	return parentWg;
+	}
+
+// -----------------------------------------------------------------------------
+// CTsAppUi::GetParentWg
+// -----------------------------------------------------------------------------
+//
+TInt CTsAppUi::GetParentWg( TInt aChildWg )
+    {
+	TInt retVal(0);
+    RArray<RWsSession::TWindowGroupChainInfo> allWgIds;
+    // Ask for window group list from RWsSession
+    TInt error = iEikonEnv->WsSession().WindowGroupList( 0, &allWgIds );
+    if ( !error )
+        {
+        TInt count( allWgIds.Count() );
+        for ( TInt i( 0 ); i < count; i++ )
+            {
+            RWsSession::TWindowGroupChainInfo info = allWgIds[i];
+            if ( info.iId == aChildWg && info.iParentId > 0)
+                {
+				retVal = info.iParentId;
+                break;
+                }
+            }
+        }
+    allWgIds.Close();
+	return retVal;
+	}
+
 // End of file