diff -r 5ef31a21fdd5 -r e7325f632549 tstaskmonitor/backstepping/src/tsbackstepping.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tstaskmonitor/backstepping/src/tsbackstepping.cpp Thu Jul 22 16:37:03 2010 +0100 @@ -0,0 +1,140 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include // key event +#include // for CApaWindowGroupName +#include +#include +#include +#include +#include +#include + +#include "tsbackstepping.h" + +const TUid KHSUid = {0x20022f35}; + + +/** + * CTsBackstepping::NewL + * two phase constructor + */ +EXPORT_C CTsBackstepping* CTsBackstepping::NewL(MTsWindowGroupsMonitor &monitor) + { + RDebug::Print(_L("CTsBackstepping::NewL")); + CTsBackstepping* self = CTsBackstepping::NewLC(monitor); + CleanupStack::Pop(self); + return self; + } + +/** + * CTsBackstepping::NewLC + * two phase constructor + */ +EXPORT_C CTsBackstepping* CTsBackstepping::NewLC(MTsWindowGroupsMonitor &monitor) +{ + CTsBackstepping* self = new (ELeave) CTsBackstepping(monitor); + CleanupStack::PushL(self); + self->ConstructL(); + return self; +} + +/** + * CTsBackstepping::CTsBackstepping + * constructor + */ +CTsBackstepping::CTsBackstepping(MTsWindowGroupsMonitor &monitor) +: +CTsWindowGroupsObserver(monitor) +{ +} + + +/** + * CTsBackstepping::~CTsBackstepping + * deconstructor + */ +EXPORT_C CTsBackstepping::~CTsBackstepping() +{ +} + +/** + * CTsBackstepping::ConstructL + * two phase constructor + */ +void CTsBackstepping::ConstructL () +{ + RDebug::Print(_L("CTsBackstepping::ConstructL")); + BaseConstructL(); +} + +/** + * CTsBackstepping::AnalyseWindowStackL + * Analyzes window stack and move homescreen to proper position + */ +void CTsBackstepping::HandleWindowGroupChanged(MTsResourceManager &resource, const TArray &windowGroups) +{ + TRAP_IGNORE(HandleWindowGroupChangedL(resource, windowGroups)); +} + +/** + * CTsBackstepping::AnalyseWindowStackL + * Analyzes window stack and move homescreen to proper position + */ +void CTsBackstepping::HandleWindowGroupChangedL(MTsResourceManager &resource, + const TArray &windowGroups) +{ + RDebug::Print(_L("CTsBackstepping::GetWindowCaption")); + + CApaWindowGroupName *windowGroupName = CApaWindowGroupName::NewLC(resource.WsSession()); + + TInt count(windowGroups.Count()); + TInt pos(0); + TInt whereToJump(1); + for (TInt i=0; iConstructFromWgIdL(windowGroups[i].iId); + if (windowGroupName->AppUid() != TUid::Null()) { + // find the window group id and check that it has no parent + if ( windowGroups[i].iParentId <= 0 ) { + RDebug::Print( _L("CTsBackstepping::GetWindowCaption wgid:%d is standalone view"), windowGroups[i].iId); + //check if it is homescreen + if (windowGroupName->AppUid() == KHSUid) { + RDebug::Print(_L("CTsBackstepping::GetWindowCaption Homescreen position = %d ; list:%d/%d"), pos, i, count); + if (pos <= 1) {// HS is in foreground or second in line - do nothing + RDebug::Print(_L("CTsBackstepping::nothing to be done - it will stop checking here")); + } else {//we should move homescreen to be second (ommit embeded views) from top + RDebug::Print(_L("CTsBackstepping::moving homescreen to be second from top")); + RDebug::Print(_L("CTsBackstepping::whereToJump = %d"), whereToJump); + resource.WsSession().SetWindowGroupOrdinalPosition(windowGroups[i].iId, whereToJump); + } + // and break + break; + } + pos++; + } else { + // only embeded items for first standalone launch should be counted + if (!pos) { + ++whereToJump; + } + RDebug::Print(_L("CTsBackstepping::GetWindowCaption wgid:%d is embedded view"), windowGroups[i].iId); + } + } + } + CleanupStack::PopAndDestroy(windowGroupName); +} + +// end of file