Merge "Modify window for rotation event and missed parts." into devel/master
[platform/core/uifw/dali-adaptor.git] / adaptors / ecore / wayland / window-impl-ecore-wl.cpp
index 0202d5f..600445b 100644 (file)
@@ -34,7 +34,6 @@
 #include <ecore-indicator-impl.h>
 #include <window-visibility-observer.h>
 #include <orientation-impl.h>
-
 namespace
 {
 const float INDICATOR_ANIMATION_DURATION( 0.18f ); // 180 milli seconds
@@ -63,8 +62,17 @@ struct Window::EventHandler
    */
   EventHandler( Window* window )
   : mWindow( window ),
+    mWindowPropertyHandler( NULL ),
+    mClientMessageHandler( NULL ),
     mEcoreWindow( 0 )
   {
+    // store ecore window handle
+    ECore::WindowRenderSurface* wlWindow( dynamic_cast< ECore::WindowRenderSurface * >( mWindow->mSurface ) );
+    if( wlWindow )
+    {
+      mEcoreWindow = wlWindow->GetWlWindow();
+    }
+    DALI_ASSERT_ALWAYS( mEcoreWindow != 0 && "There is no ecore Wl window");
   }
 
   /**
@@ -76,9 +84,9 @@ struct Window::EventHandler
     {
       ecore_event_handler_del( mWindowPropertyHandler );
     }
-    if ( mClientMessagehandler )
+    if ( mClientMessageHandler )
     {
-      ecore_event_handler_del( mClientMessagehandler );
+      ecore_event_handler_del( mClientMessageHandler );
     }
   }
 
@@ -99,7 +107,7 @@ struct Window::EventHandler
   // Data
   Window* mWindow;
   Ecore_Event_Handler* mWindowPropertyHandler;
-  Ecore_Event_Handler* mClientMessagehandler;
+  Ecore_Event_Handler* mClientMessageHandler;
   Ecore_Wl_Window* mEcoreWindow;
 };
 
@@ -153,6 +161,34 @@ void Window::ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode )
   DALI_LOG_TRACE_METHOD_FMT( gWindowLogFilter, "visible : %d\n", visibleMode );
   DALI_ASSERT_DEBUG(mOverlay);
 
+  ECore::WindowRenderSurface* wlSurface( dynamic_cast< ECore::WindowRenderSurface * >( mSurface ) );
+  DALI_ASSERT_DEBUG(wlSurface);
+  Ecore_Wl_Window* wlWindow = wlSurface->GetWlWindow();
+
+  mIndicatorVisible = visibleMode;
+
+  if ( mIndicatorVisible == Dali::Window::VISIBLE )
+  {
+    // when the indicator is visible, set proper mode for indicator server according to bg mode
+    if ( mIndicatorOpacityMode == Dali::Window::OPAQUE )
+    {
+      ecore_wl_window_indicator_opacity_set(wlWindow, ECORE_WL_INDICATOR_OPAQUE);
+    }
+    else if ( mIndicatorOpacityMode == Dali::Window::TRANSLUCENT )
+    {
+      ecore_wl_window_indicator_opacity_set(wlWindow, ECORE_WL_INDICATOR_TRANSLUCENT);
+    }
+    else if ( mIndicatorOpacityMode == Dali::Window::TRANSPARENT )
+    {
+      ecore_wl_window_indicator_opacity_set(wlWindow, ECORE_WL_INDICATOR_OPAQUE);
+    }
+  }
+  else
+  {
+    // when the indicator is not visible, set TRANSPARENT mode for indicator server
+    ecore_wl_window_indicator_opacity_set(wlWindow, ECORE_WL_INDICATOR_TRANSPARENT); // it means hidden indicator
+  }
+
   DoShowIndicator( mIndicatorOrientation );
 }
 
@@ -175,6 +211,18 @@ void Window::SetIndicatorBgOpacity( Dali::Window::IndicatorBgOpacity opacityMode
 
 void Window::SetClass(std::string name, std::string klass)
 {
+  ECore::WindowRenderSurface* wlSurface( dynamic_cast< ECore::WindowRenderSurface * >( mSurface ) );
+
+  if( wlSurface )
+  {
+    Ecore_Wl_Window* wlWindow = wlSurface->GetWlWindow();
+    ecore_wl_window_title_set( wlWindow, name.c_str() );
+    ecore_wl_window_class_name_set( wlWindow, klass.c_str() );
+  }
+  else
+  {
+    DALI_LOG_INFO( gWindowLogFilter, Debug::General, "Window has no surface\n" );
+  }
 }
 
 Window::Window()
@@ -185,6 +233,7 @@ Window::Window()
   mStarted(false),
   mIsTransparent(false),
   mWMRotationAppSet(false),
+  mEcoreEventHander(true),
   mIndicator(NULL),
   mIndicatorOrientation(Dali::Window::PORTRAIT),
   mNextIndicatorOrientation(Dali::Window::PORTRAIT),
@@ -221,10 +270,10 @@ void Window::Initialize(const PositionSize& windowPosition, const std::string& n
   // create an Wayland window by default
   Any surface;
   ECore::WindowRenderSurface* windowSurface = new ECore::WindowRenderSurface( windowPosition, surface, name, mIsTransparent );
-  SetClass( name, className );
-  windowSurface->Map();
 
   mSurface = windowSurface;
+  SetClass( name, className );
+  windowSurface->Map();
 
   mOrientation = Orientation::New(this);
 
@@ -290,10 +339,46 @@ void Window::DoRotateIndicator( Dali::Window::WindowOrientation orientation )
 
 void Window::SetIndicatorProperties( bool isShow, Dali::Window::WindowOrientation lastOrientation )
 {
+  ECore::WindowRenderSurface* wlSurface( dynamic_cast< ECore::WindowRenderSurface * >( mSurface ) );
+
+  if( wlSurface )
+  {
+    Ecore_Wl_Window* wlWindow = wlSurface->GetWlWindow();
+    if ( isShow )
+    {
+      ecore_wl_window_indicator_state_set(wlWindow, ECORE_WL_INDICATOR_STATE_ON);
+    }
+    else
+    {
+      ecore_wl_window_indicator_state_set(wlWindow, ECORE_WL_INDICATOR_STATE_OFF);
+    }
+  }
 }
 
 void Window::IndicatorTypeChanged(Indicator::Type type)
 {
+#if defined(DALI_PROFILE_MOBILE)
+  ECore::WindowRenderSurface* wlSurface( dynamic_cast< ECore::WindowRenderSurface * >( mSurface ) );
+
+  if( wlSurface )
+  {
+    Ecore_Wl_Window* wlWindow = wlSurface->GetWlWindow();
+    switch(type)
+    {
+      case Indicator::INDICATOR_TYPE_1:
+        ecore_wl_indicator_visible_type_set(wlWindow, ECORE_WL_INDICATOR_VISIBLE_TYPE_SHOWN);
+        break;
+
+      case Indicator::INDICATOR_TYPE_2:
+        ecore_wl_indicator_visible_type_set(wlWindow, ECORE_WL_INDICATOR_VISIBLE_TYPE_HIDDEN);
+        break;
+
+      case Indicator::INDICATOR_TYPE_UNKNOWN:
+      default:
+        break;
+    }
+  }
+#endif //MOBILE
 }
 
 void Window::IndicatorClosed( IndicatorInterface* indicator )
@@ -348,14 +433,17 @@ void Window::SetIndicatorActorRotation()
 
 void Window::Raise()
 {
+  ecore_wl_window_raise( mEventHandler->mEcoreWindow );
 }
 
 void Window::Lower()
 {
+  ecore_wl_window_lower( mEventHandler->mEcoreWindow );
 }
 
 void Window::Activate()
 {
+  ecore_wl_window_activate( mEventHandler->mEcoreWindow );
 }
 
 Dali::DragAndDropDetector Window::GetDragAndDropDetector() const
@@ -447,7 +535,12 @@ void Window::RemoveAvailableOrientation(Dali::Window::WindowOrientation orientat
 
 void Window::SetAvailableOrientations(const std::vector<Dali::Window::WindowOrientation>& orientations)
 {
-  DALI_ASSERT_ALWAYS( mAvailableOrientations.size() <= 4 && "Incorrect number of available orientations" );
+  int rotations[4];
+  for( std::size_t i = 0; i < mAvailableOrientations.size(); ++i )
+  {
+    rotations[i] = static_cast< int >( mAvailableOrientations[i] );
+  }
+  ecore_wl_window_rotation_available_rotations_set( mEventHandler->mEcoreWindow, rotations, mAvailableOrientations.size() );
 }
 
 const std::vector<Dali::Window::WindowOrientation>& Window::GetAvailableOrientations()
@@ -458,6 +551,8 @@ const std::vector<Dali::Window::WindowOrientation>& Window::GetAvailableOrientat
 void Window::SetPreferredOrientation(Dali::Window::WindowOrientation orientation)
 {
   mPreferredOrientation = orientation;
+
+  ecore_wl_window_rotation_preferred_rotation_set( mEventHandler->mEcoreWindow, orientation );
 }
 
 Dali::Window::WindowOrientation Window::GetPreferredOrientation()
@@ -467,6 +562,7 @@ Dali::Window::WindowOrientation Window::GetPreferredOrientation()
 
 void Window::RotationDone( int orientation, int width, int height )
 {
+  ecore_wl_window_rotation_change_done_send( mEventHandler->mEcoreWindow );
 }