Chromium Code Reviews| 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 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 530 return true; | 530 return true; |
| 531 case TAKE_PARTIAL_SCREENSHOT: | 531 case TAKE_PARTIAL_SCREENSHOT: |
| 532 if (screenshot_delegate_.get()) { | 532 if (screenshot_delegate_.get()) { |
| 533 ash::PartialScreenshotView::StartPartialScreenshot( | 533 ash::PartialScreenshotView::StartPartialScreenshot( |
| 534 screenshot_delegate_.get()); | 534 screenshot_delegate_.get()); |
| 535 } | 535 } |
| 536 // Return true to prevent propagation of the key event because | 536 // Return true to prevent propagation of the key event because |
| 537 // this key combination is reserved for partial screenshot. | 537 // this key combination is reserved for partial screenshot. |
| 538 return true; | 538 return true; |
| 539 case TOGGLE_APP_LIST: | 539 case TOGGLE_APP_LIST: |
| 540 if (accelerator.key_code() == ui::VKEY_LWIN) { | 540 if (key_code == ui::VKEY_LWIN) { |
| 541 // For bindings on the Search key, activate the binding on press if the | 541 // If something else was pressed between the Search key (LWIN) |
| 542 // Search key is not acting as a modifier. Otherwise, activate it on | 542 // being pressed and released, then ignore the release of the |
| 543 // release. | 543 // Search key. |
| 544 const bool search_as_function_key = | 544 if (previous_event_type == ui::ET_KEY_RELEASED || |
|
sky
2012/12/17 22:29:00
nit: combine ifs.
danakj
2012/12/17 22:32:13
Done.
| |
| 545 Shell::GetInstance()->delegate()->IsSearchKeyActingAsFunctionKey(); | 545 previous_key_code != ui::VKEY_LWIN) |
| 546 const bool type_pressed = accelerator.type() == ui::ET_KEY_PRESSED; | |
| 547 | |
| 548 if (!search_as_function_key && !type_pressed) | |
| 549 return false; | 546 return false; |
| 550 if (search_as_function_key && type_pressed) | |
| 551 return false; | |
| 552 if (search_as_function_key && | |
| 553 // If something else was pressed between the Search key (LWIN) | |
| 554 // being pressed and released, then ignore the release of the | |
| 555 // Search key. | |
| 556 (previous_event_type == ui::ET_KEY_RELEASED || | |
| 557 previous_key_code != ui::VKEY_LWIN)) { | |
| 558 return false; | |
| 559 } | |
| 560 } | 547 } |
| 561 if (key_code == ui::VKEY_LWIN) | 548 if (key_code == ui::VKEY_LWIN) |
| 562 shell->delegate()->RecordUserMetricsAction(UMA_ACCEL_SEARCH_LWIN); | 549 shell->delegate()->RecordUserMetricsAction(UMA_ACCEL_SEARCH_LWIN); |
| 563 // When spoken feedback is enabled, we should neither toggle the list nor | 550 // When spoken feedback is enabled, we should neither toggle the list nor |
| 564 // consume the key since Search+Shift is one of the shortcuts the a11y | 551 // consume the key since Search+Shift is one of the shortcuts the a11y |
| 565 // feature uses. crbug.com/132296 | 552 // feature uses. crbug.com/132296 |
| 566 DCHECK_EQ(ui::VKEY_LWIN, accelerator.key_code()); | 553 DCHECK_EQ(ui::VKEY_LWIN, accelerator.key_code()); |
| 567 if (Shell::GetInstance()->delegate()->IsSpokenFeedbackEnabled()) | 554 if (Shell::GetInstance()->delegate()->IsSpokenFeedbackEnabled()) |
| 568 return false; | 555 return false; |
| 569 ash::Shell::GetInstance()->ToggleAppList(NULL); | 556 ash::Shell::GetInstance()->ToggleAppList(NULL); |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 851 keyboard_brightness_control_delegate) { | 838 keyboard_brightness_control_delegate) { |
| 852 keyboard_brightness_control_delegate_ = | 839 keyboard_brightness_control_delegate_ = |
| 853 keyboard_brightness_control_delegate.Pass(); | 840 keyboard_brightness_control_delegate.Pass(); |
| 854 } | 841 } |
| 855 | 842 |
| 856 bool AcceleratorController::CanHandleAccelerators() const { | 843 bool AcceleratorController::CanHandleAccelerators() const { |
| 857 return true; | 844 return true; |
| 858 } | 845 } |
| 859 | 846 |
| 860 } // namespace ash | 847 } // namespace ash |
| OLD | NEW |