48 #endif |
48 #endif |
49 |
49 |
50 #include <LayoutPack.cdl.h> |
50 #include <LayoutPack.cdl.h> |
51 #include <CdlRefs.h> |
51 #include <CdlRefs.h> |
52 const TInt KCdlEComInterfaceId = 0x101f8243; |
52 const TInt KCdlEComInterfaceId = 0x101f8243; |
|
53 const TInt KMatrixMenuAppId = 0x101F4CD2; |
53 |
54 |
54 const TInt KLayoutChangeTimeout = 2000000; // 2s |
55 const TInt KLayoutChangeTimeout = 2000000; // 2s |
55 const TInt KWgStatesGranularity = 4; |
56 const TInt KWgStatesGranularity = 4; |
56 const TInt KRelinquishedThreadListGranularity = 4; |
57 const TInt KRelinquishedThreadListGranularity = 4; |
57 const TInt KRemoveBlankDelay = 200000; // 0.2s |
58 const TInt KRemoveBlankDelay = 200000; // 0.2s |
|
59 const TInt KChangeIdleStateDelay = 200000; // 0.2s |
58 // Drawing is slower when transparency is enabled. The time needs to be |
60 // Drawing is slower when transparency is enabled. The time needs to be |
59 // big enough to account for slowest drawing application. |
61 // big enough to account for slowest drawing application. |
60 const TInt KRemoveBlankDelayTransparency = 1500000; // 1.5s |
62 const TInt KRemoveBlankDelayTransparency = 1500000; // 1.5s |
61 |
63 |
62 // 4s should be enough for foreground app's operations to complete. |
64 // 4s should be enough for foreground app's operations to complete. |
511 delete iWinChange; |
515 delete iWinChange; |
512 delete iLayoutChangeCallBack; |
516 delete iLayoutChangeCallBack; |
513 delete iWgStates; |
517 delete iWgStates; |
514 delete iRemoveBlankCallBack; |
518 delete iRemoveBlankCallBack; |
515 delete iLayoutNotifier; |
519 delete iLayoutNotifier; |
|
520 delete iChangeIdleState; |
516 } |
521 } |
517 |
522 |
518 void CEikSgcServer::HandleWindowGroupListChangeL() |
523 void CEikSgcServer::HandleWindowGroupListChangeL() |
519 { |
524 { |
520 CWgIds* wgIds = CreateWgIdListLC(); |
525 CWgIds* wgIds = CreateWgIdListLC(); |
521 if (!TestWgListOrderOk(wgIds)) |
526 if (!TestWgListOrderOk(wgIds)) |
522 { |
527 { |
523 ReOrderWgStatesL(wgIds); |
528 ReOrderWgStatesL(wgIds); |
524 PostChangeRecalcL(); |
529 PostChangeRecalcL(); |
525 UpdateNotificationsInIdleAllowedKey(); |
530 UpdateIdleState(); |
526 } |
531 } |
527 CleanupStack::PopAndDestroy( wgIds ); |
532 CleanupStack::PopAndDestroy( wgIds ); |
528 } |
533 } |
529 |
534 |
530 void CEikSgcServer::HandleWindowGroupParamChangeL(TInt aWgId, TBitFlags aAppFlags, TInt aSpLayout, |
535 void CEikSgcServer::HandleWindowGroupParamChangeL(TInt aWgId, TBitFlags aAppFlags, TInt aSpLayout, |
1306 event.SetHandle(0); |
1311 event.SetHandle(0); |
1307 eikEnv->WsSession().SendEventToAllWindowGroups( 0, event ); |
1312 eikEnv->WsSession().SendEventToAllWindowGroups( 0, event ); |
1308 } |
1313 } |
1309 } |
1314 } |
1310 |
1315 |
1311 void CEikSgcServer::UpdateNotificationsInIdleAllowedKey() |
1316 TInt CEikSgcServer::ForegroundWgId() |
1312 { |
1317 { |
1313 // First, get screensaver window group identifier. |
1318 // First, get screensaver window group identifier. |
1314 TApaTaskList taskList(CEikonEnv::Static()->WsSession()); |
1319 TApaTaskList taskList(CEikonEnv::Static()->WsSession()); |
1315 const TApaTask screensaverTask = taskList.FindApp(KScreensaverAppUid); |
1320 const TApaTask screensaverTask = taskList.FindApp(KScreensaverAppUid); |
1316 const TInt screensaverWgId = screensaverTask.WgId(); |
1321 const TInt screensaverWgId = screensaverTask.WgId(); |
1317 |
1322 |
|
1323 const TInt wgCount = iWgStates->Count(); |
|
1324 TInt ii = FocusWgIndex(); |
|
1325 |
|
1326 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("======================================"); |
|
1327 |
|
1328 // Loops window groups from top to bottom, starting from focus window group. |
|
1329 // (Index 0 contains the foreground window group.) |
|
1330 while (ii < wgCount) |
|
1331 { |
|
1332 const TWgState& state = iWgStates->At(ii); |
|
1333 const TInt currentWgId = state.WgId(); |
|
1334 |
|
1335 LOGTEXT0("\n");LOGTEXT1(" Window group id: %d", currentWgId);LOGTEXT1(" UnderstandsPartialForeground: %d", state.UnderstandsPartialForeground());LOGTEXT1(" IsFullScreen: %d", state.IsFullScreen()); |
|
1336 |
|
1337 // Ignores non-application window groups (e.g. incall bubble), partial screen |
|
1338 // applications and screensaver. |
|
1339 if (state.UnderstandsPartialForeground() && state.IsFullScreen() |
|
1340 && currentWgId != screensaverWgId) |
|
1341 { |
|
1342 return currentWgId; |
|
1343 } |
|
1344 ++ii; |
|
1345 } |
|
1346 return KErrNotFound; |
|
1347 } |
|
1348 |
|
1349 TBool CEikSgcServer::IsIdleForeground() |
|
1350 { |
|
1351 TApaTaskList taskList(CEikonEnv::Static()->WsSession()); |
1318 // Get also idle window group identifier. |
1352 // Get also idle window group identifier. |
1319 TVwsViewId idleView; |
1353 TVwsViewId idleView; |
1320 if (AknDef::GetPhoneIdleViewId(idleView) != KErrNone) |
1354 if (AknDef::GetPhoneIdleViewId(idleView) != KErrNone) |
1321 { |
1355 { |
1322 return; |
1356 return EFalse; |
1323 } |
1357 } |
1324 |
|
1325 const TApaTask idleTask = taskList.FindApp(idleView.iAppUid); |
1358 const TApaTask idleTask = taskList.FindApp(idleView.iAppUid); |
1326 const TInt idleWgId = idleTask.WgId(); |
1359 return (idleTask.WgId() == ForegroundWgId()); |
1327 |
1360 } |
1328 // Then go through window groups skipping partial apps and screensaver - |
1361 |
1329 // check if idleWgId follows. |
1362 void CEikSgcServer::SetIdleState(TBool aFlag) |
1330 TBool result = EFalse; |
1363 { |
1331 TBool found = EFalse; |
|
1332 const TInt wgCount = iWgStates->Count(); |
|
1333 TInt ii = FocusWgIndex(); |
|
1334 |
|
1335 LOGTEXT0("======================================"); |
|
1336 LOGTEXT1("Window groups: %d", wgCount); |
|
1337 LOGTEXT1("Idle wg id: %d", idleWgId); |
|
1338 LOGTEXT1("Screensaver wg id: %d", screensaverWgId); |
|
1339 LOGTEXT1("Focus window group: %d", ii); |
|
1340 LOGTEXT0("======================================"); |
|
1341 |
|
1342 // Loops window groups from top to bottom, starting from focus window group. |
|
1343 // (Index 0 contains the foreground window group.) |
|
1344 while (ii < wgCount && !found) |
|
1345 { |
|
1346 const TWgState& state = iWgStates->At(ii); |
|
1347 const TInt currentWgId = state.WgId(); |
|
1348 |
|
1349 LOGTEXT0("\n"); |
|
1350 LOGTEXT1(" Window group id: %d", currentWgId); |
|
1351 LOGTEXT1(" UnderstandsPartialForeground: %d", state.UnderstandsPartialForeground()); |
|
1352 LOGTEXT1(" IsFullScreen: %d", state.IsFullScreen()); |
|
1353 |
|
1354 // Ignores non-application window groups (e.g. incall bubble), partial screen |
|
1355 // applications and screensaver. |
|
1356 if (state.UnderstandsPartialForeground() && |
|
1357 state.IsFullScreen() && |
|
1358 currentWgId != screensaverWgId) |
|
1359 { |
|
1360 // Check if current app is idle. |
|
1361 result = (idleWgId == currentWgId); |
|
1362 found = ETrue; |
|
1363 |
|
1364 LOGTEXT0("\n"); |
|
1365 LOGTEXT1("Window group found. Result: %d", result); |
|
1366 } |
|
1367 |
|
1368 ii++; |
|
1369 } |
|
1370 |
|
1371 // Update the P&S key only if the value has been changed. |
1364 // Update the P&S key only if the value has been changed. |
1372 if ((iNotificationsInIdleAllowed && !result) || (!iNotificationsInIdleAllowed && result)) |
1365 if ((iNotificationsInIdleAllowed && !aFlag) |
1373 { |
1366 || (!iNotificationsInIdleAllowed && aFlag)) |
1374 iNotificationsInIdleAllowed = result; |
1367 { |
1375 RProperty::Set(KPSUidAvkonDomain, KAknNotificationsInIdleAllowed, result); |
1368 iNotificationsInIdleAllowed = aFlag; |
1376 } |
1369 RProperty::Set(KPSUidAvkonDomain, KAknNotificationsInIdleAllowed,aFlag); |
1377 } |
1370 } |
1378 |
1371 } |
|
1372 |
|
1373 void CEikSgcServer::UpdateNotificationsInIdleAllowedKey() |
|
1374 { |
|
1375 SetIdleState(IsIdleForeground()); |
|
1376 } |
1379 |
1377 |
1380 TInt CEikSgcServer::RemoveBlankCallBack( TAny* aThis ) |
1378 TInt CEikSgcServer::RemoveBlankCallBack( TAny* aThis ) |
1381 { |
1379 { |
1382 static_cast<CEikSgcServer*>( aThis )->DoRemoveBlank(); |
1380 static_cast<CEikSgcServer*>( aThis )->DoRemoveBlank(); |
1383 return EFalse; |
1381 return EFalse; |