Trace use scope macro instead of begin-end
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / tizen-wayland / ecore-wl2 / window-base-ecore-wl2.cpp
index 814b2a6..84e9381 100644 (file)
@@ -57,8 +57,25 @@ Debug::Filter* gWindowBaseLogFilter = Debug::Filter::New(Debug::NoLogging, false
 
 DALI_INIT_TRACE_FILTER(gTraceFilter, DALI_TRACE_PERFORMANCE_MARKER, false);
 
-const uint32_t     MAX_TIZEN_CLIENT_VERSION = 7;
-const unsigned int PRIMARY_TOUCH_BUTTON_ID  = 1;
+/**
+ * @brief Enumeration of location for window resized by display server.
+ */
+enum class ResizeLocation
+{
+  INVALID      = 0,  ///< Invalid value
+  TOP_LEFT     = 5,  ///< Start resizing window to the top-left edge.
+  LEFT         = 4,  ///< Start resizing window to the left side.
+  BOTTOM_LEFT  = 6,  ///< Start resizing window to the bottom-left edge.
+  BOTTOM       = 2,  ///< Start resizing window to the bottom side.
+  BOTTOM_RIGHT = 10, ///< Start resizing window to the bottom-right edge.
+  RIGHT        = 8,  ///< Start resizing window to the right side.
+  TOP_RIGHT    = 9,  ///< Start resizing window to the top-right edge.
+  TOP          = 1   ///< Start resizing window to the top side.
+};
+
+const uint32_t       MAX_TIZEN_CLIENT_VERSION = 7;
+const unsigned int   PRIMARY_TOUCH_BUTTON_ID  = 1;
+const ResizeLocation RESIZE_LOCATIONS[]       = {ResizeLocation::TOP_LEFT, ResizeLocation::LEFT, ResizeLocation::BOTTOM_LEFT, ResizeLocation::BOTTOM, ResizeLocation::BOTTOM_RIGHT, ResizeLocation::RIGHT, ResizeLocation::TOP_RIGHT, ResizeLocation::TOP, ResizeLocation::INVALID};
 
 #if defined(VCONF_ENABLED)
 const char* DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME = "db/setting/accessibility/font_name"; // It will be update at vconf-key.h and replaced.
@@ -230,6 +247,69 @@ void FindKeyCode(struct xkb_keymap* keyMap, xkb_keycode_t key, void* data)
   }
 }
 
+/**
+ * Return the recalculated window resizing location according to the current orientation.
+ */
+ResizeLocation RecalculateLocationToCurrentOrientation(WindowResizeDirection direction, int windowRotationAngle)
+{
+  int index = 8;
+  switch(direction)
+  {
+    case WindowResizeDirection::TOP_LEFT:
+    {
+      index = 0;
+      break;
+    }
+    case WindowResizeDirection::LEFT:
+    {
+      index = 1;
+      break;
+    }
+    case WindowResizeDirection::BOTTOM_LEFT:
+    {
+      index = 2;
+      break;
+    }
+    case WindowResizeDirection::BOTTOM:
+    {
+      index = 3;
+      break;
+    }
+    case WindowResizeDirection::BOTTOM_RIGHT:
+    {
+      index = 4;
+      break;
+    }
+    case WindowResizeDirection::RIGHT:
+    {
+      index = 5;
+      break;
+    }
+    case WindowResizeDirection::TOP_RIGHT:
+    {
+      index = 6;
+      break;
+    }
+    case WindowResizeDirection::TOP:
+    {
+      index = 7;
+      break;
+    }
+    default:
+    {
+      index = 8;
+      break;
+    }
+  }
+
+  if(index != 8 && windowRotationAngle != 0)
+  {
+    index = (index + (windowRotationAngle / 90) * 2) % 8;
+  }
+
+  return RESIZE_LOCATIONS[index];
+}
+
 /////////////////////////////////////////////////////////////////////////////////////////////////
 // Window Callbacks
 /////////////////////////////////////////////////////////////////////////////////////////////////
@@ -718,8 +798,6 @@ WindowBaseEcoreWl2::WindowBaseEcoreWl2(Dali::PositionSize positionSize, Any surf
   mWindowRotationAngle(0),
   mScreenRotationAngle(0),
   mSupportedPreProtation(0),
-  mScreenWidth(0),
-  mScreenHeight(0),
   mNotificationChangeState(0),
   mScreenOffModeChangeState(0),
   mBrightnessChangeState(0),
@@ -1205,14 +1283,7 @@ void WindowBaseEcoreWl2::OnKeyDown(void* data, int type, void* event)
     std::string keyString("");
     std::string compose("");
 
-#ifdef TRACE_ENABLED
-    std::ostringstream stream;
-    if(gTraceFilter->IsTraceEnabled())
-    {
-      stream << "DALI_ON_KEY_DOWN [" << keyName << "]";
-      DALI_TRACE_BEGIN(gTraceFilter, stream.str().c_str());
-    }
-#endif
+    DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_KEY_DOWN");
 
     // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
     if(keyEvent->compose)
@@ -1260,13 +1331,6 @@ void WindowBaseEcoreWl2::OnKeyDown(void* data, int type, void* event)
     Integration::KeyEvent keyEvent(keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::DOWN, compose, deviceName, deviceClass, deviceSubclass);
 
     mKeyEventSignal.Emit(keyEvent);
-
-#ifdef TRACE_ENABLED
-    if(gTraceFilter->IsTraceEnabled())
-    {
-      DALI_TRACE_END(gTraceFilter, stream.str().c_str());
-    }
-#endif
   }
 }
 
@@ -1290,14 +1354,7 @@ void WindowBaseEcoreWl2::OnKeyUp(void* data, int type, void* event)
     std::string keyString("");
     std::string compose("");
 
-#ifdef TRACE_ENABLED
-    std::ostringstream stream;
-    if(gTraceFilter->IsTraceEnabled())
-    {
-      stream << "DALI_ON_KEY_UP [" << keyName << "]" << std::endl;
-      DALI_TRACE_BEGIN(gTraceFilter, stream.str().c_str());
-    }
-#endif
+    DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_KEY_UP");
 
     // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
     if(keyEvent->compose)
@@ -1345,13 +1402,6 @@ void WindowBaseEcoreWl2::OnKeyUp(void* data, int type, void* event)
     Integration::KeyEvent keyEvent(keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::UP, compose, deviceName, deviceClass, deviceSubclass);
 
     mKeyEventSignal.Emit(keyEvent);
-
-#ifdef TRACE_ENABLED
-    if(gTraceFilter->IsTraceEnabled())
-    {
-      DALI_TRACE_END(gTraceFilter, stream.str().c_str());
-    }
-#endif
   }
 }
 
@@ -1692,24 +1742,26 @@ bool WindowBaseEcoreWl2::IsEglWindowRotationSupported()
 PositionSize WindowBaseEcoreWl2::RecalculatePositionSizeToSystem(PositionSize positionSize)
 {
   PositionSize newPositionSize;
+  int32_t      screenWidth, screenHeight;
+  WindowSystem::GetScreenSize(screenWidth, screenHeight);
 
   if(mWindowRotationAngle == 90)
   {
     newPositionSize.x      = positionSize.y;
-    newPositionSize.y      = mScreenHeight - (positionSize.x + positionSize.width);
+    newPositionSize.y      = screenHeight - (positionSize.x + positionSize.width);
     newPositionSize.width  = positionSize.height;
     newPositionSize.height = positionSize.width;
   }
   else if(mWindowRotationAngle == 180)
   {
-    newPositionSize.x      = mScreenWidth - (positionSize.x + positionSize.width);
-    newPositionSize.y      = mScreenHeight - (positionSize.y + positionSize.height);
+    newPositionSize.x      = screenWidth - (positionSize.x + positionSize.width);
+    newPositionSize.y      = screenHeight - (positionSize.y + positionSize.height);
     newPositionSize.width  = positionSize.width;
     newPositionSize.height = positionSize.height;
   }
   else if(mWindowRotationAngle == 270)
   {
-    newPositionSize.x      = mScreenWidth - (positionSize.y + positionSize.height);
+    newPositionSize.x      = screenWidth - (positionSize.y + positionSize.height);
     newPositionSize.y      = positionSize.x;
     newPositionSize.width  = positionSize.height;
     newPositionSize.height = positionSize.width;
@@ -1728,25 +1780,27 @@ PositionSize WindowBaseEcoreWl2::RecalculatePositionSizeToSystem(PositionSize po
 PositionSize WindowBaseEcoreWl2::RecalculatePositionSizeToCurrentOrientation(PositionSize positionSize)
 {
   PositionSize newPositionSize;
+  int32_t      screenWidth, screenHeight;
+  WindowSystem::GetScreenSize(screenWidth, screenHeight);
 
   if(mWindowRotationAngle == 90)
   {
-    newPositionSize.x      = mScreenHeight - (positionSize.y + positionSize.height);
+    newPositionSize.x      = screenHeight - (positionSize.y + positionSize.height);
     newPositionSize.y      = positionSize.x;
     newPositionSize.width  = positionSize.height;
     newPositionSize.height = positionSize.width;
   }
   else if(mWindowRotationAngle == 180)
   {
-    newPositionSize.x      = mScreenWidth - (positionSize.x + positionSize.width);
-    newPositionSize.y      = mScreenHeight - (positionSize.y + positionSize.height);
+    newPositionSize.x      = screenWidth - (positionSize.x + positionSize.width);
+    newPositionSize.y      = screenHeight - (positionSize.y + positionSize.height);
     newPositionSize.width  = positionSize.width;
     newPositionSize.height = positionSize.height;
   }
   else if(mWindowRotationAngle == 270)
   {
     newPositionSize.x      = positionSize.y;
-    newPositionSize.y      = mScreenWidth - (positionSize.x + positionSize.width);
+    newPositionSize.y      = screenWidth - (positionSize.x + positionSize.width);
     newPositionSize.width  = positionSize.height;
     newPositionSize.height = positionSize.width;
   }
@@ -2636,9 +2690,6 @@ void WindowBaseEcoreWl2::CreateWindow(PositionSize positionSize)
 
   // Set default type
   ecore_wl2_window_type_set(mEcoreWindow, ECORE_WL2_WINDOW_TYPE_TOPLEVEL);
-
-  // Get Screen width, height
-  ecore_wl2_display_screen_size_get(display, &mScreenWidth, &mScreenHeight);
 }
 
 void WindowBaseEcoreWl2::SetParent(WindowBase* parentWinBase, bool belowParent)
@@ -2792,58 +2843,10 @@ void WindowBaseEcoreWl2::RequestResizeToServer(WindowResizeDirection direction)
     return;
   }
 
-  int location = 0;
-  switch(direction)
-  {
-    case WindowResizeDirection::TOP_LEFT:
-    {
-      location = 5;
-      break;
-    }
-    case WindowResizeDirection::TOP:
-    {
-      location = 1;
-      break;
-    }
-    case WindowResizeDirection::TOP_RIGHT:
-    {
-      location = 9;
-      break;
-    }
-    case WindowResizeDirection::LEFT:
-    {
-      location = 4;
-      break;
-    }
-    case WindowResizeDirection::RIGHT:
-    {
-      location = 8;
-      break;
-    }
-    case WindowResizeDirection::BOTTOM_LEFT:
-    {
-      location = 6;
-      break;
-    }
-    case WindowResizeDirection::BOTTOM:
-    {
-      location = 2;
-      break;
-    }
-    case WindowResizeDirection::BOTTOM_RIGHT:
-    {
-      location = 10;
-      break;
-    }
-    default:
-    {
-      location = 0;
-      break;
-    }
-  }
+  ResizeLocation location = RecalculateLocationToCurrentOrientation(direction, mWindowRotationAngle);
 
-  ecore_wl2_window_resize(mEcoreWindow, input, location);
-  DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::RequestResizeToServer, starts the window[%p] is resized by server, mode:%d\n", mEcoreWindow, location);
+  ecore_wl2_window_resize(mEcoreWindow, input, static_cast<int>(location));
+  DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::RequestResizeToServer, starts the window[%p] is resized by server, direction:%d oriention:%d mode:%d\n", mEcoreWindow, direction, mWindowRotationAngle, location);
 }
 
 void WindowBaseEcoreWl2::EnableFloatingMode(bool enable)