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

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: Add check for lock screen view visibility 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/aura_shell.gyp ('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..5b850d735b97a3da253fc4bda8b81cb57e456146 100644
--- a/ui/aura_shell/shell_accelerator_controller.cc
+++ b/ui/aura_shell/shell_accelerator_controller.cc
@@ -4,10 +4,15 @@
#include "ui/aura_shell/shell_accelerator_controller.h"
+#include <algorithm>
+
#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/base/accelerators/accelerator.h"
#include "ui/base/accelerators/accelerator_manager.h"
#include "ui/gfx/compositor/debug_utils.h"
@@ -47,16 +52,55 @@ struct AcceleratorData {
#endif
};
-bool HandleCycleBackward() {
- // TODO(mazda): http://crbug.com/105204
- NOTIMPLEMENTED();
+// Returns true if the screen is locked.
+bool IsLocked() {
Ben Goodger (Google) 2011/12/09 22:53:19 I wonder if we might want to make this a function
+ const aura::Window* lock_screen_container =
+ aura_shell::Shell::GetInstance()->GetContainer(
+ aura_shell::internal::kShellWindowId_LockScreenContainer);
+ const aura::Window::Windows& lock_screen_windows =
+ lock_screen_container->children();
+ aura::Window::Windows::const_iterator lock_screen_it =
+ std::find_if(lock_screen_windows.begin(), lock_screen_windows.end(),
+ std::mem_fun(&aura::Window::IsVisible));
+ if (lock_screen_it != lock_screen_windows.end())
+ return true;
+
+ aura::Window* lock_modal_container =
+ aura_shell::Shell::GetInstance()->GetContainer(
+ aura_shell::internal::kShellWindowId_LockModalContainer);
+ const aura::Window::Windows& lock_modal_windows =
+ lock_modal_container->children();
+ aura::Window::Windows::const_iterator lock_modal_it =
+ std::find_if(lock_modal_windows.begin(), lock_modal_windows.end(),
+ std::mem_fun(&aura::Window::IsVisible));
+ if (lock_modal_it != lock_modal_windows.end())
+ return true;
+
return false;
}
-bool HandleCycleForward() {
- // TODO(mazda): http://crbug.com/105204
- NOTIMPLEMENTED();
- return false;
+bool HandleCycleWindow(bool forward) {
+ if (IsLocked())
+ 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::RootWindow* root_window = aura::RootWindow::GetInstance();
+ aura::Window* active_window = root_window->active_window();
+ 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();
+ model->items()[next_index].window->Activate();
+ return true;
}
bool HandleTakeScreenshot() {
@@ -166,9 +210,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/aura_shell.gyp ('k') | ui/aura_shell/shell_accelerator_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698