Revert "[Tizen] Change to latest wayland inputmethod protocol"
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / tizen-wayland / ecore-wl2 / window-base-ecore-wl2.cpp
index 6e72f90..ccea97c 100644 (file)
@@ -55,10 +55,12 @@ 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
 {
@@ -578,6 +580,19 @@ static Eina_Bool EcoreEventWindowRedrawRequest(void* data, int type, void* event
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////////////
+// Window Auxiliary Message Callbacks
+/////////////////////////////////////////////////////////////////////////////////////////////////
+static Eina_Bool EcoreEventWindowAuxiliaryMessage(void *data, int type, void *event)
+{
+  WindowBaseEcoreWl2*          windowBase             = static_cast<WindowBaseEcoreWl2*>(data);
+  if(windowBase)
+  {
+    windowBase->OnEcoreEventWindowAuxiliaryMessage(event);
+  }
+  return ECORE_CALLBACK_RENEW;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////////////
 // ElDBus Accessibility Callbacks
 /////////////////////////////////////////////////////////////////////////////////////////////////
 
@@ -840,6 +855,9 @@ void WindowBaseEcoreWl2::Initialize(PositionSize positionSize, Any surface, bool
   // Register Window redraw request event
   mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_REDRAW_REQUEST, EcoreEventWindowRedrawRequest, this));
 
+  // Register Window auxiliary event
+  mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_AUX_MESSAGE, EcoreEventWindowAuxiliaryMessage, this));
+
   // Register Vconf notify - font name and size
   vconf_notify_key_changed(DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged, this);
   vconf_notify_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged, this);
@@ -847,7 +865,7 @@ void WindowBaseEcoreWl2::Initialize(PositionSize positionSize, Any surface, bool
   InitializeEcoreElDBus();
 
   Ecore_Wl2_Display* display = ecore_wl2_connected_display_get(NULL);
-  mDisplay = ecore_wl2_display_get(display);
+  mDisplay                   = ecore_wl2_display_get(display);
 
   if(mDisplay)
   {
@@ -985,7 +1003,7 @@ void WindowBaseEcoreWl2::OnRotation(void* data, int type, void* event)
     rotationEvent.angle     = ev->angle;
     rotationEvent.winResize = 0;
 
-    if(ev->w == 0 || ev->h ==0)
+    if(ev->w == 0 || ev->h == 0)
     {
       // Use previous client side window's size.
       if(mWindowRotationAngle == 90 || mWindowRotationAngle == 270)
@@ -1000,7 +1018,7 @@ void WindowBaseEcoreWl2::OnRotation(void* data, int type, void* event)
       }
     }
 
-    mWindowRotationAngle    = ev->angle;
+    mWindowRotationAngle = ev->angle;
 
     if(ev->angle == 0 || ev->angle == 180)
     {
@@ -1353,9 +1371,9 @@ void WindowBaseEcoreWl2::OnFontSizeChanged()
   mStyleChangedSignal.Emit(StyleChange::DEFAULT_FONT_SIZE_CHANGE);
 }
 
+#ifdef DALI_ELDBUS_AVAILABLE
 void WindowBaseEcoreWl2::OnEcoreElDBusAccessibilityNotification(void* context, const Eldbus_Message* message)
 {
-#ifdef DALI_ELDBUS_AVAILABLE
   AccessibilityInfo info;
 
   // The string defines the arg-list's respective types.
@@ -1365,8 +1383,8 @@ void WindowBaseEcoreWl2::OnEcoreElDBusAccessibilityNotification(void* context, c
   }
 
   mAccessibilitySignal.Emit(info);
-#endif
 }
+#endif // DALI_ELDBUS_AVAILABLE
 
 void WindowBaseEcoreWl2::OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type)
 {
@@ -1383,6 +1401,33 @@ void WindowBaseEcoreWl2::OnEcoreEventWindowRedrawRequest()
   mWindowRedrawRequestSignal.Emit();
 }
 
+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);
+   std::string key(message->key);
+   std::string value(message->val);
+   Dali::Property::Array options;
+
+   if(message->options)
+   {
+     Eina_List *l;
+     void* data;
+     EINA_LIST_FOREACH(message->options, l, data)
+     {
+       DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::OnEcoreEventWindowAuxiliaryMessage, option: %s\n",(char*)data);
+       std::string option(static_cast<char*>(data));
+       options.Add(option);
+     }
+   }
+
+   mAuxiliaryMessageSignal.Emit(key, value, options);
+ }
+}
+
+
 void WindowBaseEcoreWl2::KeymapChanged(void* data, int type, void* event)
 {
   Ecore_Wl2_Event_Seat_Keymap_Changed* changed = static_cast<Ecore_Wl2_Event_Seat_Keymap_Changed*>(event);
@@ -2513,7 +2558,7 @@ void WindowBaseEcoreWl2::CreateWindow(PositionSize positionSize)
   ecore_wl2_window_type_set(mEcoreWindow, ECORE_WL2_WINDOW_TYPE_TOPLEVEL);
 }
 
-void WindowBaseEcoreWl2::SetParent(WindowBase* parentWinBase)
+void WindowBaseEcoreWl2::SetParent(WindowBase* parentWinBase, bool belowParent)
 {
   Ecore_Wl2_Window* ecoreParent = NULL;
   if(parentWinBase)
@@ -2521,7 +2566,7 @@ void WindowBaseEcoreWl2::SetParent(WindowBase* parentWinBase)
     WindowBaseEcoreWl2* winBaseEcore2 = static_cast<WindowBaseEcoreWl2*>(parentWinBase);
     ecoreParent                       = winBaseEcore2->mEcoreWindow;
   }
-  ecore_wl2_window_parent_set(mEcoreWindow, ecoreParent);
+  ecore_wl2_window_transient_parent_set(mEcoreWindow, ecoreParent, belowParent);
 }
 
 int WindowBaseEcoreWl2::CreateFrameRenderedSyncFence()
@@ -2612,6 +2657,138 @@ void WindowBaseEcoreWl2::ImeWindowReadyToRender()
   wl_input_panel_surface_set_ready(mWlInputPanelSurface, 1);
 }
 
+void WindowBaseEcoreWl2::RequestMoveToServer()
+{
+  Ecore_Wl2_Display* display = ecore_wl2_connected_display_get(NULL);
+  if(!display)
+  {
+    DALI_LOG_ERROR("WindowBaseEcoreWl2::RequestMoveToServer, Fail to get ecore_wl2_display\n");
+    return;
+  }
+
+  Ecore_Wl2_Input* input = ecore_wl2_input_default_input_get(display);
+  if(!input)
+  {
+    DALI_LOG_ERROR("WindowBaseEcoreWl2::RequestMoveToServer, Fail to get default Ecore_Wl2_Input\n");
+    return;
+  }
+
+  ecore_wl2_window_move(mEcoreWindow, input);
+  DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::RequestMoveToServer, starts the window[%p] is moved by server\n", mEcoreWindow);
+}
+
+void WindowBaseEcoreWl2::RequestResizeToServer(WindowResizeDirection direction)
+{
+  Ecore_Wl2_Display* display = ecore_wl2_connected_display_get(NULL);
+  if(!display)
+  {
+    DALI_LOG_ERROR("WindowBaseEcoreWl2::RequestResizeToServer, Fail to get ecore_wl2_display\n");
+    return;
+  }
+
+  Ecore_Wl2_Input* input = ecore_wl2_input_default_input_get(display);
+  if(!input)
+  {
+    DALI_LOG_ERROR("WindowBaseEcoreWl2::RequestResizeToServer, Fail to get default Ecore_Wl2_Input\n");
+    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;
+    }
+  }
+
+  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);
+}
+
+void WindowBaseEcoreWl2::EnableFloatingMode(bool enable)
+{
+  DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::EnableFloatingMode, floating mode flag: [%p], enable [%d]\n", mEcoreWindow, enable);
+  if(enable == true)
+  {
+    ecore_wl2_window_floating_mode_set(mEcoreWindow, EINA_TRUE);
+  }
+  else
+  {
+    ecore_wl2_window_floating_mode_set(mEcoreWindow, EINA_FALSE);
+  }
+}
+
+bool WindowBaseEcoreWl2::IsFloatingModeEnabled() const
+{
+  return ecore_wl2_window_floating_mode_get(mEcoreWindow);
+}
+
+void WindowBaseEcoreWl2::IncludeInputRegion(const Rect<int>& inputRegion)
+{
+  Eina_Rectangle rect;
+  rect.x = inputRegion.x;
+  rect.y = inputRegion.y;
+  rect.w = inputRegion.width;
+  rect.h = inputRegion.height;
+
+  ecore_wl2_window_input_rect_add(mEcoreWindow, &rect);
+  ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
+}
+
+void WindowBaseEcoreWl2::ExcludeInputRegion(const Rect<int>& inputRegion)
+{
+  Eina_Rectangle rect;
+  rect.x = inputRegion.x;
+  rect.y = inputRegion.y;
+  rect.w = inputRegion.width;
+  rect.h = inputRegion.height;
+
+  ecore_wl2_window_input_rect_subtract(mEcoreWindow, &rect);
+  ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
+}
+
 } // namespace Adaptor
 
 } // namespace Internal