backsteppingsrv/src/bsengine.cpp
branchRCL_3
changeset 101 9e077f9a342c
parent 0 79c6a41cd166
equal deleted inserted replaced
82:ace62b58f4b2 101:9e077f9a342c
    37 // -----------------------------------------------------------------------------
    37 // -----------------------------------------------------------------------------
    38 //
    38 //
    39 CBSEngine::CBSEngine()
    39 CBSEngine::CBSEngine()
    40     {
    40     {
    41     iEnv = CEikonEnv::Static( );
    41     iEnv = CEikonEnv::Static( );
    42     swap = EFalse;
    42     iSwap = EFalse;
    43     wasPressed = EFalse;
       
    44     }
    43     }
    45 
    44 
    46 // -----------------------------------------------------------------------------
    45 // -----------------------------------------------------------------------------
    47 // Symbian 2nd phase constructor can leave.
    46 // Symbian 2nd phase constructor can leave.
    48 // -----------------------------------------------------------------------------
    47 // -----------------------------------------------------------------------------
    91 
    90 
    92 // -----------------------------------------------------------------------------
    91 // -----------------------------------------------------------------------------
    93 // 
    92 // 
    94 // -----------------------------------------------------------------------------
    93 // -----------------------------------------------------------------------------
    95 //
    94 //
    96 void CBSEngine::ApplicationKeyWasPressed()
       
    97     {
       
    98     wasPressed = ETrue;
       
    99     }
       
   100 
       
   101 // -----------------------------------------------------------------------------
       
   102 // 
       
   103 // -----------------------------------------------------------------------------
       
   104 //
       
   105 void CBSEngine::HandleFocusChangeL( const TUid& aApp )
    95 void CBSEngine::HandleFocusChangeL( const TUid& aApp )
   106     {
    96     {
   107     DEBUG(("-> HandleFocusChangeL(0x%X)", aApp.iUid ));
    97     DEBUG(("-> HandleFocusChangeL(0x%X)", aApp.iUid ));
   108     // check if application is not in ignored list
    98     // check if application is not in ignored list
   109     if ( iConfiguration->IsIgnored( aApp ) )
    99     if ( iConfiguration->IsIgnored( aApp ) )
   114 
   104 
   115     TInt fsCount = iFocusHistory.Count( );
   105     TInt fsCount = iFocusHistory.Count( );
   116     if ( fsCount > 0 && iFocusHistory[fsCount - 1] == aApp.iUid )
   106     if ( fsCount > 0 && iFocusHistory[fsCount - 1] == aApp.iUid )
   117         {
   107         {
   118         DEBUG(("\tIgnore the event - application already on top"));
   108         DEBUG(("\tIgnore the event - application already on top"));
   119         swap = EFalse;
   109         iSwap = EFalse;
   120         wasPressed = EFalse;
       
   121         return;
   110         return;
   122         }
   111         }
   123 
   112 
   124     // check if we should not reset back stepping stack
   113     // check if we should not reset back stepping stack
   125     if ( iConfiguration->IsReset( aApp ) )
   114     if ( iConfiguration->IsReset( aApp ) )
   126         {
   115         {
   127         swap = EFalse;
   116         iSwap = EFalse;
   128         wasPressed = EFalse;
       
   129         ResetHistory( );
   117         ResetHistory( );
   130         }
   118         }
   131 
   119 
   132     // check if we should reset if application was started tru 
   120     // check if we should reset if application was started tru 
   133     RArray<TInt>& thuApps = iConfiguration->ResetIfThruList( );
   121     RArray<TInt>& thuApps = iConfiguration->ResetIfThruList( );
   136         {
   124         {
   137         // position of application - i.e. fast swap
   125         // position of application - i.e. fast swap
   138         if ( aApp.iUid == thuApps[i] )
   126         if ( aApp.iUid == thuApps[i] )
   139             {
   127             {
   140             //mark that there is a fast swap or dialog
   128             //mark that there is a fast swap or dialog
   141             swap = ETrue;
   129             iSwap = ETrue;
   142             return;
   130             return;
   143             }
   131             }
   144         else
   132         else if( iSwap )
   145             {
   133             {
   146             if ( swap )
   134             iSwap = EFalse;
       
   135 
       
   136             TInt pos = iFocusHistory.Count( ) - 1;
       
   137             if ( pos >= 0 )
   147                 {
   138                 {
   148                 swap = EFalse;
       
   149                 TInt currentApp = aApp.iUid;
   139                 TInt currentApp = aApp.iUid;
   150                 TInt pos = iFocusHistory.Count( ) - 1;
   140                 TInt prevApp = iFocusHistory[pos];
   151                 if ( pos >= 0 )
   141                 if ( currentApp != prevApp )
   152                     {
   142                     {
   153                     TInt prevApp = iFocusHistory[pos];
   143                     //we are here as the result of the fast swap
   154                     if ( currentApp != prevApp && wasPressed )
   144                     ResetHistory( );
   155                         {
   145                     iFocusHistory.AppendL( thuApps[i] );
   156                         //we are here as the result of the fast swap
   146                     break;
   157                         ResetHistory( );
       
   158                         iFocusHistory.AppendL( thuApps[i] );
       
   159                         wasPressed = EFalse;
       
   160                         }
       
   161                     }
   147                     }
   162                 }
   148                 }
   163             }
   149             }
   164         }
   150         }
   165     // add application to focus history list, 
   151     // add application to focus history list,