Index: extensions/shell/browser/shell_desktop_controller_aura.cc |
diff --git a/extensions/shell/browser/shell_desktop_controller_aura.cc b/extensions/shell/browser/shell_desktop_controller_aura.cc |
index 70b19aa28ea8f7345fb814a311375cdfcfae4aa5..31201d71fcea89dedc1b23dd730fac65d5632d2f 100644 |
--- a/extensions/shell/browser/shell_desktop_controller_aura.cc |
+++ b/extensions/shell/browser/shell_desktop_controller_aura.cc |
@@ -16,6 +16,7 @@ |
#include "build/build_config.h" |
#include "extensions/browser/app_window/app_window.h" |
#include "extensions/browser/app_window/native_app_window.h" |
+#include "extensions/shell/browser/input_method_event_handler.h" |
#include "extensions/shell/browser/shell_app_delegate.h" |
#include "extensions/shell/browser/shell_app_window_client.h" |
#include "extensions/shell/browser/shell_screen.h" |
@@ -24,13 +25,13 @@ |
#include "ui/aura/client/default_capture_client.h" |
#include "ui/aura/layout_manager.h" |
#include "ui/aura/window.h" |
-#include "ui/aura/window_event_dispatcher.h" |
#include "ui/aura/window_tree_host.h" |
#include "ui/base/cursor/cursor.h" |
#include "ui/base/cursor/image_cursors.h" |
-#include "ui/base/ime/input_method_initializer.h" |
+#include "ui/base/ime/input_method.h" |
#include "ui/base/user_activity/user_activity_detector.h" |
#include "ui/display/screen.h" |
+#include "ui/events/event_processor.h" |
#include "ui/gfx/geometry/size.h" |
#include "ui/gfx/native_widget_types.h" |
#include "ui/wm/core/base_focus_rules.h" |
@@ -271,6 +272,23 @@ void ShellDesktopControllerAura::OnHostCloseRequested( |
FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); |
} |
+ui::EventDispatchDetails ShellDesktopControllerAura::DispatchKeyEventPostIME( |
+ ui::KeyEvent* key_event) { |
+ // The input method has processed this event, so prevent the handler from |
+ // dispatching it again. |
+ input_method_event_handler_->set_post_ime(true); |
+ |
+ // Send the event on to the host. |
+ ui::EventDispatchDetails details = |
+ host_->event_processor()->OnEventFromSource(key_event); |
+ |
+ // Clear the handler's PostIME flag for the next event. |
+ if (!details.dispatcher_destroyed) |
+ input_method_event_handler_->set_post_ime(false); |
+ |
+ return details; |
+} |
+ |
void ShellDesktopControllerAura::InitWindowManager() { |
wm::FocusController* focus_controller = |
new wm::FocusController(new AppsFocusRules()); |
@@ -318,12 +336,18 @@ void ShellDesktopControllerAura::CreateRootWindow() { |
screen_.reset(new ShellScreen(size)); |
display::Screen::SetScreenInstance(screen_.get()); |
- // TODO(mukai): Set up input method. |
host_.reset(screen_->CreateHostForPrimaryDisplay()); |
aura::client::SetWindowParentingClient(host_->window(), this); |
root_window_event_filter_.reset(new wm::CompoundEventFilter); |
host_->window()->AddPreTargetHandler(root_window_event_filter_.get()); |
+ |
+ // Trigger creation of an input method and become its delegate. |
+ ui::InputMethod* input_method = host_->GetInputMethod(); |
+ input_method->SetDelegate(this); |
+ input_method_event_handler_.reset(new InputMethodEventHandler(input_method)); |
+ host_->window()->AddPreTargetHandler(input_method_event_handler_.get()); |
+ |
InitWindowManager(); |
host_->AddObserver(this); |
@@ -340,7 +364,13 @@ void ShellDesktopControllerAura::DestroyRootWindow() { |
host_->window()->RemovePreTargetHandler(focus_controller); |
aura::client::SetActivationClient(host_->window(), NULL); |
} |
+ |
+ host_->window()->RemovePreTargetHandler(input_method_event_handler_.get()); |
+ input_method_event_handler_.reset(); |
+ |
+ host_->window()->RemovePreTargetHandler(root_window_event_filter_.get()); |
root_window_event_filter_.reset(); |
+ |
capture_client_.reset(); |
focus_client_.reset(); |
cursor_manager_.reset(); |
@@ -349,6 +379,7 @@ void ShellDesktopControllerAura::DestroyRootWindow() { |
#endif |
user_activity_detector_.reset(); |
host_.reset(); |
+ display::Screen::SetScreenInstance(nullptr); |
screen_.reset(); |
} |