Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(966)

Side by Side Diff: ui/aura/mus/input_method_mus.cc

Issue 2626983003: IME for Mus: Send TextInputClient information to IMEDriver. (Closed)
Patch Set: fix mojo dependencies. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « services/ui/public/interfaces/ime/ime.mojom ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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();
108 } 107 }
109 108
110 void InputMethodMus::OnInputLocaleChanged() { 109 void InputMethodMus::OnInputLocaleChanged() {
111 // TODO(moshayedi): crbug.com/637418. Not supported in ChromeOS. Investigate 110 // TODO(moshayedi): crbug.com/637418. Not supported in ChromeOS. Investigate
112 // whether we want to support this or not. 111 // whether we want to support this or not.
113 } 112 }
114 113
115 bool InputMethodMus::IsCandidatePopupOpen() const { 114 bool InputMethodMus::IsCandidatePopupOpen() const {
116 // TODO(moshayedi): crbug.com/637416. Implement this properly when we have a 115 // TODO(moshayedi): crbug.com/637416. Implement this properly when we have a
117 // mean for displaying candidate list popup. 116 // mean for displaying candidate list popup.
118 return false; 117 return false;
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
126 // TODO(moshayedi): crbug.com/681563. Handle when there is no focused clients.
127 if (!focused)
128 return;
129
127 text_input_client_ = base::MakeUnique<TextInputClientImpl>(focused); 130 text_input_client_ = base::MakeUnique<TextInputClientImpl>(focused);
128 if (ime_server_) { 131 if (ime_server_) {
129 ime_server_->StartSession(text_input_client_->CreateInterfacePtrAndBind(), 132 ui::mojom::StartSessionDetailsPtr details =
130 MakeRequest(&input_method_)); 133 ui::mojom::StartSessionDetails::New();
134 details->client = text_input_client_->CreateInterfacePtrAndBind();
135 details->input_method_request = MakeRequest(&input_method_);
136 details->text_input_type = focused->GetTextInputType();
137 details->text_input_mode = focused->GetTextInputMode();
138 details->text_direction = focused->GetTextDirection();
139 details->text_input_flags = focused->GetTextInputFlags();
140 details->caret_bounds = focused->GetCaretBounds();
141 ime_server_->StartSession(std::move(details));
131 } 142 }
132 } 143 }
133 144
134 void InputMethodMus::UpdateTextInputType() { 145 void InputMethodMus::UpdateTextInputType() {
135 ui::TextInputType type = GetTextInputType(); 146 ui::TextInputType type = GetTextInputType();
136 mojo::TextInputStatePtr state = mojo::TextInputState::New(); 147 mojo::TextInputStatePtr state = mojo::TextInputState::New();
137 state->type = mojo::ConvertTo<mojo::TextInputType>(type); 148 state->type = mojo::ConvertTo<mojo::TextInputType>(type);
138 if (window_) { 149 if (window_) {
139 WindowPortMus* window_impl_mus = WindowPortMus::Get(window_); 150 WindowPortMus* window_impl_mus = WindowPortMus::Get(window_);
140 if (type != ui::TEXT_INPUT_TYPE_NONE) 151 if (type != ui::TEXT_INPUT_TYPE_NONE)
(...skipping 20 matching lines...) Expand all
161 event_result = EventResult::HANDLED; 172 event_result = EventResult::HANDLED;
162 } 173 }
163 // |ack_callback| can be null if the standard form of DispatchKeyEvent() is 174 // |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 175 // 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. 176 // use the version with callback, but some unittests use the standard form.
166 if (ack_callback) 177 if (ack_callback)
167 ack_callback->Run(event_result); 178 ack_callback->Run(event_result);
168 } 179 }
169 180
170 } // namespace aura 181 } // namespace aura
OLDNEW
« no previous file with comments | « services/ui/public/interfaces/ime/ime.mojom ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698