Merge "(egl-implementation.cpp) Removed unnecessary Error message" into devel/master
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / tizen-wayland / ecore-wl2 / window-base-ecore-wl2.cpp
index 0a490a0..9bc72f5 100644 (file)
@@ -55,13 +55,6 @@ const unsigned int PRIMARY_TOUCH_BUTTON_ID  = 1;
 
 const char* DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME = "db/setting/accessibility/font_name"; // It will be update at vconf-key.h and replaced.
 
-#ifdef DALI_ELDBUS_AVAILABLE
-// DBUS accessibility
-const char* BUS       = "org.enlightenment.wm-screen-reader";
-const char* INTERFACE = "org.tizen.GestureNavigation";
-const char* PATH      = "/org/tizen/GestureNavigation";
-#endif // DALI_ELDBUS_AVAILABLE
-
 struct KeyCodeMap
 {
   xkb_keysym_t  keySym;
@@ -449,9 +442,9 @@ static Eina_Bool EcoreEventDataSend(void* data, int type, void* event)
 }
 
 /**
-* Called when the source window sends us about the selected content.
-* For example, when item is selected in the clipboard.
-*/
+ * Called when the source window sends us about the selected content.
+ * For example, when item is selected in the clipboard.
+ */
 static Eina_Bool EcoreEventDataReceive(void* data, int type, void* event)
 {
   WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
@@ -590,22 +583,6 @@ static Eina_Bool EcoreEventWindowAuxiliaryMessage(void* data, int type, void* ev
   return ECORE_CALLBACK_RENEW;
 }
 
-/////////////////////////////////////////////////////////////////////////////////////////////////
-// ElDBus Accessibility Callbacks
-/////////////////////////////////////////////////////////////////////////////////////////////////
-
-#ifdef DALI_ELDBUS_AVAILABLE
-// Callback for Ecore ElDBus accessibility events.
-static void EcoreElDBusAccessibilityNotification(void* context, const Eldbus_Message* message)
-{
-  WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(context);
-  if(windowBase)
-  {
-    windowBase->OnEcoreElDBusAccessibilityNotification(context, message);
-  }
-}
-#endif // DALI_ELDBUS_AVAILABLE
-
 static void RegistryGlobalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version)
 {
   WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
@@ -730,6 +707,8 @@ WindowBaseEcoreWl2::WindowBaseEcoreWl2(Dali::PositionSize positionSize, Any surf
   mWindowRotationAngle(0),
   mScreenRotationAngle(0),
   mSupportedPreProtation(0),
+  mScreenWidth(0),
+  mScreenHeight(0),
   mNotificationChangeState(0),
   mScreenOffModeChangeState(0),
   mBrightnessChangeState(0),
@@ -740,24 +719,12 @@ WindowBaseEcoreWl2::WindowBaseEcoreWl2(Dali::PositionSize positionSize, Any surf
   mVisible(true),
   mOwnSurface(false),
   mBrightnessChangeDone(true)
-#ifdef DALI_ELDBUS_AVAILABLE
-  ,
-  mSystemConnection(NULL)
-#endif
 {
   Initialize(positionSize, surface, isTransparent);
 }
 
 WindowBaseEcoreWl2::~WindowBaseEcoreWl2()
 {
-#ifdef DALI_ELDBUS_AVAILABLE
-  // Close down ElDBus connections.
-  if(mSystemConnection)
-  {
-    eldbus_connection_unref(mSystemConnection);
-  }
-#endif // DALI_ELDBUS_AVAILABLE
-
   vconf_ignore_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged);
   vconf_ignore_key_changed(DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged);
 
@@ -860,8 +827,6 @@ void WindowBaseEcoreWl2::Initialize(PositionSize positionSize, Any surface, bool
   vconf_notify_key_changed(DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged, this);
   vconf_notify_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged, this);
 
-  InitializeEcoreElDBus();
-
   Ecore_Wl2_Display* display = ecore_wl2_connected_display_get(NULL);
   mDisplay                   = ecore_wl2_display_get(display);
 
@@ -1003,34 +968,23 @@ void WindowBaseEcoreWl2::OnRotation(void* data, int type, void* event)
 
     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;
-      }
+      // When rotation event does not have the window width or height,
+      // previous DALi side window's size are used.
+      ev->w = mWindowPositionSize.width;
+      ev->h = mWindowPositionSize.height;
     }
 
     mWindowRotationAngle = ev->angle;
 
-    if(ev->angle == 0 || ev->angle == 180)
-    {
-      rotationEvent.width  = ev->w;
-      rotationEvent.height = ev->h;
-    }
-    else
-    {
-      rotationEvent.width  = ev->h;
-      rotationEvent.height = ev->w;
-    }
+    mWindowPositionSize.width  = ev->w;
+    mWindowPositionSize.height = ev->h;
 
-    mWindowPositionSize.width  = rotationEvent.width;
-    mWindowPositionSize.height = rotationEvent.height;
+    PositionSize newPositionSize = RecalculatePositionSizeToCurrentOrientation(mWindowPositionSize);
+
+    rotationEvent.x      = newPositionSize.x;
+    rotationEvent.y      = newPositionSize.y;
+    rotationEvent.width  = newPositionSize.width;
+    rotationEvent.height = newPositionSize.height;
 
     mRotationSignal.Emit(rotationEvent);
   }
@@ -1070,9 +1024,16 @@ void WindowBaseEcoreWl2::OnConfiguration(void* data, int type, void* event)
 
     if(windowMoved || windowResized)
     {
-      Dali::PositionSize newPositionSize(ev->x, ev->y, newWidth, newHeight);
-      mWindowPositionSize = newPositionSize;
-      DALI_LOG_RELEASE_INFO("Update position & resize signal by server, x[%d] y[%d] w[%d] h[%d]\n", newPositionSize.x, newPositionSize.y, newPositionSize.width, newPositionSize.height);
+      mWindowPositionSize.x      = ev->x;
+      mWindowPositionSize.y      = ev->y;
+      mWindowPositionSize.width  = newWidth;
+      mWindowPositionSize.height = newHeight;
+      DALI_LOG_RELEASE_INFO("Update position & resize signal by server, current angle [%d] x[%d] y[%d] w[%d] h[%d]\n", mWindowRotationAngle, mWindowPositionSize.x, mWindowPositionSize.y, mWindowPositionSize.width, mWindowPositionSize.height);
+
+      ecore_wl2_window_geometry_set(mEcoreWindow, mWindowPositionSize.x, mWindowPositionSize.y, mWindowPositionSize.width, mWindowPositionSize.height);
+
+      Dali::PositionSize newPositionSize = RecalculatePositionSizeToCurrentOrientation(mWindowPositionSize);
+      DALI_LOG_RELEASE_INFO("emit signal to update window's position and size, x[%d] y[%d] w[%d] h[%d]\n", newPositionSize.x, newPositionSize.y, newPositionSize.width, newPositionSize.height);
       mUpdatePositionSizeSignal.Emit(newPositionSize);
     }
 
@@ -1370,21 +1331,6 @@ void WindowBaseEcoreWl2::OnFontSizeChanged()
   mStyleChangedSignal.Emit(StyleChange::DEFAULT_FONT_SIZE_CHANGE);
 }
 
-#ifdef DALI_ELDBUS_AVAILABLE
-void WindowBaseEcoreWl2::OnEcoreElDBusAccessibilityNotification(void* context, const Eldbus_Message* message)
-{
-  AccessibilityInfo info;
-
-  // The string defines the arg-list's respective types.
-  if(!eldbus_message_arguments_get(message, "iiiiiiu", &info.gestureValue, &info.startX, &info.startY, &info.endX, &info.endY, &info.state, &info.eventTime))
-  {
-    DALI_LOG_ERROR("OnEcoreElDBusAccessibilityNotification: Error getting arguments\n");
-  }
-
-  mAccessibilitySignal.Emit(info);
-}
-#endif // DALI_ELDBUS_AVAILABLE
-
 void WindowBaseEcoreWl2::OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type)
 {
   mTransitionEffectEventSignal.Emit(state, type);
@@ -1405,7 +1351,7 @@ void WindowBaseEcoreWl2::OnEcoreEventWindowAuxiliaryMessage(void* event)
   Ecore_Wl2_Event_Aux_Message* message = static_cast<Ecore_Wl2_Event_Aux_Message*>(event);
   if(message)
   {
-    DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::OnEcoreEventWindowAuxiliaryMessage, key:%s, value:%s \n", message->key, message->val);
+    DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnEcoreEventWindowAuxiliaryMessage, key:%s, value:%s \n", message->key, message->val);
     std::string           key(message->key);
     std::string           value(message->val);
     Dali::Property::Array options;
@@ -1416,7 +1362,7 @@ void WindowBaseEcoreWl2::OnEcoreEventWindowAuxiliaryMessage(void* event)
       void*      data;
       EINA_LIST_FOREACH(message->options, l, data)
       {
-        DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::OnEcoreEventWindowAuxiliaryMessage, option: %s\n", (char*)data);
+        DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnEcoreEventWindowAuxiliaryMessage, option: %s\n", (char*)data);
         std::string option(static_cast<char*>(data));
         options.Add(option);
       }
@@ -1530,6 +1476,15 @@ int WindowBaseEcoreWl2::GetNativeWindowId()
   return ecore_wl2_window_id_get(mEcoreWindow);
 }
 
+std::string WindowBaseEcoreWl2::GetNativeWindowResourceId()
+{
+#ifdef OVER_TIZEN_VERSION_7
+  return std::to_string(ecore_wl2_window_resource_id_get(mEcoreWindow));
+#else
+  return std::string();
+#endif
+}
+
 EGLNativeWindowType WindowBaseEcoreWl2::CreateEglWindow(int width, int height)
 {
   int totalAngle = (mWindowRotationAngle + mScreenRotationAngle) % 360;
@@ -1687,22 +1642,109 @@ bool WindowBaseEcoreWl2::IsEglWindowRotationSupported()
   return false;
 }
 
+PositionSize WindowBaseEcoreWl2::RecalculatePositionSizeToSystem(PositionSize positionSize)
+{
+  PositionSize newPositionSize;
+
+  if(mWindowRotationAngle == 90)
+  {
+    newPositionSize.x      = positionSize.y;
+    newPositionSize.y      = mScreenHeight - (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.width  = positionSize.width;
+    newPositionSize.height = positionSize.height;
+  }
+  else if(mWindowRotationAngle == 270)
+  {
+    newPositionSize.x      = mScreenWidth - (positionSize.y + positionSize.height);
+    newPositionSize.y      = positionSize.x;
+    newPositionSize.width  = positionSize.height;
+    newPositionSize.height = positionSize.width;
+  }
+  else
+  {
+    newPositionSize.x      = positionSize.x;
+    newPositionSize.y      = positionSize.y;
+    newPositionSize.width  = positionSize.width;
+    newPositionSize.height = positionSize.height;
+  }
+
+  DALI_LOG_RELEASE_INFO("input coord x[%d], y[%d], w{%d], h[%d], screen w[%d], h[%d]\n", positionSize.x, positionSize.y, positionSize.width, positionSize.height, mScreenWidth, mScreenHeight);
+  DALI_LOG_RELEASE_INFO("recalc coord x[%d], y[%d], w{%d], h[%d]\n", newPositionSize.x, newPositionSize.y, newPositionSize.width, newPositionSize.height);
+
+  return newPositionSize;
+}
+
+PositionSize WindowBaseEcoreWl2::RecalculatePositionSizeToCurrentOrientation(PositionSize positionSize)
+{
+  PositionSize newPositionSize;
+
+  if(mWindowRotationAngle == 90)
+  {
+    newPositionSize.x      = mScreenHeight - (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.width  = positionSize.width;
+    newPositionSize.height = positionSize.height;
+  }
+  else if(mWindowRotationAngle == 270)
+  {
+    newPositionSize.x      = positionSize.y;
+    newPositionSize.y      = mScreenWidth - (positionSize.x + positionSize.width);
+    newPositionSize.width  = positionSize.height;
+    newPositionSize.height = positionSize.width;
+  }
+  else
+  {
+    newPositionSize.x      = positionSize.x;
+    newPositionSize.y      = positionSize.y;
+    newPositionSize.width  = positionSize.width;
+    newPositionSize.height = positionSize.height;
+  }
+
+  DALI_LOG_RELEASE_INFO("input coord x[%d], y[%d], w{%d], h[%d], screen w[%d], h[%d]\n", positionSize.x, positionSize.y, positionSize.width, positionSize.height, mScreenWidth, mScreenHeight);
+  DALI_LOG_RELEASE_INFO("recalc by current orientation coord x[%d], y[%d], w{%d], h[%d]\n", newPositionSize.x, newPositionSize.y, newPositionSize.width, newPositionSize.height);
+
+  return newPositionSize;
+}
+
 void WindowBaseEcoreWl2::Move(PositionSize positionSize)
 {
-  mWindowPositionSize = positionSize;
-  ecore_wl2_window_position_set(mEcoreWindow, positionSize.x, positionSize.y);
+  PositionSize newPositionSize = RecalculatePositionSizeToSystem(positionSize);
+
+  mWindowPositionSize = newPositionSize;
+  DALI_LOG_RELEASE_INFO("ecore_wl2_window_position_set x[%d], y[%d]\n", newPositionSize.x, newPositionSize.y);
+  ecore_wl2_window_position_set(mEcoreWindow, newPositionSize.x, newPositionSize.y);
 }
 
 void WindowBaseEcoreWl2::Resize(PositionSize positionSize)
 {
-  mWindowPositionSize = positionSize;
-  ecore_wl2_window_geometry_set(mEcoreWindow, positionSize.x, positionSize.y, positionSize.width, positionSize.height);
+  PositionSize newPositionSize = RecalculatePositionSizeToSystem(positionSize);
+
+  mWindowPositionSize = newPositionSize;
+  DALI_LOG_RELEASE_INFO("ecore_wl2_window_sync_geometry_set, x[%d], y[%d], w{%d], h[%d]\n", newPositionSize.x, newPositionSize.y, newPositionSize.width, newPositionSize.height);
+  ecore_wl2_window_sync_geometry_set(mEcoreWindow, ++mMoveResizeSerial, newPositionSize.x, newPositionSize.y, newPositionSize.width, newPositionSize.height);
 }
 
 void WindowBaseEcoreWl2::MoveResize(PositionSize positionSize)
 {
-  mWindowPositionSize = positionSize;
-  ecore_wl2_window_sync_geometry_set(mEcoreWindow, ++mMoveResizeSerial, positionSize.x, positionSize.y, positionSize.width, positionSize.height);
+  PositionSize newPositionSize = RecalculatePositionSizeToSystem(positionSize);
+
+  mWindowPositionSize = newPositionSize;
+  DALI_LOG_RELEASE_INFO("ecore_wl2_window_sync_geometry_set, x[%d], y[%d], w{%d], h[%d]\n", newPositionSize.x, newPositionSize.y, newPositionSize.width, newPositionSize.height);
+  ecore_wl2_window_sync_geometry_set(mEcoreWindow, ++mMoveResizeSerial, newPositionSize.x, newPositionSize.y, newPositionSize.width, newPositionSize.height);
 }
 
 void WindowBaseEcoreWl2::SetClass(const std::string& name, const std::string& className)
@@ -1754,7 +1796,7 @@ void WindowBaseEcoreWl2::SetAvailableAnlges(const std::vector<int>& angles)
   for(std::size_t i = 0; i < angles.size(); ++i)
   {
     rotations[i] = static_cast<int>(angles[i]);
-    DALI_LOG_RELEASE_INFO("%d ", rotations[i]);
+    DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "%d ", rotations[i]);
   }
   ecore_wl2_window_available_rotations_set(mEcoreWindow, rotations, angles.size());
 }
@@ -1774,17 +1816,7 @@ void WindowBaseEcoreWl2::Show()
 {
   if(!mVisible)
   {
-    // Ecore-wl2 has the original window size
-    // and he always sends the window rotation event with the swapped size.
-    // So, to restore, dali should set the reswapped size(original window size) to ecore-wl2 for restoring.
-    if(mWindowRotationAngle == 0 || mWindowRotationAngle == 180)
-    {
-      ecore_wl2_window_geometry_set(mEcoreWindow, mWindowPositionSize.x, mWindowPositionSize.y, mWindowPositionSize.width, mWindowPositionSize.height);
-    }
-    else
-    {
-      ecore_wl2_window_geometry_set(mEcoreWindow, mWindowPositionSize.x, mWindowPositionSize.y, mWindowPositionSize.height, mWindowPositionSize.width);
-    }
+    ecore_wl2_window_geometry_set(mEcoreWindow, mWindowPositionSize.x, mWindowPositionSize.y, mWindowPositionSize.width, mWindowPositionSize.height);
   }
   mVisible = true;
 
@@ -2523,38 +2555,6 @@ void WindowBaseEcoreWl2::SetTransparency(bool transparent)
   ecore_wl2_window_alpha_set(mEcoreWindow, transparent);
 }
 
-void WindowBaseEcoreWl2::InitializeEcoreElDBus()
-{
-#ifdef DALI_ELDBUS_AVAILABLE
-  Eldbus_Object* object;
-  Eldbus_Proxy*  manager;
-
-  if(!(mSystemConnection = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SYSTEM)))
-  {
-    DALI_LOG_ERROR("Unable to get system bus\n");
-  }
-
-  object = eldbus_object_get(mSystemConnection, BUS, PATH);
-  if(!object)
-  {
-    DALI_LOG_ERROR("Getting object failed\n");
-    return;
-  }
-
-  manager = eldbus_proxy_get(object, INTERFACE);
-  if(!manager)
-  {
-    DALI_LOG_ERROR("Getting proxy failed\n");
-    return;
-  }
-
-  if(!eldbus_proxy_signal_handler_add(manager, "GestureDetected", EcoreElDBusAccessibilityNotification, this))
-  {
-    DALI_LOG_ERROR("No signal handler returned\n");
-  }
-#endif
-}
-
 void WindowBaseEcoreWl2::CreateWindow(PositionSize positionSize)
 {
   Ecore_Wl2_Display* display = ecore_wl2_display_connect(NULL);
@@ -2574,6 +2574,9 @@ 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)