idlehomescreen/widgetmanager/src/wmeffectmanager.cpp
branchRCL_3
changeset 23 7be2816dbabd
parent 18 d05a55b217df
equal deleted inserted replaced
19:79311d856354 23:7be2816dbabd
    19 // SYSTEM INCLUDE FILES
    19 // SYSTEM INCLUDE FILES
    20 #include <eikapp.h>
    20 #include <eikapp.h>
    21 #include <aknappui.h>
    21 #include <aknappui.h>
    22 #include <gfxtranseffect/gfxtranseffect.h>  // For transition effects
    22 #include <gfxtranseffect/gfxtranseffect.h>  // For transition effects
    23 #include <akntranseffect.h>                 // For transition effects
    23 #include <akntranseffect.h>                 // For transition effects
       
    24 #include <alf/alfcompositionutility.h>
    24 
    25 
    25 // INCLUDE FILES
    26 // INCLUDE FILES
    26 #include "wmeffectmanager.h"
    27 #include "wmeffectmanager.h"
    27 
    28 
    28 // CONSTANTS
    29 // CONSTANTS
    29 const TInt KEffectTypeFullscreen = 1;
    30 const TInt KEffectTypeFullscreen = 1;
    30 
    31 
    31 const TInt KWaitForLayout = 1;
    32 const TInt KWaitForLayout = 1;
    32 const TInt KEffectStarted = 2;
    33 const TInt KEffectStarted = 2;
    33 
    34 
       
    35 const TInt KEffectWaitInterval( 250000 ); //250ms
       
    36 const TInt KWaitInterval( 25000 ); // 25ms
       
    37 
    34 // ============================ MEMBER FUNCTIONS ===============================
    38 // ============================ MEMBER FUNCTIONS ===============================
    35 
    39 
    36 // -----------------------------------------------------------------------------
    40 // -----------------------------------------------------------------------------
    37 // C++ default constructor.
    41 // C++ default constructor.
    38 // -----------------------------------------------------------------------------
    42 // -----------------------------------------------------------------------------
    45 // Symbian 2nd phase constructor.
    49 // Symbian 2nd phase constructor.
    46 // -----------------------------------------------------------------------------
    50 // -----------------------------------------------------------------------------
    47 //
    51 //
    48 void CWmEffectManager::ConstructL()
    52 void CWmEffectManager::ConstructL()
    49     {
    53     {
       
    54     iObserver = CAlfEffectObserver::NewL(); 
    50     }
    55     }
    51 
    56 
    52 // -----------------------------------------------------------------------------
    57 // -----------------------------------------------------------------------------
    53 // Two-phased constructor.
    58 // Two-phased constructor.
    54 // -----------------------------------------------------------------------------
    59 // -----------------------------------------------------------------------------
    66 // Destructor.
    71 // Destructor.
    67 // -----------------------------------------------------------------------------
    72 // -----------------------------------------------------------------------------
    68 //
    73 //
    69 CWmEffectManager::~CWmEffectManager()
    74 CWmEffectManager::~CWmEffectManager()
    70     {
    75     {
       
    76     delete iObserver;
    71     GfxTransEffect::AbortFullScreen();
    77     GfxTransEffect::AbortFullScreen();
    72     iEffects.ResetAndDestroy();
    78     iEffects.ResetAndDestroy();
    73     }
    79     }
    74 
    80 
    75 // -----------------------------------------------------------------------------
    81 // -----------------------------------------------------------------------------
    85     effect->iState = KWaitForLayout;
    91     effect->iState = KWaitForLayout;
    86     iEffects.Append( effect );
    92     iEffects.Append( effect );
    87     
    93     
    88     CleanupStack::Pop( effect );
    94     CleanupStack::Pop( effect );
    89 
    95 
    90     DoBeginFullscreenEffect( *effect );
    96     if ( !DoBeginFullscreenEffect( *effect ) )
       
    97         {
       
    98         RemoveEffect( effect );
       
    99         }
    91     }
   100     }
    92 
   101 
    93 // -----------------------------------------------------------------------------
   102 // -----------------------------------------------------------------------------
    94 // CWmEffectManager::UiRendered
   103 // CWmEffectManager::UiRendered
    95 // -----------------------------------------------------------------------------
   104 // -----------------------------------------------------------------------------
   115 
   124 
   116 // -----------------------------------------------------------------------------
   125 // -----------------------------------------------------------------------------
   117 // CWmEffectManager::DoBeginFullscreenEffect
   126 // CWmEffectManager::DoBeginFullscreenEffect
   118 // -----------------------------------------------------------------------------
   127 // -----------------------------------------------------------------------------
   119 //
   128 //
   120 void CWmEffectManager::DoBeginFullscreenEffect( TWmEffect& aEffect )
   129 TBool CWmEffectManager::DoBeginFullscreenEffect( TWmEffect& aEffect )
   121     {
   130     {
   122     if ( iCoeEnv.WsSession().GetFocusWindowGroup() != 
   131     if ( iCoeEnv.WsSession().GetFocusWindowGroup() != 
   123          iCoeEnv.RootWin().Identifier() )
   132          iCoeEnv.RootWin().Identifier() )
   124         {
   133         {
   125         // Window group is not focused
   134         // Window group is not focused
   126         RemoveEffect( &aEffect );
   135         RemoveEffect( &aEffect );
   127         return;
   136         return EFalse;
   128         }
   137         }
   129     
   138     
   130     // Must give some time before starting effect, because otherwise
   139     if ( !WaitActiveEffect( KEffectWaitInterval ) )
   131     // fullscreen effect may contain unwanted parts (dialog, note, etc.)
   140         {
   132     // which was shown when fullscreen effect is about to be started
   141         return EFalse;
   133     iCoeEnv.WsSession().Finish();
   142         }
   134     User::After( 1 );
       
   135 
   143 
   136     const TInt flags( AknTransEffect::TParameter::EActivateExplicitCancel );
   144     const TInt flags( AknTransEffect::TParameter::EActivateExplicitCancel );
   137     const TUid targetAppUid( iAvkonAppUi->Application()->AppDllUid() );
   145     const TUid targetAppUid( iAvkonAppUi->Application()->AppDllUid() );
   138 
   146 
   139     // Set effect begin point
   147     // Set effect begin point
   140     GfxTransEffect::BeginFullScreen( aEffect.iId , iAvkonAppUi->ClientRect(),
   148     GfxTransEffect::BeginFullScreen( aEffect.iId , iAvkonAppUi->ClientRect(),
   141         AknTransEffect::EParameterType, AknTransEffect::GfxTransParam(
   149         AknTransEffect::EParameterType, AknTransEffect::GfxTransParam(
   142         targetAppUid, flags ) );
   150         targetAppUid, flags ) );
   143     
   151     
   144     aEffect.iState = KEffectStarted;
   152     aEffect.iState = KEffectStarted;
       
   153     
       
   154     return ETrue;
       
   155     }
       
   156 
       
   157 // -----------------------------------------------------------------------------
       
   158 // CWmEffectManager::WaitActiveEffect
       
   159 // -----------------------------------------------------------------------------
       
   160 //
       
   161 TBool CWmEffectManager::WaitActiveEffect( TInt aInterval )     
       
   162     {
       
   163     TBool retval( EFalse );
       
   164     TInt loop( aInterval / KWaitInterval );
       
   165     
       
   166     while ( loop >= 0 )
       
   167         {               
       
   168         TInt count( iObserver->ActiveEffectsCount() );
       
   169         
       
   170         if ( count == 0 )
       
   171             {
       
   172             retval = ETrue;
       
   173             break;                        
       
   174             }
       
   175         
       
   176         User::After( KWaitInterval );
       
   177         loop--;
       
   178         }
       
   179 
       
   180     return retval;    
   145     }
   181     }
   146 
   182 
   147 // -----------------------------------------------------------------------------
   183 // -----------------------------------------------------------------------------
   148 // CXnEffectManager::RemoveEffect
   184 // CXnEffectManager::RemoveEffect
   149 // -----------------------------------------------------------------------------
   185 // -----------------------------------------------------------------------------
   157         iEffects.Remove( index );
   193         iEffects.Remove( index );
   158         delete temp;
   194         delete temp;
   159         }
   195         }
   160     }
   196     }
   161 
   197 
       
   198 // -----------------------------------------------------------------------------
       
   199 // CXnEffectManager::IsEffectActive
       
   200 // -----------------------------------------------------------------------------
       
   201 //
       
   202 TBool CWmEffectManager::IsEffectActive()
       
   203     {
       
   204     TBool retVal( EFalse );
       
   205     if ( iObserver->ActiveEffectsCount() )
       
   206         retVal = ETrue;
       
   207     return retVal;
       
   208     }
       
   209 
   162 // End fo file
   210 // End fo file
   163 
   211