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..dabf4d2b5ff23d2b5666138323b698a7b6463572 100644 |
--- a/ui/aura/window_tree_host.cc |
+++ b/ui/aura/window_tree_host.cc |
@@ -13,6 +13,7 @@ |
#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_factory.h" |
#include "ui/base/view_prop.h" |
#include "ui/compositor/dip_util.h" |
#include "ui/compositor/layer.h" |
@@ -41,6 +42,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_ = NULL; |
James Cook
2015/06/01 22:21:00
nullptr
Shu Chen
2015/06/02 04:11:16
Done.
|
+ } |
} |
#if defined(OS_ANDROID) |
@@ -177,7 +182,27 @@ void WindowTreeHost::MoveCursorToHostLocation(const gfx::Point& host_location) { |
WindowTreeHost::WindowTreeHost() |
: window_(new Window(NULL)), |
- last_cursor_(ui::kCursorNull) { |
+ last_cursor_(ui::kCursorNull), |
+ input_method_(NULL), |
+ owned_input_method_(false) { |
+} |
+ |
+ui::InputMethod* WindowTreeHost::GetInputMethod() { |
+ if (!input_method_) { |
+ input_method_ = |
+ ui::CreateInputMethod(this, GetAcceleratedWidget()).release(); |
+ // Makes sure the input method is focused by default when created. |
+ input_method_->OnFocus(); |
+ owned_input_method_ = true; |
+ } |
+ return input_method_; |
+}; |
+ |
+void WindowTreeHost::SetInputMethod(ui::InputMethod* input_method) { |
+ if (input_method_) |
James Cook
2015/06/01 22:21:00
Should it be an error and/or warning to call this
Shu Chen
2015/06/02 04:11:16
Done.
|
+ return; |
+ input_method_ = input_method; |
+ owned_input_method_ = false; |
} |
void WindowTreeHost::DestroyCompositor() { |
@@ -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); |
+ CHECK(!details.dispatcher_destroyed); |
Avi (use Gerrit)
2015/06/01 15:13:39
DCHECK
Shu Chen
2015/06/02 04:11:16
Done.
|
+ 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: |