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

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

Issue 9242003: Handle Caps Lock short cut (Shift+Search) in ash [part 1 of 2]. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review fix 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
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/launcher/launcher.h" 8 #include "ash/launcher/launcher.h"
8 #include "ash/launcher/launcher_model.h" 9 #include "ash/launcher/launcher_model.h"
9 #include "ash/screenshot_delegate.h" 10 #include "ash/screenshot_delegate.h"
10 #include "ash/shell.h" 11 #include "ash/shell.h"
11 #include "ash/shell_window_ids.h" 12 #include "ash/shell_window_ids.h"
12 #include "ash/wm/window_cycle_controller.h" 13 #include "ash/wm/window_cycle_controller.h"
13 #include "ui/aura/event.h" 14 #include "ui/aura/event.h"
14 #include "ui/aura/root_window.h" 15 #include "ui/aura/root_window.h"
15 #include "ui/base/accelerators/accelerator.h" 16 #include "ui/base/accelerators/accelerator.h"
16 #include "ui/base/accelerators/accelerator_manager.h" 17 #include "ui/base/accelerators/accelerator_manager.h"
17 #include "ui/gfx/compositor/debug_utils.h" 18 #include "ui/gfx/compositor/debug_utils.h"
18 #include "ui/gfx/compositor/layer_animation_sequence.h" 19 #include "ui/gfx/compositor/layer_animation_sequence.h"
19 #include "ui/gfx/compositor/layer_animator.h" 20 #include "ui/gfx/compositor/layer_animator.h"
20 #include "ui/gfx/compositor/screen_rotation.h" 21 #include "ui/gfx/compositor/screen_rotation.h"
21 22
22 namespace { 23 namespace {
23 24
24 enum AcceleratorAction { 25 enum AcceleratorAction {
25 CYCLE_BACKWARD, 26 CYCLE_BACKWARD,
26 CYCLE_FORWARD, 27 CYCLE_FORWARD,
27 TAKE_SCREENSHOT, 28 TAKE_SCREENSHOT,
29 TOGGLE_CAPS_LOCK,
28 #if !defined(NDEBUG) 30 #if !defined(NDEBUG)
29 ROTATE_SCREEN, 31 ROTATE_SCREEN,
30 PRINT_LAYER_HIERARCHY, 32 PRINT_LAYER_HIERARCHY,
31 TOGGLE_ROOT_WINDOW_FULL_SCREEN, 33 TOGGLE_ROOT_WINDOW_FULL_SCREEN,
32 #endif 34 #endif
33 }; 35 };
34 36
35 // Accelerators handled by AcceleratorController. 37 // Accelerators handled by AcceleratorController.
36 struct AcceleratorData { 38 struct AcceleratorData {
37 ui::KeyboardCode keycode; 39 ui::KeyboardCode keycode;
38 bool shift; 40 bool shift;
39 bool ctrl; 41 bool ctrl;
40 bool alt; 42 bool alt;
41 AcceleratorAction action; 43 AcceleratorAction action;
42 } kAcceleratorData[] = { 44 } kAcceleratorData[] = {
43 { ui::VKEY_TAB, false, false, true, CYCLE_FORWARD }, 45 { ui::VKEY_TAB, false, false, true, CYCLE_FORWARD },
44 { ui::VKEY_TAB, true, false, true, CYCLE_BACKWARD }, 46 { ui::VKEY_TAB, true, false, true, CYCLE_BACKWARD },
45 { ui::VKEY_F5, false, false, false, CYCLE_FORWARD }, 47 { ui::VKEY_F5, false, false, false, CYCLE_FORWARD },
46 { ui::VKEY_F5, true, false, false, CYCLE_BACKWARD }, 48 { ui::VKEY_F5, true, false, false, CYCLE_BACKWARD },
47 { ui::VKEY_F5, false, true, false, TAKE_SCREENSHOT }, 49 { ui::VKEY_F5, false, true, false, TAKE_SCREENSHOT },
48 { ui::VKEY_PRINT, false, false, false, TAKE_SCREENSHOT }, 50 { ui::VKEY_PRINT, false, false, false, TAKE_SCREENSHOT },
51 // On Chrome OS, Search key is mapped to LWIN.
52 { ui::VKEY_LWIN, true, false, false, TOGGLE_CAPS_LOCK },
49 #if !defined(NDEBUG) 53 #if !defined(NDEBUG)
50 { ui::VKEY_HOME, false, true, false, ROTATE_SCREEN }, 54 { ui::VKEY_HOME, false, true, false, ROTATE_SCREEN },
51 { ui::VKEY_F11, false, true, false, TOGGLE_ROOT_WINDOW_FULL_SCREEN }, 55 { ui::VKEY_F11, false, true, false, TOGGLE_ROOT_WINDOW_FULL_SCREEN },
52 { ui::VKEY_L, false, false, true, PRINT_LAYER_HIERARCHY }, 56 { ui::VKEY_L, false, false, true, PRINT_LAYER_HIERARCHY },
53 // For testing on systems where Alt-Tab is already mapped. 57 // For testing on systems where Alt-Tab is already mapped.
54 { ui::VKEY_W, false, false, true, CYCLE_FORWARD }, 58 { ui::VKEY_W, false, false, true, CYCLE_FORWARD },
55 { ui::VKEY_W, true, false, true, CYCLE_BACKWARD }, 59 { ui::VKEY_W, true, false, true, CYCLE_BACKWARD },
56 #endif 60 #endif
57 }; 61 };
58 62
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 159
156 bool AcceleratorController::Process(const ui::Accelerator& accelerator) { 160 bool AcceleratorController::Process(const ui::Accelerator& accelerator) {
157 return accelerator_manager_->Process(accelerator); 161 return accelerator_manager_->Process(accelerator);
158 } 162 }
159 163
160 void AcceleratorController::SetScreenshotDelegate( 164 void AcceleratorController::SetScreenshotDelegate(
161 ScreenshotDelegate* screenshot_delegate) { 165 ScreenshotDelegate* screenshot_delegate) {
162 screenshot_delegate_.reset(screenshot_delegate); 166 screenshot_delegate_.reset(screenshot_delegate);
163 } 167 }
164 168
169 void AcceleratorController::SetCapsLockDelegate(
170 scoped_ptr<CapsLockDelegate> caps_lock_delegate) {
171 caps_lock_delegate_.swap(caps_lock_delegate);
172 }
173
165 //////////////////////////////////////////////////////////////////////////////// 174 ////////////////////////////////////////////////////////////////////////////////
166 // AcceleratorController, ui::AcceleratorTarget implementation: 175 // AcceleratorController, ui::AcceleratorTarget implementation:
167 176
168 bool AcceleratorController::AcceleratorPressed( 177 bool AcceleratorController::AcceleratorPressed(
169 const ui::Accelerator& accelerator) { 178 const ui::Accelerator& accelerator) {
170 std::map<ui::Accelerator, int>::const_iterator it = 179 std::map<ui::Accelerator, int>::const_iterator it =
171 accelerators_.find(accelerator); 180 accelerators_.find(accelerator);
172 DCHECK(it != accelerators_.end()); 181 DCHECK(it != accelerators_.end());
173 switch (static_cast<AcceleratorAction>(it->second)) { 182 switch (static_cast<AcceleratorAction>(it->second)) {
174 case CYCLE_BACKWARD: 183 case CYCLE_BACKWARD:
175 return HandleCycleWindow(WindowCycleController::BACKWARD, 184 return HandleCycleWindow(WindowCycleController::BACKWARD,
176 accelerator.IsAltDown()); 185 accelerator.IsAltDown());
177 case CYCLE_FORWARD: 186 case CYCLE_FORWARD:
178 return HandleCycleWindow(WindowCycleController::FORWARD, 187 return HandleCycleWindow(WindowCycleController::FORWARD,
179 accelerator.IsAltDown()); 188 accelerator.IsAltDown());
180 case TAKE_SCREENSHOT: 189 case TAKE_SCREENSHOT:
181 if (screenshot_delegate_.get()) 190 if (screenshot_delegate_.get())
182 screenshot_delegate_->HandleTakeScreenshot(); 191 screenshot_delegate_->HandleTakeScreenshot();
183 // Return true to prevent propagation of the key event. 192 // Return true to prevent propagation of the key event.
184 return true; 193 return true;
194 case TOGGLE_CAPS_LOCK:
195 if (caps_lock_delegate_.get())
196 return caps_lock_delegate_->HandleToggleCapsLock();
197 break;
185 #if !defined(NDEBUG) 198 #if !defined(NDEBUG)
186 case ROTATE_SCREEN: 199 case ROTATE_SCREEN:
187 return HandleRotateScreen(); 200 return HandleRotateScreen();
188 case TOGGLE_ROOT_WINDOW_FULL_SCREEN: 201 case TOGGLE_ROOT_WINDOW_FULL_SCREEN:
189 return HandleToggleRootWindowFullScreen(); 202 return HandleToggleRootWindowFullScreen();
190 case PRINT_LAYER_HIERARCHY: 203 case PRINT_LAYER_HIERARCHY:
191 return HandlePrintLayerHierarchy(); 204 return HandlePrintLayerHierarchy();
192 #endif 205 #endif
193 default: 206 default:
194 NOTREACHED() << "Unhandled action " << it->second;; 207 NOTREACHED() << "Unhandled action " << it->second;;
195 } 208 }
196 return false; 209 return false;
197 } 210 }
198 211
199 bool AcceleratorController::CanHandleAccelerators() const { 212 bool AcceleratorController::CanHandleAccelerators() const {
200 return true; 213 return true;
201 } 214 }
202 215
203 } // namespace ash 216 } // namespace ash
OLDNEW
« no previous file with comments | « ash/accelerators/accelerator_controller.h ('k') | ash/accelerators/accelerator_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698