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

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

Issue 2445163002: Make aura work with mus (Closed)
Patch Set: NON_EXPORTED_BASE_CLASS Created 4 years, 1 month 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 | « ui/aura/mus/input_method_mus.h ('k') | ui/aura/mus/mus_types.h » ('j') | 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/views/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 "services/ui/public/cpp/window.h"
10 #include "services/ui/public/interfaces/ime.mojom.h" 9 #include "services/ui/public/interfaces/ime.mojom.h"
10 #include "services/ui/public/interfaces/window_tree_constants.mojom.h"
11 #include "ui/aura/mus/text_input_client_impl.h"
12 #include "ui/aura/mus/window_port_mus.h"
13 #include "ui/aura/window.h"
11 #include "ui/base/ime/text_input_client.h" 14 #include "ui/base/ime/text_input_client.h"
12 #include "ui/events/event.h" 15 #include "ui/events/event.h"
13 #include "ui/platform_window/mojo/ime_type_converters.h" 16 #include "ui/platform_window/mojo/ime_type_converters.h"
14 #include "ui/platform_window/mojo/text_input_state.mojom.h" 17 #include "ui/platform_window/mojo/text_input_state.mojom.h"
15 #include "ui/views/mus/text_input_client_impl.h"
16 18
17 using ui::mojom::EventResult; 19 using ui::mojom::EventResult;
18 20
19 namespace views { 21 namespace aura {
20 22
21 //////////////////////////////////////////////////////////////////////////////// 23 ////////////////////////////////////////////////////////////////////////////////
22 // InputMethodMus, public: 24 // InputMethodMus, public:
23 25
24 InputMethodMus::InputMethodMus(ui::internal::InputMethodDelegate* delegate, 26 InputMethodMus::InputMethodMus(ui::internal::InputMethodDelegate* delegate,
25 ui::Window* window) 27 Window* window)
26 : window_(window) { 28 : window_(window) {
27 SetDelegate(delegate); 29 SetDelegate(delegate);
28 } 30 }
29 31
30 InputMethodMus::~InputMethodMus() {} 32 InputMethodMus::~InputMethodMus() {}
31 33
32 void InputMethodMus::Init(service_manager::Connector* connector) { 34 void InputMethodMus::Init(service_manager::Connector* connector) {
33 connector->ConnectToInterface("service:ui", &ime_server_); 35 connector->ConnectToInterface("service:ui", &ime_server_);
34 } 36 }
35 37
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 text_input_client_ = base::MakeUnique<TextInputClientImpl>(focused); 125 text_input_client_ = base::MakeUnique<TextInputClientImpl>(focused);
124 ime_server_->StartSession(text_input_client_->CreateInterfacePtrAndBind(), 126 ime_server_->StartSession(text_input_client_->CreateInterfacePtrAndBind(),
125 GetProxy(&input_method_)); 127 GetProxy(&input_method_));
126 } 128 }
127 129
128 void InputMethodMus::UpdateTextInputType() { 130 void InputMethodMus::UpdateTextInputType() {
129 ui::TextInputType type = GetTextInputType(); 131 ui::TextInputType type = GetTextInputType();
130 mojo::TextInputStatePtr state = mojo::TextInputState::New(); 132 mojo::TextInputStatePtr state = mojo::TextInputState::New();
131 state->type = mojo::ConvertTo<mojo::TextInputType>(type); 133 state->type = mojo::ConvertTo<mojo::TextInputType>(type);
132 if (window_) { 134 if (window_) {
135 WindowPortMus* window_impl_mus = WindowPortMus::Get(window_);
133 if (type != ui::TEXT_INPUT_TYPE_NONE) 136 if (type != ui::TEXT_INPUT_TYPE_NONE)
134 window_->SetImeVisibility(true, std::move(state)); 137 window_impl_mus->SetImeVisibility(true, std::move(state));
135 else 138 else
136 window_->SetTextInputState(std::move(state)); 139 window_impl_mus->SetTextInputState(std::move(state));
137 } 140 }
138 } 141 }
139 142
140 void InputMethodMus::ProcessKeyEventCallback( 143 void InputMethodMus::ProcessKeyEventCallback(
141 const ui::KeyEvent& event, 144 const ui::KeyEvent& event,
142 std::unique_ptr<base::Callback<void(EventResult)>> ack_callback, 145 std::unique_ptr<base::Callback<void(EventResult)>> ack_callback,
143 bool handled) { 146 bool handled) {
144 EventResult event_result; 147 EventResult event_result;
145 if (!handled) { 148 if (!handled) {
146 // If not handled by IME, try dispatching the event to delegate to see if 149 // If not handled by IME, try dispatching the event to delegate to see if
147 // any client-side post-ime processing needs to be done. This includes cases 150 // any client-side post-ime processing needs to be done. This includes cases
148 // like backspace, return key, etc. 151 // like backspace, return key, etc.
149 std::unique_ptr<ui::Event> event_clone = ui::Event::Clone(event); 152 std::unique_ptr<ui::Event> event_clone = ui::Event::Clone(event);
150 ignore_result(DispatchKeyEventPostIME(event_clone->AsKeyEvent())); 153 ignore_result(DispatchKeyEventPostIME(event_clone->AsKeyEvent()));
151 event_result = 154 event_result =
152 event_clone->handled() ? EventResult::HANDLED : EventResult::UNHANDLED; 155 event_clone->handled() ? EventResult::HANDLED : EventResult::UNHANDLED;
153 } else { 156 } else {
154 event_result = EventResult::HANDLED; 157 event_result = EventResult::HANDLED;
155 } 158 }
156 // |ack_callback| can be null if the standard form of DispatchKeyEvent() is 159 // |ack_callback| can be null if the standard form of DispatchKeyEvent() is
157 // called instead of the version which provides a callback. In mus+ash we 160 // called instead of the version which provides a callback. In mus+ash we
158 // use the version with callback, but some unittests use the standard form. 161 // use the version with callback, but some unittests use the standard form.
159 if (ack_callback) 162 if (ack_callback)
160 ack_callback->Run(event_result); 163 ack_callback->Run(event_result);
161 } 164 }
162 165
163 } // namespace views 166 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/mus/input_method_mus.h ('k') | ui/aura/mus/mus_types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698