Merge branch 'devel/master' into tizen
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / common / window-impl.cpp
index 3abc7ab..2ea6269 100644 (file)
@@ -21,6 +21,8 @@
 // EXTERNAL HEADERS
 #include <dali/integration-api/core.h>
 #include <dali/integration-api/system-overlay.h>
+#include <dali/integration-api/render-task-list-integ.h>
+#include <dali/public-api/actors/camera-actor.h>
 #include <dali/public-api/render-tasks/render-task.h>
 #include <dali/public-api/render-tasks/render-task-list.h>
 #include <dali/devel-api/adaptor-framework/orientation.h>
@@ -61,7 +63,7 @@ Window* Window::New( const PositionSize& positionSize, const std::string& name,
 Window::Window()
 : mSurface( NULL ),
   mWindowBase(),
-  mIndicatorVisible( Dali::Window::VISIBLE ),
+  mIndicatorVisible( Dali::Window::INVISIBLE ),   // TODO: Enable this after indicator implementation based on tizen 5.
   mIndicatorIsShown( false ),
   mShowRotatedIndicatorOnClose( false ),
   mStarted( false ),
@@ -144,13 +146,22 @@ void Window::SetAdaptor(Dali::Adaptor& adaptor)
   DALI_ASSERT_ALWAYS( !mStarted && "Adaptor already started" );
   mStarted = true;
 
-  // Only create one overlay per window
+  // Create one overlay for the main window only
   Internal::Adaptor::Adaptor& adaptorImpl = Internal::Adaptor::Adaptor::GetImplementation(adaptor);
   Integration::Core& core = adaptorImpl.GetCore();
   mOverlay = &core.GetSystemOverlay();
 
-  Dali::RenderTaskList taskList = mOverlay->GetOverlayRenderTasks();
-  taskList.CreateTask();
+  // Only create render task list for the overlay once
+  if (!mOverlay->GetOverlayRenderTasks())
+  {
+    Dali::RenderTaskList overlayRenderTaskList = Integration::RenderTaskList::New();
+
+    Dali::Actor overlayRootActor = mOverlay->GetDefaultRootActor();
+    Dali::CameraActor overlayCameraActor = mOverlay->GetDefaultCameraActor();
+    Integration::RenderTaskList::CreateTask( overlayRenderTaskList, overlayRootActor, overlayCameraActor );
+
+    mOverlay->SetOverlayRenderTasks( overlayRenderTaskList );
+  }
 
   mAdaptor = &adaptorImpl;
   mAdaptor->AddObserver( *this );
@@ -177,7 +188,8 @@ WindowRenderSurface* Window::GetSurface()
 
 void Window::ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode )
 {
-  mIndicatorVisible = visibleMode;
+  // TODO: Enable this after indicator implementation based on tizen 5.
+//  mIndicatorVisible = visibleMode;
 
   mWindowBase->ShowIndicator( mIndicatorVisible, mIndicatorOpacityMode );
 
@@ -196,7 +208,8 @@ void Window::SetIndicatorBgOpacity( Dali::Window::IndicatorBgOpacity opacityMode
 
 void Window::SetIndicatorVisibleMode( Dali::Window::IndicatorVisibleMode mode )
 {
-  mIndicatorVisible = mode;
+  // TODO: Enable this after indicator implementation based on tizen 5.
+//  mIndicatorVisible = mode;
 }
 
 void Window::RotateIndicator( Dali::Window::WindowOrientation orientation )
@@ -475,21 +488,22 @@ void Window::SetSize( Dali::Window::WindowSize size )
     mResizeEnabled = true;
   }
 
-  PositionSize positionSize = mSurface->GetPositionSize();
+  PositionSize oldRect = mSurface->GetPositionSize();
 
-  if( positionSize.width != size.GetWidth() || positionSize.height != size.GetHeight() )
-  {
-    positionSize.width = size.GetWidth();
-    positionSize.height = size.GetHeight();
+  mSurface->MoveResize( PositionSize( oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight() ) );
 
-    mSurface->MoveResize( positionSize );
+  PositionSize newRect = mSurface->GetPositionSize();
+
+  // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
+  if( ( oldRect.width != newRect.width ) || ( oldRect.height != newRect.height ) )
+  {
+    Uint16Pair newSize( newRect.width, newRect.height );
 
-    mAdaptor->SurfaceResizePrepare( Adaptor::SurfaceSize( positionSize.width, positionSize.height ) );
+    mAdaptor->SurfaceResizePrepare( newSize );
 
-    // Emit signal
-    mResizedSignal.Emit( Dali::Window::WindowSize( positionSize.width, positionSize.height ) );
+    mResizedSignal.Emit( newSize );
 
-    mAdaptor->SurfaceResizeComplete( Adaptor::SurfaceSize( positionSize.width, positionSize.height ) );
+    mAdaptor->SurfaceResizeComplete( newSize );
   }
 }
 
@@ -508,15 +522,9 @@ void Window::SetPosition( Dali::Window::WindowPosition position )
     mResizeEnabled = true;
   }
 
-  PositionSize positionSize = mSurface->GetPositionSize();
-
-  if( positionSize.x != position.GetX() || positionSize.y != position.GetY() )
-  {
-    positionSize.x = position.GetX();
-    positionSize.y = position.GetY();
+  PositionSize oldRect = mSurface->GetPositionSize();
 
-    mSurface->MoveResize( positionSize );
-  }
+  mSurface->MoveResize( PositionSize( position.GetX(), position.GetY(), oldRect.width, oldRect.height ) );
 }
 
 Dali::Window::WindowPosition Window::GetPosition() const
@@ -526,6 +534,33 @@ Dali::Window::WindowPosition Window::GetPosition() const
   return Dali::Window::WindowPosition( positionSize.x, positionSize.y );
 }
 
+void Window::SetPositionSize( PositionSize positionSize )
+{
+  if( !mResizeEnabled )
+  {
+    AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" );
+    mResizeEnabled = true;
+  }
+
+  PositionSize oldRect = mSurface->GetPositionSize();
+
+  mSurface->MoveResize( positionSize );
+
+  PositionSize newRect = mSurface->GetPositionSize();
+
+  // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
+  if( ( oldRect.width != newRect.width ) || ( oldRect.height != newRect.height ) )
+  {
+    Uint16Pair newSize( newRect.width, newRect.height );
+
+    mAdaptor->SurfaceResizePrepare( newSize );
+
+    mResizedSignal.Emit( newSize );
+
+    mAdaptor->SurfaceResizeComplete( newSize );
+  }
+}
+
 void Window::SetTransparency( bool transparent )
 {
   mSurface->SetTransparency( transparent );