Chromium Code Reviews| Index: ui/aura/window_tree_host.cc |
| diff --git a/ui/aura/window_tree_host.cc b/ui/aura/window_tree_host.cc |
| index e60208be8c19b09974210da56efa2e38134f23d5..433811ee339e2c31b380794b17c296b0e7503d9e 100644 |
| --- a/ui/aura/window_tree_host.cc |
| +++ b/ui/aura/window_tree_host.cc |
| @@ -13,6 +13,8 @@ |
| #include "ui/aura/window_event_dispatcher.h" |
| #include "ui/aura/window_targeter.h" |
| #include "ui/aura/window_tree_host_observer.h" |
| +#include "ui/base/ime/input_method.h" |
| +#include "ui/base/ime/input_method_factory.h" |
| #include "ui/base/view_prop.h" |
| #include "ui/compositor/dip_util.h" |
| #include "ui/compositor/layer.h" |
| @@ -41,6 +43,10 @@ float GetDeviceScaleFactorFromDisplay(Window* window) { |
| WindowTreeHost::~WindowTreeHost() { |
| DCHECK(!compositor_) << "compositor must be destroyed before root window"; |
| + if (owned_input_method_) { |
| + delete input_method_; |
| + input_method_ = nullptr; |
| + } |
| } |
| #if defined(OS_ANDROID) |
| @@ -50,7 +56,7 @@ WindowTreeHost* WindowTreeHost::Create(const gfx::Rect& bounds) { |
| // adding the CHECK. |
| // TODO(sky): decide if we want a factory. |
| CHECK(false); |
| - return NULL; |
| + return nullptr; |
| } |
| #endif |
| @@ -176,8 +182,27 @@ void WindowTreeHost::MoveCursorToHostLocation(const gfx::Point& host_location) { |
| // WindowTreeHost, protected: |
| WindowTreeHost::WindowTreeHost() |
| - : window_(new Window(NULL)), |
| - last_cursor_(ui::kCursorNull) { |
| + : window_(new Window(nullptr)), |
| + last_cursor_(ui::kCursorNull), |
| + input_method_(nullptr), |
| + owned_input_method_(false) { |
| +} |
| + |
| +ui::InputMethod* WindowTreeHost::GetInputMethod() { |
|
sky
2015/06/04 13:40:28
Make order match header.
Shu Chen
2015/06/04 15:59:25
Done.
|
| + if (!input_method_) { |
| + input_method_ = |
| + ui::CreateInputMethod(this, GetAcceleratedWidget()).release(); |
| + // Makes sure the input method is focused by default when created. |
|
sky
2015/06/04 13:40:28
This doesn't make sense to me. Why does the input_
Shu Chen
2015/06/04 15:59:25
InputMethod::OnFocus() should be called when a nat
sky
2015/06/04 19:42:52
This code effects desktop too though. Is that ok?
Shu Chen
2015/06/05 00:52:18
It is ok, because this behavior remains no change
|
| + input_method_->OnFocus(); |
| + owned_input_method_ = true; |
| + } |
| + return input_method_; |
| +}; |
| + |
| +void WindowTreeHost::SetInputMethod(ui::InputMethod* input_method) { |
| + DCHECK(!input_method_); |
| + input_method_ = input_method; |
| + owned_input_method_ = false; |
| } |
| void WindowTreeHost::DestroyCompositor() { |
| @@ -186,7 +211,7 @@ void WindowTreeHost::DestroyCompositor() { |
| void WindowTreeHost::DestroyDispatcher() { |
| delete window_; |
| - window_ = NULL; |
| + window_ = nullptr; |
| dispatcher_.reset(); |
| // TODO(beng): this comment is no longer quite valid since this function |
| @@ -259,6 +284,30 @@ void WindowTreeHost::OnHostLostWindowCapture() { |
| capture_window->ReleaseCapture(); |
| } |
| +bool WindowTreeHost::DispatchKeyEventPostIME(const ui::KeyEvent& event) { |
| + ui::KeyEvent copied_event(event); |
| + ui::EventDispatchDetails details = |
| + event_processor()->OnEventFromSource(&copied_event); |
| + DCHECK(!details.dispatcher_destroyed); |
| + return copied_event.handled(); |
| +} |
| + |
| +ui::EventProcessor* WindowTreeHost::GetEventProcessor() { |
| + return event_processor(); |
| +} |
| + |
| +ui::EventDispatchDetails WindowTreeHost::DeliverEventToProcessor( |
| + ui::Event* event) { |
| + if (event->IsKeyEvent()) { |
| + if (GetInputMethod()->DispatchKeyEvent( |
| + *static_cast<ui::KeyEvent*>(event))) { |
| + event->StopPropagation(); |
| + return ui::EventDispatchDetails(); |
| + } |
| + } |
| + return ui::EventSource::DeliverEventToProcessor(event); |
| +} |
| + |
| //////////////////////////////////////////////////////////////////////////////// |
| // WindowTreeHost, private: |