javauis/mmapi_qt/baseline/src.nga/cmmasurfacewindow.cpp
changeset 61 bf7ee68962da
parent 48 e0d6e9bd3ca7
child 79 2f468c1958d0
--- a/javauis/mmapi_qt/baseline/src.nga/cmmasurfacewindow.cpp	Tue Jul 06 14:10:26 2010 +0300
+++ b/javauis/mmapi_qt/baseline/src.nga/cmmasurfacewindow.cpp	Wed Aug 18 09:43:15 2010 +0300
@@ -70,9 +70,9 @@
 
 void CMMASurfaceWindow::SetDrawRectThread(const TRect& aRect)
 {
-    LOG2(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::SetDrawRectThread TL %d %d",
+    LOG2(EJavaMMAPI, EInfo,  "CMMASurfaceWindow::SetDrawRectThread TL %d %d",
          aRect.iTl.iX, aRect.iTl.iY);
-    LOG2(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::SetDrawRectThread BR %d %d",
+    LOG2(EJavaMMAPI, EInfo,  "CMMASurfaceWindow::SetDrawRectThread BR %d %d",
          aRect.iBr.iX, aRect.iBr.iY);
 
     iContentRect = aRect;
@@ -80,16 +80,16 @@
     TInt error = StaticRedrawVideo(*this);
     if (KErrNone != error)
     {
-        ELOG1(EJavaMMAPI, "MID::CMMASurfaceWindow::SetDrawRectThread, StaticRedrawVideo error = %d", error);
+        ELOG1(EJavaMMAPI, "CMMASurfaceWindow::SetDrawRectThread, StaticRedrawVideo error = %d", error);
     }
 }
 
 void CMMASurfaceWindow::SetRWindowRect(const TRect& aRect,
                                        MMMADisplay::TThreadType aThreadType)
 {
-    LOG2(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::SetRWindowRect TL %d %d",
+    LOG2(EJavaMMAPI, EInfo,  "CMMASurfaceWindow::SetRWindowRect TL %d %d",
          aRect.iTl.iX, aRect.iTl.iY);
-    LOG2(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::SetRWindowRect BR %d %d",
+    LOG2(EJavaMMAPI, EInfo,  "CMMASurfaceWindow::SetRWindowRect BR %d %d",
          aRect.iBr.iX, aRect.iBr.iY);
 
     if (iRWindowRect == aRect)
@@ -122,14 +122,14 @@
         TInt error = SetClipRect();
         if (KErrNone != error)
         {
-            LOG1(EJavaMMAPI,EInfo,"MID::CMMASurfaceWindow::SetRWindowRect, error = %d", error);
+            LOG1(EJavaMMAPI,EInfo,"CMMASurfaceWindow::SetRWindowRect, error = %d", error);
         }
     }
 }
 
 TInt CMMASurfaceWindow::SetClipRect()
 {
-    LOG(EJavaMMAPI,EInfo,"MID::CMMASurfaceWindow::SetClipRect");
+    LOG(EJavaMMAPI,EInfo,"CMMASurfaceWindow::SetClipRect");
 
     // CMediaClientVideoDisplay expects client to RemoveDisplayWindow
     // and AddDisplayWindow again everytime when RWindow rect changes
@@ -170,7 +170,7 @@
                 EVerticalAlignCenter,
                 (RWindow*)iWindow));
 
-        LOG(EJavaMMAPI,EInfo,"MID::CMMASurfaceWindow::SetClipRect -");
+        LOG(EJavaMMAPI,EInfo,"CMMASurfaceWindow::SetClipRect -");
         return error;
     }
     return KErrNone;
@@ -178,13 +178,13 @@
 
 void CMMASurfaceWindow::SetDrawRect(const TRect& aRect)
 {
-    LOG2(EJavaMMAPI,EInfo,"MID::CMMASurfaceWindow::SetDrawRect TL %d %d",
+    LOG2(EJavaMMAPI,EInfo,"CMMASurfaceWindow::SetDrawRect TL %d %d",
          aRect.iTl.iX, aRect.iTl.iY);
-    LOG2(EJavaMMAPI,EInfo,"MID::CMMASurfaceWindow::SetDrawRect BR %d %d",
+    LOG2(EJavaMMAPI,EInfo,"CMMASurfaceWindow::SetDrawRect BR %d %d",
          aRect.iBr.iX, aRect.iBr.iY);
 
     iContentRect = aRect;
-    LOG2(EJavaMMAPI,EInfo,"MID::CMMASurfaceWindow::SetDrawRect aRect size = (%d,%d) ",iContentRect.Height(),iContentRect.Width());
+    LOG1(EJavaMMAPI,EInfo,"CMMASurfaceWindow::SetDrawRect aRect %d",iContentRect);
     if (iDisplay)
     {
         // iDisplay->UIGetCallback( *this,
@@ -199,13 +199,13 @@
         {
             iDisplay->GetCallbackInUiThread((TInt)CMMASurfaceWindow::ESetDrawRect);
         }
-        LOG(EJavaMMAPI,EInfo,"MID::CMMASurfaceWindow::SetDrawRect, after GetCallbackInUiThread");
+        LOG(EJavaMMAPI,EInfo,"CMMASurfaceWindow::SetDrawRect, after GetCallbackInUiThread");
     }
 }
 
 TInt CMMASurfaceWindow::StaticRedrawVideo(CMMASurfaceWindow& aSurfaceWindow)
 {
-    LOG(EJavaMMAPI,EInfo,"CMMASurfaceWindow::RedrawVideoL +");
+    LOG(EJavaMMAPI,EInfo,"CMMASurfaceWindow::StaticRedrawVideo +");
     TRAPD(error, aSurfaceWindow.RedrawVideoL());
     LOG1(EJavaMMAPI,EInfo,"CMMASurfaceWindow::RedrawVideoL - error = %d",error);
     return error;
@@ -216,7 +216,7 @@
     LOG(EJavaMMAPI, EInfo,  "CMMASurfaceWindow::RedrawVideoL +");
     if (!iMediaClientVideoDisplay)
     {
-        LOG(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::RedrawVideoL: no MediaClientVideoDisplay set, aborting -");
+        LOG(EJavaMMAPI, EInfo,  "CMMASurfaceWindow::RedrawVideoL: no MediaClientVideoDisplay set, aborting -");
         return;
     }
     //iVisible = true;
@@ -225,49 +225,49 @@
         TRect contentRect;
         if (iVisible)
         {
-            LOG2(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::RedrawVideoL: if visible true iContentRect = %d X %d",iContentRect.Width(),iContentRect.Height());
+            LOG2(EJavaMMAPI, EInfo,  "CMMASurfaceWindow::RedrawVideoL: if visible true iContentRect = %d X %d",iContentRect.Width(),iContentRect.Height());
             contentRect = iContentRect;
             // ScaleVideoL(contentRect);
         }
         else
         {
-            LOG(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::RedrawVideoL - if visible false");
+            LOG(EJavaMMAPI, EInfo,  "CMMASurfaceWindow::RedrawVideoL - if visible false");
             TRect emptyRect(0,0,0,0);
             contentRect = emptyRect;
         }
-        LOG2(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::RedrawVideoL: RedrawWindows() - before intersection contentRect = %d X %d",contentRect.Width(),contentRect.Height());
+        LOG2(EJavaMMAPI, EInfo,  "CMMASurfaceWindow::RedrawVideoL: RedrawWindows() - before intersection contentRect = %d X %d",contentRect.Width(),contentRect.Height());
 
         // align parent rect with respect to RWindow
         TRect relativeParentRect;
         relativeParentRect = iParentRect;
-        LOG2(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::RedrawVideoL: RedrawWindows() - before moving parentRect = %d X %d",relativeParentRect.Width(),relativeParentRect.Height());
+        LOG2(EJavaMMAPI, EInfo,  "CMMASurfaceWindow::RedrawVideoL: RedrawWindows() - before moving parentRect = %d X %d",relativeParentRect.Width(),relativeParentRect.Height());
 
-        LOG2(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::RedrawVideoL: RedrawWindows() - before moving parentRect.iTL = %d X %d",relativeParentRect.iTl.iX,relativeParentRect.iTl.iY);
-        LOG2(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::RedrawVideoL: RedrawWindows() - before moving parentRect.iBr = %d X %d\n\n",relativeParentRect.iBr.iX,relativeParentRect.iBr.iY);
-        LOG2(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::RedrawVideoL: RedrawWindows() - iRWindowRect.iTL = %d X %d",iRWindowRect.iTl.iX,iRWindowRect.iTl.iY);
-        LOG2(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::RedrawVideoL: RedrawWindows() - iRWindowRect.iBr = %d X %d\n\n",iRWindowRect.iBr.iX,iRWindowRect.iBr.iY);
+        LOG2(EJavaMMAPI, EInfo,  "CMMASurfaceWindow::RedrawVideoL: RedrawWindows() - before moving parentRect.iTL = %d X %d",relativeParentRect.iTl.iX,relativeParentRect.iTl.iY);
+        LOG2(EJavaMMAPI, EInfo,  "CMMASurfaceWindow::RedrawVideoL: RedrawWindows() - before moving parentRect.iBr = %d X %d\n\n",relativeParentRect.iBr.iX,relativeParentRect.iBr.iY);
+        LOG2(EJavaMMAPI, EInfo,  "CMMASurfaceWindow::RedrawVideoL: RedrawWindows() - iRWindowRect.iTL = %d X %d",iRWindowRect.iTl.iX,iRWindowRect.iTl.iY);
+        LOG2(EJavaMMAPI, EInfo,  "CMMASurfaceWindow::RedrawVideoL: RedrawWindows() - iRWindowRect.iBr = %d X %d\n\n",iRWindowRect.iBr.iX,iRWindowRect.iBr.iY);
 
 
 
         relativeParentRect.Move(-iRWindowRect.iTl);
-        LOG2(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::RedrawVideoL: RedrawWindows() -after moving parentRect = %d X %d",relativeParentRect.Width(),relativeParentRect.Height());
-        LOG2(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::RedrawVideoL: RedrawWindows() - after moving parentRect.iTL = %d X %d",relativeParentRect.iTl.iX,relativeParentRect.iTl.iY);
-        LOG2(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::RedrawVideoL: RedrawWindows() - after moving parentRect.iBr = %d X %d\n\n",relativeParentRect.iBr.iX,relativeParentRect.iBr.iY);
-        LOG2(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::RedrawVideoL: RedrawWindows() - before moving draw rect.iTL = %d X %d",contentRect.iTl.iX,contentRect.iTl.iY);
-        LOG2(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::RedrawVideoL: RedrawWindows() - before moving draw rect.iBr = %d X %d",contentRect.iBr.iX,contentRect.iBr.iY);
+        LOG2(EJavaMMAPI, EInfo,  "CMMASurfaceWindow::RedrawVideoL: RedrawWindows() -after moving parentRect = %d X %d",relativeParentRect.Width(),relativeParentRect.Height());
+        LOG2(EJavaMMAPI, EInfo,  "CMMASurfaceWindow::RedrawVideoL: RedrawWindows() - after moving parentRect.iTL = %d X %d",relativeParentRect.iTl.iX,relativeParentRect.iTl.iY);
+        LOG2(EJavaMMAPI, EInfo,  "CMMASurfaceWindow::RedrawVideoL: RedrawWindows() - after moving parentRect.iBr = %d X %d\n\n",relativeParentRect.iBr.iX,relativeParentRect.iBr.iY);
+        LOG2(EJavaMMAPI, EInfo,  "CMMASurfaceWindow::RedrawVideoL: RedrawWindows() - before moving draw rect.iTL = %d X %d",contentRect.iTl.iX,contentRect.iTl.iY);
+        LOG2(EJavaMMAPI, EInfo,  "CMMASurfaceWindow::RedrawVideoL: RedrawWindows() - before moving draw rect.iBr = %d X %d",contentRect.iBr.iX,contentRect.iBr.iY);
 
         // setting video draw rect and adjusting it to window
         TRect drawRect = contentRect;
         drawRect.Move(relativeParentRect.iTl);
 
-        LOG2(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::RedrawVideoL: RedrawWindows() - after moving draw rect = %d X %d",drawRect.Width(),drawRect.Height());
-        LOG2(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::RedrawVideoL: RedrawWindows() - after moving draw rect.iTL = %d X %d",drawRect.iTl.iX,drawRect.iTl.iY);
-        LOG2(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::RedrawVideoL: RedrawWindows() - after moving draw rect.iBr = %d X %d",drawRect.iBr.iX,drawRect.iBr.iY);
+        LOG2(EJavaMMAPI, EInfo,  "CMMASurfaceWindow::RedrawVideoL: RedrawWindows() - after moving draw rect = %d X %d",drawRect.Width(),drawRect.Height());
+        LOG2(EJavaMMAPI, EInfo,  "CMMASurfaceWindow::RedrawVideoL: RedrawWindows() - after moving draw rect.iTL = %d X %d",drawRect.iTl.iX,drawRect.iTl.iY);
+        LOG2(EJavaMMAPI, EInfo,  "CMMASurfaceWindow::RedrawVideoL: RedrawWindows() - after moving draw rect.iBr = %d X %d",drawRect.iBr.iX,drawRect.iBr.iY);
 
 
 
-        LOG2(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::RedrawVideoL: RedrawWindows() - iVideoCropRegion.iTL = %d X %d",iVideoCropRegion.iTl.iX,iVideoCropRegion.iTl.iY);
-        LOG2(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::RedrawVideoL: RedrawWindows() - iVideoCropRegion.iBr = %d X %d\n\n",iVideoCropRegion.iBr.iX,iVideoCropRegion.iBr.iY);
+        LOG2(EJavaMMAPI, EInfo,  "CMMASurfaceWindow::RedrawVideoL: RedrawWindows() - iVideoCropRegion.iTL = %d X %d",iVideoCropRegion.iTl.iX,iVideoCropRegion.iTl.iY);
+        LOG2(EJavaMMAPI, EInfo,  "CMMASurfaceWindow::RedrawVideoL: RedrawWindows() - iVideoCropRegion.iBr = %d X %d\n\n",iVideoCropRegion.iBr.iX,iVideoCropRegion.iBr.iY);
 
         /*TRect temp1(TPoint(127,8),TPoint(255,104));
         TRect temp2(TPoint(0,0),TPoint(128,96));
@@ -281,7 +281,7 @@
 
         LOG(EJavaMMAPI, EInfo,  "CMMASurfaceWindow::RedrawvideoL() - after setVideoExtentL");
 
-        //LOG2( EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::RedrawVideoL: RedrawWindows() -  areaRect = %d X %d",areaRect.Width(),areaRect.Height() );
+        //LOG2( EJavaMMAPI, EInfo,  "CMMASurfaceWindow::RedrawVideoL: RedrawWindows() -  areaRect = %d X %d",areaRect.Width(),areaRect.Height() );
 
         iMediaClientVideoDisplay->RedrawWindows(iVideoCropRegion);
         LOG(EJavaMMAPI, EInfo,  "CMMASurfaceWindow::RedrawvideoL() - after redrawWindows");
@@ -310,35 +310,40 @@
     TInt error = StaticRedrawVideo(*this);
     if (KErrNone != error)
     {
-        ELOG1(EJavaMMAPI, "MID::CMMASurfaceWindow::SetPosition, StaticRedrawVideo error = %d", error);
+        ELOG1(EJavaMMAPI, "CMMASurfaceWindow::SetPosition, StaticRedrawVideo error = %d", error);
     }
 }
 
 TBool CMMASurfaceWindow::IsVisible() const
 {
-    LOG1(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::IsVisible %d ", iVisible);
+    LOG1(EJavaMMAPI, EInfo,  "CMMASurfaceWindow::IsVisible %d ", iVisible);
     return iVisible;
 }
 
 void CMMASurfaceWindow::SetVisible(TBool aVisible, TBool aUseEventServer)
 {
-    LOG1(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::SetVisible aVisible %d", aVisible);
+    LOG1(EJavaMMAPI, EInfo,  "CMMASurfaceWindow::SetVisible aVisible %d", aVisible);
     RPointerArray< CMMAPlayer > players = iEventSource->Players();
 
     if (players.Find(iPlayer) != KErrNotFound)
     {
-        LOG(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::SetVisible : Player found");
+        LOG(EJavaMMAPI, EInfo,  "CMMASurfaceWindow::SetVisible : Player found");
         if (aVisible != iVisible)
         {
-            LOG(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::SetVisible: Changed visibility");
+            LOG(EJavaMMAPI, EInfo,  "CMMASurfaceWindow::SetVisible: Changed visibility");
             iVisible = aVisible;
 
             if (aUseEventServer)
             {
-                TInt error = StaticRedrawVideo(*this);
+                /*TInt error = StaticRedrawVideo(*this);
                 if (KErrNone != error)
                 {
-                    LOG1(EJavaMMAPI,EInfo,"MID::CMMASurfaceWindow::SetVisible, StaticRedrawVideo error = %d", error);
+                    LOG1(EJavaMMAPI,EInfo,"CMMASurfaceWindow::SetVisible, StaticRedrawVideo error = %d", error);
+                }*/
+                TRAPD(error,DoSetVisibleL());
+                if (error != KErrNone)
+                {
+                    LOG1(EJavaMMAPI, EInfo,"CMMASurfaceWindow::SetVisible,DoSetVisibleL error = %d", error);
                 }
             }
             else
@@ -346,9 +351,10 @@
                 if (iDisplay)
                 {
 
-                    LOG(EJavaMMAPI,EInfo,"MID::CMMASurfaceWindow::SetVisible,calling GetCallbackInUiThread");
-                    iDisplay->GetCallbackInUiThread((TInt)CMMASurfaceWindow::ESetDrawRect);
-                    LOG(EJavaMMAPI,EInfo,"MID::CMMASurfaceWindow::SetVisible,after GetCallbackInUiThread");
+                    LOG(EJavaMMAPI,EInfo,"CMMASurfaceWindow::SetVisible,calling GetCallbackInUiThread");
+                    //iDisplay->GetCallbackInUiThread((TInt)CMMASurfaceWindow::ESetDrawRect);
+                    iDisplay->GetCallbackInUiThread((TInt)CMMASurfaceWindow::EChangeVisibility);
+                    LOG(EJavaMMAPI,EInfo,"CMMASurfaceWindow::SetVisible,after GetCallbackInUiThread");
 
                 }
 
@@ -357,11 +363,65 @@
     }
 }
 
+void CMMASurfaceWindow::DoSetVisibleL()
+{
+    LOG(EJavaMMAPI,EInfo,"CMMASurfaceWindow::DoSetVisible +");
+    if (iVisible)
+    {
+        TRect contentRect;
+        if (iVisible)
+        {
+            contentRect = iContentRect;
+        }
+        else
+        {
+            TRect emptyRect(0,0,0,0);
+            contentRect = emptyRect;
+        }
+
+        // align parent rect with respect to RWindow
+        TRect relativeParentRect;
+        relativeParentRect = iParentRect;
+        relativeParentRect.Move(-iRWindowRect.iTl);
+
+        // setting video draw rect and adjusting it to window
+        TRect drawRect = contentRect;
+        drawRect.Move(relativeParentRect.iTl);
+
+        TRect clipRect(0,0,iRWindowRect.Width(),iRWindowRect.Height());
+        //iWindow->SetExtentErr(TPoint(127,8),TSize(128,96));
+        LOG(EJavaMMAPI,EInfo,"CMMASurfaceWindow::DoSetVisible:: AddDisplayWindowL");
+        if (iMediaClientVideoDisplay)
+        {
+            iMediaClientVideoDisplay->AddDisplayWindowL(iWindow,
+                    clipRect,
+                    iVideoCropRegion,
+                    drawRect,  // video extent
+                    0.0f, // ignore
+                    0.0f, // ignore
+                    EVideoRotationNone,
+                    EAutoScaleBestFit,
+                    EHorizontalAlignCenter,
+                    EVerticalAlignCenter,
+                    (RWindow*)iWindow);
+        }
+        RedrawVideoL();
+    }
+    else
+    {
+        if (iWindow && iMediaClientVideoDisplay)
+        {
+            iMediaClientVideoDisplay->RemoveDisplayWindow(*iWindow);
+        }
+    }
+    LOG(EJavaMMAPI,EInfo,"CMMASurfaceWindow::DoSetVisible -");
+}
+
 void CMMASurfaceWindow::SetWindowRect(const TRect& aRect,MMMADisplay::TThreadType /*aThreadType*/)
 {
-    LOG2(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::SetWindowRect aRect TL %d %d",
+    LOG2(EJavaMMAPI, EInfo,  "CMMASurfaceWindow::SetWindowRect aRect TL %d %d",
          aRect.iTl.iX, aRect.iTl.iY);
-    LOG2(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::SetWindowRect aRect BR %d %d",
+    LOG2(EJavaMMAPI, EInfo,  "CMMASurfaceWindow::SetWindowRect aRect BR %d %d",
          aRect.iBr.iX, aRect.iBr.iY);
 
     iParentRect = aRect;
@@ -386,7 +446,7 @@
 
 void CMMASurfaceWindow::SetDisplay(MMMADisplay *aDisplay)
 {
-    LOG(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::SetDisplay +");
+    LOG(EJavaMMAPI, EInfo,  "CMMASurfaceWindow::SetDisplay +");
 
     if (iDisplay != aDisplay)
     {
@@ -419,12 +479,12 @@
             */
     }
 
-    LOG(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::SetDisplay -");
+    LOG(EJavaMMAPI, EInfo,  "CMMASurfaceWindow::SetDisplay -");
 }
 
 void CMMASurfaceWindow::ContainerSet()
 {
-    LOG(EJavaMMAPI,EInfo, "MID::CMMASurfaceWindow::ContainerSet");
+    LOG(EJavaMMAPI,EInfo, "CMMASurfaceWindow::ContainerSet");
     // We are in UI thread now
 
     // Container was probably not set when
@@ -439,7 +499,7 @@
 
 void CMMASurfaceWindow::Destroy()
 {
-    LOG(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::Destroy");
+    LOG(EJavaMMAPI, EInfo,  "CMMASurfaceWindow::Destroy");
     // Delete itself
     delete this;
 }
@@ -451,19 +511,19 @@
     iWs = aWs;
     iScreenDevice = aScreenDevice;
     iWindow = aWindow;
-    LOG(EJavaMMAPI,EInfo, "MID::CMMASurfaceWindow::ProcureWindowResourcesFromQWidget");
+    LOG(EJavaMMAPI,EInfo, "CMMASurfaceWindow::ProcureWindowResourcesFromQWidget");
     switch (iVideoDisplayInitState)
     {
     case EUIResourcesAndSurfaceParametersNotSet:
     {
-        LOG(EJavaMMAPI,EInfo, "MID::CMMASurfaceWindow::ProcureWindowResourcesFromQWidget  -8");
+        LOG(EJavaMMAPI,EInfo, "CMMASurfaceWindow::ProcureWindowResourcesFromQWidget  -8");
         iVideoDisplayInitState =
             EUIResourcesSetAndSurfaceParametersNotSet;
     }
     break;
     case ESurfaceParametersSetAndUIResourcesNotSet:
     {
-        LOG(EJavaMMAPI,EInfo, "MID::CMMASurfaceWindow::ProcureWindowResourcesFromQWidget  -9");
+        LOG(EJavaMMAPI,EInfo, "CMMASurfaceWindow::ProcureWindowResourcesFromQWidget  -9");
         iVideoDisplayInitState =
             EUIResourcesAndSurfaceParametersSet;
     }
@@ -473,7 +533,7 @@
     case EUIResourcesAndSurfaceParametersSet:
     default:
     {
-        LOG(EJavaMMAPI,EInfo, "MID::CMMASurfaceWindow::ProcureWindowResourcesFromQWidget  -10");
+        LOG(EJavaMMAPI,EInfo, "CMMASurfaceWindow::ProcureWindowResourcesFromQWidget  -10");
         __ASSERT_DEBUG(EFalse, User::Invariant());
     }
     break;
@@ -481,12 +541,12 @@
 
     if (iVideoDisplayInitState == EUIResourcesAndSurfaceParametersSet)
     {
-        LOG(EJavaMMAPI,EInfo, "MID::CMMASurfaceWindow::ProcureWindowResourcesFromQWidget  -11");
+        LOG(EJavaMMAPI,EInfo, "CMMASurfaceWindow::ProcureWindowResourcesFromQWidget  -11");
         TRAPD(error, InitVideoDisplayL());
-        LOG(EJavaMMAPI,EInfo, "MID::CMMASurfaceWindow::ProcureWindowResourcesFromQWidget  -12");
+        LOG(EJavaMMAPI,EInfo, "CMMASurfaceWindow::ProcureWindowResourcesFromQWidget  -12");
         if (KErrNone != error)
         {
-            ELOG1(EJavaMMAPI, "MID::CMMASurfaceWindow::MdcDSAResourcesCallback, error = %d", error);
+            ELOG1(EJavaMMAPI, "CMMASurfaceWindow::MdcDSAResourcesCallback, error = %d", error);
         }
     }
 
@@ -497,7 +557,7 @@
     CWsScreenDevice &aScreenDevice,
     RWindowBase &aWindow )
     {
-    LOG(EJavaMMAPI,EInfo, "MID::CMMASurfaceWindow::MdcDSAResourcesCallback" );
+    LOG(EJavaMMAPI,EInfo, "CMMASurfaceWindow::MdcDSAResourcesCallback" );
 
     // We are in UI thread context now.
     iWs = &aWs;
@@ -533,7 +593,7 @@
             TRAPD(error, InitVideoDisplayL());
             if ( KErrNone != error )
                 {
-                LOG1(EJavaMMAPI,EInfo,"MID::CMMASurfaceWindow::MdcDSAResourcesCallback, error = %d", error);
+                LOG1(EJavaMMAPI,EInfo,"CMMASurfaceWindow::MdcDSAResourcesCallback, error = %d", error);
                 }
             }
     }
@@ -541,7 +601,7 @@
 void CMMASurfaceWindow::UICallback(TInt aCallbackId)
 {
     // We are in UI thread context now.
-    LOG1(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::MdcUICallback CallbackId = %d", aCallbackId);
+    LOG1(EJavaMMAPI, EInfo,  "CMMASurfaceWindow::UICallback CallbackId = %d", aCallbackId);
 
     TInt error = KErrNone;
     switch (aCallbackId)
@@ -549,25 +609,25 @@
     case ESetClipRect:
     {
         error = SetClipRect();
-        LOG1(EJavaMMAPI,EInfo,"MID::CMMASurfaceWindow::MdcUICallback,SetClipRect error = %d", error);
+        LOG1(EJavaMMAPI,EInfo,"CMMASurfaceWindow::UICallback,SetClipRect error = %d", error);
     }
     break;
     case ERemoveSurface:
     {
-        LOG(EJavaMMAPI, EInfo, "MID::CMMASurfaceWindow::MdcUICallback, ERemoveSurface ");
+        LOG(EJavaMMAPI, EInfo, "CMMASurfaceWindow::UICallback, ERemoveSurface ");
         DoRemoveSurface();
     }
     break;
     case ESetDrawRect:
     {
         error = StaticRedrawVideo(*this);
-        ELOG1(EJavaMMAPI, "MID::CMMASurfaceWindow::MdcUICallback,StaticRedrawVideo error = %d", error);
+        ELOG1(EJavaMMAPI, "CMMASurfaceWindow::UICallback,StaticRedrawVideo error = %d", error);
     }
     break;
     case EInitVideoDisplay:
     {
         TRAP(error, InitVideoDisplayL());
-        ELOG1(EJavaMMAPI, "MID::CMMASurfaceWindow::MdcUICallback,InitVideoDisplayL error = %d", error);
+        ELOG1(EJavaMMAPI, "CMMASurfaceWindow::UICallback,InitVideoDisplayL error = %d", error);
     }
     break;
     case ESetChangedSurfaceParameters:
@@ -590,6 +650,15 @@
         Destroy();
     }
     break;
+    case EChangeVisibility:
+    {
+        TRAPD(error,DoSetVisibleL());
+        if (error != KErrNone)
+        {
+            LOG1(EJavaMMAPI, EInfo,"CMMASurfaceWindow::UICallback,DoSetVisibleL error = %d", error);
+        }
+    }
+    break;
     default:
     {
         __ASSERT_DEBUG(EFalse, User::Invariant());
@@ -711,9 +780,9 @@
     LOG(EJavaMMAPI, EInfo, "CMMASurfaceWindow::DoRemoveSurface() +");
     if (iMediaClientVideoDisplay)
     {
-        LOG(EJavaMMAPI,EInfo,"MID::CMMASurfaceWindow::DoRemoveSurface, Removing Surface");
+        LOG(EJavaMMAPI,EInfo,"CMMASurfaceWindow::DoRemoveSurface, Removing Surface");
         iMediaClientVideoDisplay->RemoveSurface();
-        LOG(EJavaMMAPI,EInfo,"MID::CMMASurfaceWindow::DoRemoveSurface, Surface Removed");
+        LOG(EJavaMMAPI,EInfo,"CMMASurfaceWindow::DoRemoveSurface, Surface Removed");
 
     }
     LOG(EJavaMMAPI, EInfo, "CMMASurfaceWindow::DoRemoveSurface() -");
@@ -731,7 +800,7 @@
                      iPixelAspectRatio,
                      iVideoCropRegion);
 
-        ELOG1(EJavaMMAPI, "MID::CMMASurfaceWindow::DoResetSurfaceParameters,SurfaceCreated error = %d", error);
+        ELOG1(EJavaMMAPI, "CMMASurfaceWindow::DoResetSurfaceParameters,SurfaceCreated error = %d", error);
 
         iMediaClientVideoDisplay->RedrawWindows(iVideoCropRegion);
     }
@@ -745,7 +814,7 @@
                      iCropRect,
                      iPixelAspectRatio);
 
-        ELOG1(EJavaMMAPI, "MID::CMMASurfaceWindow::DoSetChangedSurfaceParameters,SurfaceParametersChanged, error = %d", error);
+        ELOG1(EJavaMMAPI, "CMMASurfaceWindow::DoSetChangedSurfaceParameters,SurfaceParametersChanged, error = %d", error);
 
         iMediaClientVideoDisplay->RedrawWindows(iVideoCropRegion);
     }
@@ -789,7 +858,7 @@
                  iPixelAspectRatio,
                  iVideoCropRegion);
 
-    ELOG1(EJavaMMAPI,  "MID::CMMASurfaceWindow::InitVideoDisplayL error = %d", error);
+    ELOG1(EJavaMMAPI,  "CMMASurfaceWindow::InitVideoDisplayL error = %d", error);
     User::LeaveIfError(error);
 
     TRect contentRect;
@@ -833,7 +902,7 @@
 
 void CMMASurfaceWindow::CleanVideoDisplay()
 {
-    LOG(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::CleanVideoDisplay +");
+    LOG(EJavaMMAPI, EInfo,  "CMMASurfaceWindow::CleanVideoDisplay +");
 
     SetVisible(EFalse, ETrue);
     if (iMediaClientVideoDisplay)
@@ -851,7 +920,7 @@
         iWs = NULL;
     }
 
-    LOG(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::CleanVideoDisplay -");
+    LOG(EJavaMMAPI, EInfo,  "CMMASurfaceWindow::CleanVideoDisplay -");
 }