| 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/accelerators/accelerator_controller.h" | 5 #include "ash/accelerators/accelerator_controller.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 return true; | 527 return true; |
| 528 case TAKE_PARTIAL_SCREENSHOT: | 528 case TAKE_PARTIAL_SCREENSHOT: |
| 529 if (screenshot_delegate_.get()) { | 529 if (screenshot_delegate_.get()) { |
| 530 ash::PartialScreenshotView::StartPartialScreenshot( | 530 ash::PartialScreenshotView::StartPartialScreenshot( |
| 531 screenshot_delegate_.get()); | 531 screenshot_delegate_.get()); |
| 532 } | 532 } |
| 533 // Return true to prevent propagation of the key event because | 533 // Return true to prevent propagation of the key event because |
| 534 // this key combination is reserved for partial screenshot. | 534 // this key combination is reserved for partial screenshot. |
| 535 return true; | 535 return true; |
| 536 case TOGGLE_APP_LIST: | 536 case TOGGLE_APP_LIST: |
| 537 if (accelerator.key_code() == ui::VKEY_LWIN) { |
| 538 // For bindings on the Search key, activate the binding on press if the |
| 539 // Search key is not acting as a modifier. Otherwise, activate it on |
| 540 // release. |
| 541 |
| 542 const ui::KeyboardCode previous_key_code = |
| 543 context_.previous_accelerator().key_code(); |
| 544 |
| 545 const bool search_as_function_key = |
| 546 Shell::GetInstance()->delegate()->IsSearchKeyActingAsFunctionKey(); |
| 547 const bool type_pressed = accelerator.type() == ui::ET_KEY_PRESSED; |
| 548 |
| 549 if (!search_as_function_key && !type_pressed) |
| 550 return false; |
| 551 if (search_as_function_key && type_pressed) |
| 552 return false; |
| 553 if (search_as_function_key && |
| 554 // If something else was pressed between the Search key (LWIN) |
| 555 // being pressed and released, then ignore the release of the |
| 556 // Search key. |
| 557 (previous_event_type == ui::ET_KEY_RELEASED || |
| 558 previous_key_code != ui::VKEY_LWIN)) { |
| 559 return false; |
| 560 } |
| 561 } |
| 537 if (key_code == ui::VKEY_LWIN && shell->delegate()) | 562 if (key_code == ui::VKEY_LWIN && shell->delegate()) |
| 538 shell->delegate()->RecordUserMetricsAction(UMA_ACCEL_SEARCH_LWIN); | 563 shell->delegate()->RecordUserMetricsAction(UMA_ACCEL_SEARCH_LWIN); |
| 539 // When spoken feedback is enabled, we should neither toggle the list nor | 564 // When spoken feedback is enabled, we should neither toggle the list nor |
| 540 // consume the key since Search+Shift is one of the shortcuts the a11y | 565 // consume the key since Search+Shift is one of the shortcuts the a11y |
| 541 // feature uses. crbug.com/132296 | 566 // feature uses. crbug.com/132296 |
| 542 DCHECK_EQ(ui::VKEY_LWIN, accelerator.key_code()); | 567 DCHECK_EQ(ui::VKEY_LWIN, accelerator.key_code()); |
| 543 if (Shell::GetInstance()->delegate()->IsSpokenFeedbackEnabled()) | 568 if (Shell::GetInstance()->delegate()->IsSpokenFeedbackEnabled()) |
| 544 return false; | 569 return false; |
| 545 ash::Shell::GetInstance()->ToggleAppList(); | 570 ash::Shell::GetInstance()->ToggleAppList(); |
| 546 return true; | 571 return true; |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 869 keyboard_brightness_control_delegate) { | 894 keyboard_brightness_control_delegate) { |
| 870 keyboard_brightness_control_delegate_ = | 895 keyboard_brightness_control_delegate_ = |
| 871 keyboard_brightness_control_delegate.Pass(); | 896 keyboard_brightness_control_delegate.Pass(); |
| 872 } | 897 } |
| 873 | 898 |
| 874 bool AcceleratorController::CanHandleAccelerators() const { | 899 bool AcceleratorController::CanHandleAccelerators() const { |
| 875 return true; | 900 return true; |
| 876 } | 901 } |
| 877 | 902 |
| 878 } // namespace ash | 903 } // namespace ash |
| OLD | NEW |