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

Unified 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: nits Created 8 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: ash/accelerators/accelerator_controller.cc
diff --git a/ash/accelerators/accelerator_controller.cc b/ash/accelerators/accelerator_controller.cc
index f6199cc4e3024597da006da8b2c15bc9c4db337e..a6a5fafa72a981c88a6407a19fbe4f2472753123 100644
--- a/ash/accelerators/accelerator_controller.cc
+++ b/ash/accelerators/accelerator_controller.cc
@@ -451,6 +451,8 @@ bool AcceleratorController::PerformAction(int action,
// Type of the previous accelerator. Used by NEXT_IME and DISABLE_CAPS_LOCK.
const ui::EventType previous_event_type =
context_.previous_accelerator().type();
+ const ui::KeyboardCode previous_key_code =
sky 2012/11/27 02:01:53 nit: since you only need this in TOGGLE_APP_LIST,
danakj 2012/11/27 02:27:18 Done.
+ context_.previous_accelerator().key_code();
// You *MUST* return true when some action is performed. Otherwise, this
// function might be called *twice*, via BrowserView::PreHandleKeyboardEvent
@@ -534,6 +536,28 @@ bool AcceleratorController::PerformAction(int action,
// this key combination is reserved for partial screenshot.
return true;
case TOGGLE_APP_LIST:
+ if (accelerator.key_code() == ui::VKEY_LWIN) {
+ // For bindings on the Search key, activate the binding on press if the
+ // Search key is not acting as a modifier. Otherwise, activate it on
+ // release.
+
+ bool search_as_function_key =
sky 2012/11/27 02:01:53 nit: if you're doing to use const like you did on
danakj 2012/11/27 02:27:18 Done.
+ Shell::GetInstance()->delegate()->IsSearchKeyActingAsFunctionKey();
+ bool type_pressed = accelerator.type() == ui::ET_KEY_PRESSED;
+
+ if (!search_as_function_key && !type_pressed)
+ return false;
+ if (search_as_function_key && type_pressed)
+ return false;
+ if (search_as_function_key &&
+ // If something else was pressed between the Search key (LWIN)
+ // being pressed and released, then ignore the release of the
+ // Search key.
+ (previous_event_type == ui::ET_KEY_RELEASED ||
+ previous_key_code != ui::VKEY_LWIN)) {
+ return false;
+ }
+ }
if (key_code == ui::VKEY_LWIN && shell->delegate())
shell->delegate()->RecordUserMetricsAction(UMA_ACCEL_SEARCH_LWIN);
// When spoken feedback is enabled, we should neither toggle the list nor
« no previous file with comments | « no previous file | ash/accelerators/accelerator_controller_unittest.cc » ('j') | chrome/browser/ui/ash/chrome_shell_delegate.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698