| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/base/ime/input_method_chromeos.h" | 5 #include "ui/base/ime/input_method_chromeos.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <cstring> | 10 #include <cstring> |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 if (ui::IMEBridge::Get()) | 56 if (ui::IMEBridge::Get()) |
| 57 ui::IMEBridge::Get()->SetInputContextHandler(NULL); | 57 ui::IMEBridge::Get()->SetInputContextHandler(NULL); |
| 58 } | 58 } |
| 59 | 59 |
| 60 void InputMethodChromeOS::DispatchKeyEvent( | 60 void InputMethodChromeOS::DispatchKeyEvent( |
| 61 ui::KeyEvent* event, | 61 ui::KeyEvent* event, |
| 62 std::unique_ptr<AckCallback> ack_callback) { | 62 std::unique_ptr<AckCallback> ack_callback) { |
| 63 DCHECK(event->IsKeyEvent()); | 63 DCHECK(event->IsKeyEvent()); |
| 64 DCHECK(!(event->flags() & ui::EF_IS_SYNTHESIZED)); | 64 DCHECK(!(event->flags() & ui::EF_IS_SYNTHESIZED)); |
| 65 | 65 |
| 66 // For linux_chromeos, the ime keyboard cannot track the caps lock state by | 66 // The Caps Lock toggling has been removed from here, because now it is |
| 67 // itself, so need to call SetCapsLockEnabled() method to reflect the caps | 67 // handled in accelerator controller. |
| 68 // lock state by the key event. | 68 // (see https://bugs.chromium.org/p/chromium/issues/detail?id=700705). |
| 69 if (!chromeos::IsRunningAsSystemCompositor()) { | |
| 70 chromeos::input_method::InputMethodManager* manager = | |
| 71 chromeos::input_method::InputMethodManager::Get(); | |
| 72 if (manager) { | |
| 73 chromeos::input_method::ImeKeyboard* keyboard = manager->GetImeKeyboard(); | |
| 74 if (keyboard && event->type() == ui::ET_KEY_PRESSED) { | |
| 75 keyboard->SetCapsLockEnabled((event->key_code() == ui::VKEY_CAPITAL) ? | |
| 76 !keyboard->CapsLockIsEnabled() : event->IsCapsLockOn()); | |
| 77 } | |
| 78 } | |
| 79 } | |
| 80 | 69 |
| 81 // If |context_| is not usable, then we can only dispatch the key event as is. | 70 // If |context_| is not usable, then we can only dispatch the key event as is. |
| 82 // We only dispatch the key event to input method when the |context_| is an | 71 // We only dispatch the key event to input method when the |context_| is an |
| 83 // normal input field (not a password field). | 72 // normal input field (not a password field). |
| 84 // Note: We need to send the key event to ibus even if the |context_| is not | 73 // Note: We need to send the key event to ibus even if the |context_| is not |
| 85 // enabled, so that ibus can have a chance to enable the |context_|. | 74 // enabled, so that ibus can have a chance to enable the |context_|. |
| 86 if (!IsNonPasswordInputFieldFocused() || !GetEngine()) { | 75 if (!IsNonPasswordInputFieldFocused() || !GetEngine()) { |
| 87 if (event->type() == ET_KEY_PRESSED) { | 76 if (event->type() == ET_KEY_PRESSED) { |
| 88 if (ExecuteCharacterComposer(*event)) { | 77 if (ExecuteCharacterComposer(*event)) { |
| 89 // Treating as PostIME event if character composer handles key event and | 78 // Treating as PostIME event if character composer handles key event and |
| (...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 648 bool InputMethodChromeOS::IsNonPasswordInputFieldFocused() { | 637 bool InputMethodChromeOS::IsNonPasswordInputFieldFocused() { |
| 649 TextInputType type = GetTextInputType(); | 638 TextInputType type = GetTextInputType(); |
| 650 return (type != TEXT_INPUT_TYPE_NONE) && (type != TEXT_INPUT_TYPE_PASSWORD); | 639 return (type != TEXT_INPUT_TYPE_NONE) && (type != TEXT_INPUT_TYPE_PASSWORD); |
| 651 } | 640 } |
| 652 | 641 |
| 653 bool InputMethodChromeOS::IsInputFieldFocused() { | 642 bool InputMethodChromeOS::IsInputFieldFocused() { |
| 654 return GetTextInputType() != TEXT_INPUT_TYPE_NONE; | 643 return GetTextInputType() != TEXT_INPUT_TYPE_NONE; |
| 655 } | 644 } |
| 656 | 645 |
| 657 } // namespace ui | 646 } // namespace ui |
| OLD | NEW |