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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 | 102 |
103 // For linux_chromeos, the ime keyboard cannot track the caps lock state by | 103 // For linux_chromeos, the ime keyboard cannot track the caps lock state by |
104 // itself, so need to call SetCapsLockEnabled() method to reflect the caps | 104 // itself, so need to call SetCapsLockEnabled() method to reflect the caps |
105 // lock state by the key event. | 105 // lock state by the key event. |
106 if (!base::SysInfo::IsRunningOnChromeOS()) { | 106 if (!base::SysInfo::IsRunningOnChromeOS()) { |
107 chromeos::input_method::InputMethodManager* manager = | 107 chromeos::input_method::InputMethodManager* manager = |
108 chromeos::input_method::InputMethodManager::Get(); | 108 chromeos::input_method::InputMethodManager::Get(); |
109 if (manager) { | 109 if (manager) { |
110 chromeos::input_method::ImeKeyboard* keyboard = manager->GetImeKeyboard(); | 110 chromeos::input_method::ImeKeyboard* keyboard = manager->GetImeKeyboard(); |
111 if (keyboard && event->type() == ui::ET_KEY_PRESSED) { | 111 if (keyboard && event->type() == ui::ET_KEY_PRESSED) { |
112 bool caps = (event->key_code() == ui::VKEY_CAPITAL) | 112 keyboard->SetCapsLockEnabled((event->key_code() == ui::VKEY_CAPITAL) ? |
113 ? !keyboard->CapsLockIsEnabled() | 113 !keyboard->CapsLockIsEnabled() : event->IsCapsLockOn()); |
114 : (event->flags() & EF_CAPS_LOCK_DOWN); | |
115 keyboard->SetCapsLockEnabled(caps); | |
116 } | 114 } |
117 } | 115 } |
118 } | 116 } |
119 | 117 |
120 // If |context_| is not usable, then we can only dispatch the key event as is. | 118 // If |context_| is not usable, then we can only dispatch the key event as is. |
121 // We only dispatch the key event to input method when the |context_| is an | 119 // We only dispatch the key event to input method when the |context_| is an |
122 // normal input field (not a password field). | 120 // normal input field (not a password field). |
123 // Note: We need to send the key event to ibus even if the |context_| is not | 121 // Note: We need to send the key event to ibus even if the |context_| is not |
124 // enabled, so that ibus can have a chance to enable the |context_|. | 122 // enabled, so that ibus can have a chance to enable the |context_|. |
125 if (!IsNonPasswordInputFieldFocused() || !GetEngine()) { | 123 if (!IsNonPasswordInputFieldFocused() || !GetEngine()) { |
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
666 bool InputMethodChromeOS::IsNonPasswordInputFieldFocused() { | 664 bool InputMethodChromeOS::IsNonPasswordInputFieldFocused() { |
667 TextInputType type = GetTextInputType(); | 665 TextInputType type = GetTextInputType(); |
668 return (type != TEXT_INPUT_TYPE_NONE) && (type != TEXT_INPUT_TYPE_PASSWORD); | 666 return (type != TEXT_INPUT_TYPE_NONE) && (type != TEXT_INPUT_TYPE_PASSWORD); |
669 } | 667 } |
670 | 668 |
671 bool InputMethodChromeOS::IsInputFieldFocused() { | 669 bool InputMethodChromeOS::IsInputFieldFocused() { |
672 return GetTextInputType() != TEXT_INPUT_TYPE_NONE; | 670 return GetTextInputType() != TEXT_INPUT_TYPE_NONE; |
673 } | 671 } |
674 | 672 |
675 } // namespace ui | 673 } // namespace ui |
OLD | NEW |