Add the exception case for window rotation.
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / tizen-wayland / ecore-wl2 / window-base-ecore-wl2.cpp
index 4c91c35..b8227e0 100644 (file)
@@ -980,6 +980,22 @@ void WindowBaseEcoreWl2::OnRotation(void* data, int type, void* event)
     RotationEvent rotationEvent;
     rotationEvent.angle     = ev->angle;
     rotationEvent.winResize = 0;
+
+    if(ev->w == 0 || ev->h ==0)
+    {
+      // Use previous client side window's size.
+      if(mWindowRotationAngle == 90 || mWindowRotationAngle == 270)
+      {
+        ev->w = mWindowPositionSize.height;
+        ev->h = mWindowPositionSize.width;
+      }
+      else
+      {
+        ev->w = mWindowPositionSize.width;
+        ev->h = mWindowPositionSize.height;
+      }
+    }
+
     mWindowRotationAngle    = ev->angle;
 
     if(ev->angle == 0 || ev->angle == 180)
@@ -1004,10 +1020,40 @@ void WindowBaseEcoreWl2::OnConfiguration(void* data, int type, void* event)
 {
   Ecore_Wl2_Event_Window_Configure* ev(static_cast<Ecore_Wl2_Event_Window_Configure*>(event));
 
-  if(ev->win == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
+  if(ev && ev->win == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
   {
     // Note: To comply with the wayland protocol, Dali should make an ack_configure
     // by calling ecore_wl2_window_commit
+
+    int tempWidth  = static_cast<int>(ev->w);
+    int tempHeight = static_cast<int>(ev->h);
+
+    // Initialize with previous size for skip resize when new size is 0.
+    // When window is just moved or window is resized by client application,
+    // The configure notification event's size will be 0.
+    // If new size is 0, the resized work should be skip.
+    int  newWidth    = mWindowPositionSize.width;
+    int  newHeight   = mWindowPositionSize.height;
+    bool windowMoved = false, windowResized = false;
+
+    if(ev->x != mWindowPositionSize.x || ev->y != mWindowPositionSize.y)
+    {
+      windowMoved = true;
+    }
+
+    if(tempWidth != 0 && tempHeight != 0 && (tempWidth != mWindowPositionSize.width || tempHeight != mWindowPositionSize.height))
+    {
+      windowResized = true;
+      newWidth      = tempWidth;
+      newHeight     = tempHeight;
+    }
+
+    if(windowMoved || windowResized)
+    {
+      Dali::PositionSize newPositionSize(ev->x, ev->y, newWidth, newHeight);
+      mUpdatePositionSizeSignal.Emit(newPositionSize);
+    }
+
     ecore_wl2_window_commit(mEcoreWindow, EINA_FALSE);
   }
 }
@@ -1849,7 +1895,7 @@ void WindowBaseEcoreWl2::SetType(Dali::WindowType type)
   ecore_wl2_window_type_set(mEcoreWindow, windowType);
 }
 
-bool WindowBaseEcoreWl2::SetNotificationLevel(Dali::WindowNotificationLevel level)
+Dali::WindowOperationResult WindowBaseEcoreWl2::SetNotificationLevel(Dali::WindowNotificationLevel level)
 {
   while(!mTizenPolicy)
   {
@@ -1910,17 +1956,17 @@ bool WindowBaseEcoreWl2::SetNotificationLevel(Dali::WindowNotificationLevel leve
   if(!mNotificationLevelChangeDone)
   {
     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Level change is failed [%d, %d]\n", level, mNotificationChangeState);
-    return false;
+    return Dali::WindowOperationResult::UNKNOWN_ERROR;
   }
   else if(mNotificationChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
   {
     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Permission denied! [%d]\n", level);
-    return false;
+    return Dali::WindowOperationResult::PERMISSION_DENIED;
   }
 
   DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Level is changed [%d]\n", mNotificationLevel);
 
-  return true;
+  return Dali::WindowOperationResult::SUCCEED;
 }
 
 Dali::WindowNotificationLevel WindowBaseEcoreWl2::GetNotificationLevel() const
@@ -1997,7 +2043,7 @@ void WindowBaseEcoreWl2::SetOpaqueState(bool opaque)
   tizen_policy_set_opaque_state(mTizenPolicy, ecore_wl2_window_surface_get(mEcoreWindow), (opaque ? 1 : 0));
 }
 
-bool WindowBaseEcoreWl2::SetScreenOffMode(WindowScreenOffMode screenOffMode)
+Dali::WindowOperationResult WindowBaseEcoreWl2::SetScreenOffMode(WindowScreenOffMode screenOffMode)
 {
   while(!mTizenPolicy)
   {
@@ -2037,17 +2083,17 @@ bool WindowBaseEcoreWl2::SetScreenOffMode(WindowScreenOffMode screenOffMode)
   if(!mScreenOffModeChangeDone)
   {
     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Screen mode change is failed [%d, %d]\n", screenOffMode, mScreenOffModeChangeState);
-    return false;
+    return Dali::WindowOperationResult::UNKNOWN_ERROR;
   }
   else if(mScreenOffModeChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
   {
     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Permission denied! [%d]\n", screenOffMode);
-    return false;
+    return Dali::WindowOperationResult::PERMISSION_DENIED;
   }
 
   DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Screen mode is changed [%d]\n", mScreenOffMode);
 
-  return true;
+  return Dali::WindowOperationResult::SUCCEED;
 }
 
 WindowScreenOffMode WindowBaseEcoreWl2::GetScreenOffMode() const
@@ -2093,7 +2139,7 @@ WindowScreenOffMode WindowBaseEcoreWl2::GetScreenOffMode() const
   return screenMode;
 }
 
-bool WindowBaseEcoreWl2::SetBrightness(int brightness)
+Dali::WindowOperationResult WindowBaseEcoreWl2::SetBrightness(int brightness)
 {
   while(!mTizenDisplayPolicy)
   {
@@ -2117,17 +2163,17 @@ bool WindowBaseEcoreWl2::SetBrightness(int brightness)
   if(!mBrightnessChangeDone)
   {
     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Brightness change is failed [%d, %d]\n", brightness, mBrightnessChangeState);
-    return false;
+    return Dali::WindowOperationResult::UNKNOWN_ERROR;
   }
   else if(mBrightnessChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
   {
     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Permission denied! [%d]\n", brightness);
-    return false;
+    return Dali::WindowOperationResult::PERMISSION_DENIED;
   }
 
   DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Brightness is changed [%d]\n", mBrightness);
 
-  return true;
+  return Dali::WindowOperationResult::SUCCEED;
 }
 
 int WindowBaseEcoreWl2::GetBrightness() const