taskswitcher/contextengine/tsfswserver/engine/src/tsfswengine.cpp
branchRCL_3
changeset 9 f966699dea19
parent 4 4d54b72983ae
child 15 ff572dfe6d86
--- a/taskswitcher/contextengine/tsfswserver/engine/src/tsfswengine.cpp	Tue Feb 02 00:04:13 2010 +0200
+++ b/taskswitcher/contextengine/tsfswserver/engine/src/tsfswengine.cpp	Fri Feb 19 22:42:37 2010 +0200
@@ -680,7 +680,7 @@
         for ( TInt i( 0 ); i < count; i++ )
             {
             RWsSession::TWindowGroupChainInfo info = allWgIds[i];
-            if ( info.iId == aWgId )
+            if ( info.iId == aWgId && info.iParentId > 0)
                 {
                 parent = info.iParentId;
                 break;
@@ -692,6 +692,25 @@
     }
 
 // --------------------------------------------------------------------------
+// CTsFswEngine::FindMostTopParentWgId
+// --------------------------------------------------------------------------
+//
+TInt CTsFswEngine::FindMostTopParentWgId( TInt aWgId )
+    {
+	TInt parent( KErrNotFound );
+	parent = FindParentWgId( aWgId );
+	if( parent != KErrNotFound)
+		{
+		TInt topParent = FindMostTopParentWgId(parent);
+		if( topParent != KErrNotFound )
+			{
+			parent = topParent;
+			}
+		}
+    return parent;
+    }
+
+// --------------------------------------------------------------------------
 // CTsFswEngine::FindAppNameLC
 // --------------------------------------------------------------------------
 //
@@ -901,30 +920,24 @@
 // --------------------------------------------------------------------------
 // CTsFswEngine::AssignScreenshotHandle
 // Called when a screenshot arrives to check if there is a corresponding
-// application in the task list.
+// application in the task list. Firstly try to match screenshot into parental
+// application then into standalone one.
 // --------------------------------------------------------------------------
 //
 void CTsFswEngine::AssignScreenshotHandle( TInt aWgIdForScreenshot,
         TInt aBitmapHandle )
     {
     TBool changed = EFalse;
-    TInt parentWgId = FindParentWgId( aWgIdForScreenshot );
+    TInt parentWgId = FindMostTopParentWgId( aWgIdForScreenshot );
     // now parentWgId is a valid wgid or KErrNotFound (-1)
-    for ( TInt i = 0, ie = iData.Count(); i != ie; ++i )
-        {
-        if ( iData[i]->Widget() )
-            {
-            // Do not do anything for now => no screenshot for widgets.
-            continue;
-            }
-        TInt appWgId = iData[i]->WgId();
-        if ( appWgId == aWgIdForScreenshot || appWgId == parentWgId )
-            {
-            iData[i]->SetScreenshotHandle( aBitmapHandle );
-            changed = ETrue;
-            break;
-            }
-        }
+    if (parentWgId != KErrNotFound)
+		{
+		AssignScreenshotHandle( parentWgId, aBitmapHandle, changed );
+		}
+    if (!changed)
+		{
+		AssignScreenshotHandle( aWgIdForScreenshot, aBitmapHandle, changed );
+		}
     if ( changed )
         {
         iObserver.FswDataChanged();
@@ -932,6 +945,34 @@
     }
 
 // --------------------------------------------------------------------------
+// CTsFswEngine::AssignScreenshotHandle
+// Called when a screenshot arrives to check if there is a corresponding
+// application in the task list. It might be tried to be match into parental 
+// or standalone application.
+// --------------------------------------------------------------------------
+//
+void CTsFswEngine::AssignScreenshotHandle(TInt aWgIdForScreenshot,
+		TInt aBitmapHandle, TBool& aAsigned)
+	{
+	aAsigned = EFalse;
+	for (TInt i = 0, ie = iData.Count(); i != ie; ++i)
+		{
+		if (iData[i]->Widget())
+			{
+			// Do not do anything for now => no screenshot for widgets.
+			continue;
+			}
+		TInt appWgId = iData[i]->WgId();
+		if (appWgId == aWgIdForScreenshot)
+			{
+			iData[i]->SetScreenshotHandle(aBitmapHandle);
+			aAsigned = ETrue;
+			break;
+			}
+		}
+	}
+
+// --------------------------------------------------------------------------
 // CTsFswEngine::LookupScreenshotHandle
 // Called to check if there is a screenshot already stored for the given
 // app. (or a screenshot with a wgid for which aWgIdForApp is the parent)