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

Side by Side Diff: ui/aura_shell/shell_accelerator_controller.cc

Issue 8817018: Implement cycle window forward/backward by keyboard shortcuts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 9 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 | « ui/aura_shell/shell.cc ('k') | ui/aura_shell/shell_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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "ui/aura_shell/shell_accelerator_controller.h" 5 #include "ui/aura_shell/shell_accelerator_controller.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "ui/aura/event.h" 8 #include "ui/aura/event.h"
9 #include "ui/aura/root_window.h" 9 #include "ui/aura/root_window.h"
10 #include "ui/aura_shell/launcher/launcher.h"
11 #include "ui/aura_shell/launcher/launcher_model.h"
10 #include "ui/aura_shell/shell.h" 12 #include "ui/aura_shell/shell.h"
13 #include "ui/aura_shell/shell_window_ids.h"
14 #include "ui/aura_shell/window_util.h"
11 #include "ui/base/accelerators/accelerator.h" 15 #include "ui/base/accelerators/accelerator.h"
12 #include "ui/base/accelerators/accelerator_manager.h" 16 #include "ui/base/accelerators/accelerator_manager.h"
13 #include "ui/gfx/compositor/debug_utils.h" 17 #include "ui/gfx/compositor/debug_utils.h"
14 #include "ui/gfx/compositor/layer_animation_sequence.h" 18 #include "ui/gfx/compositor/layer_animation_sequence.h"
15 #include "ui/gfx/compositor/layer_animator.h" 19 #include "ui/gfx/compositor/layer_animator.h"
16 #include "ui/gfx/compositor/screen_rotation.h" 20 #include "ui/gfx/compositor/screen_rotation.h"
17 21
18 namespace { 22 namespace {
19 23
20 enum AcceleratorAction { 24 enum AcceleratorAction {
(...skipping 19 matching lines...) Expand all
40 { ui::VKEY_TAB, false, false, true, CYCLE_FORWARD }, 44 { ui::VKEY_TAB, false, false, true, CYCLE_FORWARD },
41 { ui::VKEY_F5, false, true, false, TAKE_SCREENSHOT }, 45 { ui::VKEY_F5, false, true, false, TAKE_SCREENSHOT },
42 { ui::VKEY_PRINT, false, false, false, TAKE_SCREENSHOT }, 46 { ui::VKEY_PRINT, false, false, false, TAKE_SCREENSHOT },
43 #if !defined(NDEBUG) 47 #if !defined(NDEBUG)
44 { ui::VKEY_HOME, false, true, false, ROTATE_SCREEN }, 48 { ui::VKEY_HOME, false, true, false, ROTATE_SCREEN },
45 { ui::VKEY_F11, false, true, false, TOGGLE_ROOT_WINDOW_FULL_SCREEN }, 49 { ui::VKEY_F11, false, true, false, TOGGLE_ROOT_WINDOW_FULL_SCREEN },
46 { ui::VKEY_L, false, false, true, PRINT_LAYER_HIERARCHY }, 50 { ui::VKEY_L, false, false, true, PRINT_LAYER_HIERARCHY },
47 #endif 51 #endif
48 }; 52 };
49 53
50 bool HandleCycleBackward() { 54 bool HandleCycleWindow(bool forward) {
51 // TODO(mazda): http://crbug.com/105204 55 if (aura_shell::Shell::GetInstance()->IsScreenLocked())
52 NOTIMPLEMENTED(); 56 return false;
53 return false;
54 }
55 57
56 bool HandleCycleForward() { 58 // Use the same order of the windows in LauncherModel to cycle windows.
57 // TODO(mazda): http://crbug.com/105204 59 aura_shell::LauncherModel* model =
58 NOTIMPLEMENTED(); 60 aura_shell::Shell::GetInstance()->launcher()->model();
59 return false; 61 aura::Window* active_window = aura_shell::GetActiveWindow();
62 if (!active_window) {
63 LOG(ERROR) << "No active window";
64 return false;
65 }
66 int active_index = model->ItemIndexByWindow(active_window);
67 if (active_index < 0) {
68 VLOG(2) << "Active window not found in the launcher model";
69 return false;
70 }
71 int next_index = (active_index + (forward ? 1 : -1) + model->item_count()) %
72 model->item_count();
73 aura_shell::ActivateWindow(model->items()[next_index].window);
74 return true;
60 } 75 }
61 76
62 bool HandleTakeScreenshot() { 77 bool HandleTakeScreenshot() {
63 // TODO(mazda): http://crbug.com/105198 78 // TODO(mazda): http://crbug.com/105198
64 NOTIMPLEMENTED(); 79 NOTIMPLEMENTED();
65 return false; 80 return false;
66 } 81 }
67 82
68 #if !defined(NDEBUG) 83 #if !defined(NDEBUG)
69 // Rotates the screen. 84 // Rotates the screen.
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 //////////////////////////////////////////////////////////////////////////////// 174 ////////////////////////////////////////////////////////////////////////////////
160 // ShellAcceleratorController, ui::AcceleratorTarget implementation: 175 // ShellAcceleratorController, ui::AcceleratorTarget implementation:
161 176
162 bool ShellAcceleratorController::AcceleratorPressed( 177 bool ShellAcceleratorController::AcceleratorPressed(
163 const ui::Accelerator& accelerator) { 178 const ui::Accelerator& accelerator) {
164 std::map<ui::Accelerator, int>::const_iterator it = 179 std::map<ui::Accelerator, int>::const_iterator it =
165 accelerators_.find(accelerator); 180 accelerators_.find(accelerator);
166 DCHECK(it != accelerators_.end()); 181 DCHECK(it != accelerators_.end());
167 switch (static_cast<AcceleratorAction>(it->second)) { 182 switch (static_cast<AcceleratorAction>(it->second)) {
168 case CYCLE_BACKWARD: 183 case CYCLE_BACKWARD:
169 return HandleCycleBackward(); 184 return HandleCycleWindow(false);
170 case CYCLE_FORWARD: 185 case CYCLE_FORWARD:
171 return HandleCycleForward(); 186 return HandleCycleWindow(true);
172 case TAKE_SCREENSHOT: 187 case TAKE_SCREENSHOT:
173 return HandleTakeScreenshot(); 188 return HandleTakeScreenshot();
174 #if !defined(NDEBUG) 189 #if !defined(NDEBUG)
175 case ROTATE_SCREEN: 190 case ROTATE_SCREEN:
176 return HandleRotateScreen(); 191 return HandleRotateScreen();
177 case TOGGLE_ROOT_WINDOW_FULL_SCREEN: 192 case TOGGLE_ROOT_WINDOW_FULL_SCREEN:
178 return HandleToggleRootWindowFullScreen(); 193 return HandleToggleRootWindowFullScreen();
179 case PRINT_LAYER_HIERARCHY: 194 case PRINT_LAYER_HIERARCHY:
180 return HandlePrintLayerHierarchy(); 195 return HandlePrintLayerHierarchy();
181 #endif 196 #endif
182 default: 197 default:
183 NOTREACHED() << "Unhandled action " << it->second;; 198 NOTREACHED() << "Unhandled action " << it->second;;
184 } 199 }
185 return false; 200 return false;
186 } 201 }
187 202
188 } // namespace aura_shell 203 } // namespace aura_shell
OLDNEW
« no previous file with comments | « ui/aura_shell/shell.cc ('k') | ui/aura_shell/shell_accelerator_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698