Backup the InputMethodContext operations 23/216523/6
authorJiyun Yang <ji.yang@samsung.com>
Mon, 28 Oct 2019 02:20:46 +0000 (11:20 +0900)
committerJiyun Yang <ji.yang@samsung.com>
Mon, 4 Nov 2019 02:42:58 +0000 (11:42 +0900)
Backup the InputMethodContext operations such as "SetInputPanelLanguage", "AutoEnableInputPanel" and etc.

Previously, we had two problems
1. InputMethodContext ignores the options set before the actor is on a Window.
2. InputMethodContext resets its options after the actor changes its Window.

By storing operations when they are called and reapplying them after the actor is connected to Window,
the InputMethodContext can keep the options regardless of Window.

Change-Id: I5a607619a06de88d1c5202aa2d82f5fafc455c70
Signed-off-by: Jiyun Yang <ji.yang@samsung.com>
dali/internal/input/common/input-method-context-impl.cpp
dali/internal/input/common/input-method-context-impl.h
dali/internal/input/tizen-wayland/input-method-context-impl-ecore-wl.cpp

index d145b30..566027e 100755 (executable)
@@ -39,6 +39,25 @@ const std::string& InputMethodContext::GetSurroundingText() const
   return str;
 }
 
+InputMethodContext::InputMethodContext()
+: mBackupOperations( Operation::MAX_COUNT )
+{
+}
+
+void InputMethodContext::ApplyBackupOperations()
+{
+  // Items in mBackupOperations will be changed while the iteration
+  OperationList copiedList = mBackupOperations;
+
+  for( auto& operation : copiedList )
+  {
+    if( operation )
+    {
+      operation();
+    }
+  }
+}
+
 }
 }
 }
index e16cc44..dd1db18 100755 (executable)
@@ -320,7 +320,7 @@ public:
   /**
    * Constructor
    */
-  InputMethodContext() = default;
+  InputMethodContext();
 
   /**
    * Destructor
@@ -333,6 +333,33 @@ private:
   InputMethodContext& operator=( InputMethodContext& )  = delete;
 
 protected:
+  /**
+   * @brief Struct for providing Operation enumeration
+   */
+  struct Operation
+  {
+    enum Type
+    {
+      ALLOW_TEXT_PREDICTION = 0,
+      AUTO_ENABLE_INPUT_PANEL,
+      NOTIFY_TEXT_INPUT_MULTILINE,
+      SET_CONTENT_MIME_TYPES,
+      SET_INPUT_PANEL_DATA,
+      SET_INPUT_PANEL_LANGUAGE,
+      SET_INPUT_PANEL_POSITION,
+      SET_RETURN_KEY_STATE,
+      MAX_COUNT
+    };
+  };
+
+  using OperationList = std::vector< std::function<void()> >;
+
+  /**
+   * @brief Apply backup operations to the InputMethodContext
+   */
+  void ApplyBackupOperations();
+
+protected:
 
   ActivatedSignalType        mActivatedSignal;
   KeyboardEventSignalType    mEventSignal;
@@ -341,6 +368,7 @@ protected:
   LanguageChangedSignalType  mKeyboardLanguageChangedSignal;
   KeyboardTypeSignalType     mKeyboardTypeChangedSignal;
   ContentReceivedSignalType  mContentReceivedSignal;
+  OperationList              mBackupOperations;
 
 public:
 
index f68c9b8..7a9d4ae 100755 (executable)
@@ -342,6 +342,7 @@ void InputMethodContextEcoreWl::Initialize()
 {
   CreateContext();
   ConnectCallbacks();
+  ApplyBackupOperations();
 }
 
 void InputMethodContextEcoreWl::CreateContext()
@@ -767,6 +768,8 @@ void InputMethodContextEcoreWl::NotifyTextInputMultiLine( bool multiLine )
                                         (currentHint | ECORE_IMF_INPUT_HINT_MULTILINE) :
                                         (currentHint & ~ECORE_IMF_INPUT_HINT_MULTILINE)));
   }
+
+  mBackupOperations[Operation::NOTIFY_TEXT_INPUT_MULTILINE] = std::bind( &InputMethodContextEcoreWl::NotifyTextInputMultiLine, this, multiLine );
 }
 
 Dali::InputMethodContext::TextDirection InputMethodContextEcoreWl::GetTextDirection()
@@ -856,6 +859,8 @@ void InputMethodContextEcoreWl::SetInputPanelData( const std::string& data )
     int length = data.length();
     ecore_imf_context_input_panel_imdata_set( mIMFContext, data.c_str(), length );
   }
+
+  mBackupOperations[Operation::SET_INPUT_PANEL_DATA] = std::bind( &InputMethodContextEcoreWl::SetInputPanelData, this, data );
 }
 
 void InputMethodContextEcoreWl::GetInputPanelData( std::string& data )
@@ -918,6 +923,8 @@ void InputMethodContextEcoreWl::SetReturnKeyState( bool visible )
   {
     ecore_imf_context_input_panel_return_key_disabled_set( mIMFContext, !visible );
   }
+
+  mBackupOperations[Operation::SET_RETURN_KEY_STATE] = std::bind( &InputMethodContextEcoreWl::SetReturnKeyState, this, visible );
 }
 
 void InputMethodContextEcoreWl::AutoEnableInputPanel( bool enabled )
@@ -928,6 +935,8 @@ void InputMethodContextEcoreWl::AutoEnableInputPanel( bool enabled )
   {
     ecore_imf_context_input_panel_enabled_set( mIMFContext, enabled );
   }
+
+  mBackupOperations[Operation::AUTO_ENABLE_INPUT_PANEL] = std::bind( &InputMethodContextEcoreWl::AutoEnableInputPanel, this, enabled );
 }
 
 void InputMethodContextEcoreWl::ShowInputPanel()
@@ -1008,6 +1017,8 @@ void InputMethodContextEcoreWl::SetContentMIMETypes( const std::string& mimeType
   {
     ecore_imf_context_mime_type_accept_set( mIMFContext, mimeTypes.c_str() );
   }
+
+  mBackupOperations[Operation::SET_CONTENT_MIME_TYPES] = std::bind( &InputMethodContextEcoreWl::SetContentMIMETypes, this, mimeTypes );
 }
 
 bool InputMethodContextEcoreWl::FilterEventKey( const Dali::KeyEvent& keyEvent )
@@ -1039,6 +1050,8 @@ void InputMethodContextEcoreWl::AllowTextPrediction( bool prediction )
   {
     ecore_imf_context_prediction_allow_set( mIMFContext, prediction );
   }
+
+  mBackupOperations[Operation::ALLOW_TEXT_PREDICTION] = std::bind( &InputMethodContextEcoreWl::AllowTextPrediction, this, prediction );
 }
 
 bool InputMethodContextEcoreWl::IsTextPredictionAllowed() const
@@ -1071,6 +1084,8 @@ void InputMethodContextEcoreWl::SetInputPanelLanguage( Dali::InputMethodContext:
       }
     }
   }
+
+  mBackupOperations[Operation::SET_INPUT_PANEL_LANGUAGE] = std::bind( &InputMethodContextEcoreWl::SetInputPanelLanguage, this, language );
 }
 
 Dali::InputMethodContext::InputPanelLanguage InputMethodContextEcoreWl::GetInputPanelLanguage() const
@@ -1106,6 +1121,8 @@ void InputMethodContextEcoreWl::SetInputPanelPosition( unsigned int x, unsigned
   {
     ecore_imf_context_input_panel_position_set( mIMFContext, x, y );
   }
+
+  mBackupOperations[Operation::SET_INPUT_PANEL_POSITION] = std::bind( &InputMethodContextEcoreWl::SetInputPanelPosition, this, x, y );
 }
 
 Dali::InputMethodContext::PreeditStyle InputMethodContextEcoreWl::GetPreeditStyle() const