[dali_2.3.34] Merge branch 'devel/master'
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / tizen-wayland / ecore-wl2 / window-base-ecore-wl2.cpp
index 9b63464..deb8ff6 100644 (file)
@@ -23,6 +23,7 @@
 #include <dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.h>
 
 // INTERNAL HEADERS
+#include <dali/internal/graphics/common/egl-include.h>
 #include <dali/internal/input/common/key-impl.h>
 #include <dali/internal/system/common/time-service.h>
 #include <dali/internal/window-system/common/window-impl.h>
@@ -229,16 +230,6 @@ void GetDeviceSubclass(Ecore_Device_Subclass ecoreDeviceSubclass, Device::Subcla
       deviceSubclass = Device::Subclass::VIRTUAL_KEYBOARD;
       break;
     }
-    case ECORE_DEVICE_SUBCLASS_VIRTUAL_REMOCON:
-    {
-      deviceSubclass = Device::Subclass::VIRTUAL_REMOCON;
-      break;
-    }
-    case ECORE_DEVICE_SUBCLASS_VIRTUAL_MOUSE:
-    {
-      deviceSubclass = Device::Subclass::VIRTUAL_MOUSE;
-      break;
-    }
     default:
     {
       deviceSubclass = Device::Subclass::NONE;
@@ -472,6 +463,19 @@ static Eina_Bool EcoreEventMouseButtonMove(void* data, int type, void* event)
 /**
  * Called when a touch motion is received.
  */
+static Eina_Bool EcoreEventMouseFrame(void* data, int type, void* event)
+{
+  WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
+  if(windowBase)
+  {
+    windowBase->OnMouseFrame(data, type, event);
+  }
+  return ECORE_CALLBACK_PASS_ON;
+}
+
+/**
+ * Called when a touch motion is received.
+ */
 static Eina_Bool EcoreEventMouseButtonRelativeMove(void* data, int type, void* event)
 {
   WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
@@ -990,7 +994,7 @@ void WindowBaseEcoreWl2::Initialize(PositionSize positionSize, Any surface, bool
   {
     // we own the surface about to created
     mOwnSurface = true;
-    CreateWindow(positionSize);
+    CreateInternalWindow(positionSize);
   }
 
   mWlSurface = ecore_wl2_window_surface_get(mEcoreWindow);
@@ -1029,6 +1033,9 @@ void WindowBaseEcoreWl2::Initialize(PositionSize positionSize, Any surface, bool
 
   // Register pointer lock/unlock event
   mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_POINTER_CONSTRAINTS, EcoreEventPointerConstraints, this));
+
+  // Register mouse frame events
+  mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_FRAME, EcoreEventMouseFrame, this));
 #endif
 
   // Register Mouse wheel events
@@ -1323,6 +1330,10 @@ void WindowBaseEcoreWl2::OnMouseButtonDown(void* data, int type, void* event)
     point.SetMouseButton(static_cast<MouseButton::Type>(touchEvent->buttons));
 
     mTouchEventSignal.Emit(point, touchEvent->timestamp);
+
+#ifndef OVER_TIZEN_VERSION_8
+    mMouseFrameEventSignal.Emit();
+#endif
   }
 }
 
@@ -1352,6 +1363,10 @@ void WindowBaseEcoreWl2::OnMouseButtonUp(void* data, int type, void* event)
     point.SetMouseButton(static_cast<MouseButton::Type>(touchEvent->buttons));
 
     mTouchEventSignal.Emit(point, touchEvent->timestamp);
+
+#ifndef OVER_TIZEN_VERSION_8
+    mMouseFrameEventSignal.Emit();
+#endif
   }
 }
 
@@ -1380,10 +1395,25 @@ void WindowBaseEcoreWl2::OnMouseButtonMove(void* data, int type, void* event)
     point.SetDeviceSubclass(deviceSubclass);
 
     mTouchEventSignal.Emit(point, touchEvent->timestamp);
+
+#ifndef OVER_TIZEN_VERSION_8
+    mMouseFrameEventSignal.Emit();
+#endif
   }
 }
 
 #ifdef OVER_TIZEN_VERSION_8
+void WindowBaseEcoreWl2::OnMouseFrame(void* data, int type, void* event)
+{
+  Ecore_Event_Mouse_Frame* MouseFrameEvent = static_cast<Ecore_Event_Mouse_Frame*>(event);
+
+  if(MouseFrameEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)) && Dali::Adaptor::IsAvailable())
+  {
+    DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_FRAME");
+    mMouseFrameEventSignal.Emit();
+  }
+}
+
 void WindowBaseEcoreWl2::OnMouseButtonRelativeMove(void* data, int type, void* event)
 {
   Ecore_Event_Mouse_Relative_Move* relativeMoveEvent = static_cast<Ecore_Event_Mouse_Relative_Move*>(event);
@@ -1431,6 +1461,10 @@ void WindowBaseEcoreWl2::OnMouseButtonCancel(void* data, int type, void* event)
 
     mTouchEventSignal.Emit(point, touchEvent->timestamp);
 
+#ifndef OVER_TIZEN_VERSION_8
+    mMouseFrameEventSignal.Emit();
+#endif
+
     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnMouseButtonCancel\n");
   }
 }
@@ -1989,8 +2023,9 @@ void WindowBaseEcoreWl2::TizenPolicyConformantArea(void* data, struct tizen_poli
   {
     Ecore_Wl2_Event_Conformant_Change* ev = static_cast<Ecore_Wl2_Event_Conformant_Change*>(calloc(1, sizeof(Ecore_Wl2_Event_Conformant_Change)));
 
-    if(!ev)
+    if(DALI_UNLIKELY(!ev))
     {
+      DALI_LOG_ERROR("Failed to allocate Ecore_Wl2_Event_Conformant_Change. calloc size : %zu\n", sizeof(Ecore_Wl2_Event_Conformant_Change));
       return;
     }
     ev->win       = GetNativeWindowId();
@@ -2066,7 +2101,7 @@ std::string WindowBaseEcoreWl2::GetNativeWindowResourceId()
 #endif
 }
 
-EGLNativeWindowType WindowBaseEcoreWl2::CreateEglWindow(int width, int height)
+Dali::Any WindowBaseEcoreWl2::CreateWindow(int width, int height)
 {
   int totalAngle = (mWindowRotationAngle + mScreenRotationAngle) % 360;
 
@@ -2081,10 +2116,10 @@ EGLNativeWindowType WindowBaseEcoreWl2::CreateEglWindow(int width, int height)
   }
   FINISH_DURATION_CHECK("wl_egl_window_create");
 
-  return static_cast<EGLNativeWindowType>(mEglWindow);
+  return static_cast<void*>(mEglWindow);
 }
 
-void WindowBaseEcoreWl2::DestroyEglWindow()
+void WindowBaseEcoreWl2::DestroyWindow()
 {
   if(mEglWindow != NULL)
   {
@@ -2096,7 +2131,7 @@ void WindowBaseEcoreWl2::DestroyEglWindow()
   }
 }
 
-void WindowBaseEcoreWl2::SetEglWindowRotation(int angle)
+void WindowBaseEcoreWl2::SetWindowRotation(int angle)
 {
   wl_egl_window_tizen_rotation rotation;
 
@@ -2134,7 +2169,7 @@ void WindowBaseEcoreWl2::SetEglWindowRotation(int angle)
   FINISH_DURATION_CHECK("wl_egl_window_tizen_set_rotation");
 }
 
-void WindowBaseEcoreWl2::SetEglWindowBufferTransform(int angle)
+void WindowBaseEcoreWl2::SetWindowBufferTransform(int angle)
 {
   wl_output_transform bufferTransform;
 
@@ -2173,7 +2208,7 @@ void WindowBaseEcoreWl2::SetEglWindowBufferTransform(int angle)
   FINISH_DURATION_CHECK("wl_egl_window_tizen_set_buffer_transform");
 }
 
-void WindowBaseEcoreWl2::SetEglWindowTransform(int angle)
+void WindowBaseEcoreWl2::SetWindowTransform(int angle)
 {
   wl_output_transform windowTransform;
 
@@ -2212,7 +2247,7 @@ void WindowBaseEcoreWl2::SetEglWindowTransform(int angle)
   FINISH_DURATION_CHECK("wl_egl_window_tizen_set_window_transform");
 }
 
-void WindowBaseEcoreWl2::ResizeEglWindow(PositionSize positionSize)
+void WindowBaseEcoreWl2::ResizeWindow(PositionSize positionSize)
 {
   DALI_LOG_RELEASE_INFO("wl_egl_window_resize(), (%d, %d) [%d x %d]\n", positionSize.x, positionSize.y, positionSize.width, positionSize.height);
   START_DURATION_CHECK();
@@ -2227,7 +2262,7 @@ void WindowBaseEcoreWl2::ResizeEglWindow(PositionSize positionSize)
   FINISH_DURATION_CHECK("wl_egl_window functions");
 }
 
-bool WindowBaseEcoreWl2::IsEglWindowRotationSupported()
+bool WindowBaseEcoreWl2::IsWindowRotationSupported()
 {
   START_DURATION_CHECK();
   // Check capability
@@ -3260,7 +3295,7 @@ void WindowBaseEcoreWl2::SetTransparency(bool transparent)
   FINISH_DURATION_CHECK("ecore_wl2_window_alpha_set");
 }
 
-void WindowBaseEcoreWl2::CreateWindow(PositionSize positionSize)
+void WindowBaseEcoreWl2::CreateInternalWindow(PositionSize positionSize)
 {
   Ecore_Wl2_Display* display = ecore_wl2_display_connect(NULL);
   if(!display)
@@ -3630,11 +3665,41 @@ bool WindowBaseEcoreWl2::GetFrontBufferRendering()
   return mIsFrontBufferRendering;
 }
 
-void WindowBaseEcoreWl2::SetEglWindowFrontBufferMode(bool enable)
+void WindowBaseEcoreWl2::SetWindowFrontBufferMode(bool enable)
 {
   wl_egl_window_tizen_set_frontbuffer_mode(mEglWindow, enable);
 }
 
+void WindowBaseEcoreWl2::SetModal(bool modal)
+{
+  DALI_LOG_RELEASE_INFO("ecore_wl2_window_modal_set, window: [%p], flag [%d]\n", mEcoreWindow, modal);
+  START_DURATION_CHECK();
+  ecore_wl2_window_modal_set(mEcoreWindow, modal);
+  FINISH_DURATION_CHECK("ecore_wl2_window_modal_set");
+}
+
+bool WindowBaseEcoreWl2::IsModal()
+{
+  bool ret = ecore_wl2_window_modal_get(mEcoreWindow);
+  DALI_LOG_RELEASE_INFO("ecore_wl2_window_modal_get, window: [%p], flag [%d]\n", mEcoreWindow, ret);
+  return ret;
+}
+
+void WindowBaseEcoreWl2::SetAlwaysOnTop(bool alwaysOnTop)
+{
+  DALI_LOG_RELEASE_INFO("ecore_wl2_window_pin_mode_set, window: [%p], flag [%d]\n", mEcoreWindow, alwaysOnTop);
+  START_DURATION_CHECK();
+  ecore_wl2_window_pin_mode_set(mEcoreWindow, alwaysOnTop);
+  FINISH_DURATION_CHECK("ecore_wl2_window_pin_mode_set");
+}
+
+bool WindowBaseEcoreWl2::IsAlwaysOnTop()
+{
+  bool ret = ecore_wl2_window_pin_mode_get(mEcoreWindow);
+  DALI_LOG_RELEASE_INFO("ecore_wl2_window_pin_mode_get, window: [%p], flag [%d]\n", mEcoreWindow, ret);
+  return ret;
+}
+
 } // namespace Adaptor
 
 } // namespace Internal