Chromium Code Reviews| Index: ui/aura_shell/shell_accelerator_controller.cc |
| diff --git a/ui/aura_shell/shell_accelerator_controller.cc b/ui/aura_shell/shell_accelerator_controller.cc |
| index 74e36d5e7e77ce275601da95d5b062297ccd6dcc..7f7ff9b5735fc4b1d781e6a61391493c1e0fd259 100644 |
| --- a/ui/aura_shell/shell_accelerator_controller.cc |
| +++ b/ui/aura_shell/shell_accelerator_controller.cc |
| @@ -7,6 +7,8 @@ |
| #include "base/logging.h" |
| #include "ui/aura/event.h" |
| #include "ui/aura/root_window.h" |
| +#include "ui/aura_shell/launcher/launcher.h" |
| +#include "ui/aura_shell/launcher/launcher_model.h" |
| #include "ui/aura_shell/shell.h" |
| #include "ui/base/accelerators/accelerator.h" |
| #include "ui/base/accelerators/accelerator_manager.h" |
| @@ -47,16 +49,20 @@ struct AcceleratorData { |
| #endif |
| }; |
| -bool HandleCycleBackward() { |
| - // TODO(mazda): http://crbug.com/105204 |
| - NOTIMPLEMENTED(); |
| - return false; |
| -} |
| - |
| -bool HandleCycleForward() { |
| - // TODO(mazda): http://crbug.com/105204 |
| - NOTIMPLEMENTED(); |
| - return false; |
| +bool HandleCycleWindow(bool forward) { |
| + // Use the same order of the windows in LauncherModel to cycle windows. |
| + aura_shell::LauncherModel* model = |
| + aura_shell::Shell::GetInstance()->launcher()->model(); |
| + aura::RootWindow* root_window = aura::RootWindow::GetInstance(); |
| + int active_index = model->ItemIndexByWindow(root_window->active_window()); |
| + if (active_index < 0) { |
| + 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
|
| + return false; |
| + } |
| + int next_index = (active_index + (forward ? 1 : -1) + model->item_count()) % |
| + model->item_count(); |
| + model->items()[next_index].window->Activate(); |
| + return true; |
| } |
| bool HandleTakeScreenshot() { |
| @@ -166,9 +172,9 @@ bool ShellAcceleratorController::AcceleratorPressed( |
| DCHECK(it != accelerators_.end()); |
| switch (static_cast<AcceleratorAction>(it->second)) { |
| case CYCLE_BACKWARD: |
| - return HandleCycleBackward(); |
| + return HandleCycleWindow(false); |
| case CYCLE_FORWARD: |
| - return HandleCycleForward(); |
| + return HandleCycleWindow(true); |
| case TAKE_SCREENSHOT: |
| return HandleTakeScreenshot(); |
| #if !defined(NDEBUG) |