tstaskmonitor/backstepping/src/tsbackstepping.cpp
changeset 109 e0aa398e6810
parent 104 9b022b1f357c
child 115 3ab5c078b490
equal deleted inserted replaced
104:9b022b1f357c 109:e0aa398e6810
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 #include <w32std.h>// key event
       
    19 #include <apgwgnam.h>// for CApaWindowGroupName
       
    20 #include <apgtask.h>
       
    21 #include <coedef.h>
       
    22 #include <f32file.h>
       
    23 #include <flogger.h>
       
    24 #include <e32property.h>
       
    25 #include <startupdomainpskeys.h>
       
    26 
       
    27 #include "tsbackstepping.h"
       
    28 
       
    29 const TUid KHSUid = {0x20022f35};
       
    30 
       
    31 
       
    32 /** 
       
    33  *  CTsBackstepping::NewL
       
    34  *  two phase constructor
       
    35  */
       
    36 EXPORT_C CTsBackstepping* CTsBackstepping::NewL(MTsWindowGroupsMonitor &monitor)
       
    37   {
       
    38   RDebug::Print(_L("CTsBackstepping::NewL"));
       
    39   CTsBackstepping* self = CTsBackstepping::NewLC(monitor);
       
    40   CleanupStack::Pop(self);
       
    41   return self;
       
    42   }
       
    43 
       
    44 /** 
       
    45  *  CTsBackstepping::NewLC
       
    46  *  two phase constructor
       
    47  */
       
    48 EXPORT_C CTsBackstepping* CTsBackstepping::NewLC(MTsWindowGroupsMonitor &monitor)
       
    49 { 
       
    50   CTsBackstepping* self = new (ELeave) CTsBackstepping(monitor);
       
    51   CleanupStack::PushL(self);
       
    52   self->ConstructL();
       
    53   return self;
       
    54 }
       
    55 
       
    56 /** 
       
    57  * CTsBackstepping::CTsBackstepping
       
    58  * constructor
       
    59  */
       
    60 CTsBackstepping::CTsBackstepping(MTsWindowGroupsMonitor &monitor)
       
    61 :
       
    62 CTsWindowGroupsObserver(monitor)
       
    63 {
       
    64 }
       
    65 
       
    66 
       
    67 /** 
       
    68  *  CTsBackstepping::~CTsBackstepping
       
    69  *  deconstructor
       
    70  */
       
    71 EXPORT_C CTsBackstepping::~CTsBackstepping()
       
    72 {
       
    73 }
       
    74 
       
    75 /** 
       
    76  *  CTsBackstepping::ConstructL
       
    77  *  two phase constructor
       
    78  */
       
    79 void CTsBackstepping::ConstructL ()
       
    80 {
       
    81     RDebug::Print(_L("CTsBackstepping::ConstructL"));
       
    82     BaseConstructL();
       
    83 }
       
    84 
       
    85 /** 
       
    86  * CTsBackstepping::AnalyseWindowStackL
       
    87  * Analyzes window stack and move homescreen to proper position
       
    88  */
       
    89 void CTsBackstepping::HandleWindowGroupChanged(MTsResourceManager &resource, const TArray<RWsSession::TWindowGroupChainInfo> &windowGroups)
       
    90 {
       
    91     TRAP_IGNORE(HandleWindowGroupChangedL(resource, windowGroups));
       
    92 }
       
    93 
       
    94 /** 
       
    95  * CTsBackstepping::AnalyseWindowStackL
       
    96  * Analyzes window stack and move homescreen to proper position
       
    97  */
       
    98 void CTsBackstepping::HandleWindowGroupChangedL(MTsResourceManager &resource,
       
    99                                                 const TArray<RWsSession::TWindowGroupChainInfo> &windowGroups)
       
   100 {  
       
   101     RDebug::Print(_L("CTsBackstepping::GetWindowCaption"));
       
   102     
       
   103     CApaWindowGroupName *windowGroupName = CApaWindowGroupName::NewLC(resource.WsSession());
       
   104     
       
   105     TInt count(windowGroups.Count());
       
   106     TInt pos(0);
       
   107     TInt whereToJump(1);
       
   108     for (TInt i=0; i<count; i++) {//iterate through list and give debug info
       
   109         windowGroupName->ConstructFromWgIdL(windowGroups[i].iId);
       
   110         if (windowGroupName->AppUid() != TUid::Null()) {
       
   111             // find the window group id and check that it has no parent
       
   112             if ( windowGroups[i].iParentId <= 0 ) {
       
   113                 RDebug::Print( _L("CTsBackstepping::GetWindowCaption wgid:%d is standalone view"), windowGroups[i].iId);
       
   114                 //check if it is homescreen 
       
   115                 if (windowGroupName->AppUid() == KHSUid) {
       
   116                     RDebug::Print(_L("CTsBackstepping::GetWindowCaption Homescreen position = %d ; list:%d/%d"), pos, i, count);
       
   117                     if (pos <= 1) {// HS is in foreground or second in line - do nothing 
       
   118                         RDebug::Print(_L("CTsBackstepping::nothing to be done - it will stop checking here"));
       
   119                     } else {//we should move homescreen to be second (ommit embeded views) from top
       
   120                         RDebug::Print(_L("CTsBackstepping::moving homescreen to be second from top"));
       
   121                         RDebug::Print(_L("CTsBackstepping::whereToJump = %d"), whereToJump);
       
   122                         resource.WsSession().SetWindowGroupOrdinalPosition(windowGroups[i].iId, whereToJump);
       
   123                     }
       
   124                     // and break
       
   125                     break;
       
   126                 }
       
   127                 pos++;
       
   128             } else {
       
   129                 // only embeded items for first standalone launch should be counted
       
   130                 if (!pos) {
       
   131                     ++whereToJump;
       
   132                 }
       
   133                 RDebug::Print(_L("CTsBackstepping::GetWindowCaption wgid:%d is embedded view"), windowGroups[i].iId);
       
   134             }
       
   135         }
       
   136     }
       
   137     CleanupStack::PopAndDestroy(windowGroupName);
       
   138 }
       
   139 
       
   140 // end of file