Fix to get the full input text in RetrieveSurrounding 65/151865/3
authorSeoyeon Kim <seoyeon2.kim@samsung.com>
Fri, 22 Sep 2017 07:44:20 +0000 (16:44 +0900)
committerSeoyeon Kim <seoyeon2.kim@samsung.com>
Fri, 13 Oct 2017 06:27:27 +0000 (15:27 +0900)
- When an IMF retrieve surround event is received,
 DALi should send the current full text to IME.

Change-Id: Ie00c3de120fd80a54c085ee6bfc138545c938175
Signed-off-by: Seoyeon Kim <seoyeon2.kim@samsung.com>
adaptors/ecore/wayland/imf-manager-impl-ecore-wl.cpp
adaptors/x11/imf-manager-impl-x.cpp

index f171016..d476e29 100644 (file)
@@ -589,16 +589,21 @@ Eina_Bool ImfManager::RetrieveSurrounding( void* data, Ecore_IMF_Context* imfCon
 
   Dali::ImfManager::ImfEventData imfData( Dali::ImfManager::GETSURROUNDING, std::string(), 0, 0 );
   Dali::ImfManager handle( this );
-  mEventSignal.Emit( handle, imfData );
+  Dali::ImfManager::ImfCallbackData callbackData = mEventSignal.Emit( handle, imfData );
 
-  if( text )
+  if( callbackData.update )
   {
-    *text = strdup( mSurroundingText.c_str() );
-  }
+    if( text )
+    {
+      // The memory allocated by strdup() can be freed by ecore_imf_context_surrounding_get() internally.
+      *text = strdup( callbackData.currentText.c_str() );
+    }
 
-  if( cursorPosition )
-  {
-    *cursorPosition = mIMFCursorPosition;
+    if( cursorPosition )
+    {
+      mIMFCursorPosition = static_cast<int>( callbackData.cursorPosition );
+      *cursorPosition = mIMFCursorPosition;
+    }
   }
 
   return EINA_TRUE;
index 6d9d2a2..ee60d59 100644 (file)
@@ -445,6 +445,7 @@ Eina_Bool ImfManager::RetrieveSurrounding( void* data, Ecore_IMF_Context* imfCon
   {
     if( text )
     {
+      // The memory allocated by strdup() can be freed by ecore_imf_context_surrounding_get() internally.
       *text = strdup( callbackData.currentText.c_str() );
     }