Revert "[Tizen] Revert "Support multiple window rendering""
[platform/core/uifw/dali-adaptor.git] / dali / internal / input / tizen-wayland / input-method-context-impl-ecore-wl.cpp
index 212c0c9..34255a5 100755 (executable)
 // EXTERNAL INCLUDES
 #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>
 // INTERNAL INCLUDES
 #include <dali/integration-api/adaptor.h>
 #include <dali/internal/system/common/locale-utils.h>
-#include <dali/internal/adaptor/common/adaptor-impl.h>
 #include <dali/internal/system/common/singleton-service-impl.h>
 #include <dali/public-api/adaptor-framework/input-method.h>
 #include <dali/internal/input/common/key-impl.h>
+#include <dali/internal/window-system/common/window-render-surface.h>
 
 #define TOKEN_STRING(x) #x
 
@@ -271,11 +265,11 @@ Dali::TypeRegistration type( typeid(Dali::InputMethodContext), typeid(Dali::Base
 InputMethodContextPtr InputMethodContextEcoreWl::New()
 {
   InputMethodContextPtr inputMethodContext;
-  if ( Adaptor::IsAvailable() )
+
+  // Create instance only if the adaptor is available
+  if ( Dali::Adaptor::IsAvailable() )
   {
-    // Create instance only if the adaptor is available
-    Adaptor &adaptorImpl(Adaptor::GetImplementation(Adaptor::Get()));
-    Any nativeWindow = adaptorImpl.GetNativeWindowHandle();
+    Any nativeWindow = Dali::Adaptor::Get().GetNativeWindowHandle();
 
     // The window needs to use the InputMethodContext.
     // Only when the render surface is window, we can get the window.
@@ -332,20 +326,14 @@ void InputMethodContextEcoreWl::CreateContext()
 
     if( mIMFContext )
     {
-      // If we fail to get Ecore_Wl_Window, we can't use the InputMethodContext correctly.
+      // If we fail to get window id, 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 )
+      Dali::RenderSurfaceInterface& renderSurface = Dali::Adaptor::Get().GetSurface();
+      WindowRenderSurface& windowRenderSurface = static_cast< WindowRenderSurface& >( renderSurface );
+
+      int windowId = windowRenderSurface.GetNativeWindowId();
+      if( windowId != 0 )
       {
         ecore_imf_context_client_window_set( mIMFContext, reinterpret_cast< void* >( windowId ) );
       }
@@ -932,21 +920,48 @@ bool InputMethodContextEcoreWl::FilterEventKey( const Dali::KeyEvent& keyEvent )
   return eventHandled;
 }
 
+void InputMethodContextEcoreWl::AllowTextPrediction( bool prediction )
+{
+  DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextEcoreWl::AllowTextPrediction\n" );
+
+  if( mIMFContext )
+  {
+    ecore_imf_context_prediction_allow_set( mIMFContext, prediction );
+  }
+}
+
+bool InputMethodContextEcoreWl::IsTextPredictionAllowed() const
+{
+  DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextEcoreWl::IsTextPredictionAllowed\n" );
+  bool prediction = false;
+  if( mIMFContext )
+  {
+    prediction = ecore_imf_context_prediction_allow_get( mIMFContext );
+  }
+  return prediction;
+}
+
 bool InputMethodContextEcoreWl::ProcessEventKeyDown( const KeyEvent& keyEvent )
 {
   bool eventHandled( false );
   if ( mIMFContext )
   {
+    Integration::KeyEvent integKeyEvent( keyEvent );
+    std::string key = integKeyEvent.logicalKey;
+
+    std::string compose = keyEvent.GetCompose();
+    std::string deviceName = keyEvent.GetDeviceName();
+
     // We're consuming key down event so we have to pass to InputMethodContext so that it can parse it as well.
     Ecore_IMF_Event_Key_Down ecoreKeyDownEvent;
     ecoreKeyDownEvent.keyname = keyEvent.keyPressedName.c_str();
-    ecoreKeyDownEvent.key = keyEvent.keyPressedName.c_str();
+    ecoreKeyDownEvent.key = key.c_str();
     ecoreKeyDownEvent.string = keyEvent.keyPressed.c_str();
-    ecoreKeyDownEvent.compose = keyEvent.GetCompose().c_str();
+    ecoreKeyDownEvent.compose = compose.c_str();
     ecoreKeyDownEvent.timestamp = keyEvent.time;
     ecoreKeyDownEvent.modifiers = EcoreInputModifierToEcoreIMFModifier( keyEvent.keyModifier );
     ecoreKeyDownEvent.locks = EcoreInputModifierToEcoreIMFLock( keyEvent.keyModifier );
-    ecoreKeyDownEvent.dev_name = keyEvent.GetDeviceName().c_str();
+    ecoreKeyDownEvent.dev_name = deviceName.c_str();
     ecoreKeyDownEvent.dev_class = static_cast<Ecore_IMF_Device_Class> ( keyEvent.GetDeviceClass() );//ECORE_IMF_DEVICE_CLASS_KEYBOARD;
     ecoreKeyDownEvent.dev_subclass = static_cast<Ecore_IMF_Device_Subclass> ( keyEvent.GetDeviceSubclass() );//ECORE_IMF_DEVICE_SUBCLASS_NONE;
 
@@ -984,16 +999,22 @@ bool InputMethodContextEcoreWl::ProcessEventKeyUp( const KeyEvent& keyEvent )
   bool eventHandled( false );
   if( mIMFContext )
   {
+    Integration::KeyEvent integKeyEvent( keyEvent );
+    std::string key = integKeyEvent.logicalKey;
+
+    std::string compose = keyEvent.GetCompose();
+    std::string deviceName = keyEvent.GetDeviceName();
+
     // We're consuming key up event so we have to pass to InputMethodContext so that it can parse it as well.
     Ecore_IMF_Event_Key_Up ecoreKeyUpEvent;
     ecoreKeyUpEvent.keyname = keyEvent.keyPressedName.c_str();
-    ecoreKeyUpEvent.key = keyEvent.keyPressedName.c_str();
+    ecoreKeyUpEvent.key = key.c_str();
     ecoreKeyUpEvent.string = keyEvent.keyPressed.c_str();
-    ecoreKeyUpEvent.compose = keyEvent.GetCompose().c_str();
+    ecoreKeyUpEvent.compose = compose.c_str();
     ecoreKeyUpEvent.timestamp = keyEvent.time;
     ecoreKeyUpEvent.modifiers =  EcoreInputModifierToEcoreIMFModifier( keyEvent.keyModifier );
     ecoreKeyUpEvent.locks = EcoreInputModifierToEcoreIMFLock( keyEvent.keyModifier );
-    ecoreKeyUpEvent.dev_name = keyEvent.GetDeviceName().c_str();
+    ecoreKeyUpEvent.dev_name = deviceName.c_str();
     ecoreKeyUpEvent.dev_class = static_cast<Ecore_IMF_Device_Class> ( keyEvent.GetDeviceClass() );//ECORE_IMF_DEVICE_CLASS_KEYBOARD;
     ecoreKeyUpEvent.dev_subclass = static_cast<Ecore_IMF_Device_Subclass> ( keyEvent.GetDeviceSubclass() );//ECORE_IMF_DEVICE_SUBCLASS_NONE;