204 EXPORT_C void CTsFswEngine::CloseAppL( TInt aWgId ) |
211 EXPORT_C void CTsFswEngine::CloseAppL( TInt aWgId ) |
205 { |
212 { |
206 TSLOG_CONTEXT( CloseAppL, TSLOG_LOCAL ); |
213 TSLOG_CONTEXT( CloseAppL, TSLOG_LOCAL ); |
207 TSLOG1_IN( "aWgId = %d", aWgId ); |
214 TSLOG1_IN( "aWgId = %d", aWgId ); |
208 |
215 |
209 if ( iWidgetsSupported && aWgId < 0 && iWidgetAppUiWgId ) |
216 if( iWidgetsSupported && 0 > aWgId ) |
210 { |
217 { |
211 // for widgets clients see a wgid that is -1*(index+1) |
218 // convert aWgId to an index in the list of running widgets and close widget |
212 const RWidgetInfoArray& arr( iWidgetList->RunningWidgets() ); |
219 CloseWidgetL( -aWgId -1 ); |
213 // convert aWgId to an index in the list of running widgets |
220 } |
214 TInt idx = -aWgId - 1; |
221 else if( !iAlwaysShownAppList->IsAlwaysShownApp( AppUidForWgIdL( aWgId ) ) ) |
215 // if index is valid then handle the widget specially |
|
216 if ( idx >= 0 && idx < arr.Count() ) |
|
217 { |
|
218 TWsEvent event; |
|
219 event.SetType( EEventUser ); |
|
220 TUint8* eventData = event.EventData(); |
|
221 // Fill bits 0-31 with widget application uid. |
|
222 reinterpret_cast<TUint32&>( *eventData ) = KWidgetAppUidValue; |
|
223 eventData += sizeof( TUint32 ); |
|
224 // Fill bits 32-63 with uid of the widget that should be closed. |
|
225 reinterpret_cast<TUint32&>( *eventData ) = arr[idx]->iUid.iUid; |
|
226 // Send the event to Widget AppUi. |
|
227 iEnv->WsSession().SendEventToWindowGroup( |
|
228 iWidgetAppUiWgId, event ); |
|
229 // closing a widget may not cause a window group change so trigger |
|
230 // the update manually |
|
231 UpdateTaskList(); |
|
232 TSLOG0_OUT( "widget processing finished" ); |
|
233 return; |
|
234 } |
|
235 } |
|
236 |
|
237 TUid appUid = AppUidForWgIdL( aWgId ); |
|
238 if ( !iAlwaysShownAppList->IsAlwaysShownApp( appUid ) ) |
|
239 { |
222 { |
240 // send window group event to kill the app |
223 // send window group event to kill the app |
241 TWsEvent event; |
224 TWsEvent event; |
242 event.SetTimeNow(); |
225 event.SetTimeNow(); |
243 event.SetType( KAknShutOrHideApp ); |
226 event.SetType( KAknShutOrHideApp ); |
244 iEnv->WsSession().SendEventToWindowGroup( aWgId, event ); |
227 iEnv->WsSession().SendEventToWindowGroup( aWgId, event ); |
245 TSLOG0( TSLOG_INFO, "event sent to wg" ); |
228 TSLOG0( TSLOG_INFO, "event sent to wg" ); |
246 } |
229 } |
247 |
|
248 TSLOG_OUT(); |
230 TSLOG_OUT(); |
249 } |
231 } |
250 |
232 |
251 // -------------------------------------------------------------------------- |
233 // -------------------------------------------------------------------------- |
252 // CTsFswEngine::SwitchToAppL |
234 // CTsFswEngine::SwitchToAppL |
458 // ignore uninteresting entries (e.g. embedded apps) |
440 // ignore uninteresting entries (e.g. embedded apps) |
459 if ( allWgIds[i].iParentId > 0 ) |
441 if ( allWgIds[i].iParentId > 0 ) |
460 { |
442 { |
461 continue; |
443 continue; |
462 } |
444 } |
463 |
445 |
464 // get window group name |
446 // get window group name |
465 TInt wgId = allWgIds[i].iId; |
447 TInt wgId = allWgIds[i].iId; |
466 CApaWindowGroupName* windowName = |
448 CApaWindowGroupName* windowName = |
467 CApaWindowGroupName::NewLC( iWsSession, wgId ); |
449 CApaWindowGroupName::NewLC( iWsSession, wgId ); |
468 TUid appUid = windowName->AppUid(); |
450 TUid appUid = windowName->AppUid(); |
469 |
451 |
470 // ignore entries with null uid |
452 // ignore entries with null uid |
471 if ( !appUid.iUid ) |
453 if ( !appUid.iUid ) |
472 { |
454 { |
473 CleanupStack::PopAndDestroy( windowName ); |
455 CleanupStack::PopAndDestroy( windowName ); |
474 continue; |
456 continue; |
475 } |
457 } |
476 |
458 |
477 // will append the task to our own list only if it is not hidden |
459 // will append the task to our own list only if it is not hidden |
478 TBool onHiddenList = iHiddenAppList->IsHiddenL( |
460 TBool onHiddenList = iHiddenAppList->IsHiddenL( |
479 appUid, iWsSession, wgId ); |
461 appUid, iWsSession, wgId ); |
480 |
|
481 // if this is the widget app then save wgid for later use |
|
482 // and ignore it, but include running widgets instead |
|
483 if ( iWidgetsSupported && appUid.iUid == KWidgetAppUidValue ) |
|
484 { |
|
485 iWidgetAppUiWgId = wgId; |
|
486 onHiddenList = ETrue; |
|
487 CheckWidgetsL( newList ); |
|
488 } |
|
489 |
462 |
490 // get screen number (-1=console, 0=main screen, 1=cover ui) |
463 // get screen number (-1=console, 0=main screen, 1=cover ui) |
491 TInt appScreen = 0; |
464 TInt appScreen = 0; |
492 TInt scrNumErr = iAppArcSession.GetDefaultScreenNumber( appScreen, appUid ); |
465 TInt scrNumErr = iAppArcSession.GetDefaultScreenNumber( appScreen, appUid ); |
493 |
466 |
500 appUid.iUid, &captionDbg ); |
473 appUid.iUid, &captionDbg ); |
501 TSLOG4( TSLOG_INFO, "hidden=%d onhiddenlist=%d mustshow=%d scrno=%d", |
474 TSLOG4( TSLOG_INFO, "hidden=%d onhiddenlist=%d mustshow=%d scrno=%d", |
502 windowName->Hidden(), onHiddenList, mustShow, appScreen ); |
475 windowName->Hidden(), onHiddenList, mustShow, appScreen ); |
503 #endif |
476 #endif |
504 |
477 |
|
478 // if this is the widget app then save wgid for later use |
|
479 // and ignore it, but include running widgets instead |
|
480 if ( iWidgetsSupported && appUid.iUid == KWidgetAppUidValue ) |
|
481 { |
|
482 changed = ETrue; |
|
483 } |
505 // add item to task list if it is always-shown OR it is not hidden |
484 // add item to task list if it is always-shown OR it is not hidden |
506 // and it is not on cover ui |
485 // and it is not on cover ui |
507 if ( mustShow |
486 else if ( mustShow |
508 || ( !onHiddenList |
487 || ( !onHiddenList |
509 && !windowName->Hidden() |
488 && !windowName->Hidden() |
510 && ( appScreen == 0 || appScreen == -1 ) |
489 && ( appScreen == 0 || appScreen == -1 ) |
511 && scrNumErr == KErrNone ) ) |
490 && scrNumErr == KErrNone ) ) |
512 { |
491 { |
626 // CTsFswEngine::CheckWidgetsL |
606 // CTsFswEngine::CheckWidgetsL |
627 // -------------------------------------------------------------------------- |
607 // -------------------------------------------------------------------------- |
628 // |
608 // |
629 void CTsFswEngine::CheckWidgetsL( RTsFswArray& aNewList ) |
609 void CTsFswEngine::CheckWidgetsL( RTsFswArray& aNewList ) |
630 { |
610 { |
631 if ( iWidgetsSupported ) |
611 if( iWidgetsSupported ) |
632 { |
612 { |
633 iWidgetList->InitializeWidgetListL(); |
613 iWidgetList->InitializeWidgetListL(); |
634 const RWidgetInfoArray& arr( iWidgetList->RunningWidgets() ); |
614 const RWidgetInfoArray& arr( iWidgetList->RunningWidgets() ); |
635 for ( TInt i = 0, ie = arr.Count(); i != ie; ++i ) |
615 for ( TInt i = 0, ie = arr.Count(); i != ie; ++i ) |
636 { |
616 { |
637 // wgid will be a special negative value |
617 //verify if widget is working in full screen mode |
638 // windowgroupname is not needed here so pass NULL |
618 if( arr[i]->iFileSize ) |
639 AddEntryL( -(i+1), arr[i]->iUid, 0, aNewList, ETrue ); |
619 { |
|
620 // wgid will be a special negative value |
|
621 // windowgroupname is not needed here so pass NULL |
|
622 AddEntryL( -(i+1), arr[i]->iUid, 0, aNewList, ETrue ); |
|
623 } |
640 } |
624 } |
641 } |
625 } |
642 } |
626 } |
643 |
627 |
644 // -------------------------------------------------------------------------- |
628 // -------------------------------------------------------------------------- |
695 // CTsFswEngine::FindMostTopParentWgId |
679 // CTsFswEngine::FindMostTopParentWgId |
696 // -------------------------------------------------------------------------- |
680 // -------------------------------------------------------------------------- |
697 // |
681 // |
698 TInt CTsFswEngine::FindMostTopParentWgId( TInt aWgId ) |
682 TInt CTsFswEngine::FindMostTopParentWgId( TInt aWgId ) |
699 { |
683 { |
700 TInt parent( KErrNotFound ); |
684 TInt parent( KErrNotFound ); |
701 parent = FindParentWgId( aWgId ); |
685 parent = FindParentWgId( aWgId ); |
702 if( parent != KErrNotFound) |
686 if( parent != KErrNotFound) |
703 { |
687 { |
704 TInt topParent = FindMostTopParentWgId(parent); |
688 TInt topParent = FindMostTopParentWgId(parent); |
705 if( topParent != KErrNotFound ) |
689 if( topParent != KErrNotFound ) |
706 { |
690 { |
707 parent = topParent; |
691 parent = topParent; |
708 } |
692 } |
709 } |
693 } |
710 return parent; |
694 return parent; |
711 } |
695 } |
712 |
696 |
713 // -------------------------------------------------------------------------- |
697 // -------------------------------------------------------------------------- |
714 // CTsFswEngine::FindAppNameLC |
698 // CTsFswEngine::FindAppNameLC |
914 AssignScreenshotHandle( aWgId, 0 ); |
898 AssignScreenshotHandle( aWgId, 0 ); |
915 } |
899 } |
916 |
900 |
917 TSLOG_OUT(); |
901 TSLOG_OUT(); |
918 } |
902 } |
|
903 |
|
904 // -------------------------------------------------------------------------- |
|
905 // CTsFswEngine::HandleFswPpApplicationBitmapRotation |
|
906 // Callback from CTsFastSwapPreviewProvider |
|
907 // -------------------------------------------------------------------------- |
|
908 // |
|
909 void CTsFswEngine::HandleFswPpApplicationBitmapRotation( TInt aWgId, TBool aClockwise ) |
|
910 { |
|
911 TSLOG_CONTEXT( HandleFswPpApplicationBitmapRotation, TSLOG_LOCAL ); |
|
912 TSLOG1_IN( "aWgId = %d", aWgId ); |
|
913 |
|
914 CFbsBitmap** bmp = iScreenshots.Find( aWgId ); |
|
915 if ( bmp ) |
|
916 { |
|
917 // Rotate bitmap |
|
918 TRAP_IGNORE( RotateL( **bmp, aWgId, aClockwise ) ); |
|
919 // Bitmap in a array is invalid, remove it |
|
920 delete *bmp; |
|
921 iScreenshots.Remove( aWgId ); |
|
922 AssignScreenshotHandle( aWgId, 0 ); |
|
923 } |
|
924 |
|
925 TSLOG_OUT(); |
|
926 } |
|
927 |
|
928 |
|
929 // -------------------------------------------------------------------------- |
|
930 // CTsFswEngine::RotateL |
|
931 // Callback from CTsFastSwapPreviewProvider |
|
932 // -------------------------------------------------------------------------- |
|
933 // |
|
934 void CTsFswEngine::RotateL( CFbsBitmap& aBitmap, TInt aWgId, TBool aClockwise ) |
|
935 { |
|
936 CFbsBitmap* rotaBitmap = new (ELeave) CFbsBitmap; |
|
937 CleanupStack::PushL( rotaBitmap ); |
|
938 User::LeaveIfError( rotaBitmap->Duplicate( aBitmap.Handle() ) ); |
|
939 CTsRotationTask* rotaTask = new (ELeave) CTsRotationTask( *this ); |
|
940 CleanupStack::PushL( rotaTask ); |
|
941 User::LeaveIfError( iRotaTasks.Append( rotaTask ) ); |
|
942 rotaTask->StartLD( aWgId, rotaBitmap, aClockwise ); // ownership transferred |
|
943 CleanupStack::Pop( rotaTask ); |
|
944 CleanupStack::Pop( rotaBitmap ); |
|
945 } |
|
946 |
|
947 |
|
948 // -------------------------------------------------------------------------- |
|
949 // CTsFswEngine::RotationComplete |
|
950 // Callback from CTsFastSwapPreviewProvider |
|
951 // -------------------------------------------------------------------------- |
|
952 // |
|
953 void CTsFswEngine::RotationComplete( TInt aWgId, |
|
954 CFbsBitmap* aBitmap, |
|
955 CTsRotationTask* aCompletedTask, |
|
956 TInt aError ) |
|
957 { |
|
958 TSLOG_CONTEXT( RotationComplete, TSLOG_LOCAL ); |
|
959 TSLOG_IN(); |
|
960 |
|
961 TSLOG1( TSLOG_INFO, "---> rotation completed with status: %d", aError ); |
|
962 TInt idx = iRotaTasks.Find( aCompletedTask ); |
|
963 if ( idx != KErrNotFound ) |
|
964 { |
|
965 // Update task list |
|
966 iRotaTasks.Remove(idx); |
|
967 } |
|
968 |
|
969 if ( aError == KErrNone ) |
|
970 { |
|
971 if ( iScreenshots.Insert( aWgId, aBitmap ) != KErrNone ) |
|
972 { |
|
973 delete aBitmap; |
|
974 iScreenshots.Remove( aWgId ); |
|
975 AssignScreenshotHandle( aWgId, 0 ); |
|
976 } |
|
977 else |
|
978 { |
|
979 AssignScreenshotHandle( aWgId, aBitmap->Handle() ); |
|
980 } |
|
981 } |
|
982 else |
|
983 { |
|
984 // Rotation failed, cleanup bitmap |
|
985 delete aBitmap; |
|
986 } |
|
987 |
|
988 TSLOG_OUT(); |
|
989 } |
|
990 |
919 |
991 |
920 // -------------------------------------------------------------------------- |
992 // -------------------------------------------------------------------------- |
921 // CTsFswEngine::AssignScreenshotHandle |
993 // CTsFswEngine::AssignScreenshotHandle |
922 // Called when a screenshot arrives to check if there is a corresponding |
994 // Called when a screenshot arrives to check if there is a corresponding |
923 // application in the task list. Firstly try to match screenshot into parental |
995 // application in the task list. Firstly try to match screenshot into parental |
1078 TSize( screenSize.iWidth / KScreenSizeFactor, |
1150 TSize( screenSize.iWidth / KScreenSizeFactor, |
1079 screenSize.iHeight / KScreenSizeFactor ), |
1151 screenSize.iHeight / KScreenSizeFactor ), |
1080 EColor64K ); // displaymode is ignored |
1152 EColor64K ); // displaymode is ignored |
1081 } |
1153 } |
1082 |
1154 |
|
1155 // -------------------------------------------------------------------------- |
|
1156 // CTsFswEngine::CloseWidgetL |
|
1157 // -------------------------------------------------------------------------- |
|
1158 // |
|
1159 void CTsFswEngine::CloseWidgetL(TInt aOffset ) |
|
1160 { |
|
1161 TSLOG_CONTEXT( CloseWidgetL, TSLOG_LOCAL ); |
|
1162 TSLOG1_IN( "aOffset = %d", aOffset ); |
|
1163 if( iWidgetList->RunningWidgets().Count() <= aOffset ) |
|
1164 { |
|
1165 User::Leave(KErrArgument); |
|
1166 } |
|
1167 const CWidgetInfo* widgetInfo(iWidgetList->RunningWidgets()[aOffset]); |
|
1168 const TPtrC bundleName(*widgetInfo->iBundleName); |
|
1169 RApaLsSession ls; |
|
1170 User::LeaveIfError( ls.Connect() ); |
|
1171 CleanupClosePushL( ls ); |
|
1172 CApaCommandLine* const cmdLine = CApaCommandLine::NewLC(); |
|
1173 |
|
1174 HBufC8* const |
|
1175 opaque( HBufC8::NewLC( bundleName.Size() + 3 * sizeof( TUint32 ) ) ); |
|
1176 TPtr8 des ( opaque->Des() ); |
|
1177 RDesWriteStream stream; |
|
1178 stream.Open( des ); |
|
1179 CleanupClosePushL( stream ); |
|
1180 stream.WriteUint32L ( widgetInfo->iUid.iUid ); |
|
1181 stream.WriteUint32L ( bundleName.Length() ); |
|
1182 stream.WriteL ( reinterpret_cast< const TUint8* >( bundleName.Ptr() ), bundleName.Size()); |
|
1183 stream.WriteInt32L ( KCloseWidgetCmd ); |
|
1184 CleanupStack::PopAndDestroy( &stream ); |
|
1185 cmdLine->SetCommandL( EApaCommandBackgroundAndWithoutViews ); |
|
1186 cmdLine->SetOpaqueDataL( *opaque ); |
|
1187 CleanupStack::PopAndDestroy( opaque ); |
|
1188 cmdLine->SetExecutableNameL( KWidgetAppName ); |
|
1189 ls.StartApp( *cmdLine ); |
|
1190 CleanupStack::PopAndDestroy( cmdLine ); |
|
1191 CleanupStack::PopAndDestroy( &ls ); |
|
1192 TSLOG_OUT(); |
|
1193 } |
|
1194 |
|
1195 |
|
1196 |
|
1197 // -------------------------------------------------------------------------- |
|
1198 // CTsRotationListener::CTsRotationListener |
|
1199 // -------------------------------------------------------------------------- |
|
1200 // |
|
1201 CTsRotationTask::CTsRotationTask(CTsFswEngine& aEngine ) |
|
1202 : CActive(EPriorityStandard), |
|
1203 iEngine(aEngine) |
|
1204 { |
|
1205 CActiveScheduler::Add( this ); |
|
1206 } |
|
1207 |
|
1208 |
|
1209 // -------------------------------------------------------------------------- |
|
1210 // CTsRotationListener::~CTsRotationListener |
|
1211 // -------------------------------------------------------------------------- |
|
1212 // |
|
1213 CTsRotationTask::~CTsRotationTask() |
|
1214 { |
|
1215 Cancel(); |
|
1216 delete iRotator; |
|
1217 delete iBitmap; |
|
1218 } |
|
1219 |
|
1220 |
|
1221 // -------------------------------------------------------------------------- |
|
1222 // CTsRotationListener::Start |
|
1223 // -------------------------------------------------------------------------- |
|
1224 // |
|
1225 void CTsRotationTask::StartLD( TInt aWgId, |
|
1226 CFbsBitmap* aBitmap, |
|
1227 TBool aClockwise ) |
|
1228 { |
|
1229 TSLOG_CONTEXT( StartLD, TSLOG_LOCAL ); |
|
1230 TSLOG_IN(); |
|
1231 |
|
1232 iWgId = aWgId; |
|
1233 iBitmap = aBitmap; |
|
1234 iRotator = CBitmapRotator::NewL(); |
|
1235 if ( aClockwise ) |
|
1236 { |
|
1237 iRotator->Rotate(&iStatus, *iBitmap, CBitmapRotator::ERotation90DegreesClockwise); |
|
1238 } |
|
1239 else |
|
1240 { |
|
1241 iRotator->Rotate(&iStatus, *iBitmap, CBitmapRotator::ERotation270DegreesClockwise); |
|
1242 } |
|
1243 SetActive(); |
|
1244 |
|
1245 TSLOG_OUT(); |
|
1246 } |
|
1247 |
|
1248 |
|
1249 // -------------------------------------------------------------------------- |
|
1250 // CTsRotationListener::RunL |
|
1251 // -------------------------------------------------------------------------- |
|
1252 // |
|
1253 void CTsRotationTask::RunL() |
|
1254 { |
|
1255 iEngine.RotationComplete( iWgId, iBitmap, this, iStatus.Int() ); // bitmap ownership transferred |
|
1256 iBitmap = NULL; |
|
1257 delete this; |
|
1258 } |
|
1259 |
|
1260 |
|
1261 // -------------------------------------------------------------------------- |
|
1262 // CTsRotationListener::DoCancel |
|
1263 // -------------------------------------------------------------------------- |
|
1264 // |
|
1265 void CTsRotationTask::DoCancel() |
|
1266 { |
|
1267 iRotator->Cancel(); |
|
1268 } |
1083 |
1269 |
1084 // end of file |
1270 // end of file |