Merge "[Tizen] Remove profile build dependencies" into tizen
[platform/core/uifw/dali-adaptor.git] / adaptors / ecore / wayland / window-impl-ecore-wl.cpp
index ed8df95..184299c 100644 (file)
@@ -63,7 +63,7 @@ struct Window::EventHandler
   EventHandler( Window* window )
   : mWindow( window ),
     mWindowPropertyHandler( NULL ),
-    mClientMessageHandler( NULL ),
+    mWindowIconifyStateHandler( NULL ),
     mEcoreWindow( 0 )
   {
     // store ecore window handle
@@ -73,6 +73,14 @@ struct Window::EventHandler
       mEcoreWindow = wlWindow->GetWlWindow();
     }
     DALI_ASSERT_ALWAYS( mEcoreWindow != 0 && "There is no ecore Wl window");
+
+#ifndef DALI_PROFILE_UBUNTU
+    if( mWindow->mEcoreEventHander )
+    {
+      mWindowIconifyStateHandler = ecore_event_handler_add( ECORE_WL_EVENT_WINDOW_ICONIFY_STATE_CHANGE, EcoreEventWindowIconifyStateChanged, this );
+    }
+#endif
+
   }
 
   /**
@@ -84,9 +92,9 @@ struct Window::EventHandler
     {
       ecore_event_handler_del( mWindowPropertyHandler );
     }
-    if ( mClientMessageHandler )
+    if ( mWindowIconifyStateHandler )
     {
-      ecore_event_handler_del( mClientMessageHandler );
+      ecore_event_handler_del( mWindowIconifyStateHandler );
     }
   }
 
@@ -98,16 +106,41 @@ struct Window::EventHandler
     return EINA_FALSE;
   }
 
-  /// Called when the window properties are changed.
-  static Eina_Bool EcoreEventClientMessage( void* data, int type, void* event )
+#ifndef DALI_PROFILE_UBUNTU
+  /// Called when the window iconify state is changed.
+  static Eina_Bool EcoreEventWindowIconifyStateChanged( void* data, int type, void* event )
   {
-    return EINA_FALSE;
+    Ecore_Wl_Event_Window_Iconify_State_Change* iconifyChangedEvent( (Ecore_Wl_Event_Window_Iconify_State_Change*)event );
+    EventHandler* handler( (EventHandler*)data );
+    Eina_Bool handled( ECORE_CALLBACK_PASS_ON );
+
+    if ( handler && handler->mWindow )
+    {
+      WindowVisibilityObserver* observer( handler->mWindow->mAdaptor );
+      if ( observer && ( iconifyChangedEvent->win == (unsigned int) ecore_wl_window_id_get( handler->mEcoreWindow ) ) )
+      {
+        if( iconifyChangedEvent->iconified == EINA_TRUE )
+        {
+          observer->OnWindowHidden();
+          DALI_LOG_INFO( gWindowLogFilter, Debug::General, "Window (%d) Iconfied\n", handler->mEcoreWindow );
+        }
+        else
+        {
+          observer->OnWindowShown();
+          DALI_LOG_INFO( gWindowLogFilter, Debug::General, "Window (%d) Shown\n", handler->mEcoreWindow );
+        }
+        handled = ECORE_CALLBACK_DONE;
+      }
+    }
+
+    return handled;
   }
+#endif
 
   // Data
   Window* mWindow;
   Ecore_Event_Handler* mWindowPropertyHandler;
-  Ecore_Event_Handler* mClientMessageHandler;
+  Ecore_Event_Handler* mWindowIconifyStateHandler;
   Ecore_Wl_Window* mEcoreWindow;
 };
 
@@ -211,6 +244,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()
@@ -221,6 +266,7 @@ Window::Window()
   mStarted(false),
   mIsTransparent(false),
   mWMRotationAppSet(false),
+  mEcoreEventHander(true),
   mIndicator(NULL),
   mIndicatorOrientation(Dali::Window::PORTRAIT),
   mNextIndicatorOrientation(Dali::Window::PORTRAIT),
@@ -257,15 +303,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;
-
-  std::string appId;
-  mAdaptor->GetAppId( appId );
-  Ecore_Wl_Window* wlWindow = windowSurface ->GetWlWindow();
-  ecore_wl_window_class_name_set(wlWindow, appId.c_str());
+  SetClass( name, className );
+  windowSurface->Map();
 
   mOrientation = Orientation::New(this);
 
@@ -349,6 +390,7 @@ void Window::SetIndicatorProperties( bool isShow, Dali::Window::WindowOrientatio
 
 void Window::IndicatorTypeChanged(Indicator::Type type)
 {
+#if defined(DALI_PROFILE_MOBILE)
   ECore::WindowRenderSurface* wlSurface( dynamic_cast< ECore::WindowRenderSurface * >( mSurface ) );
 
   if( wlSurface )
@@ -369,6 +411,7 @@ void Window::IndicatorTypeChanged(Indicator::Type type)
         break;
     }
   }
+#endif //MOBILE
 }
 
 void Window::IndicatorClosed( IndicatorInterface* indicator )