uiacceltk/hitchcock/ServerCore/Src/alfbridge.cpp
branchRCL_3
changeset 17 c9d868f1e20c
parent 15 cd0ae4656946
child 18 1801340c26a2
equal deleted inserted replaced
15:cd0ae4656946 17:c9d868f1e20c
   194 	    }
   194 	    }
   195 	iAlfRegisteredEffects.Close();
   195 	iAlfRegisteredEffects.Close();
   196     delete iEffectEndTimer;
   196     delete iEffectEndTimer;
   197     iDeadControlGroups.Close();
   197     iDeadControlGroups.Close();
   198     iEffectWindowGroups.Close();
   198     iEffectWindowGroups.Close();
       
   199     iWindowChainsArray.Close();
   199     delete iFSFxData;
   200     delete iFSFxData;
   200     delete iFSFXDataPart2;
   201     delete iFSFXDataPart2;
   201 
   202 
   202     if (iActivated)
   203     if (iActivated)
   203         {
   204         {
   267 //  a fade that does not belong to the theme may be in use.
   268 //  a fade that does not belong to the theme may be in use.
   268 // ---------------------------------------------------------------------------
   269 // ---------------------------------------------------------------------------
   269 void CAlfBridge::RegisterFadeEffectL()
   270 void CAlfBridge::RegisterFadeEffectL()
   270     {
   271     {
   271     // TODO: RND, REMOVE MMC DRIVE-F, WHEN NOT REQUIRED FOR TESTING
   272     // TODO: RND, REMOVE MMC DRIVE-F, WHEN NOT REQUIRED FOR TESTING
       
   273 #ifdef USE_ALTERNATIVE_EFFECTS_FROM_MMC
   272     _LIT(KDrivePrefence,"FZC"); 
   274     _LIT(KDrivePrefence,"FZC"); 
       
   275 #else
       
   276     _LIT(KDrivePrefence,"Z");
       
   277 #endif
   273     // Force register fade effect. Try first MMC, then ROM.
   278     // Force register fade effect. Try first MMC, then ROM.
   274     CHuiFxEngine* engine = iHuiEnv->EffectsEngine();
   279     CHuiFxEngine* engine = iHuiEnv->EffectsEngine();
   275     RFs& fs = CHuiStatic::FsSession();
   280     RFs& fs = CHuiStatic::FsSession();
   276     if (fs.Handle() && engine)
   281     if (fs.Handle() && engine)
   277         {
   282         {
   458             }
   463             }
   459         }
   464         }
   460     while(node);
   465     while(node);
   461 	return NULL;
   466 	return NULL;
   462     }
   467     }
   463 	
   468 
       
   469 // ---------------------------------------------------------------------------
       
   470 // FindChainedGroup
       
   471 // ---------------------------------------------------------------------------
       
   472 // 
       
   473 TUint32 CAlfBridge::FindChainedGroup(
       
   474     TUint32 aTreeNodeId)
       
   475     {
       
   476     THashMapIter<TUint32, TChainData> iter(iWindowChainsArray);
       
   477     TChainData const * data = 0;
       
   478     do
       
   479         {
       
   480         data = iter.NextValue();
       
   481         if (data && data->iParent == aTreeNodeId)
       
   482             {
       
   483             TUint32 chainedTo = FindChainedGroup(data->iChainee);
       
   484             if (!chainedTo)
       
   485                 {
       
   486                 return data->iChainee; 
       
   487                 }
       
   488             else
       
   489                 {
       
   490                 return chainedTo;
       
   491                 }
       
   492             }
       
   493         }
       
   494     while(data);
       
   495     return NULL;
       
   496     }
       
   497 
       
   498 // ---------------------------------------------------------------------------
       
   499 // IsChainedGroup
       
   500 // ---------------------------------------------------------------------------
       
   501 // 
       
   502 TBool CAlfBridge::IsChainedGroup(
       
   503     TUint32 aTreeNodeId)
       
   504     {
       
   505     THashMapIter<TUint32, TChainData> iter(iWindowChainsArray);
       
   506     TChainData const * data = 0;
       
   507     do
       
   508         {
       
   509         data = iter.NextValue();
       
   510         if (data && data->iChainee == aTreeNodeId)
       
   511             {
       
   512             return ETrue;
       
   513             }
       
   514         }
       
   515     while(data);
       
   516     return EFalse;
       
   517     }
       
   518 
   464 // ---------------------------------------------------------------------------
   519 // ---------------------------------------------------------------------------
   465 // ---------------------------------------------------------------------------
   520 // ---------------------------------------------------------------------------
   466 // 
   521 // 
   467 CHuiControlGroup* CAlfBridge::FindControlGroup(TInt aWindowGroupNodeId, TInt aScreenNumber )
   522 CHuiControlGroup* CAlfBridge::FindControlGroup(TInt aWindowGroupNodeId, TInt aScreenNumber )
   468     {
   523     {
   478 
   533 
   479 // ---------------------------------------------------------------------------
   534 // ---------------------------------------------------------------------------
   480 // FindClientWindowGroupId
   535 // FindClientWindowGroupId
   481 // ---------------------------------------------------------------------------
   536 // ---------------------------------------------------------------------------
   482 //
   537 //
   483 TInt CAlfBridge::FindClientWindowGroupId( TInt aScreenNumber, CHuiControlGroup& aControlGroup  )
   538 TInt CAlfBridge::FindClientWindowGroupId(CHuiControlGroup& aControlGroup  )
   484     {
   539     {
   485     for (TInt i=0; i<iAlfScreens[aScreenNumber]->iControlGroups.Count();i++)
   540     for (TInt i=0; i<iAlfScreens[0]->iControlGroups.Count();i++)
   486         {
   541         {
   487         if( iAlfScreens[aScreenNumber]->iControlGroups[i].iControlGroup == &aControlGroup )
   542         if( iAlfScreens[0]->iControlGroups[i].iControlGroup == &aControlGroup )
   488             {
   543             {
   489             return iAlfScreens[aScreenNumber]->iControlGroups[i].iClientWindowGroupId;
   544             return iAlfScreens[0]->iControlGroups[i].iClientWindowGroupId;
   490             }
   545             }
   491         }
   546         }
   492     return KErrNotFound;
   547     return KErrNotFound;
   493     }
   548     }
   494 
   549 
   495 // ---------------------------------------------------------------------------
   550 // ---------------------------------------------------------------------------
   496 // FindWindowGroupNodeId
   551 // FindWindowGroupNodeId
   497 // ---------------------------------------------------------------------------
   552 // ---------------------------------------------------------------------------
   498 //
   553 //
   499 TInt CAlfBridge::FindWindowGroupNodeId( TInt aScreenNumber, CHuiControlGroup& aControlGroup ) const
   554 TInt CAlfBridge::FindWindowGroupNodeId(CHuiControlGroup& aControlGroup ) const
   500     {
   555     {
   501     for (TInt i=0; i<iAlfScreens[aScreenNumber]->iControlGroups.Count();i++)
   556     for (TInt i=0; i<iAlfScreens[0]->iControlGroups.Count();i++)
   502         {
   557         {
   503         if( iAlfScreens[aScreenNumber]->iControlGroups[i].iControlGroup == &aControlGroup )
   558         if( iAlfScreens[0]->iControlGroups[i].iControlGroup == &aControlGroup )
   504             {
   559             {
   505             return iAlfScreens[aScreenNumber]->iControlGroups[i].iWindowGroupNodeId;
   560             return iAlfScreens[0]->iControlGroups[i].iWindowGroupNodeId;
   506             }
   561             }
   507         }
   562         }
   508     return KErrNotFound;
   563     return KErrNotFound;
   509     }
   564     }
   510 
   565 
   571                 return groupEntry.iControlGroup;
   626                 return groupEntry.iControlGroup;
   572                 }
   627                 }
   573             }
   628             }
   574         }        
   629         }        
   575     return NULL;       
   630     return NULL;       
       
   631     }
       
   632 
       
   633 // ---------------------------------------------------------------------------
       
   634 // FindControlGroupBySecureId
       
   635 // May return multiple groups
       
   636 // ---------------------------------------------------------------------------
       
   637 //
       
   638 void CAlfBridge::FindControlGroupBySecureId( TInt aSecureId, RPointerArray<CHuiControlGroup>& aGroupList)
       
   639     {
       
   640     if ( aSecureId == 0 )
       
   641         {
       
   642         return;
       
   643         }
       
   644     
       
   645     for ( TInt i = 0; i < iAlfScreens[0]->iControlGroups.Count(); i++ )
       
   646         {
       
   647         TAlfControlGroupEntry& groupEntry = iAlfScreens[0]->iControlGroups[i];
       
   648         if ( groupEntry.iSecureId == aSecureId )
       
   649             {
       
   650             aGroupList.Append(groupEntry.iControlGroup);
       
   651             }
       
   652         }        
   576     }
   653     }
   577 
   654 
   578 // ---------------------------------------------------------------------------
   655 // ---------------------------------------------------------------------------
   579 // FindControlGroupByFullScreenToEffect
   656 // FindControlGroupByFullScreenToEffect
   580 // ---------------------------------------------------------------------------
   657 // ---------------------------------------------------------------------------
   792             TInt aWindowGroupNodeId, 
   869             TInt aWindowGroupNodeId, 
   793             TInt aClientWindowGroupId,
   870             TInt aClientWindowGroupId,
   794             TInt aSecureId,
   871             TInt aSecureId,
   795             TInt aScreenNumber )
   872             TInt aScreenNumber )
   796     {
   873     {
   797     CHuiControlGroup* group = FindControlGroup(aWindowGroupNodeId,aScreenNumber);
   874     CHuiControlGroup* group = FindControlGroup(aWindowGroupNodeId);
   798     if (!group)
   875     if (!group)
   799         {
   876         {
   800         group = &iHuiEnv->NewControlGroupL(aWindowGroupNodeId); 
   877         group = &iHuiEnv->NewControlGroupL(aWindowGroupNodeId); 
   801         group->SetSecureId(aSecureId);
   878         group->SetSecureId(aSecureId);
   802         CleanupStack::PushL(group);
   879         CleanupStack::PushL(group);
  1087                        TBool lSyncDone(EFalse);
  1164                        TBool lSyncDone(EFalse);
  1088                        if (lSyncAlfAppAndAlfEventGroup && i< (aRoster.Count()-1) )
  1165                        if (lSyncAlfAppAndAlfEventGroup && i< (aRoster.Count()-1) )
  1089                        {
  1166                        {
  1090                        lSyncDone = ETrue;
  1167                        lSyncDone = ETrue;
  1091                        CHuiControlGroup &lGroup = aRoster.ControlGroup(i+1);
  1168                        CHuiControlGroup &lGroup = aRoster.ControlGroup(i+1);
  1092                        TInt clientWindowGroupId = FindClientWindowGroupId( aScreenNumber, lGroup );
  1169                        TInt clientWindowGroupId = FindClientWindowGroupId(lGroup );
  1093                        iAppUi->AdjustWindowGroupPositionL(clientWindowGroupId,CAlfAppServer::EBehindOfParent);
  1170                        iAppUi->AdjustWindowGroupPositionL(clientWindowGroupId,CAlfAppServer::EBehindOfParent);
  1094                        }
  1171                        }
  1095                        if(!lSyncDone && aGroup.iAlfApp && aRoster.ControlGroup(i-1).ResourceId() != iAlfWindowGroupNodeId )
  1172                        if(!lSyncDone && aGroup.iAlfApp && aRoster.ControlGroup(i-1).ResourceId() != iAlfWindowGroupNodeId )
  1096                            {
  1173                            {
  1097                           
  1174                           
  1098                           CHuiControlGroup &lGroup = aRoster.ControlGroup(i);
  1175                           CHuiControlGroup &lGroup = aRoster.ControlGroup(i);
  1099                           TInt clientWindowGroupId = FindClientWindowGroupId( aScreenNumber, lGroup );
  1176                           TInt clientWindowGroupId = FindClientWindowGroupId(lGroup );
  1100                           iAppUi->AdjustWindowGroupPositionL(clientWindowGroupId,CAlfAppServer::EBehindOfParent);
  1177                           iAppUi->AdjustWindowGroupPositionL(clientWindowGroupId,CAlfAppServer::EBehindOfParent);
  1101                            }
  1178                            }
  1102                        break;
  1179                        break;
  1103                        }
  1180                        }
  1104 
  1181 
  1143             if ( iAlfScreens[0]->iControlGroups[i].iSecureId == secureId && 
  1220             if ( iAlfScreens[0]->iControlGroups[i].iSecureId == secureId && 
  1144                  iAlfScreens[0]->iControlGroups[i].iClientWindowGroupId != CHuiStatic::RootWin(0)->Identifier())
  1221                  iAlfScreens[0]->iControlGroups[i].iClientWindowGroupId != CHuiStatic::RootWin(0)->Identifier())
  1145                 {
  1222                 {
  1146                 iAlfWindowGroupNodeId = iAlfScreens[0]->iControlGroups[i].iWindowGroupNodeId;
  1223                 iAlfWindowGroupNodeId = iAlfScreens[0]->iControlGroups[i].iWindowGroupNodeId;
  1147                 
  1224                 
  1148                 CHuiControlGroup* controlGroup = FindControlGroup(iAlfWindowGroupNodeId, 0);
  1225                 CHuiControlGroup* controlGroup = FindControlGroup(iAlfWindowGroupNodeId);
  1149                 CHuiControl& control = controlGroup->Control(0);
  1226                 CHuiControl& control = controlGroup->Control(0);
  1150                 CHuiVisual* layout = &control.Visual(0);
  1227                 CHuiVisual* layout = &control.Visual(0);
  1151                 iAlfScreens[0]->iDisplay->Roster().SetAlfEventWindow(layout);
  1228                 iAlfScreens[0]->iDisplay->Roster().SetAlfEventWindow(layout);
  1152                 return;
  1229                 return;
  1153                 }
  1230                 }
  1277                 {
  1354                 {
  1278                 TBuf<8> numBuf;
  1355                 TBuf<8> numBuf;
  1279                 numBuf.AppendNum(fps, TRealFormat(5,1));
  1356                 numBuf.AppendNum(fps, TRealFormat(5,1));
  1280                 TRAP_IGNORE(
  1357                 TRAP_IGNORE(
  1281                         {
  1358                         {
  1282                         iAlfScreens[screenNumber]->iFPSText->SetTextL( numBuf );
  1359                         iAlfScreens[0]->iFPSText->SetTextL( numBuf );
  1283                         })
  1360                         })
  1284                 }
  1361                 }
  1285             }
  1362             }
  1286 #endif
  1363 #endif
  1287         if (!iActivated)            
  1364         if (!iActivated)            
  1288             {
  1365             {
  1289             TInt err = iBridgerClient.Connect();
  1366             TInt err = iBridgerClient.Connect();
  1290             iActivated = (err == KErrNone);            
  1367             iActivated = (err == KErrNone);            
  1291             }
  1368             }
  1292                     
  1369                     
  1293         if (iAlfScreens[screenNumber]->IsVisualTreeVisibilityChanged())
  1370         if (iAlfScreens[0]->IsVisualTreeVisibilityChanged())
  1294             {
  1371             {
  1295             HandleVisualVisibility( screenNumber );    
  1372             HandleVisualVisibility( screenNumber );    
  1296             iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(EFalse);
  1373             iAlfScreens[0]->SetVisualTreeVisibilityChanged(EFalse);
  1297             }
  1374             }
  1298         }
  1375         }
  1299     }
  1376     }
  1300 
  1377 
  1301 // ---------------------------------------------------------------------------
  1378 // ---------------------------------------------------------------------------
  1354         }
  1431         }
  1355 
  1432 
  1356     transparent |= (!((aVisual.Flags() & EHuiVisualFlagOpaqueHint) == EHuiVisualFlagOpaqueHint));
  1433     transparent |= (!((aVisual.Flags() & EHuiVisualFlagOpaqueHint) == EHuiVisualFlagOpaqueHint));
  1357     transparent |= (aVisual.iOpacity.Now() < KAlfVisualDefaultOpacity);
  1434     transparent |= (aVisual.iOpacity.Now() < KAlfVisualDefaultOpacity);
  1358     transparent |= (aVisual.iOpacity.Target() < KAlfVisualDefaultOpacity);
  1435     transparent |= (aVisual.iOpacity.Target() < KAlfVisualDefaultOpacity);
  1359     
  1436     if(aVisual.Effect())
       
  1437         {
       
  1438         transparent |= (aVisual.iEffectOpacity < KAlfVisualDefaultOpacity);
       
  1439         }
  1360     return  !transparent;            
  1440     return  !transparent;            
  1361     }
  1441     }
  1362 
  1442 
  1363 // ---------------------------------------------------------------------------
  1443 // ---------------------------------------------------------------------------
  1364 // ---------------------------------------------------------------------------
  1444 // ---------------------------------------------------------------------------
  1485         }    
  1565         }    
  1486     
  1566     
  1487 	
  1567 	
  1488 	TBool alfWindowGroupFoundVisible = EFalse;
  1568 	TBool alfWindowGroupFoundVisible = EFalse;
  1489 	TBool alfClientWindowGroupVisible = EFalse;
  1569 	TBool alfClientWindowGroupVisible = EFalse;
       
  1570 	TBool firstAlfControlGroupFound = EFalse;
  1490 	
  1571 	
  1491     AMT_SET_VALUE( iVisibleVisualCount, 0 );
  1572     AMT_SET_VALUE( iVisibleVisualCount, 0 );
  1492 	
  1573 	
  1493     // skip the topmost (effect) layer, start from floating sprite group
  1574     // skip the topmost (effect) layer, start from floating sprite group
  1494     for (TInt j=screen->iDisplay->Roster().Count() - screen->FixedControlGroupCount(); j>=0; j--)
  1575     for (TInt j=screen->iDisplay->Roster().Count() - screen->FixedControlGroupCount(); j>=0; j--)
  1537                 {
  1618                 {
  1538                 activeSession = iAppUi->ActiveSession();
  1619                 activeSession = iAppUi->ActiveSession();
  1539                 }
  1620                 }
  1540             // !fullscreenCovered need to be checked because for fullscreen
  1621             // !fullscreenCovered need to be checked because for fullscreen
  1541             // alf applications alf event window group could be on top of alf client windowgroup
  1622             // alf applications alf event window group could be on top of alf client windowgroup
  1542             if ( (alfClientWindowGroupVisible || !fullscreenCovered)  && activeSession)
  1623             if ( (!firstAlfControlGroupFound || !fullscreenCovered)  && activeSession)
  1543                 {
  1624                 {
  1544                 // clear inactive flag if client has not made this controlgroup hidden
  1625                 // clear inactive flag if client has not made this controlgroup hidden
  1545                 if(!(flags&EHuiVisualFlagUnderOpaqueHint))
  1626                 if(!(flags&EHuiVisualFlagUnderOpaqueHint))
  1546                     {
  1627                     {
  1547                     if(iAppUi)
  1628                     if(iAppUi)
  1558                             hostContainer->ClearFlags(EHuiVisualFlagInactive);
  1639                             hostContainer->ClearFlags(EHuiVisualFlagInactive);
  1559                             // just add the rect to covered region because alf draws solid background
  1640                             // just add the rect to covered region because alf draws solid background
  1560                             iTempRegion.AddRect(fullscreen);
  1641                             iTempRegion.AddRect(fullscreen);
  1561                             iTempRegion.Tidy();
  1642                             iTempRegion.Tidy();
  1562                             fullscreenCovered = ETrue;
  1643                             fullscreenCovered = ETrue;
  1563                             alfClientWindowGroupVisible = EFalse;  // change flag so that we don't go in this branch again
  1644                             firstAlfControlGroupFound = ETrue;  // change flag so that we don't go in this branch again
  1564                             }
  1645                             }
  1565                         }
  1646                         }
  1566                     }
  1647                     }
  1567                 else // else put as inactive
  1648                 else // else put as inactive
  1568                     {
  1649                     {
  1628                HandleLayoutVisualVisibility( layout, controlgroup, control, 
  1709                HandleLayoutVisualVisibility( layout, controlgroup, control, 
  1629                    fullscreenCovered, fullscreen, screen, 
  1710                    fullscreenCovered, fullscreen, screen, 
  1630                    subTreeCovered, hasLayers, IsVisualOpaque(*layout) );
  1711                    subTreeCovered, hasLayers, IsVisualOpaque(*layout) );
  1631             }
  1712             }
  1632         
  1713         
  1633 
  1714         if ( hasLayers && iActivated )
  1634         TBool hasFadeEffectsInVisualTree = (layout->CanvasFlags() & EHuiCanvasFlagExternalFadeExistsInsideVisualTree);        
  1715             {
  1635 
  1716             HandleLayerVisibility( layout, controlgroup, control, hasActiveVisualsInVisualTree );
       
  1717             }
       
  1718         
       
  1719         TBool isLayoutActive = !(layout->Flags() & EHuiVisualFlagInactive);        
       
  1720         
       
  1721         // we need to set /clear inactive flags before we evaluate the fade effect,
       
  1722         // otherwise the fade effect will be removed without a reason in
       
  1723         // some use cases
       
  1724         if (isLayoutActive && (fullscreenCovered || (!hasActiveVisualsInVisualTree && !IsOpaqueEffect(layout->Effect()))))
       
  1725             {
       
  1726             // don't inactivate alf event wg if alf client is visible
       
  1727             if( !( alfClientWindowGroupVisible && (controlgroup.ResourceId() == iAlfWindowGroupNodeId)) )
       
  1728                 // Setting also the root visual (layout) as inactive, if it had none
       
  1729                 // active children. This is because otherwise the Inactive checks won't
       
  1730                 // work correctly within RosterImpl ScanDirty & ClearChanged phases.
       
  1731                 // If root visual is having an opaque effect, it must remain active
       
  1732                 {
       
  1733                 layout->SetFlag(EHuiVisualFlagInactive);
       
  1734                 }
       
  1735             }
       
  1736         else if(!isLayoutActive && !fullscreenCovered && (hasActiveVisualsInVisualTree || IsOpaqueEffect(layout->Effect())) ||
       
  1737                 (alfClientWindowGroupVisible && (controlgroup.ResourceId() == iAlfWindowGroupNodeId)) )
       
  1738             {
       
  1739             layout->ClearFlag(EHuiVisualFlagInactive);
       
  1740             layout->SetPos(fullscreen.iTl);
       
  1741             layout->SetSize(fullscreen.Size());
       
  1742             
       
  1743 		    // New visible window group may have received effect just before appearing to the screen.
       
  1744 			// start the effect if this is the case.
       
  1745             if(iFSFxData && iFSFxData->iToSecureId == controlgroup.SecureId() )
       
  1746                 {
       
  1747                 TInt windowGroupId = FindClientWindowGroupId(controlgroup);
       
  1748 
       
  1749                 if (iFSFxData->iToWg == windowGroupId && iFSFxData->State() == EWaitEndFullScreen &&
       
  1750                         iFSFxData->iTwoPhaseEffect <= CFullScreenEffectState::ESecondPartActive)
       
  1751                     {
       
  1752                     GfxTriggerEffectWhenFullScreenDrawn(&controlgroup);
       
  1753                     }
       
  1754                 }
       
  1755             }
       
  1756 
       
  1757         // If root visuals effect is marked as opaque, then add whole screen area as covered.
       
  1758         if (!fullscreenCovered)
       
  1759             {
       
  1760             fullscreenCovered = IsOpaqueEffect(layout->Effect());
       
  1761             }    
       
  1762 
       
  1763         
  1636         // if native alf app is found visible and the client it self is not covering whole screen, we can assume that alf content
  1764         // if native alf app is found visible and the client it self is not covering whole screen, we can assume that alf content
  1637         // fills the rest. 
  1765         // fills the rest. 
  1638         // this is for embedded native alf application cases. Otherwise chained window groups tend to
  1766         // this is for embedded native alf application cases. Otherwise chained window groups tend to
  1639         // flicker from time to time
  1767         // flicker from time to time
  1640         // also if alfcontent is not hided below avkon content the fading effect would reveal alfconent
  1768         // also if alfcontent is not hided below avkon content the fading effect would reveal alfconent
  1647                 iTempRegion.Tidy();
  1775                 iTempRegion.Tidy();
  1648                 fullscreenCovered = ETrue;
  1776                 fullscreenCovered = ETrue;
  1649                 alfClientWindowGroupVisible = ETrue;
  1777                 alfClientWindowGroupVisible = ETrue;
  1650                 }
  1778                 }
  1651             }
  1779             }
  1652         
       
  1653         // If root visuals effect is marked as opaque, then add whole screen area as covered.
       
  1654         if (!fullscreenCovered)
       
  1655             {
       
  1656             fullscreenCovered = IsOpaqueEffect(layout->Effect());
       
  1657             }                    
       
  1658         
       
  1659         if ( hasLayers && iActivated )
       
  1660             {
       
  1661             HandleLayerVisibility( layout, controlgroup, control, hasActiveVisualsInVisualTree );
       
  1662             }
       
  1663         
       
  1664         TBool isLayoutActive = !(layout->Flags() & EHuiVisualFlagInactive);        
       
  1665         
       
  1666         // we need to set /clear inactive flags before we evaluate the fade effect,
       
  1667         // otherwise the fade effect will be removed without a reason in
       
  1668         // some use cases
       
  1669         if (isLayoutActive && !hasActiveVisualsInVisualTree && !IsOpaqueEffect(layout->Effect()))
       
  1670             {
       
  1671             // Setting also the root visual (layout) as inactive, if it had none
       
  1672 			// active children. This is because otherwise the Inactive checks won't
       
  1673 			// work correctly within RosterImpl ScanDirty & ClearChanged phases.
       
  1674 			// If root visual is having an opaque effect, it must remain active
       
  1675             layout->SetFlag(EHuiVisualFlagInactive);
       
  1676             }
       
  1677         else if(!isLayoutActive && (hasActiveVisualsInVisualTree || IsOpaqueEffect(layout->Effect())))
       
  1678             {
       
  1679             layout->ClearFlag(EHuiVisualFlagInactive);
       
  1680             layout->SetPos(fullscreen.iTl);
       
  1681             layout->SetSize(fullscreen.Size());
       
  1682             }
       
  1683  
       
  1684             
  1780             
       
  1781         TBool hasFadeEffectsInVisualTree = (layout->CanvasFlags() & EHuiCanvasFlagExternalFadeExistsInsideVisualTree);        
       
  1782 
  1685 		// If we layout is active setup the fade effects. Also if it is inactive, but has been
  1783 		// If we layout is active setup the fade effects. Also if it is inactive, but has been
  1686 		// flagged as containing fade effect, then run the setup as well so that effects which
  1784 		// flagged as containing fade effect, then run the setup as well so that effects which
  1687 		// are no more needed get removed.
  1785 		// are no more needed get removed.
  1688         if (hasActiveVisualsInVisualTree || (!hasActiveVisualsInVisualTree && hasFadeEffectsInVisualTree))
  1786         if (hasActiveVisualsInVisualTree || (!hasActiveVisualsInVisualTree && hasFadeEffectsInVisualTree))
  1689             {
  1787             {
  2450 //                HandleGetNativeWindowDataL( data );
  2548 //                HandleGetNativeWindowDataL( data );
  2451                 break;
  2549                 break;
  2452                 }
  2550                 }
  2453             case EAlfDSGroupChained:
  2551             case EAlfDSGroupChained:
  2454             	{
  2552             	{
  2455             	__ALFLOGSTRING("CAlfBridge::DoDispatchL, EAlfDSGroupChained");    
  2553             	HandleGroupChained(data);
  2456             	// TODO, link groups 
       
  2457             	break;
  2554             	break;
  2458             	}
  2555             	}
  2459             case EAlfDSGroupChainBroken:
  2556             case EAlfDSGroupChainBroken:
  2460             	{
  2557             	{
  2461             	__ALFLOGSTRING("CAlfBridge::DoDispatchL, EAlfDSGroupChainBroken");    
  2558             	HandleGroupChainBroken(data);
  2462             	// TODO, break link
       
  2463             	break;
  2559             	break;
  2464             	}
  2560             	}
  2465             case EAlfDSMoveWindowToNewGroup:
  2561             case EAlfDSMoveWindowToNewGroup:
  2466             	{
  2562             	{
  2467             	HandleMoveWindowToNewGroupL( data );
  2563             	HandleMoveWindowToNewGroupL( data );
  2666 void CAlfBridge::HandleNewWindowL( TAlfBridgerData& aData )
  2762 void CAlfBridge::HandleNewWindowL( TAlfBridgerData& aData )
  2667 	{
  2763 	{
  2668 	TInt windowGroupNodeId = aData.iInt1;
  2764 	TInt windowGroupNodeId = aData.iInt1;
  2669 	TInt windowNodeId = aData.iInt2;
  2765 	TInt windowNodeId = aData.iInt2;
  2670 	TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*) (*iHost)->GetVarDataL( (TInt)aData.iPtr );
  2766 	TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*) (*iHost)->GetVarDataL( (TInt)aData.iPtr );
  2671 	TInt screenNumber = windowAttributes->iScreenNumber; 
       
  2672 	__ALFLOGSTRING1("CAlfBridge::HandleNewWindowL: new window %d!",windowNodeId);    
  2767 	__ALFLOGSTRING1("CAlfBridge::HandleNewWindowL: new window %d!",windowNodeId);    
  2673 	                
  2768 	                
  2674 	switch (windowAttributes->iWindowNodeType)
  2769 	switch (windowAttributes->iWindowNodeType)
  2675 		{
  2770 		{
  2676 		case EAlfWinTreeNodeGroup:
  2771 		case EAlfWinTreeNodeGroup:
  2677 			{
  2772 			{
  2678 			CHuiControlGroup& controlGroup = CreateControlGroupL(
  2773 			CHuiControlGroup& controlGroup = CreateControlGroupL(
  2679 			        windowGroupNodeId, 
  2774 			        windowGroupNodeId, 
  2680 			        windowAttributes->iClientHandle, 
  2775 			        windowAttributes->iClientHandle, 
  2681 			        windowAttributes->iSecureId,
  2776 			        windowAttributes->iSecureId,
  2682 			        screenNumber);                            
  2777 			        0 // Only one screen for avkon content supported 
       
  2778 					);                            
  2683 
  2779 
  2684 			// We just received notification for our own window group creation, store its node id for doing
  2780 			// We just received notification for our own window group creation, store its node id for doing
  2685 			// faster lookups later...
  2781 			// faster lookups later...
  2686 			if (windowAttributes->iClientHandle == iAlfWindowGroupId)
  2782 			if (windowAttributes->iClientHandle == iAlfWindowGroupId)
  2687 				{
  2783 				{
  2693 		case EAlfWinTreeNodeRoot: // TODO: Root window receives drawing commands too
  2789 		case EAlfWinTreeNodeRoot: // TODO: Root window receives drawing commands too
  2694 		case EAlfWinTreeNodeAnim:
  2790 		case EAlfWinTreeNodeAnim:
  2695 		case EAlfWinTreeNodeSprite:
  2791 		case EAlfWinTreeNodeSprite:
  2696 		case EAlfWinTreeNodeTextCursor:
  2792 		case EAlfWinTreeNodeTextCursor:
  2697 			{
  2793 			{
  2698 			CHuiControlGroup* controlGroup = FindControlGroup(windowGroupNodeId,screenNumber);
  2794 			CHuiControlGroup* controlGroup = FindControlGroup(windowGroupNodeId);
  2699 			// Floating sprites only require own group. Normal sprites should behave as normal visuals.
  2795 			// Floating sprites only require own group. Normal sprites should behave as normal visuals.
  2700 			if (!controlGroup && windowAttributes->iWindowNodeType == EAlfWinTreeNodeSprite )
  2796 			if (!controlGroup && windowAttributes->iWindowNodeType == EAlfWinTreeNodeSprite )
  2701 				{                            
  2797 				{                            
  2702 				controlGroup = iAlfScreens[screenNumber]->iFloatingSpriteControlGroup;
  2798 				controlGroup = iAlfScreens[0]->iFloatingSpriteControlGroup;
  2703 				}
  2799 				}
  2704 
  2800 
  2705 			if (controlGroup)
  2801 			if (controlGroup)
  2706 				{
  2802 				{
  2707 				CHuiControl& control = controlGroup->Control(0);
  2803 				CHuiControl& control = controlGroup->Control(0);
  2716 				else
  2812 				else
  2717 				    {
  2813 				    {
  2718                     viz = CHuiCanvasVisual::AddNewL(control, layout);
  2814                     viz = CHuiCanvasVisual::AddNewL(control, layout);
  2719 				    }
  2815 				    }
  2720 
  2816 
  2721 				__ALFFXLOGSTRING2("CAlfBridge::HandleNewWindowL visual: 0x%x, id 0x%x", viz, windowNodeId);
  2817 				__ALFFXLOGSTRING3("CAlfBridge::HandleNewWindowL visual: 0x%x, id 0x%x, Owner group Uid: 0x%x", viz, windowNodeId, viz->Owner().ControlGroup()->SecureId());
  2722 				AddVisual( 
  2818 				AddVisual( 
  2723 				    windowNodeId, 
  2819 				    windowNodeId, 
  2724 					windowAttributes->iClientHandle, 
  2820 					windowAttributes->iClientHandle, 
  2725 					windowAttributes->iClientGroupHandle, 
  2821 					windowAttributes->iClientGroupHandle, 
  2726 					viz );
  2822 					viz );
  2775 		default:
  2871 		default:
  2776 			{
  2872 			{
  2777 			__ALFLOGSTRING("CAlfBridge::HandleNewWindowL: Unknown window node type received !");
  2873 			__ALFLOGSTRING("CAlfBridge::HandleNewWindowL: Unknown window node type received !");
  2778 			}
  2874 			}
  2779 		}
  2875 		}
  2780 	iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(ETrue);
  2876 	iAlfScreens[0]->SetVisualTreeVisibilityChanged(ETrue);
  2781 	}
  2877 	}
  2782 
  2878 
  2783 // ---------------------------------------------------------------------------
  2879 // ---------------------------------------------------------------------------
  2784 // HandleDestroyWindow
  2880 // HandleDestroyWindow
  2785 // ---------------------------------------------------------------------------
  2881 // ---------------------------------------------------------------------------
  2858 	{
  2954 	{
  2859 	TInt windowGroupNodeId = aData.iInt1;
  2955 	TInt windowGroupNodeId = aData.iInt1;
  2860 	TInt windowNodeId = aData.iInt2;
  2956 	TInt windowNodeId = aData.iInt2;
  2861 
  2957 
  2862 	TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*) (*iHost)->GetVarDataL( (TInt)aData.iPtr );
  2958 	TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*) (*iHost)->GetVarDataL( (TInt)aData.iPtr );
  2863 	TInt screenNumber = windowAttributes->iScreenNumber;
  2959 	
  2864 
       
  2865 	switch (windowAttributes->iWindowNodeType)
  2960 	switch (windowAttributes->iWindowNodeType)
  2866 		{
  2961 		{
  2867 		case EAlfWinTreeNodeGroup:
  2962 		case EAlfWinTreeNodeGroup:
  2868 			{
  2963 			{
  2869 			HandleVisualVisibility(0);
  2964 			HandleVisualVisibility(0);
  2870 			DeleteControlGroupL(windowGroupNodeId, screenNumber);                            
  2965 			DeleteControlGroupL(windowGroupNodeId);                            
  2871 			break;    
  2966 			break;    
  2872 			}
  2967 			}
  2873 		case EAlfWinTreeNodeClient:
  2968 		case EAlfWinTreeNodeClient:
  2874 		case EAlfWinTreeNodeRoot:
  2969 		case EAlfWinTreeNodeRoot:
  2875 		case EAlfWinTreeNodeAnim:
  2970 		case EAlfWinTreeNodeAnim:
  2885 
  2980 
  2886 			//just remove the visual
  2981 			//just remove the visual
  2887 			CHuiCanvasVisual* viz;
  2982 			CHuiCanvasVisual* viz;
  2888 			
  2983 			
  2889 			viz = (CHuiCanvasVisual*)FindVisual(windowNodeId);
  2984 			viz = (CHuiCanvasVisual*)FindVisual(windowNodeId);
  2890 			CHuiControlGroup* controlGroup = FindControlGroup( windowGroupNodeId, screenNumber );
  2985 			CHuiControlGroup* controlGroup = FindControlGroup( windowGroupNodeId);
  2891 		     // Sprite is in its own group, and can be deleted normally.
  2986 		     // Sprite is in its own group, and can be deleted normally.
  2892 			if ( !controlGroup  && windowAttributes->iWindowNodeType != EAlfWinTreeNodeSprite )
  2987 			if ( !controlGroup  && windowAttributes->iWindowNodeType != EAlfWinTreeNodeSprite )
  2893 			    {
  2988 			    {
  2894 			    __ALFLOGSTRING("CAlfBridge::HandleDestroyWindowL: group containing this visual has been destroyed.");
  2989 			    __ALFLOGSTRING("CAlfBridge::HandleDestroyWindowL: group containing this visual has been destroyed.");
  2895 			    // the group containing this visual has been destroyed. 
  2990 			    // the group containing this visual has been destroyed. 
  2925 			break;
  3020 			break;
  2926 			}
  3021 			}
  2927 		}
  3022 		}
  2928 	// TODO: Toolkit does not support recycling (of visuals),
  3023 	// TODO: Toolkit does not support recycling (of visuals),
  2929 	// this is not in line with Nokia environmental policy...
  3024 	// this is not in line with Nokia environmental policy...
  2930 	iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(ETrue);
  3025 	iAlfScreens[0]->SetVisualTreeVisibilityChanged(ETrue);
  2931 	}
  3026 	}
  2932 
  3027 
  2933 // ---------------------------------------------------------------------------
  3028 // ---------------------------------------------------------------------------
  2934 // HandleSetWindowPosL
  3029 // HandleSetWindowPosL
  2935 // ---------------------------------------------------------------------------
  3030 // ---------------------------------------------------------------------------
  2936 // 
  3031 // 
  2937 void CAlfBridge::HandleSetWindowPosL( TAlfBridgerData& aData )
  3032 void CAlfBridge::HandleSetWindowPosL( TAlfBridgerData& aData )
  2938 	{
  3033 	{
  2939 	TInt windowNodeId = aData.iInt2;
  3034 	TInt windowNodeId = aData.iInt2;
  2940 	TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*) (*iHost)->GetVarDataL( (TInt)aData.iPtr );
  3035 	TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*) (*iHost)->GetVarDataL( (TInt)aData.iPtr );
  2941 	TInt screenNumber = windowAttributes->iScreenNumber;
       
  2942 	// fetch visual
  3036 	// fetch visual
  2943 	CHuiVisual* viz = FindVisual(windowNodeId);
  3037 	CHuiVisual* viz = FindVisual(windowNodeId);
  2944 	if (viz)
  3038 	if (viz)
  2945 		{
  3039 		{
  2946 #ifdef HUI_DEBUG_TRACK_DRAWING
  3040 #ifdef HUI_DEBUG_TRACK_DRAWING
  2948 		    {
  3042 		    {
  2949 		    RDebug::Print(_L("CAlfBridge::HandleSetWindowPosL - Tracked visual"));
  3043 		    RDebug::Print(_L("CAlfBridge::HandleSetWindowPosL - Tracked visual"));
  2950 		    }
  3044 		    }
  2951 #endif
  3045 #endif
  2952 
  3046 
  2953 		viz->SetPos(windowAttributes->iPosition, windowAttributes->iTransitionTime);
  3047         viz->SetPos(windowAttributes->iPosition, windowAttributes->iTransitionTime);
  2954 		  iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(ETrue); // TODO: Check if really changed   
  3048         iAlfScreens[0]->SetVisualTreeVisibilityChanged(ETrue); // TODO: Check if really changed   
  2955 		}
  3049 		}
  2956 	else
  3050 	else
  2957 		{
  3051 		{
  2958 		__ALFLOGSTRING("CAlfBridge::HandleSetWindowPosL, EAlfDSSetWindowPos: Visual not found!");    
  3052 		__ALFLOGSTRING("CAlfBridge::HandleSetWindowPosL, EAlfDSSetWindowPos: Visual not found!");    
  2959 		}   
  3053 		}   
  2971 // 
  3065 // 
  2972 void CAlfBridge::HandleSetWindowSizeL( TAlfBridgerData& aData )
  3066 void CAlfBridge::HandleSetWindowSizeL( TAlfBridgerData& aData )
  2973 	{
  3067 	{
  2974 	TInt windowNodeId = aData.iInt2;
  3068 	TInt windowNodeId = aData.iInt2;
  2975 	TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*) (*iHost)->GetVarDataL( (TInt)aData.iPtr );
  3069 	TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*) (*iHost)->GetVarDataL( (TInt)aData.iPtr );
  2976 	TInt screenNumber = windowAttributes->iScreenNumber;
       
  2977 	// fetch visual
  3070 	// fetch visual
  2978 	CHuiVisual* viz = FindVisual(windowNodeId);
  3071 	CHuiVisual* viz = FindVisual(windowNodeId);
  2979 	if (viz)
  3072 	if (viz)
  2980 		{
  3073 		{
  2981 #ifdef HUI_DEBUG_TRACK_DRAWING
  3074 #ifdef HUI_DEBUG_TRACK_DRAWING
  2988 		}
  3081 		}
  2989 	else
  3082 	else
  2990 		{
  3083 		{
  2991 		__ALFLOGSTRING("CAlfBridge::HandleSetWindowSizeL, EAlfDSSetWindowSize: Visual not found!");    
  3084 		__ALFLOGSTRING("CAlfBridge::HandleSetWindowSizeL, EAlfDSSetWindowSize: Visual not found!");    
  2992 		}   
  3085 		}   
  2993     iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(ETrue);
  3086     iAlfScreens[0]->SetVisualTreeVisibilityChanged(ETrue);
  2994     
  3087     
  2995     AMT_INC_COUNTER_IF(viz, iVisualSizeChangedCount );
  3088     AMT_INC_COUNTER_IF(viz, iVisualSizeChangedCount );
  2996     AMT_SET_VALUE_IF(viz, iLatestVisualExtentRect, TRect( windowAttributes->iPosition, windowAttributes->iSize ) );
  3089     AMT_SET_VALUE_IF(viz, iLatestVisualExtentRect, TRect( windowAttributes->iPosition, windowAttributes->iSize ) );
  2997     
  3090     
  2998     AMT_MAP_SET_VALUE_IF( viz, iSizeMap, windowNodeId, 
  3091     AMT_MAP_SET_VALUE_IF( viz, iSizeMap, windowNodeId, 
  3034 // 
  3127 // 
  3035 void CAlfBridge::HandleSetWindowOpacityL( TAlfBridgerData& aData )
  3128 void CAlfBridge::HandleSetWindowOpacityL( TAlfBridgerData& aData )
  3036 	{
  3129 	{
  3037 	TInt windowNodeId = aData.iInt2;
  3130 	TInt windowNodeId = aData.iInt2;
  3038 	TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*) (*iHost)->GetVarDataL( (TInt)aData.iPtr );
  3131 	TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*) (*iHost)->GetVarDataL( (TInt)aData.iPtr );
  3039 	TInt screenNumber = windowAttributes->iScreenNumber;
       
  3040 	// fetch visual
  3132 	// fetch visual
  3041 	CHuiVisual* viz = FindVisual(windowNodeId);
  3133 	CHuiVisual* viz = FindVisual(windowNodeId);
  3042 	if (viz)
  3134 	if (viz)
  3043 		{
  3135 		{
  3044 #ifdef HUI_DEBUG_TRACK_DRAWING
  3136 #ifdef HUI_DEBUG_TRACK_DRAWING
  3045         if ( viz->Tracking() )
  3137         if ( viz->Tracking() )
  3046             {
  3138             {
  3047             RDebug::Print(_L("CAlfBridge::HandleSetWindowOpacityL - Tracked visual"));
  3139             RDebug::Print(_L("CAlfBridge::HandleSetWindowOpacityL - Tracked visual"));
  3048             }
  3140             }
  3049 #endif
  3141 #endif
  3050 		viz->iOpacity.Set(windowAttributes->iOpacity, windowAttributes->iTransitionTime);
  3142         viz->iOpacity.Set(windowAttributes->iOpacity, windowAttributes->iTransitionTime);
  3051 		  iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(ETrue);  // TODO: Check if really changed  
  3143         iAlfScreens[0]->SetVisualTreeVisibilityChanged(ETrue);  // TODO: Check if really changed  
  3052 		}
  3144         }
  3053 	else
  3145 	else
  3054 		{
  3146 		{
  3055 		__ALFLOGSTRING("CAlfBridge::HandleSetWindowOpacityL, EAlfDSSetWindowOpacity: Visual not found!");                                                
  3147 		__ALFLOGSTRING("CAlfBridge::HandleSetWindowOpacityL, EAlfDSSetWindowOpacity: Visual not found!");                                                
  3056 		}  
  3148 		}  
  3057 	}
  3149 	}
  3062 // 
  3154 // 
  3063 void CAlfBridge::HandleSetTransparencyAlphaChannelL( TAlfBridgerData& aData )
  3155 void CAlfBridge::HandleSetTransparencyAlphaChannelL( TAlfBridgerData& aData )
  3064     {
  3156     {
  3065 	TInt windowNodeId = aData.iInt2;
  3157 	TInt windowNodeId = aData.iInt2;
  3066 	TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*) (*iHost)->GetVarDataL( (TInt)aData.iPtr );
  3158 	TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*) (*iHost)->GetVarDataL( (TInt)aData.iPtr );
  3067 	TInt screenNumber = windowAttributes->iScreenNumber;
       
  3068 	// fetch visual
  3159 	// fetch visual
  3069 	CHuiVisual* viz = FindVisual(windowNodeId);
  3160 	CHuiVisual* viz = FindVisual(windowNodeId);
  3070 	if (viz)
  3161 	if (viz)
  3071 		{
  3162 		{
  3072 #ifdef HUI_DEBUG_TRACK_DRAWING
  3163 #ifdef HUI_DEBUG_TRACK_DRAWING
  3082 		else
  3173 		else
  3083 		    {
  3174 		    {
  3084 		    viz->SetFlag( EHuiVisualFlagOpaqueHint );
  3175 		    viz->SetFlag( EHuiVisualFlagOpaqueHint );
  3085 		    }
  3176 		    }
  3086 		
  3177 		
  3087 	    iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(ETrue);  // TODO: Check if really changed  
  3178 	    iAlfScreens[0]->SetVisualTreeVisibilityChanged(ETrue);  // TODO: Check if really changed  
  3088 		}
  3179 		}
  3089 	else
  3180 	else
  3090 		{
  3181 		{
  3091 		__ALFLOGSTRING("CAlfBridge::HandleSetTransparencyAlphaChannel, EAlfDSSetTransparencyAlphaChannel: Visual not found!");                                                
  3182 		__ALFLOGSTRING("CAlfBridge::HandleSetTransparencyAlphaChannel, EAlfDSSetTransparencyAlphaChannel: Visual not found!");                                                
  3092 		}          
  3183 		}          
  3098 // 
  3189 // 
  3099 void CAlfBridge::HandleIncludeToVisibilityCalculationL( TAlfBridgerData& aData )
  3190 void CAlfBridge::HandleIncludeToVisibilityCalculationL( TAlfBridgerData& aData )
  3100     {
  3191     {
  3101     TInt windowNodeId = aData.iInt2;
  3192     TInt windowNodeId = aData.iInt2;
  3102     TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*) (*iHost)->GetVarDataL( (TInt)aData.iPtr );
  3193     TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*) (*iHost)->GetVarDataL( (TInt)aData.iPtr );
  3103     TInt screenNumber = windowAttributes->iScreenNumber;
       
  3104     // fetch visual
  3194     // fetch visual
  3105     CHuiVisual* viz = FindVisual(windowNodeId);
  3195     CHuiVisual* viz = FindVisual(windowNodeId);
  3106     if (viz)
  3196     if (viz)
  3107         {
  3197         {
  3108 #ifdef HUI_DEBUG_TRACK_DRAWING
  3198 #ifdef HUI_DEBUG_TRACK_DRAWING
  3123                 {
  3213                 {
  3124                 canvasVisual->ClearCanvasFlags( EHuiCanvasFlagIncludeToVisibilityCalculation );
  3214                 canvasVisual->ClearCanvasFlags( EHuiCanvasFlagIncludeToVisibilityCalculation );
  3125                 }
  3215                 }
  3126             }
  3216             }
  3127         
  3217         
  3128         iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(ETrue);  // TODO: Check if really changed  
  3218         iAlfScreens[0]->SetVisualTreeVisibilityChanged(ETrue);  // TODO: Check if really changed  
  3129         }
  3219         }
  3130     else
  3220     else
  3131         {
  3221         {
  3132         __ALFLOGSTRING("CAlfBridge::HandleIncludeToVisibilityCalculationL, EAlfDSIncludeToVisibilityCalculation: Visual not found!");                                                
  3222         __ALFLOGSTRING("CAlfBridge::HandleIncludeToVisibilityCalculationL, EAlfDSIncludeToVisibilityCalculation: Visual not found!");                                                
  3133         }              
  3223         }              
  3140 void CAlfBridge::HandleSetWindowAreaL( TAlfBridgerData& aData )
  3230 void CAlfBridge::HandleSetWindowAreaL( TAlfBridgerData& aData )
  3141 	{
  3231 	{
  3142 	TInt windowNodeId = aData.iInt2;
  3232 	TInt windowNodeId = aData.iInt2;
  3143 	TAny* ptr = (TAny*)(*iHost)->GetVarDataL( (TInt)aData.iPtr );
  3233 	TAny* ptr = (TAny*)(*iHost)->GetVarDataL( (TInt)aData.iPtr );
  3144 	
  3234 	
  3145 	TInt screenNumber = 0;
       
  3146 	TPoint origin;
  3235 	TPoint origin;
  3147 	TInt count = 0;
  3236 	TInt count = 0;
  3148 	RRegion region;
  3237 	RRegion region;
  3149 	CleanupClosePushL( region );
  3238 	CleanupClosePushL( region );
  3150 	
  3239 	
  3151 	    {
  3240 	    {
  3152 	    RMemReadStream str(ptr, 4*sizeof(TInt32));	
  3241 	    RMemReadStream str(ptr, 4*sizeof(TInt32));	
  3153 	    screenNumber = str.ReadInt32L(); 
  3242 	    str.ReadInt32L(); // screen number, obsolete 
  3154     	origin.iX = str.ReadInt32L();
  3243     	origin.iX = str.ReadInt32L();
  3155 	    origin.iY = str.ReadInt32L();
  3244 	    origin.iY = str.ReadInt32L();
  3156 	    count = str.ReadInt32L();
  3245 	    count = str.ReadInt32L();
  3157         str.Release();
  3246         str.Release();
  3158         }
  3247         }
  3186 		
  3275 		
  3187 		
  3276 		
  3188 		CHuiCanvasVisual* canvas = static_cast<CHuiCanvasVisual*>(viz);
  3277 		CHuiCanvasVisual* canvas = static_cast<CHuiCanvasVisual*>(viz);
  3189 		canvas->SetShape( origin, region );
  3278 		canvas->SetShape( origin, region );
  3190 		
  3279 		
  3191 		iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(ETrue);
  3280 		iAlfScreens[0]->SetVisualTreeVisibilityChanged(ETrue);
  3192 		}
  3281 		}
  3193 	else
  3282 	else
  3194 		{
  3283 		{
  3195 		__ALFLOGSTRING("CAlfBridge::HandleSetWindowAreaL, EAlfDSSetWindowArea: Visual not found!");                                                
  3284 		__ALFLOGSTRING("CAlfBridge::HandleSetWindowAreaL, EAlfDSSetWindowArea: Visual not found!");                                                
  3196 		}  
  3285 		}  
  3205 void CAlfBridge::HandleReorderWindowL( TAlfBridgerData& aData )
  3294 void CAlfBridge::HandleReorderWindowL( TAlfBridgerData& aData )
  3206 	{
  3295 	{
  3207 	TInt windowGroupNodeId = aData.iInt1;
  3296 	TInt windowGroupNodeId = aData.iInt1;
  3208 	TInt windowNodeId = aData.iInt2;
  3297 	TInt windowNodeId = aData.iInt2;
  3209 	TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*) (*iHost)->GetVarDataL( (TInt)aData.iPtr );
  3298 	TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*) (*iHost)->GetVarDataL( (TInt)aData.iPtr );
  3210 	TInt screenNumber = windowAttributes->iScreenNumber;
       
  3211 	TInt ordinalPosition = windowAttributes->iOrdinalPosition;
  3299 	TInt ordinalPosition = windowAttributes->iOrdinalPosition;
  3212 
  3300 
  3213 	switch (windowAttributes->iWindowNodeType)
  3301 	switch (windowAttributes->iWindowNodeType)
  3214 		{
  3302 		{
  3215 		case EAlfWinTreeNodeGroup:
  3303 		case EAlfWinTreeNodeGroup:
  3225 				{
  3313 				{
  3226 				__ALFLOGSTRING1("CAlfBridge::HandleReorderWindowL, EAlfDSReorder: WS window group going to: %d ",windowAttributes->iOrdinalPosition);                                        
  3314 				__ALFLOGSTRING1("CAlfBridge::HandleReorderWindowL, EAlfDSReorder: WS window group going to: %d ",windowAttributes->iOrdinalPosition);                                        
  3227 				}    
  3315 				}    
  3228 			#endif
  3316 			#endif
  3229 
  3317 
  3230 			CHuiControlGroup* controlGroup = FindControlGroup(windowGroupNodeId,screenNumber);
  3318 			CHuiControlGroup* controlGroup = FindControlGroup(windowGroupNodeId);
  3231 			
  3319 			
  3232             if (!controlGroup)
  3320             if (!controlGroup)
  3233                 {
  3321                 {
  3234                 User::Leave(KErrNotFound);
  3322                 User::Leave(KErrNotFound);
  3235                 }
  3323                 }
  3236             ResolveAfterEffectAppearingApplicationL(controlGroup); // does nothing, if effect is not active on this control group
  3324             ResolveAfterEffectAppearingApplicationL(controlGroup); // does nothing, if effect is not active on this control group
  3237 			// Window server nodes are in inverted Z-order, we switch it here.
  3325 			// Window server nodes are in inverted Z-order, we switch it here.
  3238 			iAlfScreens[screenNumber]->iDisplay->Roster().Hide(*controlGroup);                            
  3326 			iAlfScreens[0]->iDisplay->Roster().Hide(*controlGroup);                            
  3239 			TInt wsWindowGroupCount = 0;
  3327 			TInt wsWindowGroupCount = 0;
  3240 			for (TInt i=0; i<iAlfScreens[screenNumber]->iDisplay->Roster().Count();i++)
  3328 			for (TInt i=0; i<iAlfScreens[0]->iDisplay->Roster().Count();i++)
  3241 				{
  3329 				{
  3242                 if (iAlfScreens[screenNumber]->iDisplay->Roster().ControlGroup(i).Control(0).Role()==EHuiWindowGroupContainer)
  3330                 if (iAlfScreens[0]->iDisplay->Roster().ControlGroup(i).Control(0).Role()==EHuiWindowGroupContainer)
  3243 					{
  3331 					{
  3244 					wsWindowGroupCount++;    
  3332 					wsWindowGroupCount++;    
  3245 					}
  3333 					}
  3246 				}
  3334 				}
  3247 			ordinalPosition = wsWindowGroupCount - windowAttributes->iOrdinalPosition;
  3335 			ordinalPosition = wsWindowGroupCount - windowAttributes->iOrdinalPosition;
  3255 			if (ordinalPosition < -1)
  3343 			if (ordinalPosition < -1)
  3256 				{
  3344 				{
  3257 				ordinalPosition = -1; // show at top ?    
  3345 				ordinalPosition = -1; // show at top ?    
  3258 				}
  3346 				}
  3259 			
  3347 			
  3260 			if (iAlfScreens[screenNumber]->iDisplay && controlGroup)
  3348 			if (iAlfScreens[0]->iDisplay && controlGroup)
  3261 				{
  3349 				{
  3262 				ShowControlGroupL(iAlfScreens[screenNumber]->iDisplay->Roster(), *controlGroup, ordinalPosition, screenNumber); 
  3350 				ShowControlGroupL(iAlfScreens[0]->iDisplay->Roster(), *controlGroup, ordinalPosition); 
  3263 				}
  3351 				}
  3264 			else
  3352 			else
  3265 				{
  3353 				{
  3266 				__ALFLOGSTRING2("CAlfBridge::HandleReorderWindowL, EAlfDSReorder: Control group not found! Screen: %d, Id: %d ", screenNumber, windowNodeId );        
  3354 				__ALFLOGSTRING1("CAlfBridge::HandleReorderWindowL, EAlfDSReorder: Control group not found! Id: %d ", windowNodeId );        
  3267 				}
  3355 				}
  3268 			
  3356 			
  3269 			ReorderAlfControlGroupsL(screenNumber);                                        
  3357 			ReorderAlfControlGroupsL();                                        
  3270 			break;    
  3358 			break;    
  3271 			}
  3359 			}
  3272 		case EAlfWinTreeNodeClient:
  3360 		case EAlfWinTreeNodeClient:
  3273 		case EAlfWinTreeNodeRoot:
  3361 		case EAlfWinTreeNodeRoot:
  3274 		case EAlfWinTreeNodeAnim:
  3362 		case EAlfWinTreeNodeAnim:
  3302 				pos = layoutCount - pos - 1;    
  3390 				pos = layoutCount - pos - 1;    
  3303 				layout->Reorder(*viz, pos);
  3391 				layout->Reorder(*viz, pos);
  3304 				}
  3392 				}
  3305 			else
  3393 			else
  3306 				{
  3394 				{
  3307 				__ALFLOGSTRING2("CAlfBridge::HandleReorderWindowL, EAlfDSReorder: Visual not found! Screen: %d, Id: %d ", screenNumber, windowNodeId );    
  3395 				__ALFLOGSTRING1("CAlfBridge::HandleReorderWindowL, EAlfDSReorder: Visual not found! Id: %d ", windowNodeId );    
  3308 				}                       
  3396 				}                       
  3309 			break;
  3397 			break;
  3310 			}
  3398 			}
  3311 		default:
  3399 		default:
  3312 			{
  3400 			{
  3313 			__ALFLOGSTRING("CAlfBridge::HandleReorderWindowL: Unknown window node type received !");    
  3401 			__ALFLOGSTRING("CAlfBridge::HandleReorderWindowL: Unknown window node type received !");    
  3314 			break;
  3402 			break;
  3315 			}
  3403 			}
  3316 		}
  3404 		}
  3317   
  3405   
  3318 	iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(ETrue); // TODO: Check if really changed
  3406 	iAlfScreens[0]->SetVisualTreeVisibilityChanged(ETrue); // TODO: Check if really changed
  3319 
  3407 
  3320 	AMT_MAP_BRIDGE_SET_ORDINAL_POSITION();
  3408 	AMT_MAP_BRIDGE_SET_ORDINAL_POSITION();
  3321 	}
  3409 	}
  3322 
  3410 
  3323 // ---------------------------------------------------------------------------
  3411 // ---------------------------------------------------------------------------
  3327 void CAlfBridge::HandlePostCanvasBufferL( TAlfBridgerData& aData )
  3415 void CAlfBridge::HandlePostCanvasBufferL( TAlfBridgerData& aData )
  3328 	{
  3416 	{
  3329 	TInt windowGroupNodeId = aData.iInt1;
  3417 	TInt windowGroupNodeId = aData.iInt1;
  3330 	TInt windowNodeId = aData.iInt2;
  3418 	TInt windowNodeId = aData.iInt2;
  3331 	TAlfWindowCommandBufferAttributes* bufferAttributes = (TAlfWindowCommandBufferAttributes*)(*iHost)->GetVarDataL( (TInt)aData.iPtr );
  3419 	TAlfWindowCommandBufferAttributes* bufferAttributes = (TAlfWindowCommandBufferAttributes*)(*iHost)->GetVarDataL( (TInt)aData.iPtr );
  3332 	TInt screenNumber = bufferAttributes->iScreenNumber;
       
  3333 
  3420 
  3334 	CHuiCanvasVisual* viz = (CHuiCanvasVisual*)FindVisual(windowNodeId);
  3421 	CHuiCanvasVisual* viz = (CHuiCanvasVisual*)FindVisual(windowNodeId);
  3335 	
  3422 	
  3336 	// For now we omit drawing commands to ALF window group because in some configurations it causes issues
  3423 	// For now we omit drawing commands to ALF window group because in some configurations it causes issues
  3337 	// TODO: Possible viz->Flags() & EHuiVisualFlagDrawAf.. is not needed anymore. To be checked. Currently this enables floating sprites on the "root visual"
  3424 	// TODO: Possible viz->Flags() & EHuiVisualFlagDrawAf.. is not needed anymore. To be checked. Currently this enables floating sprites on the "root visual"
  3339 	        ||  ( viz && viz->Flags() & EHuiVisualFlagDrawAfterOthers )/* THIS LINE IS HACK FOR DRAWING FLOATING SPRITES */ )
  3426 	        ||  ( viz && viz->Flags() & EHuiVisualFlagDrawAfterOthers )/* THIS LINE IS HACK FOR DRAWING FLOATING SPRITES */ )
  3340 		{
  3427 		{
  3341 #ifdef HUI_DEBUG_TRACK_DRAWING
  3428 #ifdef HUI_DEBUG_TRACK_DRAWING
  3342         TBool tracking( EFalse );
  3429         TBool tracking( EFalse );
  3343 	CHuiControlGroup* controlGroup = FindControlGroup( windowGroupNodeId, screenNumber );
  3430 	CHuiControlGroup* controlGroup = FindControlGroup( windowGroupNodeId, screenNumber );
  3344 	CAlfScreen* screen = iAlfScreens[screenNumber];
  3431 	CAlfScreen* screen = iAlfScreens[0];
  3345 	
  3432 	
  3346 	//TInt clientWindowGroupId = FindClientWindowGroupId( screenNumber, *controlGroup );
  3433 	//TInt clientWindowGroupId = FindClientWindowGroupId( screenNumber, *controlGroup );
  3347 	// NOTE, THE FOLLOWING WServClientFileName MAY CAUSE DEADLOCK. 
  3434 	// NOTE, THE FOLLOWING WServClientFileName MAY CAUSE DEADLOCK. 
  3348 	// THIS DOES NOT HAPPEN IF HUI_DEBUG_TRACK_DRAWING IS NOT ENABLED (DEFAULT)
  3435 	// THIS DOES NOT HAPPEN IF HUI_DEBUG_TRACK_DRAWING IS NOT ENABLED (DEFAULT)
  3349 	TFileName processName;/* = iCommandDebug->WServClientFileName( clientWindowGroupId, CHuiStatic::WsSession() );
  3436 	TFileName processName;/* = iCommandDebug->WServClientFileName( clientWindowGroupId, CHuiStatic::WsSession() );
  3362 	    
  3449 	    
  3363 	    if (!viz->HasCommandBuffers(EFalse))
  3450 	    if (!viz->HasCommandBuffers(EFalse))
  3364 	        {
  3451 	        {
  3365             // For performance resons, only set visual tree changed if this 
  3452             // For performance resons, only set visual tree changed if this 
  3366             // was the first buffer for the window. 
  3453             // was the first buffer for the window. 
  3367 	        iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(ETrue);
  3454 	        iAlfScreens[0]->SetVisualTreeVisibilityChanged(ETrue);
  3368 	        }
  3455 	        }
  3369 
  3456 
  3370 		TPtrC8 commands((TUint8*)bufferAttributes->iBuffer, bufferAttributes->iBufferLength);
  3457 		TPtrC8 commands((TUint8*)bufferAttributes->iBuffer, bufferAttributes->iBufferLength);
  3371 		if ( bufferAttributes->iEmptyThisBuffer )
  3458 		if ( bufferAttributes->iEmptyThisBuffer )
  3372 			{
  3459 			{
  3423 				break;
  3510 				break;
  3424 			}
  3511 			}
  3425 		}
  3512 		}
  3426 	else
  3513 	else
  3427 		{
  3514 		{
  3428 		__ALFLOGSTRING3("CAlfBridge::HandlePostCanvasBufferL, EAlfDSPostCanvasBuffer: Visual not found! Screen: %d, Id: %d, GroupId: %d ", screenNumber, windowNodeId, windowGroupNodeId );                                 
  3515 		__ALFLOGSTRING2("CAlfBridge::HandlePostCanvasBufferL, EAlfDSPostCanvasBuffer: Visual not found! Id: %d, GroupId: %d ",  windowNodeId, windowGroupNodeId );                                 
  3429 		}    
  3516 		}    
       
  3517 	    // Uncomment the following for tracking which application is doing drawing
       
  3518         //__ALFFXLOGSTRING1("CAlfBridge::HandlePostCanvasBufferL 0x%x", viz->Owner().ControlGroup()->SecureId());
  3430 #ifdef	USE_APPLICATION_ENDFULLSCREEN_TIMEOUT	
  3519 #ifdef	USE_APPLICATION_ENDFULLSCREEN_TIMEOUT	
  3431 	    if (iFSFxData
  3520 	    if (iFSFxData
  3432 	            && iFSFxData->iEffectType != CFullScreenEffectState::ENotDefinedEffect 
  3521 	            && iFSFxData->iEffectType != CFullScreenEffectState::ENotDefinedEffect 
  3433 	            && ((iFSFxData->State() == EWaitEndFullScreen && iFSFxData->iTwoPhaseEffect <= CFullScreenEffectState::EFirstPartRunning)))
  3522 	            && ((iFSFxData->State() == EWaitEndFullScreen && iFSFxData->iTwoPhaseEffect <= CFullScreenEffectState::ESecondPartActive)))
  3434 	        {
  3523 	        {
  3435 	        CHuiControlGroup *to_group = NULL;
  3524 	        CHuiControlGroup *to_group = NULL;
  3436             if (iFSFxData->iEffectType == CFullScreenEffectState::EExitEffect)
  3525             if (iFSFxData->iEffectType == CFullScreenEffectState::EExitEffect)
  3437                 {
  3526                 {
  3438                 to_group = FindControlGroupByFullScreenFromEffect();
  3527                 to_group = FindControlGroupByFullScreenFromEffect();
  3503 void CAlfBridge::SetWindowActiveL(CHuiVisual* aVisual, TBool aActive)
  3592 void CAlfBridge::SetWindowActiveL(CHuiVisual* aVisual, TBool aActive)
  3504     {
  3593     {
  3505     TInt effectIndex;
  3594     TInt effectIndex;
  3506     if (!HasActiveEffect(aVisual, effectIndex))
  3595     if (!HasActiveEffect(aVisual, effectIndex))
  3507         {
  3596         {
       
  3597         __ALFFXLOGSTRING2("CAlfBridge::SetWindowActiveL 0x%x - New state: %d", aVisual, aActive);
  3508         // Does not have effect
  3598         // Does not have effect
  3509         if (aActive)
  3599         if (aActive)
  3510             {
  3600             {
  3511             aVisual->ClearFlags(EHuiVisualFlagShouldBeHidden | EHuiVisualFlagShouldBeShown);
  3601             aVisual->ClearFlags(EHuiVisualFlagShouldBeHidden | EHuiVisualFlagShouldBeShown);
  3512             aVisual->iOpacity.Set(KAlfVisualDefaultOpacity);
  3602             aVisual->iOpacity.Set(KAlfVisualDefaultOpacity);
  3568 void CAlfBridge::HandleSetWindowActiveL( TAlfBridgerData& aData )
  3658 void CAlfBridge::HandleSetWindowActiveL( TAlfBridgerData& aData )
  3569 	{
  3659 	{
  3570 	TInt windowGroupNodeId = aData.iInt1;
  3660 	TInt windowGroupNodeId = aData.iInt1;
  3571 	TInt windowNodeId = aData.iInt2;
  3661 	TInt windowNodeId = aData.iInt2;
  3572 	TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*)(*iHost)->GetVarDataL( (TInt)aData.iPtr );
  3662 	TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*)(*iHost)->GetVarDataL( (TInt)aData.iPtr );
  3573 	TInt screenNumber = windowAttributes->iScreenNumber;
       
  3574 
  3663 
  3575     if (windowAttributes->iWindowNodeType == EAlfWinTreeNodeTextCursor && iCursorTimer)
  3664     if (windowAttributes->iWindowNodeType == EAlfWinTreeNodeTextCursor && iCursorTimer)
  3576 	    {
  3665 	    {
  3577 		if (!windowAttributes->iActive)
  3666 		if (!windowAttributes->iActive)
  3578 		    {
  3667 		    {
  3587 
  3676 
  3588 	switch (windowAttributes->iWindowNodeType)
  3677 	switch (windowAttributes->iWindowNodeType)
  3589 		{
  3678 		{
  3590 		case EAlfWinTreeNodeGroup:
  3679 		case EAlfWinTreeNodeGroup:
  3591 			{
  3680 			{
  3592 			CHuiControlGroup* controlGroup = FindControlGroup(windowGroupNodeId,screenNumber);
  3681 			CHuiControlGroup* controlGroup = FindControlGroup(windowGroupNodeId);
  3593 			if (controlGroup)
  3682 			if (controlGroup)
  3594 				{
  3683 				{
  3595 				CHuiControl& control = controlGroup->Control(0);
  3684 				CHuiControl& control = controlGroup->Control(0);
  3596 				CHuiLayout* layout = (CHuiLayout*)&control.Visual(0);
  3685 				CHuiLayout* layout = (CHuiLayout*)&control.Visual(0);
  3597                 // Uses opacity for now
  3686                 // Uses opacity for now
  3633 			__ALFLOGSTRING("CAlfBridge::HandleSetWindowActiveL, EAlfDSSetWindowActive: Unknown iWindowNodeType!");                                                         	
  3722 			__ALFLOGSTRING("CAlfBridge::HandleSetWindowActiveL, EAlfDSSetWindowActive: Unknown iWindowNodeType!");                                                         	
  3634 			USER_INVARIANT();
  3723 			USER_INVARIANT();
  3635 			break;                       	        
  3724 			break;                       	        
  3636 			}
  3725 			}
  3637 		}
  3726 		}
  3638     iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(ETrue);	// TODO: Check if really changed                       
  3727     iAlfScreens[0]->SetVisualTreeVisibilityChanged(ETrue);	// TODO: Check if really changed                       
  3639 
  3728 
  3640     AMT_INC_COUNTER( iTotalVisualFlagChangedCount );
  3729     AMT_INC_COUNTER( iTotalVisualFlagChangedCount );
  3641     AMT_INC_COUNTER_IF( windowAttributes->iActive, iActiveVisualCount );
  3730     AMT_INC_COUNTER_IF( windowAttributes->iActive, iActiveVisualCount );
  3642     AMT_INC_COUNTER_IF( !windowAttributes->iActive, iPassiveVisualCount );
  3731     AMT_INC_COUNTER_IF( !windowAttributes->iActive, iPassiveVisualCount );
  3643 
  3732 
  3655 void CAlfBridge::HandleSetWindowFlagL( TAlfBridgerData& aData, TInt aOp )
  3744 void CAlfBridge::HandleSetWindowFlagL( TAlfBridgerData& aData, TInt aOp )
  3656     {
  3745     {
  3657     TInt windowGroupNodeId = aData.iInt1;
  3746     TInt windowGroupNodeId = aData.iInt1;
  3658     TInt windowNodeId = aData.iInt2;
  3747     TInt windowNodeId = aData.iInt2;
  3659     TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*)(*iHost)->GetVarDataL( (TInt)aData.iPtr );
  3748     TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*)(*iHost)->GetVarDataL( (TInt)aData.iPtr );
  3660     TInt screenNumber = windowAttributes->iScreenNumber;
       
  3661     TInt windowFlag = windowAttributes->iActive;
  3749     TInt windowFlag = windowAttributes->iActive;
  3662     THuiVisualFlags visualFlag = (THuiVisualFlags)0;
  3750     THuiVisualFlags visualFlag = (THuiVisualFlags)0;
  3663     switch(windowFlag)
  3751     switch(windowFlag)
  3664         {
  3752         {
  3665         case TAlfWindowData::EShouldInactivate:
  3753         case TAlfWindowData::EShouldInactivate:
  3677     
  3765     
  3678     switch (windowAttributes->iWindowNodeType)
  3766     switch (windowAttributes->iWindowNodeType)
  3679         {
  3767         {
  3680         case EAlfWinTreeNodeGroup:
  3768         case EAlfWinTreeNodeGroup:
  3681             {
  3769             {
  3682             CHuiControlGroup* controlGroup = FindControlGroup(windowGroupNodeId,screenNumber);
  3770             CHuiControlGroup* controlGroup = FindControlGroup(windowGroupNodeId);
  3683             if (controlGroup)
  3771             if (controlGroup)
  3684                 {
  3772                 {
  3685                 CHuiControl& control = controlGroup->Control(0);
  3773                 CHuiControl& control = controlGroup->Control(0);
  3686                 CHuiLayout* layout = (CHuiLayout*)&control.Visual(0);
  3774                 CHuiLayout* layout = (CHuiLayout*)&control.Visual(0);
  3687                 // Uses opacity for now                            
  3775                 // Uses opacity for now                            
  3738             __ALFLOGSTRING("CAlfBridge::HandleSetWindowFlagL, HandleSetWindowFlagL: Unknown iWindowNodeType!");                                                          
  3826             __ALFLOGSTRING("CAlfBridge::HandleSetWindowFlagL, HandleSetWindowFlagL: Unknown iWindowNodeType!");                                                          
  3739             USER_INVARIANT();
  3827             USER_INVARIANT();
  3740             break;                                  
  3828             break;                                  
  3741             }
  3829             }
  3742         }
  3830         }
  3743     iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(ETrue); // TODO: Check if really changed                       
  3831     iAlfScreens[0]->SetVisualTreeVisibilityChanged(ETrue); // TODO: Check if really changed                       
  3744     }
  3832     }
  3745 
  3833 
  3746 // ---------------------------------------------------------------------------
  3834 // ---------------------------------------------------------------------------
  3747 // InsertImageBrushL
  3835 // InsertImageBrushL
  3748 // ---------------------------------------------------------------------------
  3836 // ---------------------------------------------------------------------------
  3822 void CAlfBridge::HandleSetSurfaceExtentL( TAlfBridgerData& aData )
  3910 void CAlfBridge::HandleSetSurfaceExtentL( TAlfBridgerData& aData )
  3823 	{
  3911 	{
  3824 	TInt windowGroupNodeId = aData.iInt1;
  3912 	TInt windowGroupNodeId = aData.iInt1;
  3825 	TInt windowNodeId = aData.iInt2;
  3913 	TInt windowNodeId = aData.iInt2;
  3826 	TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*)(*iHost)->GetVarDataL( (TInt)aData.iPtr );
  3914 	TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*)(*iHost)->GetVarDataL( (TInt)aData.iPtr );
  3827 	TInt screenNumber = windowAttributes->iScreenNumber;
       
  3828 	// fetch visual
  3915 	// fetch visual
  3829 	CHuiCanvasVisual* viz = FindVisual(windowNodeId);
  3916 	CHuiCanvasVisual* viz = FindVisual(windowNodeId);
  3830 
  3917 
  3831     // We should not do this for alf window, but renderstage does not know if it is
  3918     // We should not do this for alf window, but renderstage does not know if it is
  3832     // handling alf window or other window, so we ignore the request here if needed.
  3919     // handling alf window or other window, so we ignore the request here if needed.
  3858 	else
  3945 	else
  3859 		{
  3946 		{
  3860 		if (iAlfWindowGroupNodeId != windowGroupNodeId)
  3947 		if (iAlfWindowGroupNodeId != windowGroupNodeId)
  3861 		    __ALFLOGSTRING("CAlfBridge::HandleSetSurfaceExtentL, EAlfDSSetSurfaceExtent: Visual not found!");    
  3948 		    __ALFLOGSTRING("CAlfBridge::HandleSetSurfaceExtentL, EAlfDSSetSurfaceExtent: Visual not found!");    
  3862 		}                            
  3949 		}                            
  3863     iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(ETrue); // TODO: Check if really changed   
  3950     iAlfScreens[0]->SetVisualTreeVisibilityChanged(ETrue); // TODO: Check if really changed   
  3864 	}
  3951 	}
  3865 
  3952 
  3866 // ---------------------------------------------------------------------------
  3953 // ---------------------------------------------------------------------------
  3867 // HandleLayerUsesAlphaFlagChanged
  3954 // HandleLayerUsesAlphaFlagChanged
  3868 // ---------------------------------------------------------------------------
  3955 // ---------------------------------------------------------------------------
  3870 void CAlfBridge::HandleLayerUsesAlphaFlagChanged( TAlfBridgerData& aData )
  3957 void CAlfBridge::HandleLayerUsesAlphaFlagChanged( TAlfBridgerData& aData )
  3871     {
  3958     {
  3872     TInt windowGroupNodeId = aData.iInt1;
  3959     TInt windowGroupNodeId = aData.iInt1;
  3873     TInt windowNodeId = aData.iInt2;
  3960     TInt windowNodeId = aData.iInt2;
  3874     TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*)(*iHost)->GetVarDataL( (TInt)aData.iPtr );
  3961     TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*)(*iHost)->GetVarDataL( (TInt)aData.iPtr );
  3875     TInt screenNumber = windowAttributes->iScreenNumber;
       
  3876     
  3962     
  3877     // fetch visual
  3963     // fetch visual
  3878     CHuiCanvasVisual* viz = (CHuiCanvasVisual*)FindVisual(windowNodeId);
  3964     CHuiCanvasVisual* viz = (CHuiCanvasVisual*)FindVisual(windowNodeId);
  3879 
  3965 
  3880     // We should not do this for alf window, but renderstage does not know if it is
  3966     // We should not do this for alf window, but renderstage does not know if it is
  3887     else
  3973     else
  3888         {
  3974         {
  3889         if (iAlfWindowGroupNodeId != windowGroupNodeId)
  3975         if (iAlfWindowGroupNodeId != windowGroupNodeId)
  3890             __ALFLOGSTRING("CAlfBridge::HandleLayerUsesAlphaFlagChanged: Visual not found!");    
  3976             __ALFLOGSTRING("CAlfBridge::HandleLayerUsesAlphaFlagChanged: Visual not found!");    
  3891         }                            
  3977         }                            
  3892     iAlfScreens[screenNumber]->SetVisualTreeVisibilityChanged(ETrue); // TODO: Check if really changed   
  3978     iAlfScreens[0]->SetVisualTreeVisibilityChanged(ETrue); // TODO: Check if really changed   
  3893     }
  3979     }
  3894 
  3980 
  3895 
  3981 
  3896 // ---------------------------------------------------------------------------
  3982 // ---------------------------------------------------------------------------
  3897 // HandleGetNativeWindowDataL
  3983 // HandleGetNativeWindowDataL
  4332         }
  4418         }
  4333     
  4419     
  4334     return (didFadeEffectLoad || alreadyFaded);
  4420     return (didFadeEffectLoad || alreadyFaded);
  4335     }
  4421     }
  4336 
  4422 
       
  4423 // ---------------------------------------------------------------------------
       
  4424 //	HandleGroupChained
       
  4425 //
       
  4426 // 	Chain information is used for redirecting effects to correct windowgroup
       
  4427 // ---------------------------------------------------------------------------
       
  4428 //
       
  4429 void CAlfBridge::HandleGroupChained( TAlfBridgerData& aData)
       
  4430     {
       
  4431     TInt parentId = aData.iInt1;
       
  4432     TInt chainedId = aData.iInt2;
       
  4433        
       
  4434     TChainData data(parentId, chainedId);
       
  4435     iWindowChainsArray.Insert(parentId,data);
       
  4436     __ALFFXLOGSTRING3("CAlfBridge::DoDispatchL, EAlfDSGroupChained %d chained to %d (host), iWindowChainsArray.Count() = %d", chainedId, parentId, iWindowChainsArray.Count());
       
  4437 #ifdef _ALF_FXLOGGING
       
  4438     CHuiControlGroup* parent = FindControlGroup(parentId);
       
  4439     CHuiControlGroup* chained = FindControlGroup(chainedId);
       
  4440 
       
  4441     if (parent)
       
  4442         {
       
  4443         RDebug::Printf("CAlfBridge::DoDispatch - parent: 0x%x", parent->SecureId());
       
  4444         }
       
  4445     if (chained)
       
  4446         {
       
  4447         RDebug::Printf("CAlfBridge::DoDispatch - chained: 0x%x", chained->SecureId());
       
  4448         }
       
  4449 #endif
       
  4450     } 
       
  4451 
       
  4452 // ---------------------------------------------------------------------------
       
  4453 // HandleGroupChainBroken
       
  4454 // ---------------------------------------------------------------------------
       
  4455 //
       
  4456 void CAlfBridge::HandleGroupChainBroken( TAlfBridgerData& aData)
       
  4457     {
       
  4458     TInt parentId = aData.iInt2;
       
  4459     iWindowChainsArray.Remove(parentId);
       
  4460     __ALFFXLOGSTRING2("CAlfBridge::DoDispatchL, EAlfDSGroupChainBroken - parent: %d, iWindowChainsArray.Count() = %d", parentId, iWindowChainsArray.Count());
       
  4461     }
  4337 
  4462 
  4338 // ---------------------------------------------------------------------------
  4463 // ---------------------------------------------------------------------------
  4339 // HandleMoveWindowToNewGroupL
  4464 // HandleMoveWindowToNewGroupL
  4340 // ---------------------------------------------------------------------------
  4465 // ---------------------------------------------------------------------------
  4341 // 
  4466 // 
  4342 void CAlfBridge::HandleMoveWindowToNewGroupL( TAlfBridgerData& aData )
  4467 void CAlfBridge::HandleMoveWindowToNewGroupL( TAlfBridgerData& aData )
  4343     {
  4468     {
  4344     TInt windowNodeId = aData.iInt1;
  4469     TInt windowNodeId = aData.iInt1;
  4345     TInt screenNumber = aData.iInt2;
       
  4346     TInt newWindowGroupNodeId = (TInt)aData.iPtr;
  4470     TInt newWindowGroupNodeId = (TInt)aData.iPtr;
  4347    
  4471    
  4348     CHuiCanvasVisual* viz = (CHuiCanvasVisual*)FindVisual(windowNodeId);
  4472     CHuiCanvasVisual* viz = (CHuiCanvasVisual*)FindVisual(windowNodeId);
  4349     
  4473     
  4350 #ifdef _ALF_LOGGING
  4474 #ifdef _ALF_LOGGING
  4351     CHuiControlGroup* oldControlGroup = viz->Owner().ControlGroup();
  4475     CHuiControlGroup* oldControlGroup = viz->Owner().ControlGroup();
  4352     TInt oldWindowGroupId = 0; 
  4476     TInt oldWindowGroupId = 0; 
  4353     if ( oldControlGroup  )
  4477     if ( oldControlGroup  )
  4354         {
  4478         {
  4355         oldWindowGroupId = FindWindowGroupNodeId(screenNumber, *oldControlGroup );
  4479         oldWindowGroupId = FindWindowGroupNodeId(*oldControlGroup );
  4356         }   
  4480         }   
  4357     __ALFLOGSTRING3("CAlfBridge::HandleMoveWindowToNewGroupL moving nodeId 0x%x from group 0x%x to 0x%x ",windowNodeId, oldWindowGroupId, newWindowGroupNodeId );
  4481     __ALFLOGSTRING3("CAlfBridge::HandleMoveWindowToNewGroupL moving nodeId 0x%x from group 0x%x to 0x%x ",windowNodeId, oldWindowGroupId, newWindowGroupNodeId );
  4358 #endif
  4482 #endif
  4359     
  4483     
  4360     if (viz)
  4484     if (viz)
  4384         
  4508         
  4385         // remove from the old control
  4509         // remove from the old control
  4386         viz->Owner().Remove(viz);
  4510         viz->Owner().Remove(viz);
  4387         
  4511         
  4388         // #2 insert visual to the beginning of the new group
  4512         // #2 insert visual to the beginning of the new group
  4389         CHuiControlGroup* newControlGroup = FindControlGroup(newWindowGroupNodeId,screenNumber);
  4513         CHuiControlGroup* newControlGroup = FindControlGroup(newWindowGroupNodeId);
  4390         if (newControlGroup)
  4514         if (newControlGroup)
  4391             {
  4515             {
  4392             CHuiControl& newControl = newControlGroup->Control(0);
  4516             CHuiControl& newControl = newControlGroup->Control(0);
  4393             if ( isRootOfTheMovingTree )
  4517             if ( isRootOfTheMovingTree )
  4394                 {
  4518                 {
  4430         {
  4554         {
  4431         viz = (CHuiVisual*)FindVisual(windowNodeId);
  4555         viz = (CHuiVisual*)FindVisual(windowNodeId);
  4432         }
  4556         }
  4433     else
  4557     else
  4434         {
  4558         {
  4435         CHuiControlGroup* cg = FindControlGroup(windowNodeId, 0); // TODO: Screen            
  4559         CHuiControlGroup* cg = FindControlGroup(windowNodeId); // TODO: Screen            
  4436         if (cg) 
  4560         if (cg) 
  4437             {
  4561             {
  4438             CHuiControl& control = cg->Control(0);
  4562             CHuiControl& control = cg->Control(0);
  4439             viz = &control.Visual(0);
  4563             viz = &control.Visual(0);
  4440             }        
  4564             }        
  4622         __ALFFXLOGSTRING("CAlfBridge::StoreLayoutIfRequiredByEffectL - Storing not required");
  4746         __ALFFXLOGSTRING("CAlfBridge::StoreLayoutIfRequiredByEffectL - Storing not required");
  4623         return ETrue; // no storing requred, no screenshot required => success
  4747         return ETrue; // no storing requred, no screenshot required => success
  4624         }
  4748         }
  4625     }
  4749     }
  4626 
  4750 
  4627 TBool CAlfBridge::HandleGfxEventL(CFullScreenEffectState& aEvent, CHuiLayout* aToLayout, CHuiLayout *aFromLayout)
  4751 // ---------------------------------------------------------------------------
       
  4752 // HandleGfxRedirection
       
  4753 //
       
  4754 // This effect might have been request for the host application, while the intent was to show it on the application started embedded.
       
  4755 // Embedded application has its _own_ windowgroup separate from the host application. Fullscreen effect are shown on a windowgroup level.
       
  4756 // e.g. Messaging -> New Message (editor), or Settings -> Themes (application)
       
  4757 // Wserv notifies us the window group chaining of applications. See HandleGroupChained and HandleGroupChainBroken for more details. This code
       
  4758 // will redirect the requested effect on correct windowgroup.
       
  4759 //
       
  4760 // NOTE! If embedded application effects are implemented, this will need revision
       
  4761 // ---------------------------------------------------------------------------
       
  4762     
       
  4763 void CAlfBridge::HandleGfxRedirection(CFullScreenEffectState& aEvent, CHuiLayout*& aToLayout)
       
  4764     {
       
  4765     TInt windowGroupNodeId = FindWindowGroupNodeId(*((*aToLayout).Owner().ControlGroup()));
       
  4766     CHuiControlGroup* chainedGroup = NULL;
       
  4767     
       
  4768     // check, if the effect is being asked for chained application. This propably indicates that there are two or more instances of it and 
       
  4769     // effect was supposed to go to the single standalone instance
       
  4770     if (IsChainedGroup(windowGroupNodeId))
       
  4771         { 
       
  4772         RPointerArray<CHuiControlGroup> groupList;
       
  4773         FindControlGroupBySecureId(aEvent.iToSecureId, groupList);
       
  4774         TInt i = groupList.Count();
       
  4775         TInt standaloneGroups = 0;
       
  4776         while(--i >= 0)
       
  4777             {
       
  4778             windowGroupNodeId = FindWindowGroupNodeId(*groupList[i]);
       
  4779             
       
  4780             if (!IsChainedGroup(windowGroupNodeId))
       
  4781                 {
       
  4782                 // This is an educated guess, which will make the standalone version to have effect. 
       
  4783                 // Currently (tm) standard appstart effect is never requested for embbedded instances. 
       
  4784                 chainedGroup = groupList[i];
       
  4785                 standaloneGroups++;
       
  4786                 __ALFFXLOGSTRING2("CAlfBridge::HandleGfxRedirection - Wg id: %d is NOT chained. Index: %d",windowGroupNodeId, i);
       
  4787                 }
       
  4788             else
       
  4789                 {
       
  4790                 __ALFFXLOGSTRING2("CAlfBridge::HandleGfxRedirection - Wg id: %d IS chained. Index: %d", windowGroupNodeId, i);
       
  4791                 }
       
  4792             }
       
  4793         groupList.Close();
       
  4794         // If there are multiple standalone app groups (e.g. single application having multiple groups), effecting anything would be a guess.
       
  4795         if (standaloneGroups>1)
       
  4796             {
       
  4797             chainedGroup = NULL;
       
  4798             aEvent.iIsRedirected = ETrue;
       
  4799             if (iFSFXDataPart2)
       
  4800                 {
       
  4801                 iFSFXDataPart2->iIsRedirected = ETrue;
       
  4802                 }
       
  4803             }
       
  4804         }
       
  4805     else
       
  4806         {
       
  4807         // Which group is chained to this group?
       
  4808         TUint32 chainedId = FindChainedGroup(windowGroupNodeId); 
       
  4809         chainedGroup = FindControlGroup(chainedId);
       
  4810         }
       
  4811     
       
  4812     if (chainedGroup)
       
  4813         {
       
  4814         __ALFFXLOGSTRING2("CAlfBridge::HandleGfxEffects - Chained app found for this application. Transferring effect from 0x%x to 0x%x.", aToLayout->Owner().ControlGroup()->SecureId(), chainedGroup->SecureId());
       
  4815         aToLayout = (CHuiLayout*)&chainedGroup->Control(0).Visual(0);
       
  4816         // we'll change the original effect request to point to this new group. Thus, if effect is 
       
  4817         // canceled, it will be removed from the right place.
       
  4818         aEvent.iIsRedirected = ETrue;
       
  4819         aEvent.iToSecureId = chainedGroup->SecureId(); // Update the effect
       
  4820         aEvent.iToWg = FindClientWindowGroupId(*chainedGroup);
       
  4821         
       
  4822         if (iFSFXDataPart2)
       
  4823             {
       
  4824             iFSFXDataPart2->iIsRedirected = ETrue;
       
  4825             iFSFXDataPart2->iToSecureId = aEvent.iToSecureId;
       
  4826             iFSFXDataPart2->iToWg = aEvent.iToWg;
       
  4827             }
       
  4828         }
       
  4829     }
       
  4830 
       
  4831 // ---------------------------------------------------------------------------
       
  4832 // HandleGfxEventL
       
  4833 //
       
  4834 // ---------------------------------------------------------------------------
       
  4835 //
       
  4836 TBool CAlfBridge::HandleGfxEventL(CFullScreenEffectState& aEvent, CHuiLayout* aToLayout, CHuiLayout* /*aFromLayout */)
  4628     {
  4837     {
  4629     __ALFFXLOGSTRING3("CAlfBridge::HandleGfxEventL - To SecureUid: 0x%x, From SecureUid: 0x%x, effect %S", aEvent.iToSecureId, aEvent.iFromSecureId, aEvent.iEffectName);
  4838     __ALFFXLOGSTRING3("CAlfBridge::HandleGfxEventL - To SecureUid: 0x%x, From SecureUid: 0x%x, effect %S", aEvent.iToSecureId, aEvent.iFromSecureId, aEvent.iEffectName);
  4630     __ALFFXLOGSTRING4("CAlfBridge::HandleGfxEventL - To layout: 0x%x, From layout: 0x%x, Effect handle: %d, Action: %d", aToLayout, aFromLayout, aEvent.iHandle, aEvent.iAction);
  4839     __ALFFXLOGSTRING3("CAlfBridge::HandleGfxEventL - To layout: 0x%x Effect handle: %d, Action: %d", aToLayout, aEvent.iHandle, aEvent.iAction);
  4631     
  4840     
       
  4841     if (!aEvent.iIsRedirected)
       
  4842         {
       
  4843         HandleGfxRedirection(aEvent, aToLayout);
       
  4844         }
       
  4845         
  4632     TInt err = KErrNone;
  4846     TInt err = KErrNone;
  4633     TBool failed = EFalse;
  4847     TBool failed = EFalse;
  4634     
  4848     
  4635     // Check if there is an effects engine in HuiEnv
  4849     // Check if there is an effects engine in HuiEnv
  4636     CHuiFxEffect* effect = NULL;
  4850     CHuiFxEffect* effect = NULL;
  4678                     case AknTransEffect::EApplicationStartRect:
  4892                     case AknTransEffect::EApplicationStartRect:
  4679                     case AknTransEffect::EApplicationStartSwitch:
  4893                     case AknTransEffect::EApplicationStartSwitch:
  4680                     case AknTransEffect::EApplicationStartSwitchRect:
  4894                     case AknTransEffect::EApplicationStartSwitchRect:
  4681                     case KAlfFSTaskSwapperAppStart:
  4895                     case KAlfFSTaskSwapperAppStart:
  4682                         {
  4896                         {
  4683                         aToLayout->iOpacity.Set(0.0f);    // these are meant for applications that are not yet ready to be drawn, but possible already on the foreground
       
  4684                         FreezeLayoutUntilEffectDestroyedL(aFromLayout, aEvent.iHandle);
       
  4685                         aEvent.iEffectType = CFullScreenEffectState::EStartEffect;
  4897                         aEvent.iEffectType = CFullScreenEffectState::EStartEffect;
  4686                         if (iFSFXDataPart2)
  4898                         if (iFSFXDataPart2)
  4687                             {
  4899                             {
  4688                             iFSFXDataPart2->iEffectType = CFullScreenEffectState::EStartEffect; 
  4900                             iFSFXDataPart2->iEffectType = CFullScreenEffectState::EStartEffect; 
  4689                             }
  4901                             }
  4762                         aToLayout->iOpacity.Set(1.0f);
  4974                         aToLayout->iOpacity.Set(1.0f);
  4763                         }
  4975                         }
  4764                         
  4976                         
  4765                     if (aToLayout)
  4977                     if (aToLayout)
  4766                         {
  4978                         {
  4767                         // if this was timeout appstart effect, we need to take screenshot at this point. 
  4979                          
  4768                         // It was not taken in the beginfullscreen
  4980                         // However, if this is timeout, then we should be having update to date screenshot for the long app start effect usage
  4769                         
  4981                         // For the second part of the effect, screenshot must be update. Thus the transition may continue smoothly, where app_start_long.fxml finished.
  4770                         if (aEvent.iLongAppStartTimeout)
  4982                         if ((aEvent.iLongAppStartTimeout && !aToLayout->StoredRenderBuffer()) 
       
  4983                                 || aEvent.iTwoPhaseEffect == CFullScreenEffectState::ESecondPartActive // update the screenshot, that the app_start effect can use the end result of app_start_long.fxml as input
       
  4984 								)
  4771                             {
  4985                             {
  4772                             __ALFFXLOGSTRING1("CAlfBridge::HandleGfxEventL  - taking screenshot for the timeout appstart effect. Handle: %d",  aEvent.iHandle );
  4986                             __ALFFXLOGSTRING1("CAlfBridge::HandleGfxEventL  - taking screenshot for the timeout appstart effect. Handle: %d",  aEvent.iHandle );
  4773                             aToLayout->SetStoredRenderBufferModificationsEnabled(ETrue);
  4987                             aToLayout->SetStoredRenderBufferModificationsEnabled(ETrue);
  4774                             TBool neededStoredBuffers(EFalse); // dummy 
  4988                             TBool neededStoredBuffers(EFalse); // dummy 
  4775                             StoreLayoutIfRequiredByEffectL(aToLayout, aEvent, neededStoredBuffers);
  4989                             StoreLayoutIfRequiredByEffectL(aToLayout, aEvent, neededStoredBuffers);
  4822                                 {
  5036                                 {
  4823                                 engine->AddEffectToGroup(activeEffectGroup);
  5037                                 engine->AddEffectToGroup(activeEffectGroup);
  4824                                 }
  5038                                 }
  4825                             __ALFFXLOGSTRING1("CAlfBridge::HandleGfxEventL - Active effect group: %d", activeEffectGroup);
  5039                             __ALFFXLOGSTRING1("CAlfBridge::HandleGfxEventL - Active effect group: %d", activeEffectGroup);
  4826                             effectFlags = KHuiFxDelayRunUntilFirstFrameHasBeenDrawn;
  5040                             effectFlags = KHuiFxDelayRunUntilFirstFrameHasBeenDrawn;
  4827                             if (FxmlHasOpaqueHint(iHuiEnv->EffectsEngine(), *aEvent.iEffectName) ||
  5041                             if (FxmlHasOpaqueHint(iHuiEnv->EffectsEngine(), *aEvent.iEffectName))
  4828                                     aEvent.iTwoPhaseEffect == CFullScreenEffectState::ESecondPartActive)
       
  4829                                 {
  5042                                 {
  4830                                 effectFlags |= KHuiFxOpaqueHint;
  5043                                 effectFlags |= KHuiFxOpaqueHint;
  4831                                 }
  5044                                 }
  4832                             if (iFSFXDataPart2)
  5045                             if (iFSFXDataPart2)
  4833                                 {
  5046                                 {
  4890 void CAlfBridge::FreezeLayoutUntilEffectDestroyedL(CHuiLayout* aLayout, TInt aHandle)
  5103 void CAlfBridge::FreezeLayoutUntilEffectDestroyedL(CHuiLayout* aLayout, TInt aHandle)
  4891     {
  5104     {
  4892     if (aLayout)
  5105     if (aLayout)
  4893         {
  5106         {
  4894 		TRAPD(err, StoreRenderBufferStartL(aLayout));
  5107 		TRAPD(err, StoreRenderBufferStartL(aLayout));
  4895 		__ALFFXLOGSTRING2("CAlfBridge::FreezeLayoutUntilEffectDestroyed - StoreRenderBufferStartL call returned: %d for layout 0x%x", err, aLayout);
  5108 		__ALFFXLOGSTRING3("CAlfBridge::FreezeLayoutUntilEffectDestroyed - Storing SecureId x%x, StoreRenderBufferStartL call returned: %d for layout 0x%x", aLayout->Owner().ControlGroup()->SecureId(), err, aLayout);
  4896 		if (err == KErrNone)
  5109 		if (err == KErrNone)
  4897 			{
  5110 			{
  4898             // Freeze only, if buffer was reserved succesfully 
  5111             // Freeze only, if buffer was reserved succesfully 
  4899             aLayout->SetFreezeState(ETrue);
  5112             aLayout->SetFreezeState(ETrue);
  4900         	TBool itemsDestroyed;
  5113         	if (!HasActiveEffect(aLayout))
  4901     	    AddFxItemL(aHandle, aLayout, NULL, NULL, EFalse, itemsDestroyed, ETrue, EFalse);
  5114         	    {
       
  5115         	    TBool itemsDestroyed;
       
  5116         	    AddFxItemL(aHandle, aLayout, NULL, NULL, EFalse, itemsDestroyed, ETrue, EFalse);
       
  5117         	    }
  4902 	        iFSFxData->iAppStartScreenshotItemHandle = aHandle;
  5118 	        iFSFxData->iAppStartScreenshotItemHandle = aHandle;
  4903 			}
  5119 			}
  4904         }
  5120         }
  4905     }
  5121     }
  4906 
  5122 
  5007     TInt operation = stream.ReadInt32L();
  5223     TInt operation = stream.ReadInt32L();
  5008     
  5224     
  5009     // If we are in low memory state, we don't want to do any effects
  5225     // If we are in low memory state, we don't want to do any effects
  5010     if(iHuiEnv->MemoryLevel() < EHuiMemoryLevelReduced)
  5226     if(iHuiEnv->MemoryLevel() < EHuiMemoryLevelReduced)
  5011         {
  5227         {
  5012         __ALFFXLOGSTRING("CAlfBridge::HandleGfxEffectsL - Returning because memory level below NORMAL");
  5228         __ALFFXLOGSTRING("CAlfBridge::HandleGfxEffectsL - WARNING! - Returning because memory level below NORMAL - EFFECT IS NOT SHOWN!");
  5013 		stream.Release();
  5229 		stream.Release();
  5014         return;
  5230         return;
  5015         }
  5231         }
  5016      
  5232      
  5017     if ( operation == MAlfGfxEffectPlugin::EBeginFullscreen )
  5233     if ( operation == MAlfGfxEffectPlugin::EBeginFullscreen )
  5245         if (fxData && 
  5461         if (fxData && 
  5246                 toGroup 
  5462                 toGroup 
  5247                 && fxData->iOperation == MAlfGfxEffectPlugin::EBeginFullscreen 
  5463                 && fxData->iOperation == MAlfGfxEffectPlugin::EBeginFullscreen 
  5248                 && fxData->iEffectType == CFullScreenEffectState::EStartEffect)
  5464                 && fxData->iEffectType == CFullScreenEffectState::EStartEffect)
  5249             {
  5465             {
       
  5466             __ALFFXLOGSTRING("CAlfBridge::HandleGfxEffectsL - Try triggering effect immediately");
  5250             GfxTriggerEffectWhenFullScreenDrawn(toGroup);
  5467             GfxTriggerEffectWhenFullScreenDrawn(toGroup);
  5251             }
  5468             }
  5252         }
  5469         }
  5253     
  5470     
  5254     for (TInt i = 0; i < iAlfScreens.Count(); i++)
  5471     for (TInt i = 0; i < iAlfScreens.Count(); i++)
  5294     TBool fullscreenCovered(EFalse);
  5511     TBool fullscreenCovered(EFalse);
  5295     TInt dummy = 0;
  5512     TInt dummy = 0;
  5296     
  5513     
  5297     CHuiControl& control = aToGroup->Control(0);
  5514     CHuiControl& control = aToGroup->Control(0);
  5298     CHuiLayout* toLayout = control.VisualCount() > 0 ? (CHuiLayout*)&control.Visual(0) : NULL;
  5515     CHuiLayout* toLayout = control.VisualCount() > 0 ? (CHuiLayout*)&control.Visual(0) : NULL;
  5299     if (!toLayout)
  5516     if (!toLayout || (toLayout->Flags() & EHuiVisualFlagInactive ))
  5300         {
  5517         {
  5301         // no point starting effect, if the layout is still inactive.
  5518         // no point starting effect, if the layout is still inactive.
       
  5519 		__ALFFXLOGSTRING1("CAlfBridge::GfxTriggerEffectWhenFullScreenDrawn - Do not trigger. Layout 0x%x inactive or not found.", toLayout);
  5302         return EFalse;
  5520         return EFalse;
  5303         }
  5521         }
  5304     TBool opaque = ETrue; // in app start case the layout is propably not opaque. Fake it.
  5522     TBool opaque = ETrue; // in app start case the layout is propably not opaque. Fake it.
  5305     IsFullScreenDrawnRecursive(toLayout, *aToGroup, control, fullscreenCovered, fullscreen, screen, dummy, opaque, iAlfScreens[0]->iDisplay->Orientation());
  5523     IsFullScreenDrawnRecursive(toLayout, *aToGroup, control, fullscreenCovered, fullscreen, screen, dummy, opaque, iAlfScreens[0]->iDisplay->Orientation());
  5306     fullscreenCovered = IsRectCoveredByRegion(fullscreen, iTempRegion);
  5524     fullscreenCovered = IsRectCoveredByRegion(fullscreen, iTempRegion);
  5307     // alf content check is relavant only for alf apps
  5525     // alf content check is relavant only for alf apps
  5308     if (!fullscreenCovered && aToGroup->iAlfApp) 
  5526     if (!fullscreenCovered && aToGroup->iAlfApp) 
  5309         {
  5527         {
  5310         TInt clientGroupId = FindClientWindowGroupId(0, *aToGroup);
  5528         TInt clientGroupId = FindClientWindowGroupId(*aToGroup);
  5311         if (clientGroupId != KErrNotFound)
  5529         if (clientGroupId != KErrNotFound)
  5312             {
  5530             {
  5313             fullscreenCovered = HasActiveAlfContent(clientGroupId);
  5531             fullscreenCovered = HasActiveAlfContent(clientGroupId);
  5314             }
  5532             }
  5315         }
  5533         }