[Tizen] Add rotation's values to winBase-wl2
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / tizen-wayland / ecore-wl2 / window-base-ecore-wl2.cpp
index 2e68a93..9624c20 100755 (executable)
@@ -690,7 +690,10 @@ WindowBaseEcoreWl2::WindowBaseEcoreWl2( Dali::PositionSize positionSize, Any sur
   mBrightnessChangeDone( true ),
   mOwnSurface( false ),
   mMoveResizeSerial( 0 ),
-  mLastSubmittedMoveResizeSerial( 0 )
+  mLastSubmittedMoveResizeSerial( 0 ),
+  mWindowRotationAngle( 0 ),
+  mScreenRotationAngle( 0 ),
+  mSupportedPreProtation( 0 )
 #ifdef DALI_ELDBUS_AVAILABLE
   , mSystemConnection( NULL )
 #endif
@@ -757,6 +760,11 @@ void WindowBaseEcoreWl2::Initialize( PositionSize positionSize, Any surface, boo
     CreateWindow( positionSize );
   }
 
+  for( int i = 0; i < 4; ++i )
+  {
+    mAvaiableWindowOrientations[i] = 0;
+  }
+
   mWlSurface = ecore_wl2_window_surface_get( mEcoreWindow );
 
   SetTransparency( isTransparent );
@@ -1071,7 +1079,7 @@ void WindowBaseEcoreWl2::OnMouseButtonCancel( void* data, int type, void* event
 
     mTouchEventSignal.Emit( point, touchEvent->timestamp );
 
-    DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::OnMouseButtonCancel\n" );
+    DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnMouseButtonCancel\n" );
   }
 }
 
@@ -1081,7 +1089,7 @@ void WindowBaseEcoreWl2::OnMouseWheel( void* data, int type, void* event )
 
   if( mouseWheelEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
   {
-    DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::OnMouseWheel: direction: %d, modifiers: %d, x: %d, y: %d, z: %d\n", mouseWheelEvent->direction, mouseWheelEvent->modifiers, mouseWheelEvent->x, mouseWheelEvent->y, mouseWheelEvent->z );
+    DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::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 );
 
@@ -1093,12 +1101,12 @@ void WindowBaseEcoreWl2::OnDetentRotation( void* data, int type, void* event )
 {
   Ecore_Event_Detent_Rotate* detentEvent = static_cast< Ecore_Event_Detent_Rotate* >( event );
 
-  DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::OnDetentRotation\n" );
+  DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::OnDetentRotation\n" );
 
   int direction = ( detentEvent->direction == ECORE_DETENT_DIRECTION_CLOCKWISE ) ? 1 : -1;
   int timeStamp = detentEvent->timestamp;
 
-  WheelEvent wheelEvent( WheelEvent::CUSTOM_WHEEL, 0, 0, Vector2( 0.0f, 0.0f ), direction, timeStamp );
+  WheelEvent wheelEvent( WheelEvent::CUSTOM_WHEEL, direction, 0, Vector2( 0.0f, 0.0f ), 0, timeStamp );
 
   mWheelEventSignal.Emit( wheelEvent );
 }
@@ -1109,7 +1117,7 @@ void WindowBaseEcoreWl2::OnKeyDown( void* data, int type, void* event )
 
   if( keyEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
   {
-    DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::OnKeyDown\n" );
+    DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnKeyDown\n" );
 
     std::string keyName( keyEvent->keyname );
     std::string logicalKey( "" );
@@ -1171,7 +1179,7 @@ void WindowBaseEcoreWl2::OnKeyUp( void* data, int type, void* event )
 
   if( keyEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
   {
-    DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::OnKeyUp\n" );
+    DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnKeyUp\n" );
 
     std::string keyName( keyEvent->keyname );
     std::string logicalKey( "" );
@@ -1513,9 +1521,10 @@ bool WindowBaseEcoreWl2::IsEglWindowRotationSupported()
   wl_egl_window_tizen_capability capability = static_cast< wl_egl_window_tizen_capability >( wl_egl_window_tizen_get_capabilities( mEglWindow ) );
   if( capability == WL_EGL_WINDOW_TIZEN_CAPABILITY_ROTATION_SUPPORTED )
   {
+    mSupportedPreProtation = true;
     return true;
   }
-
+  mSupportedPreProtation = false;
   return false;
 }
 
@@ -1558,14 +1567,14 @@ void WindowBaseEcoreWl2::Activate()
 
 void WindowBaseEcoreWl2::SetAvailableAnlges( const std::vector< int >& angles )
 {
-  int rotations[4] = { 0 };
   DALI_LOG_RELEASE_INFO( "WindowBaseEcoreWl2::SetAvailableAnlges, angle's count: %d, angles\n", angles.size() );
-  for( std::size_t i = 0; i < angles.size(); ++i )
+  std::size_t size = angles.size();
+  for( std::size_t i = 0; i < size; ++i )
   {
-    rotations[i] = static_cast< int >( angles[i] );
-    DALI_LOG_RELEASE_INFO( "%d ", rotations[i] );
+    mAvaiableWindowOrientations[i] = static_cast< int >( angles[i] );
+    DALI_LOG_RELEASE_INFO( "%d ", mAvaiableWindowOrientations[i] );
   }
-  ecore_wl2_window_available_rotations_set( mEcoreWindow, rotations, angles.size() );
+  ecore_wl2_window_available_rotations_set( mEcoreWindow, mAvaiableWindowOrientations, size );
 }
 
 void WindowBaseEcoreWl2::SetPreferredAngle( int angle )
@@ -2259,6 +2268,16 @@ void WindowBaseEcoreWl2::GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiV
   dpiVertical   = int( yres + 0.5f );
 }
 
+int WindowBaseEcoreWl2::GetOrientation() const
+{
+  int orientation = (mScreenRotationAngle + mWindowRotationAngle) % 360;
+  if( mSupportedPreProtation )
+  {
+    orientation = 0;
+  }
+  return orientation;
+}
+
 int WindowBaseEcoreWl2::GetScreenRotationAngle()
 {
   int transform = 0;
@@ -2271,15 +2290,21 @@ int WindowBaseEcoreWl2::GetScreenRotationAngle()
   {
     transform = ecore_wl2_output_transform_get( ecore_wl2_window_output_find( mEcoreWindow ) );
   }
-
-  return transform * 90;
+  mScreenRotationAngle = transform * 90;
+  return mScreenRotationAngle;
 }
 
 void WindowBaseEcoreWl2::SetWindowRotationAngle( int degree )
 {
+  mWindowRotationAngle = degree;
   ecore_wl2_window_rotation_set( mEcoreWindow, degree );
 }
 
+int WindowBaseEcoreWl2::GetWindowRotationAngle()
+{
+  return mWindowRotationAngle;
+}
+
 void WindowBaseEcoreWl2::WindowRotationCompleted( int degree, int width, int height )
 {
   ecore_wl2_window_rotation_change_done_send( mEcoreWindow, degree, width, height );