| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/corewm/input_method_event_filter.h" | 5 #include "ui/views/corewm/input_method_event_filter.h" |
| 6 | 6 |
| 7 #include "ui/aura/client/aura_constants.h" | 7 #include "ui/aura/client/aura_constants.h" |
| 8 #include "ui/aura/window_event_dispatcher.h" | 8 #include "ui/aura/window_event_dispatcher.h" |
| 9 #include "ui/base/ime/input_method.h" | 9 #include "ui/base/ime/input_method.h" |
| 10 #include "ui/base/ime/input_method_factory.h" | 10 #include "ui/base/ime/input_method_factory.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 const ui::EventType type = event->type(); | 40 const ui::EventType type = event->type(); |
| 41 if (type == ui::ET_TRANSLATED_KEY_PRESS || | 41 if (type == ui::ET_TRANSLATED_KEY_PRESS || |
| 42 type == ui::ET_TRANSLATED_KEY_RELEASE) { | 42 type == ui::ET_TRANSLATED_KEY_RELEASE) { |
| 43 // The |event| is already handled by this object, change the type of the | 43 // The |event| is already handled by this object, change the type of the |
| 44 // event to ui::ET_KEY_* and pass it to the next filter. | 44 // event to ui::ET_KEY_* and pass it to the next filter. |
| 45 static_cast<ui::TranslatedKeyEvent*>(event)->ConvertToKeyEvent(); | 45 static_cast<ui::TranslatedKeyEvent*>(event)->ConvertToKeyEvent(); |
| 46 } else { | 46 } else { |
| 47 // If the focused window is changed, all requests to IME will be | 47 // If the focused window is changed, all requests to IME will be |
| 48 // discarded so it's safe to update the target_dispatcher_ here. | 48 // discarded so it's safe to update the target_dispatcher_ here. |
| 49 aura::Window* target = static_cast<aura::Window*>(event->target()); | 49 aura::Window* target = static_cast<aura::Window*>(event->target()); |
| 50 target_dispatcher_ = target->GetRootWindow()->GetDispatcher(); | 50 target_dispatcher_ = target->GetRootWindow()->GetHost()->dispatcher(); |
| 51 DCHECK(target_dispatcher_); | 51 DCHECK(target_dispatcher_); |
| 52 if (input_method_->DispatchKeyEvent(*event)) | 52 if (input_method_->DispatchKeyEvent(*event)) |
| 53 event->StopPropagation(); | 53 event->StopPropagation(); |
| 54 } | 54 } |
| 55 } | 55 } |
| 56 | 56 |
| 57 //////////////////////////////////////////////////////////////////////////////// | 57 //////////////////////////////////////////////////////////////////////////////// |
| 58 // InputMethodEventFilter, ui::InputMethodDelegate implementation: | 58 // InputMethodEventFilter, ui::InputMethodDelegate implementation: |
| 59 | 59 |
| 60 bool InputMethodEventFilter::DispatchKeyEventPostIME( | 60 bool InputMethodEventFilter::DispatchKeyEventPostIME( |
| 61 const ui::KeyEvent& event) { | 61 const ui::KeyEvent& event) { |
| 62 #if defined(OS_WIN) | 62 #if defined(OS_WIN) |
| 63 if (DCHECK_IS_ON() && event.HasNativeEvent()) | 63 if (DCHECK_IS_ON() && event.HasNativeEvent()) |
| 64 DCHECK_NE(event.native_event().message, static_cast<UINT>(WM_CHAR)); | 64 DCHECK_NE(event.native_event().message, static_cast<UINT>(WM_CHAR)); |
| 65 #endif | 65 #endif |
| 66 ui::TranslatedKeyEvent aura_event(event); | 66 ui::TranslatedKeyEvent aura_event(event); |
| 67 ui::EventDispatchDetails details = | 67 ui::EventDispatchDetails details = |
| 68 target_dispatcher_->OnEventFromSource(&aura_event); | 68 target_dispatcher_->OnEventFromSource(&aura_event); |
| 69 CHECK(!details.dispatcher_destroyed); | 69 CHECK(!details.dispatcher_destroyed); |
| 70 return aura_event.handled(); | 70 return aura_event.handled(); |
| 71 } | 71 } |
| 72 | 72 |
| 73 } // namespace corewm | 73 } // namespace corewm |
| 74 } // namespace views | 74 } // namespace views |
| OLD | NEW |