OLD | NEW |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/aura/mus/input_method_mus.h" | 5 #include "ui/aura/mus/input_method_mus.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "services/ui/public/interfaces/constants.mojom.h" | 10 #include "services/ui/public/interfaces/constants.mojom.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 | 85 |
86 void InputMethodMus::DispatchKeyEvent(ui::KeyEvent* event) { | 86 void InputMethodMus::DispatchKeyEvent(ui::KeyEvent* event) { |
87 DispatchKeyEvent(event, nullptr); | 87 DispatchKeyEvent(event, nullptr); |
88 } | 88 } |
89 | 89 |
90 void InputMethodMus::OnTextInputTypeChanged(const ui::TextInputClient* client) { | 90 void InputMethodMus::OnTextInputTypeChanged(const ui::TextInputClient* client) { |
91 if (IsTextInputClientFocused(client)) | 91 if (IsTextInputClientFocused(client)) |
92 UpdateTextInputType(); | 92 UpdateTextInputType(); |
93 InputMethodBase::OnTextInputTypeChanged(client); | 93 InputMethodBase::OnTextInputTypeChanged(client); |
94 | 94 |
95 if (input_method_) { | 95 if (input_method_) |
96 input_method_->OnTextInputTypeChanged(client->GetTextInputType()); | 96 input_method_->OnTextInputTypeChanged(client->GetTextInputType()); |
97 } | |
98 } | 97 } |
99 | 98 |
100 void InputMethodMus::OnCaretBoundsChanged(const ui::TextInputClient* client) { | 99 void InputMethodMus::OnCaretBoundsChanged(const ui::TextInputClient* client) { |
101 if (input_method_) | 100 if (input_method_) |
102 input_method_->OnCaretBoundsChanged(client->GetCaretBounds()); | 101 input_method_->OnCaretBoundsChanged(client->GetCaretBounds()); |
103 } | 102 } |
104 | 103 |
105 void InputMethodMus::CancelComposition(const ui::TextInputClient* client) { | 104 void InputMethodMus::CancelComposition(const ui::TextInputClient* client) { |
106 if (input_method_) | 105 if (input_method_) |
107 input_method_->CancelComposition(); | 106 input_method_->CancelComposition(); |
(...skipping 11 matching lines...) Expand all Loading... |
119 } | 118 } |
120 | 119 |
121 void InputMethodMus::OnDidChangeFocusedClient( | 120 void InputMethodMus::OnDidChangeFocusedClient( |
122 ui::TextInputClient* focused_before, | 121 ui::TextInputClient* focused_before, |
123 ui::TextInputClient* focused) { | 122 ui::TextInputClient* focused) { |
124 InputMethodBase::OnDidChangeFocusedClient(focused_before, focused); | 123 InputMethodBase::OnDidChangeFocusedClient(focused_before, focused); |
125 UpdateTextInputType(); | 124 UpdateTextInputType(); |
126 | 125 |
127 text_input_client_ = base::MakeUnique<TextInputClientImpl>(focused); | 126 text_input_client_ = base::MakeUnique<TextInputClientImpl>(focused); |
128 if (ime_server_) { | 127 if (ime_server_) { |
129 ime_server_->StartSession(text_input_client_->CreateInterfacePtrAndBind(), | 128 ui::mojom::TextInputClientInformationPtr client_info = |
| 129 ui::mojom::TextInputClientInformation::New(); |
| 130 client_info->text_input_type = focused->GetTextInputType(); |
| 131 client_info->text_input_mode = focused->GetTextInputMode(); |
| 132 client_info->text_direction = focused->GetTextDirection(); |
| 133 client_info->text_input_flags = focused->GetTextInputFlags(); |
| 134 client_info->caret_bounds = focused->GetCaretBounds(); |
| 135 ime_server_->StartSession(std::move(client_info), |
| 136 text_input_client_->CreateInterfacePtrAndBind(), |
130 MakeRequest(&input_method_)); | 137 MakeRequest(&input_method_)); |
131 } | 138 } |
132 } | 139 } |
133 | 140 |
134 void InputMethodMus::UpdateTextInputType() { | 141 void InputMethodMus::UpdateTextInputType() { |
135 ui::TextInputType type = GetTextInputType(); | 142 ui::TextInputType type = GetTextInputType(); |
136 mojo::TextInputStatePtr state = mojo::TextInputState::New(); | 143 mojo::TextInputStatePtr state = mojo::TextInputState::New(); |
137 state->type = mojo::ConvertTo<mojo::TextInputType>(type); | 144 state->type = mojo::ConvertTo<mojo::TextInputType>(type); |
138 if (window_) { | 145 if (window_) { |
139 WindowPortMus* window_impl_mus = WindowPortMus::Get(window_); | 146 WindowPortMus* window_impl_mus = WindowPortMus::Get(window_); |
(...skipping 21 matching lines...) Expand all Loading... |
161 event_result = EventResult::HANDLED; | 168 event_result = EventResult::HANDLED; |
162 } | 169 } |
163 // |ack_callback| can be null if the standard form of DispatchKeyEvent() is | 170 // |ack_callback| can be null if the standard form of DispatchKeyEvent() is |
164 // called instead of the version which provides a callback. In mus+ash we | 171 // called instead of the version which provides a callback. In mus+ash we |
165 // use the version with callback, but some unittests use the standard form. | 172 // use the version with callback, but some unittests use the standard form. |
166 if (ack_callback) | 173 if (ack_callback) |
167 ack_callback->Run(event_result); | 174 ack_callback->Run(event_result); |
168 } | 175 } |
169 | 176 |
170 } // namespace aura | 177 } // namespace aura |
OLD | NEW |