[Tizen] Add screen and client rotation itself function
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / ubuntu-x11 / window-base-ecore-x.cpp
index 41568e9..77567d4 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  *
  */
 
-// Ecore is littered with C style cast
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wold-style-cast"
-
 // CLASS HEADER
 #include <dali/internal/window-system/ubuntu-x11/window-base-ecore-x.h>
 
 // INTERNAL HEADERS
 #include <dali/internal/window-system/common/window-impl.h>
+#include <dali/internal/window-system/common/window-system.h>
 #include <dali/internal/window-system/common/window-render-surface.h>
 #include <dali/internal/window-system/ubuntu-x11/ecore-x-types.h>
 
@@ -31,7 +28,7 @@
 #include <dali/public-api/object/any.h>
 #include <dali/public-api/events/mouse-button.h>
 #include <dali/integration-api/debug.h>
-#include <Ecore_Input.h>
+#include <dali/internal/input/ubuntu-x11/dali-ecore-input.h>
 
 namespace Dali
 {
@@ -267,6 +264,8 @@ WindowBaseEcoreX::~WindowBaseEcoreX()
   if( mOwnSurface )
   {
     ecore_x_window_free( mEcoreWindow );
+
+    WindowSystem::Shutdown();
   }
 }
 
@@ -278,6 +277,8 @@ void WindowBaseEcoreX::Initialize( PositionSize positionSize, Any surface, bool
   // if the surface is empty, create a new one.
   if( surfaceId == 0 )
   {
+    WindowSystem::Initialize();
+
     // we own the surface about to created
     mOwnSurface = true;
     CreateWindow( positionSize, isTransparent );
@@ -468,7 +469,7 @@ void WindowBaseEcoreX::OnMouseButtonUp( void* data, int type, void* event )
     point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
     point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
     point.SetPressure( touchEvent->multi.pressure );
-    point.SetAngle( Degree( touchEvent->multi.angle ) );
+    point.SetAngle( Degree( static_cast<float>( touchEvent->multi.angle ) ) );
     if( touchEvent->buttons)
     {
       point.SetMouseButton( static_cast< MouseButton::Type >( touchEvent->buttons) );
@@ -487,10 +488,10 @@ void WindowBaseEcoreX::OnMouseButtonMove( void* data, int type, void* event )
     Integration::Point point;
     point.SetDeviceId( touchEvent->multi.device );
     point.SetState( PointState::MOTION );
-    point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
-    point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
-    point.SetPressure( touchEvent->multi.pressure );
-    point.SetAngle( Degree( touchEvent->multi.angle ) );
+    point.SetScreenPosition( Vector2( static_cast<float>( touchEvent->x ), static_cast<float>( touchEvent->y ) ) );
+    point.SetRadius( static_cast<float>( touchEvent->multi.radius ), Vector2( static_cast<float>( touchEvent->multi.radius_x ), static_cast<float>( touchEvent->multi.radius_y ) ) );
+    point.SetPressure( static_cast<float>( touchEvent->multi.pressure ) );
+    point.SetAngle( Degree( static_cast<float>( touchEvent->multi.angle ) ) );
 
     mTouchEventSignal.Emit( point, touchEvent->timestamp );
   }
@@ -504,7 +505,7 @@ void WindowBaseEcoreX::OnMouseWheel( void* data, int type, void* event )
   {
     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreX::OnMouseWheel: direction: %d, modifiers: %d, x: %d, y: %d, z: %d\n", mouseWheelEvent->direction, mouseWheelEvent->modifiers, mouseWheelEvent->x, mouseWheelEvent->y, mouseWheelEvent->z );
 
-    WheelEvent wheelEvent( WheelEvent::MOUSE_WHEEL, mouseWheelEvent->direction, mouseWheelEvent->modifiers, Vector2( mouseWheelEvent->x, mouseWheelEvent->y ), mouseWheelEvent->z, mouseWheelEvent->timestamp );
+    WheelEvent wheelEvent( WheelEvent::MOUSE_WHEEL, mouseWheelEvent->direction, mouseWheelEvent->modifiers, Vector2( static_cast<float>( mouseWheelEvent->x ), static_cast<float>( mouseWheelEvent->y ) ), mouseWheelEvent->z, mouseWheelEvent->timestamp );
 
     mWheelEventSignal.Emit( wheelEvent );
   }
@@ -683,49 +684,6 @@ void WindowBaseEcoreX::MoveResize( PositionSize positionSize )
   ecore_x_window_move_resize( mEcoreWindow, positionSize.x, positionSize.y, positionSize.width, positionSize.height );
 }
 
-void WindowBaseEcoreX::ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode, Dali::Window::IndicatorBgOpacity opacityMode )
-{
-  DALI_LOG_TRACE_METHOD_FMT( gWindowBaseLogFilter, "visible : %d\n", visibleMode );
-
-  if( visibleMode == Dali::Window::VISIBLE )
-  {
-    // when the indicator is visible, set proper mode for indicator server according to bg mode
-    if( opacityMode == Dali::Window::OPAQUE )
-    {
-      ecore_x_e_illume_indicator_opacity_set( mEcoreWindow, ECORE_X_ILLUME_INDICATOR_OPAQUE );
-    }
-    else if( opacityMode == Dali::Window::TRANSLUCENT )
-    {
-      ecore_x_e_illume_indicator_opacity_set( mEcoreWindow, ECORE_X_ILLUME_INDICATOR_TRANSLUCENT );
-    }
-  }
-  else
-  {
-    // when the indicator is not visible, set TRANSPARENT mode for indicator server
-    ecore_x_e_illume_indicator_opacity_set( mEcoreWindow, ECORE_X_ILLUME_INDICATOR_TRANSPARENT ); // it means hidden indicator
-  }
-}
-
-void WindowBaseEcoreX::SetIndicatorProperties( bool isShow, Dali::Window::WindowOrientation lastOrientation )
-{
-  int show_state = static_cast< int >( isShow );
-  ecore_x_window_prop_property_set( mEcoreWindow, ECORE_X_ATOM_E_ILLUME_INDICATOR_STATE,
-                                    ECORE_X_ATOM_CARDINAL, 32, &show_state, 1 );
-
-  if( isShow )
-  {
-    ecore_x_e_illume_indicator_state_set( mEcoreWindow, ECORE_X_ILLUME_INDICATOR_STATE_ON );
-  }
-  else
-  {
-    ecore_x_e_illume_indicator_state_set( mEcoreWindow, ECORE_X_ILLUME_INDICATOR_STATE_OFF );
-  }
-}
-
-void WindowBaseEcoreX::IndicatorTypeChanged( IndicatorInterface::Type type )
-{
-}
-
 void WindowBaseEcoreX::SetClass( const std::string& name, const std::string& className )
 {
   ecore_x_icccm_title_set( mEcoreWindow, name.c_str() );
@@ -748,11 +706,11 @@ void WindowBaseEcoreX::Activate()
   ecore_x_netwm_client_active_request( ecore_x_window_root_get( mEcoreWindow ), mEcoreWindow, 1 /* request type, 1:application, 2:pager */, 0 );
 }
 
-void WindowBaseEcoreX::SetAvailableOrientations( const std::vector< Dali::Window::WindowOrientation >& orientations )
+void WindowBaseEcoreX::SetAvailableAnlges( const std::vector< int >& angles )
 {
 }
 
-void WindowBaseEcoreX::SetPreferredOrientation( Dali::Window::WindowOrientation orientation )
+void WindowBaseEcoreX::SetPreferredAngle( int angle )
 {
 }
 
@@ -869,15 +827,16 @@ bool WindowBaseEcoreX::UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali
 
 void WindowBaseEcoreX::GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical )
 {
-  // calculate DPI
-  float xres, yres;
-
   // 1 inch = 25.4 millimeters
-  xres = ecore_x_dpi_get();
-  yres = ecore_x_dpi_get();
+  // ecore does not account for differing DPI in the x and y axes, so only get for x is available
+
+  dpiHorizontal = ecore_x_dpi_get();
+  dpiVertical   = ecore_x_dpi_get();
+}
 
-  dpiHorizontal = int( xres + 0.5f );  // rounding
-  dpiVertical   = int( yres + 0.5f );
+int WindowBaseEcoreX::GetOrientation() const
+{
+  return 0;
 }
 
 int WindowBaseEcoreX::GetScreenRotationAngle()
@@ -889,6 +848,11 @@ void WindowBaseEcoreX::SetWindowRotationAngle( int degree )
 {
 }
 
+int WindowBaseEcoreX::GetWindowRotationAngle()
+{
+  return 0;
+}
+
 void WindowBaseEcoreX::WindowRotationCompleted( int degree, int width, int height )
 {
 }
@@ -913,7 +877,7 @@ unsigned int WindowBaseEcoreX::GetSurfaceId( Any surface ) const
     }
     else
     {
-      surfaceId = AnyCast< XWindow >( surface );
+      surfaceId = static_cast<unsigned int>( AnyCast< XWindow >( surface ) );
     }
   }
   return surfaceId;
@@ -939,10 +903,24 @@ void WindowBaseEcoreX::CreateWindow( PositionSize positionSize, bool isTranspare
  }
 }
 
+void WindowBaseEcoreX::SetParent( WindowBase* parentWinBase )
+{
+  Ecore_X_Window ecoreParent = 0;
+  if( parentWinBase )
+  {
+    WindowBaseEcoreX* winBaseEcoreX = static_cast<WindowBaseEcoreX*>( parentWinBase );
+    ecoreParent = winBaseEcoreX->mEcoreWindow;
+    ecore_x_icccm_transient_for_set( mEcoreWindow, ecoreParent );
+  }
+  else
+  {
+    ecoreParent = 0;
+    ecore_x_icccm_transient_for_unset( mEcoreWindow );
+  }
+}
+
 } // namespace Adaptor
 
 } // namespace Internal
 
 } // namespace Dali
-
-#pragma GCC diagnostic pop