uifw/AknGlobalUI/AknCapServer/src/AknEikSgcs.cpp
branchRCL_3
changeset 19 aecbbf00d063
parent 8 71dd06cfe933
child 20 d48ab3b357f1
--- a/uifw/AknGlobalUI/AknCapServer/src/AknEikSgcs.cpp	Thu Aug 19 10:11:06 2010 +0300
+++ b/uifw/AknGlobalUI/AknCapServer/src/AknEikSgcs.cpp	Tue Aug 31 15:28:30 2010 +0300
@@ -26,7 +26,6 @@
 #include <aknappui.h>
 #include <e32property.h>
 #include <UikonInternalPSKeys.h>
-#include <akncapserveralternatefsplugin.h>
 #include <avkondomainpskeys.h>
 #include <AknSettingCache.h>
 #include "AknCapServerEntry.h"
@@ -51,13 +50,11 @@
 #include <layoutpack.cdl.h>
 #include <CdlRefs.h>
 const TInt KCdlEComInterfaceId = 0x101f8243;
-const TInt KMatrixMenuAppId = 0x101F4CD2;
 
 const TInt KLayoutChangeTimeout = 2000000; // 2s
 const TInt KWgStatesGranularity = 4;
 const TInt KRelinquishedThreadListGranularity = 4;
 const TInt KRemoveBlankDelay = 200000; // 0.2s
-const TInt KChangeIdleStateDelay = 200000; // 0.2s
 // Drawing is slower when transparency is enabled. The time needs to be
 // big enough to account for slowest drawing application.
 const TInt KRemoveBlankDelayTransparency = 1500000; // 1.5s
@@ -415,8 +412,6 @@
 	iLayoutNotifier = CEComPluginNotifier::NewL(KNullUid, callback);
 	iLayoutNotifier->Start();
 	EComPluginUtils::GetInfoArrayL(TUid::Uid(KCdlEComInterfaceId), iPrevPluginInfo);
-	
-	iChangeIdleState = CPeriodic::NewL(CActive::EPriorityStandard);  
     }
 
 TInt CEikSgcServer::LayoutInstallationCallBack(TAny* aPtr)
@@ -518,7 +513,6 @@
     delete iWgStates;
     delete iRemoveBlankCallBack;
     delete iLayoutNotifier;
-    delete iChangeIdleState;
     }
 
 void CEikSgcServer::HandleWindowGroupListChangeL()
@@ -528,7 +522,7 @@
         {
         ReOrderWgStatesL(wgIds);
         PostChangeRecalcL();
-        UpdateIdleState();
+        UpdateNotificationsInIdleAllowedKey();
         }
     CleanupStack::PopAndDestroy( wgIds );
     }
@@ -571,7 +565,7 @@
         LOGTEXT1("  understandsPartialForegroundChanged: %d", understandsPartialForegroundChanged);
         LOGTEXT1("  fullScreenChanged: %d",                   fullScreenChanged);        
         
-        UpdateIdleState();
+        UpdateNotificationsInIdleAllowedKey();
         }
     
     LOGTEXT0("CEikSgcServer::HandleWindowGroupParamChangeL - EXIT");
@@ -1026,15 +1020,9 @@
         
     TInt modeIndex = mode.ModeNumber();
     TBool blank = iLastScreenModeSet != -1;
-    
-    // We need to force a screen mode change if the new topState is not for a specified orientation
-    // and we have been doing any deferring of the state change
-    TBool forceScreenModeChange = (!topState.IsOrientationSpecified()) && BackgroundAppsStateChangeDeferred();
-            
-    if (modeIndex != iLastScreenModeSet  || forceScreenModeChange )
+    if (modeIndex != iLastScreenModeSet)
         {
-        SetBackgroundAppsStateChangeDeferred( EFalse );
-        
+
         // Touch compatibility mode. Disable transition effects if compa-mode
         // application becomes foreground. Restore back in opposite case.
         if (iTouchCompaModeIf)
@@ -1058,8 +1046,8 @@
 	   	    }
 #endif
 
-	//	if (!tfxOn)
-	    //	eikEnv->WsSession().ClearAllRedrawStores();
+		if (!tfxOn)
+	    	eikEnv->WsSession().ClearAllRedrawStores();
 		
         // If AknNfySrv or EikSrv is displaying a global note,
         // the screen blanker is allowed to stay on until it times
@@ -1082,8 +1070,8 @@
 		FadeColorGenerationL();
         SetLayoutBlankScreenL(blank, ESetLayoutBlankBetweenLayoutLoadAndScreenRotate);
 
- 		//if (tfxOn)
-	    //	eikEnv->WsSession().ClearAllRedrawStores();
+ 		if (tfxOn)
+	    	eikEnv->WsSession().ClearAllRedrawStores();
    	
 		// if layout change is preemptive for app change, move the app here
         DoMoveApp();
@@ -1099,9 +1087,7 @@
         iAvkonAppUiBase->SetLayoutAwareApp(!topState.IsLegacyLayout());
 
         // Start callback for handling new layout
-        // Need to execute even if the layout is not new, but apps need to catch up
-        // to it because of deferred layout switches
-        if (newLayoutLoaded || forceScreenModeChange)
+        if (newLayoutLoaded)
             {
             // Swap the screen blanker to update the foreground app's layout
             if (blank && iSetLayoutBlankStep < ESetLayoutBlankAfterScreenRotate) 
@@ -1141,10 +1127,7 @@
                 // The callback will not remove the screen blanker,
                 // so remove it now.
                 iBlankCount--;
-
-#ifndef RD_NO_SYSTEM_SCREEN_BLANKING
                 iAknCapAppServerAppUi->BlankScreenL(EFalse);
-#endif
                 }
             }
         }
@@ -1157,9 +1140,7 @@
         {
         // blank the screen and keep track of how many times it's been blanked
         iBlankCount++;
-#ifndef RD_NO_SYSTEM_SCREEN_BLANKING
         iAknCapAppServerAppUi->BlankScreenL(ETrue, ETrue);
-#endif
         }
 	}
 
@@ -1327,74 +1308,74 @@
         }
     }
 
-TInt  CEikSgcServer::ForegroundWgId()
+void CEikSgcServer::UpdateNotificationsInIdleAllowedKey()
     {
     // First, get screensaver window group identifier.
     TApaTaskList taskList(CEikonEnv::Static()->WsSession());
     const TApaTask screensaverTask = taskList.FindApp(KScreensaverAppUid);
     const TInt screensaverWgId = screensaverTask.WgId();
-
-    const TInt wgCount = iWgStates->Count();
-    TInt ii = FocusWgIndex();
-
-    LOGTEXT0("======================================");LOGTEXT1("Window groups: %d", wgCount);LOGTEXT1("Idle wg id: %d", idleWgId);LOGTEXT1("Screensaver wg id: %d", screensaverWgId);LOGTEXT1("Focus window group: %d", ii);LOGTEXT0("======================================");
-
-    // Loops window groups from top to bottom, starting from focus window group.
-    // (Index 0 contains the foreground window group.)
-    while (ii < wgCount)
-        {
-        const TWgState& state = iWgStates->At(ii);
-        const TInt currentWgId = state.WgId();
-
-        LOGTEXT0("\n");LOGTEXT1("  Window group id: %d", currentWgId);LOGTEXT1("  UnderstandsPartialForeground: %d", state.UnderstandsPartialForeground());LOGTEXT1("  IsFullScreen: %d", state.IsFullScreen());
-
-        // Ignores non-application window groups (e.g. incall bubble), partial screen
-        // applications and screensaver. 
-        if (state.UnderstandsPartialForeground() && state.IsFullScreen()
-                && currentWgId != screensaverWgId)
-            {
-            return currentWgId;
-            }
-        ++ii;
-        }
-    return KErrNotFound;
-    }
-
-TBool CEikSgcServer::IsIdleForeground()
-    {
-    TApaTaskList taskList(CEikonEnv::Static()->WsSession());
+    
     // Get also idle window group identifier.
     TVwsViewId idleView;
     if (AknDef::GetPhoneIdleViewId(idleView) != KErrNone)
         {
-        return EFalse;
-        }
-    const TApaTask idleTask = taskList.FindApp(idleView.iAppUid);
-    return (idleTask.WgId() == ForegroundWgId());
-    }
-
-void CEikSgcServer::SetIdleState(TBool aFlag)
-    {
-	//idle is changed to nonidle if taskswitcher is shown 
-    if (aFlag && iAknCapAppServerAppUi->AlternateFS()
-              && iAknCapAppServerAppUi->AlternateFS()->IsVisible())
-        {
-        aFlag = EFalse;
+        return;
         }
-
-    // Update the P&S key only if the value has been changed.
-    if ((iNotificationsInIdleAllowed && !aFlag)
-            || (!iNotificationsInIdleAllowed && aFlag))
+        
+    const TApaTask idleTask = taskList.FindApp(idleView.iAppUid);
+    const TInt idleWgId = idleTask.WgId();
+    
+    // Then go through window groups skipping partial apps and screensaver - 
+    // check if idleWgId follows.
+    TBool result = EFalse;
+    TBool found = EFalse;
+    const TInt wgCount = iWgStates->Count();
+    TInt ii = FocusWgIndex();
+        
+    LOGTEXT0("======================================");
+    LOGTEXT1("Window groups: %d",      wgCount);
+    LOGTEXT1("Idle wg id: %d",         idleWgId);
+    LOGTEXT1("Screensaver wg id: %d",  screensaverWgId);
+    LOGTEXT1("Focus window group: %d", ii);
+    LOGTEXT0("======================================");
+                
+    // Loops window groups from top to bottom, starting from focus window group.
+    // (Index 0 contains the foreground window group.)
+    while (ii < wgCount && !found)
         {
-        iNotificationsInIdleAllowed = aFlag;
-        RProperty::Set(KPSUidAvkonDomain, KAknNotificationsInIdleAllowed,aFlag);
+        const TWgState& state = iWgStates->At(ii);
+        const TInt currentWgId = state.WgId();
+        
+        LOGTEXT0("\n");
+        LOGTEXT1("  Window group id: %d",              currentWgId);
+        LOGTEXT1("  UnderstandsPartialForeground: %d", state.UnderstandsPartialForeground());
+        LOGTEXT1("  IsFullScreen: %d",                 state.IsFullScreen());
+        
+        // Ignores non-application window groups (e.g. incall bubble), partial screen
+        // applications and screensaver. 
+        if (state.UnderstandsPartialForeground() &&
+            state.IsFullScreen()                 && 
+            currentWgId != screensaverWgId)        
+            {
+            // Check if current app is idle.
+            result = (idleWgId == currentWgId);
+            found = ETrue;
+            
+            LOGTEXT0("\n");
+            LOGTEXT1("Window group found. Result: %d", result);
+            }
+            
+        ii++;
         }
-    }
-
-void CEikSgcServer::UpdateNotificationsInIdleAllowedKey()
-    {
-    SetIdleState(IsIdleForeground());
-    }     
+        
+    // Update the P&S key only if the value has been changed.
+    if ((iNotificationsInIdleAllowed && !result) || (!iNotificationsInIdleAllowed && result))
+        {
+        iNotificationsInIdleAllowed = result;
+        RProperty::Set(KPSUidAvkonDomain, KAknNotificationsInIdleAllowed, result);
+        }
+    } 
+    
 
 TInt CEikSgcServer::RemoveBlankCallBack( TAny* aThis )
     {
@@ -1407,9 +1388,7 @@
     // remove any remaining screen blanker
     for (; iRemoveBlankCount>0; iRemoveBlankCount--)
         {
-#ifndef RD_NO_SYSTEM_SCREEN_BLANKING
         TRAP_IGNORE( iAknCapAppServerAppUi->BlankScreenL( EFalse ) );
-#endif
         }
         
     iRemoveBlankCount = 0;
@@ -1514,46 +1493,7 @@
     	}
 	}
 
-void CEikSgcServer::UpdateIdleState()
-    {
-    if (ForegroundWgId() == KMatrixMenuAppId)
-        {
-        UpdateNotificationsInIdleAllowedKey();
-        return;
-        }
 
-    if (iChangeIdleState && iChangeIdleState->IsActive())
-        {
-        iChangeIdleState->Cancel();
-        }
-
-    iChangeIdleState->Start(KChangeIdleStateDelay, KChangeIdleStateDelay, TCallBack(ChangeIdleStateCallBack, this));
-    }
-
-void CEikSgcServer::DoChangeIdleState()
-    {
-    if(iChangeIdleState)
-        {
-        iChangeIdleState->Cancel();
-        }
-
-    UpdateNotificationsInIdleAllowedKey();
-    }
-TInt CEikSgcServer::ChangeIdleStateCallBack(TAny* aThis)
-    {
-    static_cast<CEikSgcServer*>(aThis)->DoChangeIdleState();
-    return EFalse;
-    }
-
-void CEikSgcServer::SetBackgroundAppsStateChangeDeferred(TBool aDeferred)
-    {
-    iBackgroundLayoutDeferred = aDeferred;
-    }
-
-TBool CEikSgcServer::BackgroundAppsStateChangeDeferred() const
-    {
-    return iBackgroundLayoutDeferred;
-    }
 //
 // CAknSgcServerImpl
 //