Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1540)

Unified Diff: ash/common/accelerators/accelerator_controller.cc

Issue 2686833005: Fix the toggle caps lock accelerator not always working. (Closed)
Patch Set: Nits Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/accelerators/accelerator_controller_unittest.cc ('k') | ash/common/accelerators/accelerator_table.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/common/accelerators/accelerator_controller.cc
diff --git a/ash/common/accelerators/accelerator_controller.cc b/ash/common/accelerators/accelerator_controller.cc
index 28a4958ea56c7a4eb39c0ceb868a8f8b8346074d..17fd8591587648ba7ac006115dbf43402147650c 100644
--- a/ash/common/accelerators/accelerator_controller.cc
+++ b/ash/common/accelerators/accelerator_controller.cc
@@ -434,18 +434,37 @@ void HandleCycleUser(SessionStateDelegate::CycleUser cycle_user) {
bool CanHandleToggleCapsLock(const ui::Accelerator& accelerator,
const ui::Accelerator& previous_accelerator) {
- if (accelerator.key_code() == ui::VKEY_LWIN) {
- // If something else was pressed between the Search key (LWIN)
- // being pressed and released, then ignore the release of the
- // Search key.
- // TODO(danakj): Releasing Alt first breaks this: crbug.com/166495
- if (previous_accelerator.type() == ui::ET_KEY_RELEASED ||
- previous_accelerator.key_code() != ui::VKEY_LWIN)
- return false;
- }
chromeos::input_method::InputMethodManager* ime =
chromeos::input_method::InputMethodManager::Get();
- return ime && ime->GetImeKeyboard();
+
+ // This shortcust is set to be trigger on release. Either the current
+ // accelerator is a Search release or Alt release.
+ if (accelerator.key_code() == ui::VKEY_LWIN &&
+ accelerator.type() == ui::ET_KEY_RELEASED) {
+ // The previous must be either an Alt press or Search press:
+ // 1. Press Alt, Press Search, Release Search, Release Alt.
+ // 2. Press Search, Press Alt, Release Search, Release Alt.
+ if (previous_accelerator.type() == ui::ET_KEY_PRESSED &&
+ (previous_accelerator.key_code() == ui::VKEY_LWIN ||
+ previous_accelerator.key_code() == ui::VKEY_MENU)) {
+ return ime && ime->GetImeKeyboard();
+ }
+ }
+
+ // Alt release.
+ if (accelerator.key_code() == ui::VKEY_MENU &&
+ accelerator.type() == ui::ET_KEY_RELEASED) {
+ // The previous must be either an Alt press or Search press:
+ // 3. Press Alt, Press Search, Release Alt, Release Search.
+ // 4. Press Search, Press Alt, Release Alt, Release Search.
+ if (previous_accelerator.type() == ui::ET_KEY_PRESSED &&
+ (previous_accelerator.key_code() == ui::VKEY_LWIN ||
+ previous_accelerator.key_code() == ui::VKEY_MENU)) {
+ return ime && ime->GetImeKeyboard();
+ }
+ }
+
+ return false;
}
void HandleToggleCapsLock() {
« no previous file with comments | « ash/accelerators/accelerator_controller_unittest.cc ('k') | ash/common/accelerators/accelerator_table.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698