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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..8c966ce7dfc604e90720f7301162fe479f670e95 100644
--- a/ui/aura_shell/shell_accelerator_controller.cc
+++ b/ui/aura_shell/shell_accelerator_controller.cc
@@ -7,7 +7,11 @@
#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/aura_shell/shell_window_ids.h"
+#include "ui/aura_shell/window_util.h"
#include "ui/base/accelerators/accelerator.h"
#include "ui/base/accelerators/accelerator_manager.h"
#include "ui/gfx/compositor/debug_utils.h"
@@ -47,16 +51,27 @@ 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) {
+ if (aura_shell::Shell::GetInstance()->IsScreenLocked())
+ return false;
+
+ // Use the same order of the windows in LauncherModel to cycle windows.
+ aura_shell::LauncherModel* model =
+ aura_shell::Shell::GetInstance()->launcher()->model();
+ aura::Window* active_window = aura_shell::GetActiveWindow();
+ if (!active_window) {
+ LOG(ERROR) << "No active window";
+ return false;
+ }
+ int active_index = model->ItemIndexByWindow(active_window);
+ if (active_index < 0) {
+ VLOG(2) << "Active window not found in the launcher model";
+ return false;
+ }
+ int next_index = (active_index + (forward ? 1 : -1) + model->item_count()) %
+ model->item_count();
+ aura_shell::ActivateWindow(model->items()[next_index].window);
+ return true;
}
bool HandleTakeScreenshot() {
@@ -166,9 +181,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)
« 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