IME show properly after disappear the clipboard.
[framework/web/webkit-efl.git] / Source / WebKit2 / UIProcess / efl / InputMethodContextEfl.cpp
index e9decb1..d810116 100755 (executable)
@@ -37,6 +37,7 @@ InputMethodContextEfl::InputMethodContextEfl(EwkViewImpl* viewImpl, PassOwnPtr<E
 #if ENABLE(TIZEN_ISF_PORT)
     , m_useInputMethod(false)
     , m_state(ECORE_IMF_INPUT_PANEL_STATE_HIDE)
+    , m_inputPickerType(-1)
 #endif
 {
     ASSERT(context);
@@ -324,13 +325,17 @@ void InputMethodContextEfl::handleKeyDownEvent(const Evas_Event_Key_Down* downEv
 void InputMethodContextEfl::updateTextInputState()
 {
     const EditorState& editor = m_viewImpl->page()->editorState();
+    if (editor.shouldIgnoreCompositionSelectionChange)
+        return;
 
-    if (!editor.shouldIgnoreCompositionSelectionChange) {
-        if (editor.isContentEditable && m_useInputMethod)
-            showIMFContext(editor);
-        else
-            hideIMFContext();
-    }
+    if (editor.isContentEditable && m_useInputMethod) {
+#if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
+        if (m_viewImpl->pageClient->isClipboardWindowOpened())
+            m_viewImpl->pageClient->closeClipboardWindow();
+#endif
+        showIMFContext(editor);
+    } else
+        hideIMFContext();
 
     if (m_context)
         ecore_imf_context_cursor_position_set(m_context.get(), editor.cursorPosition);
@@ -437,6 +442,11 @@ Ecore_IMF_Autocapital_Type InputMethodContextEfl::autoCapitalType()
 
 void InputMethodContextEfl::onFocusIn()
 {
+    if (m_inputPickerType >= 0) {
+        showInputPicker(m_viewImpl->page()->editorState());
+        return;
+    }
+
     if (!m_context || !m_focused)
         return;
 
@@ -489,23 +499,23 @@ void InputMethodContextEfl::showIMFContext(const EditorState& editor)
     bool defaultKeypadEnabled = ewk_settings_default_keypad_enabled_get(settings);
 
 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
-    if (editor.inputMethodHints == "date") {
-        showInputPicker(EWK_INPUT_TYPE_DATE, editor);
-        return;
-    } else if (editor.inputMethodHints == "datetime") {
-        showInputPicker(EWK_INPUT_TYPE_DATETIME, editor);
-        return;
-    } else if (editor.inputMethodHints == "datetime-local") {
-        showInputPicker(EWK_INPUT_TYPE_DATETIMELOCAL, editor);
-        return;
-    } else if (editor.inputMethodHints == "month") {
-        showInputPicker(EWK_INPUT_TYPE_MONTH, editor);
-        return;
-    } else if (editor.inputMethodHints == "time") {
-        showInputPicker(EWK_INPUT_TYPE_TIME, editor);
-        return;
-    } else if (editor.inputMethodHints == "week") {
-        showInputPicker(EWK_INPUT_TYPE_WEEK, editor);
+    if (editor.inputMethodHints == "date")
+        m_inputPickerType = EWK_INPUT_TYPE_DATE;
+    else if (editor.inputMethodHints == "datetime")
+        m_inputPickerType = EWK_INPUT_TYPE_DATETIME;
+    else if (editor.inputMethodHints == "datetime-local")
+        m_inputPickerType = EWK_INPUT_TYPE_DATETIMELOCAL;
+    else if (editor.inputMethodHints == "month")
+        m_inputPickerType = EWK_INPUT_TYPE_MONTH;
+    else if (editor.inputMethodHints == "time")
+        m_inputPickerType = EWK_INPUT_TYPE_TIME;
+    else if (editor.inputMethodHints == "week")
+        m_inputPickerType = EWK_INPUT_TYPE_WEEK;
+    else
+        m_inputPickerType = -1;
+
+    if (m_inputPickerType >= 0) {
+        showInputPicker(editor);
         return;
     }
 
@@ -531,13 +541,6 @@ void InputMethodContextEfl::showIMFContext(const EditorState& editor)
 #endif
 #endif // ENABLE(TIZEN_INPUT_TAG_EXTENSION)
 
-#if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
-    if (m_viewImpl->pageClient->isClipboardWindowOpened()) {
-        LOG(ISF, "[FAIL] Clipboard\n");
-        return;
-    }
-#endif
-
     bool hasFocus = evas_object_focus_get(m_viewImpl->view());
 
     if (!defaultKeypadEnabled) {
@@ -564,6 +567,7 @@ void InputMethodContextEfl::showIMFContext(const EditorState& editor)
     ewk_view_focused_node_adjust(m_viewImpl->view(), EINA_TRUE);
 
     m_focused = true;
+    m_state = ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW;
 }
 
 void InputMethodContextEfl::hideIMFContext()
@@ -575,6 +579,8 @@ void InputMethodContextEfl::hideIMFContext()
     }
 #endif
 
+    m_inputPickerType = -1;
+
     if (!m_context || !m_focused)
         return;
 
@@ -583,7 +589,8 @@ void InputMethodContextEfl::hideIMFContext()
 
     m_focused = false;
 
-    if (ecore_imf_context_input_panel_state_get(m_context.get()) != ECORE_IMF_INPUT_PANEL_STATE_HIDE) {
+    if (ecore_imf_context_input_panel_state_get(m_context.get()) != ECORE_IMF_INPUT_PANEL_STATE_HIDE
+        && evas_object_focus_get(m_viewImpl->view())) {
         ecore_imf_context_reset(m_context.get());
         ecore_imf_context_input_panel_hide(m_context.get());
         ecore_imf_context_focus_out(m_context.get());
@@ -598,12 +605,13 @@ void InputMethodContextEfl::destroyIMFContextList()
 }
 
 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
-void InputMethodContextEfl::showInputPicker(Ewk_Input_Type type, const EditorState& editorState)
+void InputMethodContextEfl::showInputPicker(const EditorState& editorState)
 {
     if (editorState.selectionIsRange || !evas_object_focus_get(m_viewImpl->view()))
         return;
 
-    ewkViewInputPickerRequest(m_viewImpl->view(), type, editorState.surroundingText);
+    ewkViewInputPickerRequest(m_viewImpl->view(), static_cast<Ewk_Input_Type>(m_inputPickerType), editorState.surroundingText);
+    m_inputPickerType = -1;
 }
 #endif