Chromium Code Reviews| 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..28971c7c5f136d4bc8d6dd92a052db5b3cf9a88a 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" |
| @@ -28,7 +29,8 @@ |
| #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/ime/input_method_factory.h" |
| #include "ui/base/user_activity/user_activity_detector.h" |
| #include "ui/display/screen.h" |
| #include "ui/gfx/geometry/size.h" |
| @@ -271,6 +273,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_->SetPostIME(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_->SetPostIME(false); |
| + |
| + return details; |
| +} |
| + |
| void ShellDesktopControllerAura::InitWindowManager() { |
| wm::FocusController* focus_controller = |
| new wm::FocusController(new AppsFocusRules()); |
| @@ -318,12 +337,19 @@ 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()); |
| + |
| + // Handle key events. |
| + input_method_ = ui::CreateInputMethod(this, host_->GetAcceleratedWidget()); |
| + host_->SetSharedInputMethod(input_method_.get()); |
|
Rahul Chaturvedi
2016/12/15 22:42:46
When we're destructing, and input_method_ will no
michaelpg
2016/12/15 23:55:52
Ugh, good point, this isn't quite safe. shuchen, a
|
| + input_method_event_handler_.reset( |
| + new InputMethodEventHandler(input_method_.get())); |
| + host_->window()->AddPreTargetHandler(input_method_event_handler_.get()); |
| + |
| InitWindowManager(); |
| host_->AddObserver(this); |
| @@ -340,7 +366,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(); |