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

Side by Side Diff: ash/accelerators/accelerator_controller.cc

Issue 11578044: Enable Search-key modifiers for extended key shortcuts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | ash/accelerators/accelerator_controller_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | ash/accelerators/accelerator_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698