Revert "[Tizen] Support Ecore-Wayland2"
[platform/core/uifw/dali-adaptor.git] / dali / internal / input / tizen-wayland / input-method-context-impl-ecore-wl.cpp
index 212c0c9..b4f71ea 100755 (executable)
 #include <dali/internal/input/tizen-wayland/input-method-context-impl-ecore-wl.h>
 
 // EXTERNAL INCLUDES
+#include <Ecore_IMF.h>
 #include <Ecore_Input.h>
-
-#ifdef ECORE_WAYLAND2
-#include <Ecore_Wl2.h>
-#else
-#include <Ecore_Wayland.h>
-#endif
-
 #include <dali/public-api/events/key-event.h>
 #include <dali/public-api/adaptor-framework/key.h>
 #include <dali/public-api/object/type-registry.h>
@@ -277,11 +271,15 @@ InputMethodContextPtr InputMethodContextEcoreWl::New()
     Adaptor &adaptorImpl(Adaptor::GetImplementation(Adaptor::Get()));
     Any nativeWindow = adaptorImpl.GetNativeWindowHandle();
 
-    // The window needs to use the InputMethodContext.
-    // Only when the render surface is window, we can get the window.
-    if( !nativeWindow.Empty() )
+    // The Ecore_Wl_Window needs to use the InputMethodContext.
+    // Only when the render surface is window, we can get the Ecore_Wl_Window.
+    Ecore_Wl_Window *ecoreWwin(AnyCast<Ecore_Wl_Window *>(nativeWindow));
+    if (ecoreWwin)
     {
-      inputMethodContext = new InputMethodContextEcoreWl();
+      // If we fail to get Ecore_Wl_Window, we can't use the InputMethodContext correctly.
+      // Thus you have to call "ecore_imf_context_client_window_set" somewhere.
+      // In EvasPlugIn, this function is called in EvasPlugin::ConnectEcoreEvent().
+      inputMethodContext = new InputMethodContextEcoreWl(ecoreWwin);
     }
     else
     {
@@ -299,8 +297,9 @@ void InputMethodContextEcoreWl::Finalize()
   DeleteContext();
 }
 
-InputMethodContextEcoreWl::InputMethodContextEcoreWl()
+InputMethodContextEcoreWl::InputMethodContextEcoreWl( Ecore_Wl_Window *ecoreWlwin )
 : mIMFContext(),
+  mEcoreWlwin( ecoreWlwin ),
   mIMFCursorPosition( 0 ),
   mSurroundingText(),
   mRestoreAfterFocusLost( false ),
@@ -317,11 +316,11 @@ InputMethodContextEcoreWl::~InputMethodContextEcoreWl()
 
 void InputMethodContextEcoreWl::Initialize()
 {
-  CreateContext();
+  CreateContext( mEcoreWlwin );
   ConnectCallbacks();
 }
 
-void InputMethodContextEcoreWl::CreateContext()
+void InputMethodContextEcoreWl::CreateContext( Ecore_Wl_Window *ecoreWlwin )
 {
   DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContext::CreateContext\n" );
 
@@ -332,22 +331,10 @@ void InputMethodContextEcoreWl::CreateContext()
 
     if( mIMFContext )
     {
-      // If we fail to get Ecore_Wl_Window, we can't use the InputMethodContext correctly.
-      // Thus you have to call "ecore_imf_context_client_window_set" somewhere.
-      // In EvasPlugIn, this function is called in EvasPlugin::ConnectEcoreEvent().
-      Adaptor& adaptorImpl( Adaptor::GetImplementation( Adaptor::Get() ) );
-      Any nativeWindow = adaptorImpl.GetNativeWindowHandle();
-
-#ifdef ECORE_WAYLAND2
-      Ecore_Wl2_Window* ecoreWlwin( AnyCast< Ecore_Wl2_Window* >( nativeWindow ) );
-      int windowId = ecore_wl2_window_id_get( ecoreWlwin );
-#else
-      Ecore_Wl_Window* ecoreWlwin( AnyCast< Ecore_Wl_Window* >( nativeWindow ) );
-      int windowId = ecore_wl_window_id_get( ecoreWlwin );
-#endif
       if( ecoreWlwin )
       {
-        ecore_imf_context_client_window_set( mIMFContext, reinterpret_cast< void* >( windowId ) );
+        ecore_imf_context_client_window_set( mIMFContext,
+        reinterpret_cast<void*>( ecore_wl_window_id_get(ecoreWlwin)) );
       }
     }
     else