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

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 | « no previous file | no next file » | 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"
11 #include "ui/base/accelerators/accelerator.h" 13 #include "ui/base/accelerators/accelerator.h"
12 #include "ui/base/accelerators/accelerator_manager.h" 14 #include "ui/base/accelerators/accelerator_manager.h"
13 #include "ui/gfx/compositor/debug_utils.h" 15 #include "ui/gfx/compositor/debug_utils.h"
14 #include "ui/gfx/compositor/layer_animation_sequence.h" 16 #include "ui/gfx/compositor/layer_animation_sequence.h"
15 #include "ui/gfx/compositor/layer_animator.h" 17 #include "ui/gfx/compositor/layer_animator.h"
16 #include "ui/gfx/compositor/screen_rotation.h" 18 #include "ui/gfx/compositor/screen_rotation.h"
17 19
18 namespace { 20 namespace {
19 21
(...skipping 20 matching lines...) Expand all
40 { ui::VKEY_TAB, false, false, true, CYCLE_FORWARD }, 42 { ui::VKEY_TAB, false, false, true, CYCLE_FORWARD },
41 { ui::VKEY_F5, false, true, false, TAKE_SCREENSHOT }, 43 { ui::VKEY_F5, false, true, false, TAKE_SCREENSHOT },
42 { ui::VKEY_PRINT, false, false, false, TAKE_SCREENSHOT }, 44 { ui::VKEY_PRINT, false, false, false, TAKE_SCREENSHOT },
43 #if !defined(NDEBUG) 45 #if !defined(NDEBUG)
44 { ui::VKEY_HOME, false, true, false, ROTATE_SCREEN }, 46 { ui::VKEY_HOME, false, true, false, ROTATE_SCREEN },
45 { ui::VKEY_F11, false, true, false, TOGGLE_ROOT_WINDOW_FULL_SCREEN }, 47 { ui::VKEY_F11, false, true, false, TOGGLE_ROOT_WINDOW_FULL_SCREEN },
46 { ui::VKEY_L, false, false, true, PRINT_LAYER_HIERARCHY }, 48 { ui::VKEY_L, false, false, true, PRINT_LAYER_HIERARCHY },
47 #endif 49 #endif
48 }; 50 };
49 51
50 bool HandleCycleBackward() { 52 bool HandleCycleWindow(bool forward) {
51 // TODO(mazda): http://crbug.com/105204 53 // Use the same order of the windows in LauncherModel to cycle windows.
52 NOTIMPLEMENTED(); 54 aura_shell::LauncherModel* model =
53 return false; 55 aura_shell::Shell::GetInstance()->launcher()->model();
54 } 56 aura::RootWindow* root_window = aura::RootWindow::GetInstance();
55 57 int active_index = model->ItemIndexByWindow(root_window->active_window());
56 bool HandleCycleForward() { 58 if (active_index < 0) {
57 // TODO(mazda): http://crbug.com/105204 59 LOG(ERROR) << "Active window not found";
Ben Goodger (Google) 2011/12/07 17:13:00 does this ever happen?
mazda 2011/12/09 15:09:46 All the windows in the launcher model are containe
58 NOTIMPLEMENTED(); 60 return false;
59 return false; 61 }
62 int next_index = (active_index + (forward ? 1 : -1) + model->item_count()) %
63 model->item_count();
64 model->items()[next_index].window->Activate();
65 return true;
60 } 66 }
61 67
62 bool HandleTakeScreenshot() { 68 bool HandleTakeScreenshot() {
63 // TODO(mazda): http://crbug.com/105198 69 // TODO(mazda): http://crbug.com/105198
64 NOTIMPLEMENTED(); 70 NOTIMPLEMENTED();
65 return false; 71 return false;
66 } 72 }
67 73
68 #if !defined(NDEBUG) 74 #if !defined(NDEBUG)
69 // Rotates the screen. 75 // Rotates the screen.
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 //////////////////////////////////////////////////////////////////////////////// 165 ////////////////////////////////////////////////////////////////////////////////
160 // ShellAcceleratorController, ui::AcceleratorTarget implementation: 166 // ShellAcceleratorController, ui::AcceleratorTarget implementation:
161 167
162 bool ShellAcceleratorController::AcceleratorPressed( 168 bool ShellAcceleratorController::AcceleratorPressed(
163 const ui::Accelerator& accelerator) { 169 const ui::Accelerator& accelerator) {
164 std::map<ui::Accelerator, int>::const_iterator it = 170 std::map<ui::Accelerator, int>::const_iterator it =
165 accelerators_.find(accelerator); 171 accelerators_.find(accelerator);
166 DCHECK(it != accelerators_.end()); 172 DCHECK(it != accelerators_.end());
167 switch (static_cast<AcceleratorAction>(it->second)) { 173 switch (static_cast<AcceleratorAction>(it->second)) {
168 case CYCLE_BACKWARD: 174 case CYCLE_BACKWARD:
169 return HandleCycleBackward(); 175 return HandleCycleWindow(false);
170 case CYCLE_FORWARD: 176 case CYCLE_FORWARD:
171 return HandleCycleForward(); 177 return HandleCycleWindow(true);
172 case TAKE_SCREENSHOT: 178 case TAKE_SCREENSHOT:
173 return HandleTakeScreenshot(); 179 return HandleTakeScreenshot();
174 #if !defined(NDEBUG) 180 #if !defined(NDEBUG)
175 case ROTATE_SCREEN: 181 case ROTATE_SCREEN:
176 return HandleRotateScreen(); 182 return HandleRotateScreen();
177 case TOGGLE_ROOT_WINDOW_FULL_SCREEN: 183 case TOGGLE_ROOT_WINDOW_FULL_SCREEN:
178 return HandleToggleRootWindowFullScreen(); 184 return HandleToggleRootWindowFullScreen();
179 case PRINT_LAYER_HIERARCHY: 185 case PRINT_LAYER_HIERARCHY:
180 return HandlePrintLayerHierarchy(); 186 return HandlePrintLayerHierarchy();
181 #endif 187 #endif
182 default: 188 default:
183 NOTREACHED() << "Unhandled action " << it->second;; 189 NOTREACHED() << "Unhandled action " << it->second;;
184 } 190 }
185 return false; 191 return false;
186 } 192 }
187 193
188 } // namespace aura_shell 194 } // namespace aura_shell
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698