--- a/uifw/AknGlobalUI/AknCapServer/src/AknEikSgcs.cpp Tue Aug 31 15:28:30 2010 +0300
+++ b/uifw/AknGlobalUI/AknCapServer/src/AknEikSgcs.cpp Wed Sep 01 12:16:19 2010 +0100
@@ -26,6 +26,7 @@
#include <aknappui.h>
#include <e32property.h>
#include <UikonInternalPSKeys.h>
+#include <akncapserveralternatefsplugin.h>
#include <avkondomainpskeys.h>
#include <AknSettingCache.h>
#include "AknCapServerEntry.h"
@@ -50,11 +51,13 @@
#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
@@ -412,6 +415,8 @@
iLayoutNotifier = CEComPluginNotifier::NewL(KNullUid, callback);
iLayoutNotifier->Start();
EComPluginUtils::GetInfoArrayL(TUid::Uid(KCdlEComInterfaceId), iPrevPluginInfo);
+
+ iChangeIdleState = CPeriodic::NewL(CActive::EPriorityStandard);
}
TInt CEikSgcServer::LayoutInstallationCallBack(TAny* aPtr)
@@ -513,6 +518,7 @@
delete iWgStates;
delete iRemoveBlankCallBack;
delete iLayoutNotifier;
+ delete iChangeIdleState;
}
void CEikSgcServer::HandleWindowGroupListChangeL()
@@ -522,7 +528,7 @@
{
ReOrderWgStatesL(wgIds);
PostChangeRecalcL();
- UpdateNotificationsInIdleAllowedKey();
+ UpdateIdleState();
}
CleanupStack::PopAndDestroy( wgIds );
}
@@ -565,7 +571,7 @@
LOGTEXT1(" understandsPartialForegroundChanged: %d", understandsPartialForegroundChanged);
LOGTEXT1(" fullScreenChanged: %d", fullScreenChanged);
- UpdateNotificationsInIdleAllowedKey();
+ UpdateIdleState();
}
LOGTEXT0("CEikSgcServer::HandleWindowGroupParamChangeL - EXIT");
@@ -1020,9 +1026,15 @@
TInt modeIndex = mode.ModeNumber();
TBool blank = iLastScreenModeSet != -1;
- if (modeIndex != iLastScreenModeSet)
+
+ // 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 )
{
-
+ SetBackgroundAppsStateChangeDeferred( EFalse );
+
// Touch compatibility mode. Disable transition effects if compa-mode
// application becomes foreground. Restore back in opposite case.
if (iTouchCompaModeIf)
@@ -1046,8 +1058,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
@@ -1070,8 +1082,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();
@@ -1087,7 +1099,9 @@
iAvkonAppUiBase->SetLayoutAwareApp(!topState.IsLegacyLayout());
// Start callback for handling new layout
- if (newLayoutLoaded)
+ // 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)
{
// Swap the screen blanker to update the foreground app's layout
if (blank && iSetLayoutBlankStep < ESetLayoutBlankAfterScreenRotate)
@@ -1127,7 +1141,10 @@
// The callback will not remove the screen blanker,
// so remove it now.
iBlankCount--;
+
+#ifndef RD_NO_SYSTEM_SCREEN_BLANKING
iAknCapAppServerAppUi->BlankScreenL(EFalse);
+#endif
}
}
}
@@ -1140,7 +1157,9 @@
{
// 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
}
}
@@ -1308,74 +1327,74 @@
}
}
-void CEikSgcServer::UpdateNotificationsInIdleAllowedKey()
+TInt CEikSgcServer::ForegroundWgId()
{
// 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;
+ return EFalse;
}
-
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)
+ 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())
{
- 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++;
+ aFlag = EFalse;
}
-
+
// Update the P&S key only if the value has been changed.
- if ((iNotificationsInIdleAllowed && !result) || (!iNotificationsInIdleAllowed && result))
+ if ((iNotificationsInIdleAllowed && !aFlag)
+ || (!iNotificationsInIdleAllowed && aFlag))
{
- iNotificationsInIdleAllowed = result;
- RProperty::Set(KPSUidAvkonDomain, KAknNotificationsInIdleAllowed, result);
+ iNotificationsInIdleAllowed = aFlag;
+ RProperty::Set(KPSUidAvkonDomain, KAknNotificationsInIdleAllowed,aFlag);
}
- }
-
+ }
+
+void CEikSgcServer::UpdateNotificationsInIdleAllowedKey()
+ {
+ SetIdleState(IsIdleForeground());
+ }
TInt CEikSgcServer::RemoveBlankCallBack( TAny* aThis )
{
@@ -1388,7 +1407,9 @@
// remove any remaining screen blanker
for (; iRemoveBlankCount>0; iRemoveBlankCount--)
{
+#ifndef RD_NO_SYSTEM_SCREEN_BLANKING
TRAP_IGNORE( iAknCapAppServerAppUi->BlankScreenL( EFalse ) );
+#endif
}
iRemoveBlankCount = 0;
@@ -1493,7 +1514,46 @@
}
}
+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
//