806 // Initiliaze global data in TLS and open global module testing chunk and mutex |
802 // Initiliaze global data in TLS and open global module testing chunk and mutex |
807 User::LeaveIfError(Dll::SetTls(new(ELeave) CAlfModuleTestDataControl())); |
803 User::LeaveIfError(Dll::SetTls(new(ELeave) CAlfModuleTestDataControl())); |
808 User::LeaveIfError(AMT_CONTROL()->OpenGlobalObjects()); |
804 User::LeaveIfError(AMT_CONTROL()->OpenGlobalObjects()); |
809 #endif |
805 #endif |
810 |
806 |
811 TInt flags = EStandardApp|ENoScreenFurniture|ENonStandardResourceFile|EAknEnableSkin; |
|
812 CCoeEnv* coe = CCoeEnv::Static(); |
|
813 iData = new (ELeave) CAlfAppUiData(); |
807 iData = new (ELeave) CAlfAppUiData(); |
814 |
808 |
815 iData->iSettingsHandler = CAlfSrvSettingsHandler::NewL( *this ); |
809 iData->iSettingsHandler = CAlfSrvSettingsHandler::NewL( *this ); |
816 CreateHuiEnvL(); |
810 CreateHuiEnvL(); |
817 |
811 |
818 if (coe) |
812 iData->iServer = CAlfAppServer::NewAppServerL(); |
819 { |
|
820 // initialize app basic services |
|
821 CAknAppUi::BaseConstructL(flags); |
|
822 |
|
823 // create direct pointer to server so no need to access coestatics whenever server needed |
|
824 iData->iServer = static_cast<CAlfAppServer*>(static_cast<CEikonEnv*>(coe)->AppServer()); |
|
825 } |
|
826 else |
|
827 { |
|
828 iData->iServer = CAlfAppServer::NewAppServerL(); |
|
829 } |
|
830 |
813 |
831 iData->iServer->SetAppUi(this); |
814 iData->iServer->SetAppUi(this); |
832 |
815 |
833 RWindowGroup& mainWg = *CHuiStatic::RootWin(); |
816 RWindowGroup& mainWg = *CHuiStatic::RootWin(); |
834 // to non-focusing |
817 // to non-focusing |
836 // disable pointer events based autoforwarding |
819 // disable pointer events based autoforwarding |
837 mainWg.AutoForeground(EFalse); |
820 mainWg.AutoForeground(EFalse); |
838 mainWg.SetOrdinalPosition(-1,ECoeWinPriorityNeverAtFront); |
821 mainWg.SetOrdinalPosition(-1,ECoeWinPriorityNeverAtFront); |
839 |
822 |
840 |
823 |
841 if (!coe) // multiple screen support missing, for main display only atm |
824 TUid appUid = TUid::Uid(KAlfAppServerInterfaceUid3); |
842 { |
825 // complete server construction |
843 TUid appUid = TUid::Uid(KAlfAppServerInterfaceUid3); |
826 TName serverName; |
844 // complete server construction |
827 _LIT(KServerNameFormat, "%08x_%08x_AppServer"); |
845 TName serverName; |
828 serverName.Format( |
846 _LIT(KServerNameFormat, "%08x_%08x_AppServer"); |
|
847 serverName.Format( |
|
848 KServerNameFormat, |
829 KServerNameFormat, |
849 appUid, |
830 appUid, |
850 appUid.iUid ); |
831 appUid.iUid ); |
851 |
832 |
852 iData->iServer->ConstructL(serverName); |
833 iData->iServer->ConstructL(serverName); |
853 |
834 |
854 // parametrize our window group |
835 // parametrize our window group |
855 CApaWindowGroupName* wgName = CApaWindowGroupName::NewLC(CHuiStatic::WsSession()); |
836 CApaWindowGroupName* wgName = CApaWindowGroupName::NewLC(CHuiStatic::WsSession()); |
856 wgName->SetHidden(ETrue); // hides us from FSW and protects us from OOM FW etc. |
837 wgName->SetHidden(ETrue); // hides us from FSW and protects us from OOM FW etc. |
857 wgName->SetSystem(ETrue); // Allow only application with PowerManagement cap to shut us down |
838 wgName->SetSystem(ETrue); // Allow only application with PowerManagement cap to shut us down |
858 wgName->SetCaptionL(_L("ALF")); |
839 wgName->SetCaptionL(_L("ALF")); |
859 wgName->SetAppUid(appUid); |
840 wgName->SetAppUid(appUid); |
860 wgName->SetWindowGroupName(mainWg); |
841 wgName->SetWindowGroupName(mainWg); |
861 CleanupStack::PopAndDestroy(); |
842 CleanupStack::PopAndDestroy(); |
862 } |
|
863 // misc settings for surroundings |
|
864 if (coe) |
|
865 { // we ndon't need these in NGA |
|
866 mainWg.EnableFocusChangeEvents(); |
|
867 } |
|
868 |
|
869 CHuiStatic::WsSession().ComputeMode(RWsSession::EPriorityControlDisabled); |
843 CHuiStatic::WsSession().ComputeMode(RWsSession::EPriorityControlDisabled); |
870 |
844 |
871 RThread thread; |
845 RThread thread; |
872 thread.SetPriority(EPriorityAbsoluteForeground); |
846 thread.SetPriority(EPriorityAbsoluteForeground); |
873 |
847 |
874 // delegates.. |
848 // delegates.. |
875 iData->iResourceManager = CAlfSrvResourceManager::NewL( *iData->iHuiEnv ); |
849 iData->iResourceManager = CAlfSrvResourceManager::NewL( *iData->iHuiEnv ); |
876 |
850 |
877 if (coe) |
851 CHuiStatic::WsSession().EnableWindowSizeCacheL(); |
878 { |
852 iData->iPlainWindow = new (ELeave) RWindow(CHuiStatic::WsSession()); |
879 iData->iSharedWindow = new (ELeave) CAlfSharedDisplayCoeControl(); |
853 iData->iPlainWindow->Construct(*CHuiStatic::RootWin(),0x000FAB10); // FYI: multiple display support neglegted atm |
880 iData->iSharedWindow->ConstructL(); |
854 iData->iPlainWindow->SetExtentErr(TPoint(0,0),CHuiStatic::ScreenDevice()->SizeInPixels()); // FYI: multiple display support neglegted atm |
881 iData->iSharedWindow->DrawableWindow()->EnableVisibilityChangeEvents(); |
855 iData->iPlainWindow->Size(); // to populate size cache |
882 } |
856 iData->iPlainWindow->Activate(); |
883 else |
857 iData->iPlainWindow->SetVisible(ETrue); |
884 { |
858 iData->iPlainWindow->SetTransparencyAlphaChannel(); |
885 //mainWg.EnableScreenChangeEvents(); |
859 iData->iPlainWindow->SetBackgroundColor(~0); |
886 |
|
887 CHuiStatic::WsSession().EnableWindowSizeCacheL(); |
|
888 iData->iPlainWindow = new (ELeave) RWindow(CHuiStatic::WsSession()); |
|
889 iData->iPlainWindow->Construct(*CHuiStatic::RootWin(),0x000FAB10); // FYI: multiple display support neglegted atm |
|
890 iData->iPlainWindow->SetExtentErr(TPoint(0,0),CHuiStatic::ScreenDevice()->SizeInPixels()); // FYI: multiple display support neglegted atm |
|
891 iData->iPlainWindow->Size(); // to populate size cache |
|
892 iData->iPlainWindow->Activate(); |
|
893 iData->iPlainWindow->SetVisible(ETrue); |
|
894 iData->iPlainWindow->SetTransparencyAlphaChannel(); |
|
895 iData->iPlainWindow->SetBackgroundColor(~0); |
|
896 } |
|
897 |
860 |
898 iData->iBridge = CAlfStreamerBridge::NewL(0); |
861 iData->iBridge = CAlfStreamerBridge::NewL(0); |
899 iData->iBridge->iAlfWindowData.iAlfWindowGrpId = mainWg.Identifier(); |
862 iData->iBridge->iAlfWindowData.iAlfWindowGrpId = mainWg.Identifier(); |
900 iData->iBridge->iAlfWindowData.iAlfWindowHandle = iData->iPlainWindow->ClientHandle(); |
863 iData->iBridge->iAlfWindowData.iAlfWindowHandle = iData->iPlainWindow->ClientHandle(); |
901 iData->iBridge->iAlfWindowData.iScreenNumber = 0; // TBD multiple screen support |
864 iData->iBridge->iAlfWindowData.iScreenNumber = 0; // TBD multiple screen support |
906 iData->iBridge->SetObserver(iData->iBridgeObj); |
869 iData->iBridge->SetObserver(iData->iBridgeObj); |
907 |
870 |
908 iData->iAlfEffectObserver = new (ELeave) TAlfEffectObserver(&iData->iBridge->iActiveEffectCount, *iData->iBridgeObj); |
871 iData->iAlfEffectObserver = new (ELeave) TAlfEffectObserver(&iData->iBridge->iActiveEffectCount, *iData->iBridgeObj); |
909 iData->iHuiEnv->EffectsEngine()->SetObserver(iData->iAlfEffectObserver); |
872 iData->iHuiEnv->EffectsEngine()->SetObserver(iData->iAlfEffectObserver); |
910 |
873 |
911 if( !iData->iPlainWindow) |
874 iData->iBridgeObj->AddNewScreenFromWindowL(iData->iPlainWindow); |
912 { |
875 iData->iEventAo = new (ELeave) CAlfEventBridge(*this, *iData->iBridgeObj->Display(0)); |
913 // Create default CAlfScreen already now to be able to show controlgroups early enough... |
876 |
914 iData->iBridgeObj->AddNewScreenL(iData->iSharedWindow); |
877 RThread eventThread; |
915 } |
878 |
916 else |
879 User::LeaveIfError(eventThread.Create( |
917 { |
|
918 iData->iBridgeObj->AddNewScreenFromWindowL(iData->iPlainWindow); |
|
919 iData->iEventAo = new (ELeave) CAlfEventBridge(*this, *iData->iBridgeObj->Display(0)); |
|
920 |
|
921 RThread eventThread; |
|
922 |
|
923 User::LeaveIfError(eventThread.Create( |
|
924 KAlfEventThreadName, |
880 KAlfEventThreadName, |
925 AlfEventThreadStartFunction, |
881 AlfEventThreadStartFunction, |
926 16384, // magic |
882 16384, // magic |
927 0, // uses same heap |
883 0, // uses same heap |
928 (TAny*)iData->iEventAo, |
884 (TAny*)iData->iEventAo, |
929 EOwnerThread)); |
885 EOwnerThread)); |
930 |
886 |
931 eventThread.Resume(); |
887 eventThread.Resume(); |
932 eventThread.Close(); |
888 eventThread.Close(); |
933 } |
|
934 |
889 |
935 AppendDisplayOnSharedWindowL(*(iData->iBridgeObj->Display(0))); |
890 AppendDisplayOnSharedWindowL(*(iData->iBridgeObj->Display(0))); |
936 |
891 |
937 TThreadId threadId; |
892 TThreadId threadId; |
938 CAlfStreamerServer::LaunchServer(threadId, iData->iBridge); |
893 CAlfStreamerServer::LaunchServer(threadId, iData->iBridge); |
939 |
894 |
940 // Inform texture manager that env has been created. |
895 // Inform texture manager that env has been created. |
941 iData->iServer->TextureManager().HandleEnvCreateL( *iData->iHuiEnv ); |
896 iData->iServer->TextureManager().HandleEnvCreateL( *iData->iHuiEnv ); |
942 |
897 |
943 // Construct transition effect instance if it does not yet exist |
898 // Construct transition effect instance if it does not yet exist |
|
899 // OBSOLETE |
944 iData->iServer->CreateTransitionEffectsL(); |
900 iData->iServer->CreateTransitionEffectsL(); |
945 |
901 |
946 // Load Tfx server client API plugin, if exists |
902 // Load Tfx server client API plugin, if exists |
|
903 // OBSOLETE |
947 iData->iServer->CreateTfxServerPlugin(); |
904 iData->iServer->CreateTfxServerPlugin(); |
948 |
905 |
949 #ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS |
906 #ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS |
950 iData->iBridgeObj->ForceSwRendering(ETrue); |
907 iData->iBridgeObj->ForceSwRendering(ETrue); |
951 #endif |
908 #endif |
954 } |
911 } |
955 |
912 |
956 // --------------------------------------------------------------------------- |
913 // --------------------------------------------------------------------------- |
957 // From class CAknAppUi. |
914 // From class CAknAppUi. |
958 // Handles system event. |
915 // Handles system event. |
959 // --------------------------------------------------------------------------- |
916 // OBSOLETE |
960 // |
917 // --------------------------------------------------------------------------- |
961 EXPORT_C void CAlfAppUi::HandleSystemEventL(const TWsEvent& aEvent) |
918 // |
962 { |
919 EXPORT_C void CAlfAppUi::HandleSystemEventL(const TWsEvent&) |
963 switch (*(TApaSystemEvent*)(aEvent.EventData())) |
920 { |
964 { |
|
965 case EApaSystemEventBroughtToForeground: |
|
966 { // we need to suppress this event as it causes undesired effects on applications underneath |
|
967 break; |
|
968 } |
|
969 default: |
|
970 CAknAppUi::HandleSystemEventL(aEvent); |
|
971 } |
|
972 |
|
973 return; |
|
974 } |
921 } |
975 |
922 |
976 void CAlfAppUi::StartPointerEventHandling() |
923 void CAlfAppUi::StartPointerEventHandling() |
977 { |
924 { |
978 if (iData->iActiveSession) |
925 if (iData->iActiveSession) |
1021 // Handles window server event. |
957 // Handles window server event. |
1022 // --------------------------------------------------------------------------- |
958 // --------------------------------------------------------------------------- |
1023 // |
959 // |
1024 EXPORT_C void CAlfAppUi::HandleWsEventL(const TWsEvent& aEvent, CCoeControl* aDestination) |
960 EXPORT_C void CAlfAppUi::HandleWsEventL(const TWsEvent& aEvent, CCoeControl* aDestination) |
1025 { |
961 { |
1026 TBool handlingPtrEvent(EFalse); |
|
1027 |
|
1028 if (aEvent.Type() >= EEventPointer && aEvent.Type() <= EEventDragDrop ) |
962 if (aEvent.Type() >= EEventPointer && aEvent.Type() <= EEventDragDrop ) |
1029 { |
963 { |
1030 StartPointerEventHandling(); |
964 StartPointerEventHandling(); |
1031 handlingPtrEvent = ETrue; // just to play it safe |
965 } |
1032 } |
966 |
1033 |
967 if( aEvent.Type() == EEventScreenDeviceChanged ) |
1034 // A Fix for AlfServer not shutting down on power off (ANIA-7EWFV6) |
968 { |
1035 if ( aEvent.Type() == EEventPowerMgmt ) |
969 HandleResourceChangeL( KEikDynamicLayoutVariantSwitch ); |
1036 { |
|
1037 TApaSystemEvent systemEvent( *(TApaSystemEvent*)(aEvent.EventData()) ); |
|
1038 if ( systemEvent == EApaSystemEventShutdown || systemEvent == EApaSystemEventSecureShutdown ) |
|
1039 { |
|
1040 // Don't let this event go further to base class' HandleWsEventL, |
|
1041 // since it'll start the appShutter, which will be ignored first, |
|
1042 // and when it would be really needed (after AllClientsClosed), it's already destroyed. |
|
1043 return; |
|
1044 } |
|
1045 } |
|
1046 |
|
1047 if (!iData->iEventAo) // CCoeEnv exists |
|
1048 { |
|
1049 CAknAppUi::HandleWsEventL(aEvent, aDestination); |
|
1050 if (handlingPtrEvent) |
|
1051 { |
|
1052 EndPointerEventHandling(); |
|
1053 } |
|
1054 } |
|
1055 else |
|
1056 { |
|
1057 if( aEvent.Type() == EEventScreenDeviceChanged ) |
|
1058 { |
|
1059 HandleResourceChangeL( KEikDynamicLayoutVariantSwitch ); |
|
1060 } |
|
1061 } |
970 } |
1062 |
971 |
1063 switch ( aEvent.Type() ) |
972 switch ( aEvent.Type() ) |
1064 { |
973 { |
1065 case EEventFocusGroupChanged: |
974 case EEventFocusGroupChanged: |
1246 // --------------------------------------------------------------------------- |
1154 // --------------------------------------------------------------------------- |
1247 // From class CAknAppUi. |
1155 // From class CAknAppUi. |
1248 // Called when a command is received. |
1156 // Called when a command is received. |
1249 // --------------------------------------------------------------------------- |
1157 // --------------------------------------------------------------------------- |
1250 // |
1158 // |
1251 EXPORT_C void CAlfAppUi::HandleCommandL(TInt aCommand) |
1159 EXPORT_C void CAlfAppUi::HandleCommandL(TInt) |
1252 { |
1160 { |
1253 if (aCommand == EEikCmdExit && iData->iAllClientsClosed) |
|
1254 { |
|
1255 Exit(); |
|
1256 } |
|
1257 } |
1161 } |
1258 |
1162 |
1259 // --------------------------------------------------------------------------- |
1163 // --------------------------------------------------------------------------- |
1260 // Return settings handler |
1164 // Return settings handler |
1261 // --------------------------------------------------------------------------- |
1165 // --------------------------------------------------------------------------- |
1267 |
1171 |
1268 // --------------------------------------------------------------------------- |
1172 // --------------------------------------------------------------------------- |
1269 // Updates non-fading setting to window. |
1173 // Updates non-fading setting to window. |
1270 // --------------------------------------------------------------------------- |
1174 // --------------------------------------------------------------------------- |
1271 // |
1175 // |
1272 void CAlfAppUi::SetContainerNonFading( TBool aNonFading ) |
1176 void CAlfAppUi::SetContainerNonFading(TBool) |
1273 { |
1177 { |
1274 const TBool nonFading = iData->iSharedWindowNonFading; |
|
1275 if ( ( nonFading && !aNonFading ) || |
|
1276 ( !nonFading && aNonFading ) ) |
|
1277 { |
|
1278 // Update window server setting. |
|
1279 iData->iSharedWindowNonFading = aNonFading; |
|
1280 iData->iSharedWindow->DrawableWindow()->SetNonFading( aNonFading ); |
|
1281 |
|
1282 // If non-fading is turned off, update fading to correct value. |
|
1283 // It's assumed that alfred applications are not shown in a pop up. |
|
1284 // If it were possible, we would need to know if alfred pop up is |
|
1285 // topmost. |
|
1286 if ( !aNonFading ) |
|
1287 { |
|
1288 iData->iSharedWindow->DrawableWindow()->SetFaded( |
|
1289 IsFaded(), |
|
1290 RWindowTreeNode::EFadeIncludeChildren ); |
|
1291 } |
|
1292 } |
|
1293 } |
1178 } |
1294 |
1179 |
1295 // --------------------------------------------------------------------------- |
1180 // --------------------------------------------------------------------------- |
1296 // Called when setting changes. |
1181 // Called when setting changes. |
1297 // --------------------------------------------------------------------------- |
1182 // --------------------------------------------------------------------------- |
1382 // --------------------------------------------------------------------------- |
1267 // --------------------------------------------------------------------------- |
1383 // |
1268 // |
1384 void CAlfAppUi::ShowControlGroupL(CHuiRoster& aRoster, CHuiControlGroup& aGroup, TInt aWhere, TInt aScreenNumber ) |
1269 void CAlfAppUi::ShowControlGroupL(CHuiRoster& aRoster, CHuiControlGroup& aGroup, TInt aWhere, TInt aScreenNumber ) |
1385 { |
1270 { |
1386 iData->iBridgeObj->ShowControlGroupL(aRoster, aGroup, aWhere, aScreenNumber); |
1271 iData->iBridgeObj->ShowControlGroupL(aRoster, aGroup, aWhere, aScreenNumber); |
1387 iData->iBridgeObj->HandleVisualVisibility( aScreenNumber ); |
1272 iData->iBridgeObj->HandleVisualVisibility( aScreenNumber ); |
1388 |
|
1389 } |
1273 } |
1390 |
1274 |
1391 // --------------------------------------------------------------------------- |
1275 // --------------------------------------------------------------------------- |
1392 // PostQTCommandBufferL |
1276 // PostQTCommandBufferL |
1393 // --------------------------------------------------------------------------- |
1277 // --------------------------------------------------------------------------- |