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

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

Issue 9132004: Makes Ctrl-Shift-L work in AppList (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed accelerator_table Created 8 years, 11 months 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 "ash/caps_lock_delegate.h" 7 #include "ash/caps_lock_delegate.h"
8 #include "ash/launcher/launcher.h" 8 #include "ash/launcher/launcher.h"
9 #include "ash/launcher/launcher_model.h" 9 #include "ash/launcher/launcher_model.h"
10 #include "ash/screenshot_delegate.h" 10 #include "ash/screenshot_delegate.h"
11 #include "ash/shell.h" 11 #include "ash/shell.h"
12 #include "ash/shell_delegate.h"
12 #include "ash/shell_window_ids.h" 13 #include "ash/shell_window_ids.h"
13 #include "ash/wm/window_cycle_controller.h" 14 #include "ash/wm/window_cycle_controller.h"
14 #include "ui/aura/event.h" 15 #include "ui/aura/event.h"
15 #include "ui/aura/root_window.h" 16 #include "ui/aura/root_window.h"
16 #include "ui/base/accelerators/accelerator.h" 17 #include "ui/base/accelerators/accelerator.h"
17 #include "ui/base/accelerators/accelerator_manager.h" 18 #include "ui/base/accelerators/accelerator_manager.h"
18 #include "ui/gfx/compositor/debug_utils.h" 19 #include "ui/gfx/compositor/debug_utils.h"
19 #include "ui/gfx/compositor/layer_animation_sequence.h" 20 #include "ui/gfx/compositor/layer_animation_sequence.h"
20 #include "ui/gfx/compositor/layer_animator.h" 21 #include "ui/gfx/compositor/layer_animator.h"
21 #include "ui/gfx/compositor/screen_rotation.h" 22 #include "ui/gfx/compositor/screen_rotation.h"
22 23
23 namespace { 24 namespace {
24 25
25 enum AcceleratorAction { 26 enum AcceleratorAction {
26 CYCLE_BACKWARD, 27 CYCLE_BACKWARD,
27 CYCLE_FORWARD, 28 CYCLE_FORWARD,
29 #if defined(OS_CHROMEOS)
30 LOCK_SCREEN,
31 #endif
28 TAKE_SCREENSHOT, 32 TAKE_SCREENSHOT,
29 TOGGLE_CAPS_LOCK, 33 TOGGLE_CAPS_LOCK,
30 #if !defined(NDEBUG) 34 #if !defined(NDEBUG)
31 ROTATE_SCREEN, 35 ROTATE_SCREEN,
32 PRINT_LAYER_HIERARCHY, 36 PRINT_LAYER_HIERARCHY,
33 TOGGLE_ROOT_WINDOW_FULL_SCREEN, 37 TOGGLE_ROOT_WINDOW_FULL_SCREEN,
34 #endif 38 #endif
35 }; 39 };
36 40
37 // Accelerators handled by AcceleratorController. 41 // Accelerators handled by AcceleratorController.
38 struct AcceleratorData { 42 struct AcceleratorData {
39 ui::KeyboardCode keycode; 43 ui::KeyboardCode keycode;
40 bool shift; 44 bool shift;
41 bool ctrl; 45 bool ctrl;
42 bool alt; 46 bool alt;
43 AcceleratorAction action; 47 AcceleratorAction action;
44 } kAcceleratorData[] = { 48 } kAcceleratorData[] = {
45 { ui::VKEY_TAB, false, false, true, CYCLE_FORWARD }, 49 { ui::VKEY_TAB, false, false, true, CYCLE_FORWARD },
46 { ui::VKEY_TAB, true, false, true, CYCLE_BACKWARD }, 50 { ui::VKEY_TAB, true, false, true, CYCLE_BACKWARD },
47 { ui::VKEY_F5, false, false, false, CYCLE_FORWARD }, 51 { ui::VKEY_F5, false, false, false, CYCLE_FORWARD },
52 #if defined(OS_CHROMEOS)
53 { ui::VKEY_L, true, true, false, LOCK_SCREEN },
54 #endif
48 { ui::VKEY_F5, true, false, false, CYCLE_BACKWARD }, 55 { ui::VKEY_F5, true, false, false, CYCLE_BACKWARD },
49 { ui::VKEY_F5, false, true, false, TAKE_SCREENSHOT }, 56 { ui::VKEY_F5, false, true, false, TAKE_SCREENSHOT },
50 { ui::VKEY_PRINT, false, false, false, TAKE_SCREENSHOT }, 57 { ui::VKEY_PRINT, false, false, false, TAKE_SCREENSHOT },
51 // On Chrome OS, Search key is mapped to LWIN. 58 // On Chrome OS, Search key is mapped to LWIN.
52 { ui::VKEY_LWIN, true, false, false, TOGGLE_CAPS_LOCK }, 59 { ui::VKEY_LWIN, true, false, false, TOGGLE_CAPS_LOCK },
53 #if !defined(NDEBUG) 60 #if !defined(NDEBUG)
54 { ui::VKEY_HOME, false, true, false, ROTATE_SCREEN }, 61 { ui::VKEY_HOME, false, true, false, ROTATE_SCREEN },
55 { ui::VKEY_F11, false, true, false, TOGGLE_ROOT_WINDOW_FULL_SCREEN }, 62 { ui::VKEY_F11, false, true, false, TOGGLE_ROOT_WINDOW_FULL_SCREEN },
56 { ui::VKEY_L, false, false, true, PRINT_LAYER_HIERARCHY }, 63 { ui::VKEY_L, false, false, true, PRINT_LAYER_HIERARCHY },
57 // For testing on systems where Alt-Tab is already mapped. 64 // For testing on systems where Alt-Tab is already mapped.
58 { ui::VKEY_W, false, false, true, CYCLE_FORWARD }, 65 { ui::VKEY_W, false, false, true, CYCLE_FORWARD },
59 { ui::VKEY_W, true, false, true, CYCLE_BACKWARD }, 66 { ui::VKEY_W, true, false, true, CYCLE_BACKWARD },
60 #endif 67 #endif
61 }; 68 };
62 69
63 bool HandleCycleWindow(ash::WindowCycleController::Direction direction, 70 bool HandleCycleWindow(ash::WindowCycleController::Direction direction,
64 bool is_alt_down) { 71 bool is_alt_down) {
65 ash::Shell::GetInstance()-> 72 ash::Shell::GetInstance()->
66 window_cycle_controller()->HandleCycleWindow(direction, is_alt_down); 73 window_cycle_controller()->HandleCycleWindow(direction, is_alt_down);
67 // Always report we handled the key, even if the window didn't change. 74 // Always report we handled the key, even if the window didn't change.
68 return true; 75 return true;
69 } 76 }
70 77
78 #if defined(OS_CHROMEOS)
79 bool HandleLock() {
80 ash::ShellDelegate* delegate = ash::Shell::GetInstance()->delegate();
81 if (!delegate)
82 return false;
83 delegate->LockScreen();
84 return true;
85 }
86 #endif
87
71 #if !defined(NDEBUG) 88 #if !defined(NDEBUG)
72 // Rotates the screen. 89 // Rotates the screen.
73 bool HandleRotateScreen() { 90 bool HandleRotateScreen() {
74 static int i = 0; 91 static int i = 0;
75 int delta = 0; 92 int delta = 0;
76 switch (i) { 93 switch (i) {
77 case 0: delta = 90; break; 94 case 0: delta = 90; break;
78 case 1: delta = 90; break; 95 case 1: delta = 90; break;
79 case 2: delta = 90; break; 96 case 2: delta = 90; break;
80 case 3: delta = 90; break; 97 case 3: delta = 90; break;
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 accelerator.IsAltDown()); 205 accelerator.IsAltDown());
189 case TAKE_SCREENSHOT: 206 case TAKE_SCREENSHOT:
190 if (screenshot_delegate_.get()) 207 if (screenshot_delegate_.get())
191 screenshot_delegate_->HandleTakeScreenshot(); 208 screenshot_delegate_->HandleTakeScreenshot();
192 // Return true to prevent propagation of the key event. 209 // Return true to prevent propagation of the key event.
193 return true; 210 return true;
194 case TOGGLE_CAPS_LOCK: 211 case TOGGLE_CAPS_LOCK:
195 if (caps_lock_delegate_.get()) 212 if (caps_lock_delegate_.get())
196 return caps_lock_delegate_->HandleToggleCapsLock(); 213 return caps_lock_delegate_->HandleToggleCapsLock();
197 break; 214 break;
215 #if defined(OS_CHROMEOS)
216 case LOCK_SCREEN:
217 return HandleLock();
218 #endif
198 #if !defined(NDEBUG) 219 #if !defined(NDEBUG)
199 case ROTATE_SCREEN: 220 case ROTATE_SCREEN:
200 return HandleRotateScreen(); 221 return HandleRotateScreen();
201 case TOGGLE_ROOT_WINDOW_FULL_SCREEN: 222 case TOGGLE_ROOT_WINDOW_FULL_SCREEN:
202 return HandleToggleRootWindowFullScreen(); 223 return HandleToggleRootWindowFullScreen();
203 case PRINT_LAYER_HIERARCHY: 224 case PRINT_LAYER_HIERARCHY:
204 return HandlePrintLayerHierarchy(); 225 return HandlePrintLayerHierarchy();
205 #endif 226 #endif
206 default: 227 default:
207 NOTREACHED() << "Unhandled action " << it->second;; 228 NOTREACHED() << "Unhandled action " << it->second;;
208 } 229 }
209 return false; 230 return false;
210 } 231 }
211 232
212 bool AcceleratorController::CanHandleAccelerators() const { 233 bool AcceleratorController::CanHandleAccelerators() const {
213 return true; 234 return true;
214 } 235 }
215 236
216 } // namespace ash 237 } // 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