| 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 "ash/common/accelerators/accelerator_controller.h" | 5 #include "ash/common/accelerators/accelerator_controller.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "ash/common/accelerators/accelerator_commands.h" | 9 #include "ash/common/accelerators/accelerator_commands.h" |
| 10 #include "ash/common/accelerators/accelerator_controller_delegate.h" | 10 #include "ash/common/accelerators/accelerator_controller_delegate.h" |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 break; | 427 break; |
| 428 case SessionStateDelegate::CYCLE_TO_PREVIOUS_USER: | 428 case SessionStateDelegate::CYCLE_TO_PREVIOUS_USER: |
| 429 base::RecordAction(UserMetricsAction("Accel_Switch_To_Previous_User")); | 429 base::RecordAction(UserMetricsAction("Accel_Switch_To_Previous_User")); |
| 430 break; | 430 break; |
| 431 } | 431 } |
| 432 WmShell::Get()->GetSessionStateDelegate()->CycleActiveUser(cycle_user); | 432 WmShell::Get()->GetSessionStateDelegate()->CycleActiveUser(cycle_user); |
| 433 } | 433 } |
| 434 | 434 |
| 435 bool CanHandleToggleCapsLock(const ui::Accelerator& accelerator, | 435 bool CanHandleToggleCapsLock(const ui::Accelerator& accelerator, |
| 436 const ui::Accelerator& previous_accelerator) { | 436 const ui::Accelerator& previous_accelerator) { |
| 437 if (accelerator.key_code() == ui::VKEY_LWIN) { | |
| 438 // If something else was pressed between the Search key (LWIN) | |
| 439 // being pressed and released, then ignore the release of the | |
| 440 // Search key. | |
| 441 // TODO(danakj): Releasing Alt first breaks this: crbug.com/166495 | |
| 442 if (previous_accelerator.type() == ui::ET_KEY_RELEASED || | |
| 443 previous_accelerator.key_code() != ui::VKEY_LWIN) | |
| 444 return false; | |
| 445 } | |
| 446 chromeos::input_method::InputMethodManager* ime = | 437 chromeos::input_method::InputMethodManager* ime = |
| 447 chromeos::input_method::InputMethodManager::Get(); | 438 chromeos::input_method::InputMethodManager::Get(); |
| 448 return ime && ime->GetImeKeyboard(); | 439 |
| 440 // This shortcust is set to be trigger on release. Either the current |
| 441 // accelerator is a Search release or Alt release. |
| 442 if (accelerator.key_code() == ui::VKEY_LWIN && |
| 443 accelerator.type() == ui::ET_KEY_RELEASED) { |
| 444 // The previous must be either an Alt press or Search press: |
| 445 // 1. Press Alt, Press Search, Release Search, Release Alt. |
| 446 // 2. Press Search, Press Alt, Release Search, Release Alt. |
| 447 if (previous_accelerator.type() == ui::ET_KEY_PRESSED && |
| 448 (previous_accelerator.key_code() == ui::VKEY_LWIN || |
| 449 previous_accelerator.key_code() == ui::VKEY_MENU)) { |
| 450 return ime && ime->GetImeKeyboard(); |
| 451 } |
| 452 } |
| 453 |
| 454 // Alt release. |
| 455 if (accelerator.key_code() == ui::VKEY_MENU && |
| 456 accelerator.type() == ui::ET_KEY_RELEASED) { |
| 457 // The previous must be either an Alt press or Search press: |
| 458 // 3. Press Alt, Press Search, Release Alt, Release Search. |
| 459 // 4. Press Search, Press Alt, Release Alt, Release Search. |
| 460 if (previous_accelerator.type() == ui::ET_KEY_PRESSED && |
| 461 (previous_accelerator.key_code() == ui::VKEY_LWIN || |
| 462 previous_accelerator.key_code() == ui::VKEY_MENU)) { |
| 463 return ime && ime->GetImeKeyboard(); |
| 464 } |
| 465 } |
| 466 |
| 467 return false; |
| 449 } | 468 } |
| 450 | 469 |
| 451 void HandleToggleCapsLock() { | 470 void HandleToggleCapsLock() { |
| 452 base::RecordAction(UserMetricsAction("Accel_Toggle_Caps_Lock")); | 471 base::RecordAction(UserMetricsAction("Accel_Toggle_Caps_Lock")); |
| 453 chromeos::input_method::InputMethodManager* ime = | 472 chromeos::input_method::InputMethodManager* ime = |
| 454 chromeos::input_method::InputMethodManager::Get(); | 473 chromeos::input_method::InputMethodManager::Get(); |
| 455 chromeos::input_method::ImeKeyboard* keyboard = ime->GetImeKeyboard(); | 474 chromeos::input_method::ImeKeyboard* keyboard = ime->GetImeKeyboard(); |
| 456 keyboard->SetCapsLockEnabled(!keyboard->CapsLockIsEnabled()); | 475 keyboard->SetCapsLockEnabled(!keyboard->CapsLockIsEnabled()); |
| 457 } | 476 } |
| 458 | 477 |
| (...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1165 data->old_shortcut_id, data->new_shortcut_id); | 1184 data->old_shortcut_id, data->new_shortcut_id); |
| 1166 } | 1185 } |
| 1167 | 1186 |
| 1168 if (!data->deprecated_enabled) | 1187 if (!data->deprecated_enabled) |
| 1169 return AcceleratorProcessingStatus::STOP; | 1188 return AcceleratorProcessingStatus::STOP; |
| 1170 | 1189 |
| 1171 return AcceleratorProcessingStatus::PROCEED; | 1190 return AcceleratorProcessingStatus::PROCEED; |
| 1172 } | 1191 } |
| 1173 | 1192 |
| 1174 } // namespace ash | 1193 } // namespace ash |
| OLD | NEW |