Merge branch 'devel/master' into tizen
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / tizen-wayland / ecore-wl / window-base-ecore-wl.cpp
index 509ddd4..74a67c0 100644 (file)
@@ -565,32 +565,36 @@ const struct tizen_display_policy_listener tizenDisplayPolicyListener =
 
 } // unnamed namespace
 
-WindowBaseEcoreWl::WindowBaseEcoreWl( Dali::PositionSize positionSize, Any surface, bool isTransparent )
+WindowBaseEcoreWl::WindowBaseEcoreWl(Dali::PositionSize positionSize, Any surface, bool isTransparent)
 : mEcoreEventHandler(),
-  mEcoreWindow( NULL ),
-  mWlSurface( NULL ),
-  mEglWindow( NULL ),
-  mDisplay( NULL ),
-  mEventQueue( NULL ),
-  mTizenPolicy( NULL ),
-  mTizenDisplayPolicy( NULL ),
+  mEcoreWindow(nullptr),
+  mWlSurface(nullptr),
+  mEglWindow(nullptr),
+  mDisplay(nullptr),
+  mEventQueue(nullptr),
+  mTizenPolicy(nullptr),
+  mTizenDisplayPolicy(nullptr),
   mSupportedAuxiliaryHints(),
   mAuxiliaryHints(),
-  mNotificationLevel( -1 ),
-  mNotificationChangeState( 0 ),
-  mNotificationLevelChangeDone( true ),
-  mScreenOffMode( 0 ),
-  mScreenOffModeChangeState( 0 ),
-  mScreenOffModeChangeDone( true ),
-  mBrightness( 0 ),
-  mBrightnessChangeState( 0 ),
-  mBrightnessChangeDone( true ),
-  mOwnSurface( false )
+  mNotificationLevel(-1),
+  mNotificationChangeState(0),
+  mNotificationLevelChangeDone(true),
+  mScreenOffMode(0),
+  mScreenOffModeChangeState(0),
+  mScreenOffModeChangeDone(true),
+  mBrightness(0),
+  mBrightnessChangeState(0),
+  mBrightnessChangeDone(true),
+  mOwnSurface(false),
+  mWindowRotationAngle(0),
+  mScreenRotationAngle(0),
+  mSupportedPreProtation(0)
 #ifdef DALI_ELDBUS_AVAILABLE
-  , mSystemConnection( NULL )
+  ,
+  mSystemConnection(NULL)
 #endif
 {
-  Initialize( positionSize, surface, isTransparent );
+  Initialize(positionSize, surface, isTransparent);
 }
 
 WindowBaseEcoreWl::~WindowBaseEcoreWl()
@@ -944,7 +948,7 @@ void WindowBaseEcoreWl::OnMouseWheel( void* data, int type, void* event )
   {
     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 );
 
-    WheelEvent wheelEvent( WheelEvent::MOUSE_WHEEL, mouseWheelEvent->direction, mouseWheelEvent->modifiers, Vector2( mouseWheelEvent->x, mouseWheelEvent->y ), mouseWheelEvent->z, mouseWheelEvent->timestamp );
+    Integration::WheelEvent wheelEvent( Integration::WheelEvent::MOUSE_WHEEL, mouseWheelEvent->direction, mouseWheelEvent->modifiers, Vector2( mouseWheelEvent->x, mouseWheelEvent->y ), mouseWheelEvent->z, mouseWheelEvent->timestamp );
 
     mWheelEventSignal.Emit( wheelEvent );
   }
@@ -959,7 +963,7 @@ void WindowBaseEcoreWl::OnDetentRotation( void* data, int type, void* event )
   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 );
+  Integration::WheelEvent wheelEvent( Integration::WheelEvent::CUSTOM_WHEEL, 0, 0, Vector2( 0.0f, 0.0f ), direction, timeStamp );
 
   mWheelEventSignal.Emit( wheelEvent );
 }
@@ -1012,7 +1016,7 @@ void WindowBaseEcoreWl::OnKeyDown( void* data, int type, void* event )
     GetDeviceClass( ecore_device_class_get( keyEvent->dev ), deviceClass );
     GetDeviceSubclass( ecore_device_subclass_get( keyEvent->dev ), deviceSubclass );
 
-    Integration::KeyEvent keyEvent( keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::Down, compose, deviceName, deviceClass, deviceSubclass );
+    Integration::KeyEvent keyEvent( keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::DOWN, compose, deviceName, deviceClass, deviceSubclass );
 
      mKeyEventSignal.Emit( keyEvent );
   }
@@ -1026,6 +1030,15 @@ void WindowBaseEcoreWl::OnKeyUp( void* data, int type, void* event )
   {
     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::OnKeyUp\n" );
 
+#if defined(ECORE_VERSION_MAJOR) && (ECORE_VERSION_MAJOR >= 1) && defined(ECORE_VERSION_MINOR) && (ECORE_VERSION_MINOR >= 23)
+    // Cancel processing flag is sent because this key event will combine with the previous key. So, the event should not actually perform anything.
+    if( keyEvent->event_flags & ECORE_EVENT_FLAG_CANCEL )
+    {
+      DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::OnKeyUp: This event flag indicates the event is canceled. \n" );
+      return;
+    }
+#endif // Since ecore 1.23 version
+
     std::string keyName( keyEvent->keyname );
     std::string logicalKey( "" );
     std::string keyString( "" );
@@ -1066,7 +1079,7 @@ void WindowBaseEcoreWl::OnKeyUp( void* data, int type, void* event )
     GetDeviceClass( ecore_device_class_get( keyEvent->dev ), deviceClass );
     GetDeviceSubclass( ecore_device_subclass_get( keyEvent->dev ), deviceSubclass );
 
-    Integration::KeyEvent keyEvent( keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::Up, compose, deviceName, deviceClass, deviceSubclass );
+    Integration::KeyEvent keyEvent( keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::UP, compose, deviceName, deviceClass, deviceSubclass );
 
      mKeyEventSignal.Emit( keyEvent );
   }
@@ -1317,9 +1330,10 @@ bool WindowBaseEcoreWl::IsEglWindowRotationSupported()
   wl_egl_window_capability capability = static_cast< wl_egl_window_capability >( wl_egl_window_get_capabilities( mEglWindow ) );
   if( capability == WL_EGL_WINDOW_CAPABILITY_ROTATION_SUPPORTED )
   {
+    mSupportedPreProtation = true;
     return true;
   }
-
+  mSupportedPreProtation = false;
   return false;
 }
 
@@ -1522,28 +1536,28 @@ void WindowBaseEcoreWl::SetInputRegion( const Rect< int >& inputRegion )
   ecore_wl_window_input_region_set( mEcoreWindow, inputRegion.x, inputRegion.y, inputRegion.width, inputRegion.height );
 }
 
-void WindowBaseEcoreWl::SetType( Dali::Window::Type type )
+void WindowBaseEcoreWl::SetType( Dali::WindowType type )
 {
   Ecore_Wl_Window_Type windowType;
 
   switch( type )
   {
-    case Dali::Window::NORMAL:
+    case Dali::WindowType::NORMAL:
     {
       windowType = ECORE_WL_WINDOW_TYPE_TOPLEVEL;
       break;
     }
-    case Dali::Window::NOTIFICATION:
+    case Dali::WindowType::NOTIFICATION:
     {
       windowType = ECORE_WL_WINDOW_TYPE_NOTIFICATION;
       break;
     }
-    case Dali::Window::UTILITY:
+    case Dali::WindowType::UTILITY:
     {
       windowType = ECORE_WL_WINDOW_TYPE_UTILITY;
       break;
     }
-    case Dali::Window::DIALOG:
+    case Dali::WindowType::DIALOG:
     {
       windowType = ECORE_WL_WINDOW_TYPE_DIALOG;
       break;
@@ -1558,7 +1572,7 @@ void WindowBaseEcoreWl::SetType( Dali::Window::Type type )
   ecore_wl_window_type_set( mEcoreWindow, windowType );
 }
 
-bool WindowBaseEcoreWl::SetNotificationLevel( Dali::Window::NotificationLevel::Type level )
+bool WindowBaseEcoreWl::SetNotificationLevel( Dali::WindowNotificationLevel level )
 {
   while( !mTizenPolicy )
   {
@@ -1569,27 +1583,27 @@ bool WindowBaseEcoreWl::SetNotificationLevel( Dali::Window::NotificationLevel::T
 
   switch( level )
   {
-    case Dali::Window::NotificationLevel::NONE:
+    case Dali::WindowNotificationLevel::NONE:
     {
       notificationLevel = TIZEN_POLICY_LEVEL_NONE;
       break;
     }
-    case Dali::Window::NotificationLevel::BASE:
+    case Dali::WindowNotificationLevel::BASE:
     {
       notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
       break;
     }
-    case Dali::Window::NotificationLevel::MEDIUM:
+    case Dali::WindowNotificationLevel::MEDIUM:
     {
       notificationLevel = TIZEN_POLICY_LEVEL_MEDIUM;
       break;
     }
-    case Dali::Window::NotificationLevel::HIGH:
+    case Dali::WindowNotificationLevel::HIGH:
     {
       notificationLevel = TIZEN_POLICY_LEVEL_HIGH;
       break;
     }
-    case Dali::Window::NotificationLevel::TOP:
+    case Dali::WindowNotificationLevel::TOP:
     {
       notificationLevel = TIZEN_POLICY_LEVEL_TOP;
       break;
@@ -1632,7 +1646,7 @@ bool WindowBaseEcoreWl::SetNotificationLevel( Dali::Window::NotificationLevel::T
   return true;
 }
 
-Dali::Window::NotificationLevel::Type WindowBaseEcoreWl::GetNotificationLevel() const
+Dali::WindowNotificationLevel WindowBaseEcoreWl::GetNotificationLevel() const
 {
   while( !mTizenPolicy )
   {
@@ -1654,39 +1668,39 @@ Dali::Window::NotificationLevel::Type WindowBaseEcoreWl::GetNotificationLevel()
     return Dali::Window::NotificationLevel::NONE;
   }
 
-  Dali::Window::NotificationLevel::Type level;
+  Dali::WindowNotificationLevel level;
 
   switch( mNotificationLevel )
   {
     case TIZEN_POLICY_LEVEL_NONE:
     {
-      level = Dali::Window::NotificationLevel::NONE;
+      level = Dali::WindowNotificationLevel::NONE;
       break;
     }
     case TIZEN_POLICY_LEVEL_DEFAULT:
     {
-      level = Dali::Window::NotificationLevel::BASE;
+      level = Dali::WindowNotificationLevel::BASE;
       break;
     }
     case TIZEN_POLICY_LEVEL_MEDIUM:
     {
-      level = Dali::Window::NotificationLevel::MEDIUM;
+      level = Dali::WindowNotificationLevel::MEDIUM;
       break;
     }
     case TIZEN_POLICY_LEVEL_HIGH:
     {
-      level = Dali::Window::NotificationLevel::HIGH;
+      level = Dali::WindowNotificationLevel::HIGH;
       break;
     }
     case TIZEN_POLICY_LEVEL_TOP:
     {
-      level = Dali::Window::NotificationLevel::TOP;
+      level = Dali::WindowNotificationLevel::TOP;
       break;
     }
     default:
     {
       DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetNotificationLevel: invalid level [%d]\n", mNotificationLevel );
-      level = Dali::Window::NotificationLevel::NONE;
+      level = Dali::WindowNotificationLevel::NONE;
       break;
     }
   }
@@ -1706,7 +1720,7 @@ void WindowBaseEcoreWl::SetOpaqueState( bool opaque )
   tizen_policy_set_opaque_state( mTizenPolicy, ecore_wl_window_surface_get( mEcoreWindow ), ( opaque ? 1 : 0 ) );
 }
 
-bool WindowBaseEcoreWl::SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode)
+bool WindowBaseEcoreWl::SetScreenOffMode(WindowScreenOffMode screenOffMode)
 {
   while( !mTizenPolicy )
   {
@@ -1720,12 +1734,12 @@ bool WindowBaseEcoreWl::SetScreenOffMode(Dali::Window::ScreenOffMode::Type scree
 
   switch( screenOffMode )
   {
-    case Dali::Window::ScreenOffMode::TIMEOUT:
+    case WindowScreenOffMode::TIMEOUT:
     {
       mode = 0;
       break;
     }
-    case Dali::Window::ScreenOffMode::NEVER:
+    case WindowScreenOffMode::NEVER:
     {
       mode = 1;
       break;
@@ -1759,7 +1773,7 @@ bool WindowBaseEcoreWl::SetScreenOffMode(Dali::Window::ScreenOffMode::Type scree
   return true;
 }
 
-Dali::Window::ScreenOffMode::Type WindowBaseEcoreWl::GetScreenOffMode() const
+WindowScreenOffMode WindowBaseEcoreWl::GetScreenOffMode() const
 {
   while( !mTizenPolicy )
   {
@@ -1778,21 +1792,21 @@ Dali::Window::ScreenOffMode::Type WindowBaseEcoreWl::GetScreenOffMode() const
   if( !mScreenOffModeChangeDone )
   {
     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetScreenOffMode: Error! [%d]\n", mScreenOffModeChangeState );
-    return Dali::Window::ScreenOffMode::TIMEOUT;
+    return WindowScreenOffMode::TIMEOUT;
   }
 
-  Dali::Window::ScreenOffMode::Type screenMode = Dali::Window::ScreenOffMode::TIMEOUT;
+  WindowScreenOffMode screenMode = WindowScreenOffMode::TIMEOUT;
 
   switch( mScreenOffMode )
   {
     case 0:
     {
-      screenMode = Dali::Window::ScreenOffMode::TIMEOUT;
+      screenMode = WindowScreenOffMode::TIMEOUT;
       break;
     }
     case 1:
     {
-      screenMode = Dali::Window::ScreenOffMode::NEVER;
+      screenMode = WindowScreenOffMode::NEVER;
       break;
     }
   }
@@ -2062,6 +2076,16 @@ void WindowBaseEcoreWl::GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVe
   dpiVertical   = int( yres + 0.5f );
 }
 
+int WindowBaseEcoreWl::GetOrientation() const
+{
+  int orientation = (mScreenRotationAngle + mWindowRotationAngle) % 360;
+  if(mSupportedPreProtation)
+  {
+    orientation = 0;
+  }
+  return orientation;
+}
+
 int WindowBaseEcoreWl::GetScreenRotationAngle()
 {
   int transform = 0;
@@ -2075,11 +2099,13 @@ int WindowBaseEcoreWl::GetScreenRotationAngle()
     transform = ecore_wl_output_transform_get( ecore_wl_window_output_find( mEcoreWindow ) );
   }
 
-  return transform * 90;
+  mScreenRotationAngle = transform * 90;
+  return mScreenRotationAngle;
 }
 
 void WindowBaseEcoreWl::SetWindowRotationAngle( int degree )
 {
+  mWindowRotationAngle = degree;
   ecore_wl_window_rotation_set( mEcoreWindow, degree );
 }
 
@@ -2146,6 +2172,16 @@ void WindowBaseEcoreWl::SetParent( WindowBase* parentWinBase )
   ecore_wl_window_parent_set( mEcoreWindow, ecoreParent );
 }
 
+int WindowBaseEcoreWl::CreateFrameRenderedSyncFence()
+{
+  return -1;
+}
+
+int WindowBaseEcoreWl::CreateFramePresentedSyncFence()
+{
+  return -1;
+}
+
 } // namespace Adaptor
 
 } // namespace Internal