uiacceltk/hitchcock/ServerCore/Src/alfbridge.cpp
changeset 21 6ce30188c5bf
parent 19 f5bac0badc7e
child 25 f7f1ae431f74
--- a/uiacceltk/hitchcock/ServerCore/Src/alfbridge.cpp	Mon May 03 13:22:43 2010 +0300
+++ b/uiacceltk/hitchcock/ServerCore/Src/alfbridge.cpp	Fri May 14 16:46:13 2010 +0300
@@ -91,13 +91,21 @@
 const TInt KEffectCleanupDelayInMs = 10;
 
 const TInt KPreventingCollisionOfIdsInSynchDrawRequests = 35;
-
+const TInt KRequestFrameSynchForComposition = -1; // bogus
+
+const TInt KAlfFSTaskSwapperAppStart = 1507;
 _LIT8(KAlfWindowGroupContainerControlTag, "WGROUP");
 
 #define USE_APPLICATION_ENDFULLSCREEN_TIMEOUT
 // This debug option shows window groups in a grid
 //#define ALF_DEBUG_VISUALIZE_WINDOWGROUP_ORDER
 
+// Timeout for manual refresh
+const TInt KAlfManualRefreshTimeout = 35000;
+
+_LIT_SECURITY_POLICY_PASS(KAlwaysPass);
+const TUid KPSSysCategory = { KUidSystemCategoryValue };
+const TUint32 KAlfPSKeyHSVisible = 0x2002EA91;
 
 const TInt KFadeAction = 6000;
 
@@ -174,6 +182,7 @@
 #endif
     delete iCursorTimer;
     delete iLayoutSwitchEffectCoordinator;
+    delete iManualRefreshTimer;
 	}
     
 
@@ -215,6 +224,12 @@
     iOrphanStorage->ConstructL();
 	
     RegisterFadeEffectL();
+    
+    iManualRefreshTimer = CPeriodic::NewL(CActive::EPriorityStandard);
+
+    RProperty::Define( KPSSysCategory, KAlfPSKeyHSVisible, RProperty::EInt, KAlwaysPass, KAlwaysPass );
+    RProperty::Set( KPSSysCategory, KAlfPSKeyHSVisible, 0 );
+    
     }
 
 // ---------------------------------------------------------------------------
@@ -787,6 +802,7 @@
             
             
             // First HandleGfxEvent, then clear iWaitingWindowGroup.
+            __ALFFXLOGSTRING1("CAlfBridge::CreateControlGroupL - try triggering effect 0x%x", layout);
             TBool failed = HandleGfxEventL( *iFullScreenEffectData, layout, fromLayout );
             if ( iFullScreenEffectData )
                 {
@@ -795,6 +811,7 @@
             if ( failed )
                 {
                 // Effect failed, reset state
+                __ALFFXLOGSTRING1("CAlfBridge::CreateControlGroupL - effect failed on layout 0x%x", layout);
                 HandleGfxStopEvent( EFalse ); // destroys iFullScreenEffectData
                 }
             }     
@@ -1355,7 +1372,7 @@
     
     CAlfScreen* screen = iAlfScreens[aScreenNumber];
     TRect fullscreen = TRect(TPoint(0,0), screen->Size());
-    TBool fadeEffectInScreen = EFalse;
+    TBool checkFadeEffectInScreen = EFalse;
     
     
     // Prepare SW render target (if needed)
@@ -1376,6 +1393,7 @@
     
     iBgSurfaceFound = EFalse;
     iHomeScreenWallpaperWindowFound = EFalse;
+    iHomeScreenVisible = EFalse;
    
     // Check if effect group has an effect with opaque hint.
     CHuiControlGroup& fxcontrolgroup = *(iAlfScreens[aScreenNumber]->iFullscreenEffectControlGroup);
@@ -1448,20 +1466,21 @@
                     if(iAppUi)
                         {
                         topMostAlfSrvSession = iAppUi->SrvSessionForControlGroup(controlgroup);
-                        }
-                    TInt clientWindowGroupId = topMostAlfSrvSession->ClientWindowGroup();
-                    __ALFLOGSTRING1("Alf Application: clientWindowGroupId %d", clientWindowGroupId);
-                    // checking the case if there are multiple alf application openend.
-                    if (clientWindowGroupId == iAppUi->GetLastActiveClient())
-                        {
-                        alfWindowGroupFoundVisible = ETrue;
-                        hostContainer->ClearFlags(EHuiVisualFlagInactive);
-
-                        // just add the rect to covered region because alf draws solid background
-                        iTempRegion.AddRect(fullscreen);
-                        iTempRegion.Tidy();
-                        fullscreenCovered = ETrue;
-                        alfClientWindowGroupVisible = EFalse;  // change flag so that we don't go in this branch again
+                        
+                        TInt clientWindowGroupId = topMostAlfSrvSession->ClientWindowGroup();
+                        __ALFLOGSTRING1("Alf Application: clientWindowGroupId %d", clientWindowGroupId);
+                        // checking the case if there are multiple alf application openend.
+                        if (clientWindowGroupId == iAppUi->GetLastActiveClient())
+                            {
+                            __ALFLOGSTRING1("Alf Application: GetLastActiveClient %d", iAppUi->GetLastActiveClient());
+                            alfWindowGroupFoundVisible = ETrue;
+                            hostContainer->ClearFlags(EHuiVisualFlagInactive);
+                            // just add the rect to covered region because alf draws solid background
+                            iTempRegion.AddRect(fullscreen);
+                            iTempRegion.Tidy();
+                            fullscreenCovered = ETrue;
+                            alfClientWindowGroupVisible = EFalse;  // change flag so that we don't go in this branch again
+                            }
                         }
                     }
                 else // else put as inactive
@@ -1507,21 +1526,12 @@
 #endif
             }
         
-		// if native alf app is found visible we can assume it should cover whole screen with alfcontent
-		// this is for embedded native alf application cases. Otherwise chained window groups tend to
-		// flicker from time to time
-        if(!fullscreenCovered && controlgroup.iAlfApp)
-            {
-            alfClientWindowGroupVisible = ETrue;
-            }
-        
-        
         TBool subTreeCovered = EFalse;
         TBool hasLayers = EFalse;
         
         TBool hasActiveVisualsInVisualTree(EFalse);
         
-        //embedded native alf application assumes that it should cover whole screen with alfcontent
+        // native alf application assumes that it should cover whole screen with alfcontent
         // it makes alfeventwindowgroup as inactive and fading is not done on alf content
         // this call is exculsive for alfeventwindowgroup 
         if (alfClientWindowGroupVisible && (controlgroup.ResourceId() == iAlfWindowGroupNodeId))
@@ -1531,7 +1541,6 @@
                    hasActiveVisualsInVisualTree, fullscreen, screen, 
                    subTreeCovered, hasLayers, IsVisualOpaque(*layout),alfClientWindowGroupVisible );
             }
-        
         else
             {
             hasActiveVisualsInVisualTree = 
@@ -1543,11 +1552,21 @@
 
         TBool hasFadeEffectsInVisualTree = (layout->CanvasFlags() & EHuiCanvasFlagExternalFadeExistsInsideVisualTree);        
 
-        if(!fullscreenCovered && alfClientWindowGroupVisible)
-            {
-            iTempRegion.AddRect(fullscreen);
-            iTempRegion.Tidy();
-            fullscreenCovered = ETrue;
+        // if native alf app is found visible and the client it self is not covering whole screen, we can assume that alf content
+        // fills the rest. 
+        // this is for embedded native alf application cases. Otherwise chained window groups tend to
+        // flicker from time to time
+        // also if alfcontent is not hided below avkon content the fading effect would reveal alfconent
+        if(controlgroup.iAlfApp)
+            {
+            fullscreenCovered = IsRectCoveredByRegion(fullscreen, iTempRegion); 
+            if(!fullscreenCovered )
+                {
+                iTempRegion.AddRect(fullscreen);
+                iTempRegion.Tidy();
+                fullscreenCovered = ETrue;
+                alfClientWindowGroupVisible = ETrue;
+                }
             }
         
         // If root visuals effect is marked as opaque, then add whole screen area as covered.
@@ -1566,7 +1585,7 @@
 		// are no more needed get removed.
         if (hasActiveVisualsInVisualTree || (!hasActiveVisualsInVisualTree && hasFadeEffectsInVisualTree))
             {
-            fadeEffectInScreen = ETrue;
+            checkFadeEffectInScreen = ETrue;
             
             // Prepare fade effects to whole visual tree  below layout
             PrepareFadeEffects( *layout );
@@ -1653,7 +1672,22 @@
                 }
             }
         }
-
+        
+    if (iHomeScreenPSValue != iHomeScreenVisible)
+        {
+        TInt value = iHomeScreenVisible;
+        if ((iHomeScreenVisible && iHomeScreenWallpaperWindowFound) || iBgAnimHidden)
+            {
+            value = EFalse;
+            }
+        if (value != iHomeScreenPSValue)
+            {
+            RProperty::Set( KPSSysCategory, KAlfPSKeyHSVisible, value );
+            iHomeScreenPSValue = value;
+            }
+        }
+
+    
     if ( iSwRenderingEnabled )
         {
         screen->iDisplay->SetForegroundTextureOptions( alfWindowGroupFoundVisible );
@@ -1662,7 +1696,7 @@
     // Finally, if there are fadeeffects applied to windowgroups, make sure first one does not
     // blend itself, but other windowgroups do blend. Otherwise windowgrouops above others
     // would clear the screen areas where they do not really draw.
-    if (fadeEffectInScreen)
+    if (checkFadeEffectInScreen)
         {
         TBool firstFadedWindowGroupFound = EFalse;
         for (TInt j=0; j<screen->iDisplay->Roster().Count() - screen->FixedControlGroupCount(); j++) // skip the topmost (effect) layer 
@@ -1851,6 +1885,7 @@
             // We found an _ACTIVE_ window in homescreens controlgroup
             if (aControlGroup.SecureId() == 0x102750F0)
                 {
+                iHomeScreenVisible = ETrue;
                 // which is fully opaque, and visible ...
                 if ( (canvasVisual->iOpacity.Now() > 0.001) && canvasVisual->Flags() & EHuiVisualFlagOpaqueHint)
                     {
@@ -2061,9 +2096,17 @@
             // Determine if surface is visible.
             TBool surfaceWasVisible = ( canvasVisual->CanvasFlags() & EHuiCanvasFlagSurfaceVisible );
             TBool surfaceWasInvisible = ( canvasVisual->CanvasFlags() & EHuiCanvasFlagSurfaceInvisible );
-            __ALFLOGSTRING2("CAlfBridge::HideTarget: %d %d", aVisible, surfaceWasVisible);
+            __ALFLOGSTRING2("CAlfBridge::HandleLayerVisibility aVisible %d surfaceWasVisible %d", aVisible, surfaceWasVisible);
 
             TBool forcedUpdate = !surfaceWasVisible && !surfaceWasInvisible;
+
+#ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS                    
+            if ( !aVisible && canvasVisual->LayerUsesAlphaFlag() )
+                {
+                __ALFLOGSTRING( "CAlfBridge::HandleLayerVisibility LayerUsesAlphaFlag setting visible" ); 
+                aVisible = ETrue;
+                }
+#endif // SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS                    
     
             if ( !aVisible && ( forcedUpdate || surfaceWasVisible ) )
                 {
@@ -2467,6 +2510,11 @@
         	   iHuiEnv->ContinueRefresh();
         	   break;
         	   }
+           case EAlfDSSetDistractionWindow:
+               {
+               HandleSetDistractionWindowL( data );
+               break;
+               }
            case KUnInitialized:
                {
                __ALFLOGSTRING1("CAlfBridge::DoDispatchL: Received KUnInitialized: %d - CRITICAL ERROR!",data.iOp);
@@ -2478,6 +2526,8 @@
               __ALFLOGSTRING1("CAlfBridge::DoDispatchL: Received Unknown op: %d",data.iOp);
               }
             }
+        
+        AsynchRefresh();
         }
    }
 
@@ -2606,14 +2656,10 @@
 	                viz->SetCanvasFlags(EHuiCanvasFlagEnableCanvasClipping);
 	                viz->SetParentCanvas(parentViz);	                
 	                }
-	            else
-	                {
-	                __ALFLOGSTRING1("CAlfBridge::HandleNewWindowL: Parent not found for visual %d!",windowNodeId);    
-	                }								
 				}
 			else
 				{
-				__ALFLOGSTRING1("CAlfBridge::HandleNewWindowL: Control group not found for visual %d!",windowNodeId);    
+				__ALFLOGSTRING1("CAlfBridge::HandleNewWindowL: Control group not found for visual 0x%x!",windowNodeId);    
 				}    
 
 			break; 
@@ -2662,6 +2708,16 @@
     if (layout)
         layout->Remove(aVisual);
     aVisual->Owner().Remove(aVisual);
+    RPointerArray<CHuiLayout> familyTree;
+    ListFamilyTreeL(familyTree, (CHuiLayout*)aVisual); // recursively dig the family tree
+    for (TInt familyIndex = 1; familyIndex < familyTree.Count();familyIndex++)
+        {
+        CHuiLayout* lVisual = familyTree[familyIndex];
+        lVisual->Owner().Remove(lVisual);
+        iOrphanStorage->AppendL( lVisual );
+        }
+    familyTree.Close();
+         
     __ALFLOGSTRING1("CAlfBridge::HandleDestroyWindow - destroying visual 0x%x", aVisual);
     // check if visual is having an effect at the moment. This could occur, if options menu is exited (with effect) and then 
     // application is exited. EHuiVisualFlagDrawOnlyAsExternalContent is indication that
@@ -4483,6 +4539,7 @@
                     case AknTransEffect::EApplicationStartRect:
                     case AknTransEffect::EApplicationStartSwitch:
                     case AknTransEffect::EApplicationStartSwitchRect:
+                    case KAlfFSTaskSwapperAppStart:
                         {
                         aToLayout->iOpacity.Set(0.0f);    // these are meant for applications that are not yet ready to be drawn, but possible already on the foreground
                         FreezeLayoutUntilEffectDestroyedL(aFromLayout, aEvent.iHandle);
@@ -4789,16 +4846,12 @@
 				__ALFFXLOGSTRING("CAlfBridge::HandleGfxEffectsL - WARNING - Another fullscreen effect to different app. Deleting the previous ongoing effect"); 
                 RemoveEffectFromApp(iFullScreenEffectData->iToSecureId, iFullScreenEffectData->iToWg);// Fullscreen effect for another app has arrived, and the previous has not finished and abort effect was not called.
                 RemoveEffectFromApp(iFullScreenEffectData->iFromSecureId, iFullScreenEffectData->iFromWg);
+                __ALFFXLOGSTRING2("CAlfBridge::HandleGfxEffectsL - Effect request has changed from appUid 0x%x to 0x%x. Cancel previous effect.", iFullScreenEffectData->iToAppId, fxData->iToAppId);
+                RemoveEffectFromApp(iFullScreenEffectData->iToAppId);
                 // Fullscreen effect for another 
                 }
 
-            if (iFullScreenEffectData && iFullScreenEffectData->iToAppId != fxData->iToAppId)
-                {
-                // effected application has changed. Only single begin - end request supported at a time.
-                __ALFFXLOGSTRING2("CAlfBridge::HandleGfxEffectsL - Effect request has changed from appUid 0x%x to 0x%x. Cancel previous effect.", iFullScreenEffectData->iToAppId, fxData->iToAppId);
-                RemoveEffectFromApp(iFullScreenEffectData->iToAppId);
-                }
-            delete iFullScreenEffectData;
+               delete iFullScreenEffectData;
             iFullScreenEffectData = fxData;
             iFullScreenEffectData->iAppStartScreenshotItemHandle = fxData->iHandle;
             
@@ -4933,6 +4986,7 @@
     CHuiLayout* toLayout = control.VisualCount() > 0 ? (CHuiLayout*)&control.Visual(0) : NULL;
     if (!toLayout)
         {
+        // no point starting effect, if the layout is still inactive.
         return EFalse;
         }
     TBool opaque = ETrue; // in app start case the layout is propably not opaque. Fake it.
@@ -5006,7 +5060,36 @@
     __ALFFXLOGSTRING("CAlfBridge::HandleGfxStopControlEffectsL - end");
     }
 
-
+void CAlfBridge::HandleSetDistractionWindowL( TAlfBridgerData data )
+    {
+    TInt windowGroupId = data.iInt1;
+    TInt windowClientHandle = data.iInt2;
+    TBool setDistractionWindow = (TBool)data.iPtr;
+        
+    CControlEffectState* fxData = new (ELeave) CControlEffectState;
+    CleanupStack::PushL(fxData);
+    fxData->ConstructL(windowClientHandle, windowGroupId, setDistractionWindow);
+
+    __ALFFXLOGSTRING2("CAlfBridge::HandleSetDistractionWindowL client handle: %d, group: %d",  windowClientHandle, windowGroupId );
+    CHuiCanvasVisual* visual = FindVisualByClientSideIds(windowClientHandle, windowGroupId);
+    
+    iControlEffectData = fxData;
+    CleanupStack::Pop(fxData);
+    
+    if (visual)
+        {
+        HandleGfxControlEventL(*iControlEffectData, visual);
+        }
+    else
+        {
+        __ALFFXLOGSTRING2("CAlfBridge::HandleGfxControlEffectsL - Control not found. iClientHandle %d, iClientGroupHandle %d", 
+                fxData->iClientHandle, 
+                fxData->iClientGroupHandle);
+        return;
+        }
+    delete iControlEffectData;
+    iControlEffectData = NULL;
+    }
 void CAlfBridge::HandleRegisterEffectL( TAlfBridgerData data )
     {     
     TInt action = data.iInt1;
@@ -5270,6 +5353,32 @@
 void CAlfBridge::HandleGfxControlEventL(CControlEffectState& aEvent,
         CHuiCanvasVisual* aCanvasVisual)
     {
+	
+    if (aEvent.iSetDistractionWindow) 
+        {
+		// marks the background clear window that comes as courtesy of the framework.
+		__ALFFXLOGSTRING2("CAlfBridge::HandleGfxControlEventL - setting distraction window 0x%x to state %d", aCanvasVisual, aEvent.iSetDistractionWindow);
+        switch(aEvent.iSetDistractionWindow)
+            {
+            case CControlEffectState::ESetDistractionWindow:
+                {
+                aCanvasVisual->SetCanvasFlags(EHuiCanvasFlagDistractionWindow);
+                break;
+                }
+            case CControlEffectState::ERemoveDistractionWindow:
+                {
+                aCanvasVisual->ClearCanvasFlags(EHuiCanvasFlagDistractionWindow);
+                break;
+                }
+            }
+        return;
+        }
+		
+    if ( aCanvasVisual && aCanvasVisual->Owner().ControlGroup() && aCanvasVisual->Owner().ControlGroup()->SecureId() == 0x101f857A ) // Camera id
+        {
+        __ALFFXLOGSTRING("CAlfBridge::HandleGfxControlEventL - Returning because inside camera app");
+        return;
+        }
     TInt err = KErrNone;
     // Check if there is an effects engine in HuiEnv
     CHuiFxEffect* effect = NULL;
@@ -6041,6 +6150,11 @@
         // SetCapturingBufferL is called from HandleVisualVisibility.
         iAlfScreens[i]->SetVisualTreeVisibilityChanged(ETrue);
         }
+
+    if (!iSwRenderingEnabled && iManualRefreshTimer)
+        {
+        iManualRefreshTimer->Cancel();
+        }
     }
 
 // ---------------------------------------------------------------------------
@@ -6254,7 +6368,11 @@
 // 
 void CAlfBridge::Synchronized(TInt aId)
     {
-    if(aId == iIdForLayoutSwitchFrameSync)
+    if (aId == KRequestFrameSynchForComposition)
+        {
+        return;    
+        }    
+    else if (aId == iIdForLayoutSwitchFrameSync)
         {
         // send notification to alfstreamer server about
         if (iActivated)
@@ -6342,7 +6460,6 @@
     TRect fullscreen = TRect(TPoint(0,0), screen->Size());
     __ALFFXLOGSTRING3("CAlfBridge::IsFullScreenDrawn - new orientation %d, screen size: (%d,%d)", aOrientation, fullscreen.iBr.iX, fullscreen.iBr.iY );
     TBool fullscreenCovered = EFalse;
-    CAlfAppSrvSessionBase* topMostAlfSrvSession = NULL;
         
     // Check if effect group has an effect with opaque hint.
     CHuiControlGroup& fxcontrolgroup = *(iAlfScreens[0]->iFullscreenEffectControlGroup);
@@ -6358,9 +6475,9 @@
         {
         fullscreenCovered = ETrue;
         }    
+
+    TBool alfClientWindowGroupVisible = EFalse;
     
-    TBool alfWindowGroupFoundVisible = EFalse;
-
     AMT_SET_VALUE( iVisibleVisualCount, 0 );
     
     // skip the topmost (effect) layer, start from floating sprite group
@@ -6383,7 +6500,10 @@
         if (!fullscreenCovered)
             {
             fullscreenCovered = IsRectCoveredByRegion(fullscreen, iTempRegion);
-            
+            if(fullscreenCovered)
+                {
+                return ETrue;
+                }
             for(TInt ii=0;ii< iTempRegion.Count(); ii++)
                 {
                 __ALFFXLOGSTRING4("CAlfBridge::IsFullScreenDrawn (%d,%d)-(%d,%d)", iTempRegion[ii].iTl.iX, iTempRegion[ii].iTl.iY , iTempRegion[ii].iBr.iX, iTempRegion[ii].iBr.iY );
@@ -6395,44 +6515,25 @@
             {
             CHuiLayout* hostContainer = control.ContainerLayout( NULL );
             TInt flags = hostContainer->Flags();            
-            if (!fullscreenCovered)
+            if (alfClientWindowGroupVisible)
                 {
-                
+                // check visual sizes if client has not made this control group hidden
                 if(!(flags&EHuiVisualFlagUnderOpaqueHint))
                     {
-                    alfWindowGroupFoundVisible = ETrue;
                     if(iAppUi)
                         {
-                        topMostAlfSrvSession = iAppUi->SrvSessionForControlGroup(controlgroup);
+                        CAlfAppSrvSessionBase* alfSrvSession = iAppUi->SrvSessionForControlGroup(controlgroup);
+                        
+                        TInt clientWindowGroupId = alfSrvSession->ClientWindowGroup();
+                        // checking the case if there are multiple alf application openend.
+                        if (clientWindowGroupId == iAppUi->GetLastActiveClient())
+                            {
+                            if(IsFullScreenDrawnRecursiveAlfContent(hostContainer, fullscreen) )
+                                {
+                                return ETrue;
+                                }
+                            }
                         }
-
-                    // just add the rect to covered region because alf draws solid background
-                    iTempRegion.AddRect(fullscreen);
-                    iTempRegion.Tidy();
-                    fullscreenCovered = ETrue;
-                    }
-                }
-            else if(!alfWindowGroupFoundVisible || flags&EHuiVisualFlagUnderOpaqueHint)
-                {
-                // this alf session control group should not be visible anymore because avkon application is on top
-                // -> change to inactive
-                
-                }
-            else if(!(flags&EHuiVisualFlagUnderOpaqueHint)) // alf app covers full screen
-                {
-                // check if current controlgroup belongs to same srvsession as the topmost visible alf session container
-                CAlfAppSrvSessionBase* alfsrvsession = NULL;
-                if(iAppUi)
-                    {
-                    alfsrvsession = iAppUi->SrvSessionForControlGroup(controlgroup);
-                    }
-                if(topMostAlfSrvSession!=NULL && topMostAlfSrvSession == alfsrvsession)
-                    {
-                
-                    }
-                else
-                    {
-                
                     }
                 }
             continue;
@@ -6450,6 +6551,11 @@
             }                    
         */    
        
+        if(controlgroup.iAlfApp && layout->iOpacity.Now() > 0.0f )
+            {
+            alfClientWindowGroupVisible = ETrue;
+            }
+        
         if (fullscreenCovered)
             {
             return ETrue;
@@ -6458,6 +6564,40 @@
     return fullscreenCovered;
     }
 
+TBool CAlfBridge::IsFullScreenDrawnRecursiveAlfContent(CHuiVisual* aVisual, TRect& aFullScreen)
+    {
+    if(aVisual)
+        {
+        TInt flags = aVisual->Flags();
+        if(!(flags && EHuiVisualFlagInactive) && aVisual->iOpacity.Now() > 0 ) // don't take inactive or invisible visual into account
+            {
+            TPoint point = aVisual->Pos().Now();
+            TPoint size = aVisual->Size().Now();
+            TRect visualRect(point, TSize(size.iX, size.iY));
+            iTempRegion.AddRect(visualRect);
+            iTempRegion.Tidy();
+
+            if( IsRectCoveredByRegion(aFullScreen, iTempRegion) )
+                {
+                return ETrue;
+                }
+            }
+        TInt count = aVisual->Count();
+        if(count)
+            {
+            for(TInt i = 0 ; i < count ; i++)
+                {
+                if( IsFullScreenDrawnRecursiveAlfContent( &aVisual->Visual(i), aFullScreen ) )
+                    {
+                    return ETrue;
+                    }
+                }
+            }
+        }
+    return EFalse;
+    }
+
+
 TBool CAlfBridge::IsFullScreenDrawnRecursive(
         CHuiLayout* aLayout, 
         CHuiControlGroup& aControlGroup,
@@ -6537,7 +6677,9 @@
             visualIsOpaque = EFalse;    
             }
     
-        if (visualIsActive && visualIsOpaque && !visualRectIsCovered)
+        if (visualIsActive && visualIsOpaque && !visualRectIsCovered 
+                && !(canvasVisual->CanvasFlags() & EHuiCanvasFlagDistractionWindow) // exclude the akn clearer window from heuristics 
+                )
             { 
             // New visibility system takes only window shape into account.
             if ( canvasVisual->CanvasFlags() & EHuiCanvasFlagIncludeToVisibilityCalculation )
@@ -6648,5 +6790,39 @@
     return 0;      
     }
 
+void CAlfBridge::RefreshNow(TBool aSyncWait)
+    {
+    if (!iHuiEnv)
+        {
+        return;
+        }
+
+    if (iSwRenderingEnabled && iManualRefreshTimer)
+        {
+        iManualRefreshTimer->Cancel();
+        }
+
+    if (aSyncWait)
+        {
+        iHuiEnv->Synchronize( KRequestFrameSynchForComposition, this );
+        }
+        
+    iHuiEnv->RefreshCallBack((TAny*)iHuiEnv);
+    }
+
+static TInt DoAlfBridgeRefreshNow(TAny* aAny)
+    {
+    CAlfBridge* bridge = static_cast<CAlfBridge*>(aAny);
+    bridge->RefreshNow(EFalse);
+    return KErrNone;
+    }
+
+void CAlfBridge::AsynchRefresh()
+    {
+    if (iSwRenderingEnabled && iManualRefreshTimer && !iManualRefreshTimer->IsActive())
+        {
+        iManualRefreshTimer->Start(KAlfManualRefreshTimeout, KAlfManualRefreshTimeout, TCallBack(DoAlfBridgeRefreshNow, this));
+        }
+    }
 
 // end of file