Revert "[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 cc99dfd..ab67b43 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 );
   }
@@ -705,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 )
 {
 }
 
@@ -826,15 +827,11 @@ 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 = int( xres + 0.5f );  // rounding
-  dpiVertical   = int( yres + 0.5f );
+  dpiHorizontal = ecore_x_dpi_get();
+  dpiVertical   = ecore_x_dpi_get();
 }
 
 int WindowBaseEcoreX::GetScreenRotationAngle()
@@ -870,7 +867,7 @@ unsigned int WindowBaseEcoreX::GetSurfaceId( Any surface ) const
     }
     else
     {
-      surfaceId = AnyCast< XWindow >( surface );
+      surfaceId = static_cast<unsigned int>( AnyCast< XWindow >( surface ) );
     }
   }
   return surfaceId;
@@ -896,10 +893,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