Index: ui/views/mus/input_method_mus.cc |
diff --git a/ui/views/mus/input_method_mus.cc b/ui/views/mus/input_method_mus.cc |
index 942dde7411a78d78c883fbf6c25478a96fc05fb3..c8d027eeab2e91aab2862567895df904e38a850f 100644 |
--- a/ui/views/mus/input_method_mus.cc |
+++ b/ui/views/mus/input_method_mus.cc |
@@ -7,51 +7,43 @@ |
#include <utility> |
#include "services/ui/public/cpp/window.h" |
-#include "services/ui/public/interfaces/ime.mojom.h" |
#include "ui/base/ime/text_input_client.h" |
#include "ui/events/event.h" |
#include "ui/platform_window/mojo/ime_type_converters.h" |
#include "ui/platform_window/mojo/text_input_state.mojom.h" |
-#include "ui/views/mus/text_input_client_impl.h" |
namespace views { |
//////////////////////////////////////////////////////////////////////////////// |
-// InputMethodMus, public: |
+// InputMethodMUS, public: |
-InputMethodMus::InputMethodMus(ui::internal::InputMethodDelegate* delegate, |
+InputMethodMUS::InputMethodMUS(ui::internal::InputMethodDelegate* delegate, |
ui::Window* window) |
: window_(window) { |
SetDelegate(delegate); |
} |
-InputMethodMus::~InputMethodMus() {} |
- |
-void InputMethodMus::Init(shell::Connector* connector) { |
- connector->ConnectToInterface("mojo:ui", &ime_server_); |
-} |
+InputMethodMUS::~InputMethodMUS() {} |
//////////////////////////////////////////////////////////////////////////////// |
-// InputMethodMus, ui::InputMethod implementation: |
+// InputMethodMUS, ui::InputMethod implementation: |
-void InputMethodMus::OnFocus() { |
+void InputMethodMUS::OnFocus() { |
InputMethodBase::OnFocus(); |
UpdateTextInputType(); |
} |
-void InputMethodMus::OnBlur() { |
+void InputMethodMUS::OnBlur() { |
InputMethodBase::OnBlur(); |
UpdateTextInputType(); |
} |
-bool InputMethodMus::OnUntranslatedIMEMessage(const base::NativeEvent& event, |
+bool InputMethodMUS::OnUntranslatedIMEMessage(const base::NativeEvent& event, |
NativeEventResult* result) { |
- // This method is not called on non-Windows platforms. See the comments for |
- // ui::InputMethod::OnUntranslatedIMEMessage(). |
return false; |
} |
-void InputMethodMus::DispatchKeyEvent(ui::KeyEvent* event) { |
+void InputMethodMUS::DispatchKeyEvent(ui::KeyEvent* event) { |
DCHECK(event->type() == ui::ET_KEY_PRESSED || |
event->type() == ui::ET_KEY_RELEASED); |
@@ -61,14 +53,12 @@ |
return; |
} |
- // TODO(moshayedi): crbug.com/641355. Currently if we stop propagation of |
- // non-char events here, accelerators ddn't work. This is because we send the |
- // event ack too early in NativeWidgetMus. We should send both char and |
- // non-char events to the IME driver once we fix this. |
+ // Here is where we change the differ from our base class's logic. Instead of |
+ // always dispatching a key down event, and then sending a synthesized |
+ // character event, we instead check to see if this is a character event and |
+ // send out the key if it is. (We fallback to normal dispatch if it isn't.) |
if (event->is_char()) { |
- // IME driver will notify the text input client if it is not interested in |
- // event, which in turn will call DispatchKeyEventPostIME(). |
- input_method_->ProcessKeyEvent(ui::Event::Clone(*event)); |
+ GetTextInputClient()->InsertChar(*event); |
event->StopPropagation(); |
return; |
} |
@@ -76,65 +66,41 @@ |
ignore_result(DispatchKeyEventPostIME(event)); |
} |
-void InputMethodMus::OnTextInputTypeChanged(const ui::TextInputClient* client) { |
+void InputMethodMUS::OnTextInputTypeChanged(const ui::TextInputClient* client) { |
if (IsTextInputClientFocused(client)) |
UpdateTextInputType(); |
InputMethodBase::OnTextInputTypeChanged(client); |
- |
- if (input_method_) { |
- input_method_->OnTextInputTypeChanged( |
- static_cast<ui::mojom::TextInputType>(client->GetTextInputType())); |
- } |
} |
-void InputMethodMus::OnCaretBoundsChanged(const ui::TextInputClient* client) { |
- if (input_method_) |
- input_method_->OnCaretBoundsChanged(client->GetCaretBounds()); |
+void InputMethodMUS::OnCaretBoundsChanged(const ui::TextInputClient* client) {} |
+ |
+void InputMethodMUS::CancelComposition(const ui::TextInputClient* client) {} |
+ |
+void InputMethodMUS::OnInputLocaleChanged() {} |
+ |
+std::string InputMethodMUS::GetInputLocale() { |
+ return ""; |
} |
-void InputMethodMus::CancelComposition(const ui::TextInputClient* client) { |
- if (input_method_) |
- input_method_->CancelComposition(); |
-} |
- |
-void InputMethodMus::OnInputLocaleChanged() { |
- // TODO(moshayedi): crbug.com/637418. Not supported in ChromeOS. Investigate |
- // whether we want to support this or not. |
-} |
- |
-std::string InputMethodMus::GetInputLocale() { |
- // TODO(moshayedi): crbug.com/637418. Not supported in ChromeOS. Investigate |
- // whether we want to support this or not. |
- return std::string(); |
-} |
- |
-bool InputMethodMus::IsCandidatePopupOpen() const { |
- // TODO(moshayedi): crbug.com/637416. Implement this properly when we have a |
- // mean for displaying candidate list popup. |
+bool InputMethodMUS::IsCandidatePopupOpen() const { |
return false; |
} |
-void InputMethodMus::OnDidChangeFocusedClient( |
+void InputMethodMUS::OnDidChangeFocusedClient( |
ui::TextInputClient* focused_before, |
ui::TextInputClient* focused) { |
InputMethodBase::OnDidChangeFocusedClient(focused_before, focused); |
UpdateTextInputType(); |
- |
- text_input_client_.reset(new TextInputClientImpl(focused, this)); |
- ime_server_->StartSession(text_input_client_->CreateInterfacePtrAndBind(), |
- GetProxy(&input_method_)); |
} |
-void InputMethodMus::UpdateTextInputType() { |
+void InputMethodMUS::UpdateTextInputType() { |
ui::TextInputType type = GetTextInputType(); |
mojo::TextInputStatePtr state = mojo::TextInputState::New(); |
state->type = mojo::ConvertTo<mojo::TextInputType>(type); |
- if (window_) { |
- if (type != ui::TEXT_INPUT_TYPE_NONE) |
- window_->SetImeVisibility(true, std::move(state)); |
- else |
- window_->SetTextInputState(std::move(state)); |
- } |
+ if (type != ui::TEXT_INPUT_TYPE_NONE) |
+ window_->SetImeVisibility(true, std::move(state)); |
+ else |
+ window_->SetTextInputState(std::move(state)); |
} |
} // namespace views |