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

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

Issue 11421055: Add power-user keyboard mode for ChromeOS with Search key acting as a typical Fn key. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ToggleAppList on press 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 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 // should never be suspended. 442 // should never be suspended.
443 const bool gesture_event = key_code == ui::VKEY_UNKNOWN; 443 const bool gesture_event = key_code == ui::VKEY_UNKNOWN;
444 444
445 // Ignore accelerators invoked as repeated (while holding a key for a long 445 // Ignore accelerators invoked as repeated (while holding a key for a long
446 // time, if their handling is nonrepeatable. 446 // time, if their handling is nonrepeatable.
447 if (nonrepeatable_actions_.find(action) != nonrepeatable_actions_.end() && 447 if (nonrepeatable_actions_.find(action) != nonrepeatable_actions_.end() &&
448 context_.repeated() && !gesture_event) { 448 context_.repeated() && !gesture_event) {
449 return true; 449 return true;
450 } 450 }
451 // Type of the previous accelerator. Used by NEXT_IME and DISABLE_CAPS_LOCK. 451 // Type of the previous accelerator. Used by NEXT_IME and DISABLE_CAPS_LOCK.
452 const ui::EventType previous_event_type = 452 const ui::EventType previous_event_type =
Yusuke Sato 2012/11/27 01:04:38 nit: could you define previous_key_code here? it's
danakj 2012/11/27 01:44:32 Done.
453 context_.previous_accelerator().type(); 453 context_.previous_accelerator().type();
454 454
455 // You *MUST* return true when some action is performed. Otherwise, this 455 // You *MUST* return true when some action is performed. Otherwise, this
456 // function might be called *twice*, via BrowserView::PreHandleKeyboardEvent 456 // function might be called *twice*, via BrowserView::PreHandleKeyboardEvent
457 // and BrowserView::HandleKeyboardEvent, for a single accelerator press. 457 // and BrowserView::HandleKeyboardEvent, for a single accelerator press.
458 switch (action) { 458 switch (action) {
459 case CYCLE_BACKWARD_MRU: 459 case CYCLE_BACKWARD_MRU:
460 if (key_code == ui::VKEY_TAB && shell->delegate()) 460 if (key_code == ui::VKEY_TAB && shell->delegate())
461 shell->delegate()->RecordUserMetricsAction(UMA_ACCEL_PREVWINDOW_TAB); 461 shell->delegate()->RecordUserMetricsAction(UMA_ACCEL_PREVWINDOW_TAB);
462 return HandleCycleWindowMRU(WindowCycleController::BACKWARD, 462 return HandleCycleWindowMRU(WindowCycleController::BACKWARD,
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 bool search_as_function_key =
543 Shell::GetInstance()->delegate()->IsSearchKeyActingAsFunctionKey();
544 bool type_pressed = accelerator.type() == ui::ET_KEY_PRESSED;
545
546 if (!search_as_function_key && !type_pressed)
547 return false;
548 if (search_as_function_key && type_pressed)
549 return false;
550 if (search_as_function_key &&
551 // See: case NEXT_IME.
552 (previous_event_type == ui::ET_KEY_RELEASED ||
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 (accelerator.type() == ui::ET_KEY_RELEASED &&
557 context_.previous_accelerator().key_code() != ui::VKEY_LWIN))) {
Yusuke Sato 2012/11/27 01:04:38 nit: previous_key_code != ui::VKEY_LWIN
danakj 2012/11/27 01:44:32 Done.
558 return false;
559 }
560 }
537 if (key_code == ui::VKEY_LWIN && shell->delegate()) 561 if (key_code == ui::VKEY_LWIN && shell->delegate())
538 shell->delegate()->RecordUserMetricsAction(UMA_ACCEL_SEARCH_LWIN); 562 shell->delegate()->RecordUserMetricsAction(UMA_ACCEL_SEARCH_LWIN);
539 // When spoken feedback is enabled, we should neither toggle the list nor 563 // 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 564 // consume the key since Search+Shift is one of the shortcuts the a11y
541 // feature uses. crbug.com/132296 565 // feature uses. crbug.com/132296
542 DCHECK_EQ(ui::VKEY_LWIN, accelerator.key_code()); 566 DCHECK_EQ(ui::VKEY_LWIN, accelerator.key_code());
543 if (Shell::GetInstance()->delegate()->IsSpokenFeedbackEnabled()) 567 if (Shell::GetInstance()->delegate()->IsSpokenFeedbackEnabled())
544 return false; 568 return false;
545 ash::Shell::GetInstance()->ToggleAppList(); 569 ash::Shell::GetInstance()->ToggleAppList();
546 return true; 570 return true;
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
869 keyboard_brightness_control_delegate) { 893 keyboard_brightness_control_delegate) {
870 keyboard_brightness_control_delegate_ = 894 keyboard_brightness_control_delegate_ =
871 keyboard_brightness_control_delegate.Pass(); 895 keyboard_brightness_control_delegate.Pass();
872 } 896 }
873 897
874 bool AcceleratorController::CanHandleAccelerators() const { 898 bool AcceleratorController::CanHandleAccelerators() const {
875 return true; 899 return true;
876 } 900 }
877 901
878 } // namespace ash 902 } // 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