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

Unified Diff: ash/accelerators/accelerator_controller.cc

Issue 9582039: Changing the ominbar text colors according to spec. This change was marked as 'optional' and (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Adding Alt+<number> window switching accelerators Created 8 years, 9 months 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 | « ash/accelerators/accelerator_controller.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/accelerators/accelerator_controller.cc
diff --git a/ash/accelerators/accelerator_controller.cc b/ash/accelerators/accelerator_controller.cc
index 1df6887fd1a8cd0619651af764c031bd1acdfb36..159a27f71a7a478ff9c23467b6570ee9bc14f45b 100644
--- a/ash/accelerators/accelerator_controller.cc
+++ b/ash/accelerators/accelerator_controller.cc
@@ -16,6 +16,7 @@
#include "ash/volume_control_delegate.h"
#include "ash/wm/window_cycle_controller.h"
#include "ash/wm/window_util.h"
+#include "ui/aura/client/activation_client.h"
#include "ui/aura/event.h"
#include "ui/aura/root_window.h"
#include "ui/base/accelerators/accelerator.h"
@@ -52,6 +53,15 @@ enum AcceleratorAction {
TOGGLE_DESKTOP_BACKGROUND_MODE,
TOGGLE_ROOT_WINDOW_FULL_SCREEN,
#endif
+ SELECT_WIN_0,
+ SELECT_WIN_1,
+ SELECT_WIN_2,
+ SELECT_WIN_3,
+ SELECT_WIN_4,
+ SELECT_WIN_5,
+ SELECT_WIN_6,
+ SELECT_WIN_7,
+ SELECT_WIN_8,
};
// Accelerators handled by AcceleratorController.
@@ -119,6 +129,25 @@ const struct AcceleratorData {
{ ui::ET_TRANSLATED_KEY_PRESS, ui::VKEY_F10, false, false, false, VOLUME_UP },
{ ui::ET_TRANSLATED_KEY_PRESS, ui::VKEY_VOLUME_UP, false, false, false,
VOLUME_UP },
+ { ui::ET_TRANSLATED_KEY_PRESS, ui::VKEY_1, false, false, true,
+ SELECT_WIN_0 },
+ { ui::ET_TRANSLATED_KEY_PRESS, ui::VKEY_2, false, false, true,
+ SELECT_WIN_1 },
+ { ui::ET_TRANSLATED_KEY_PRESS, ui::VKEY_3, false, false, true,
+ SELECT_WIN_2 },
+ { ui::ET_TRANSLATED_KEY_PRESS, ui::VKEY_4, false, false, true,
+ SELECT_WIN_3 },
+ { ui::ET_TRANSLATED_KEY_PRESS, ui::VKEY_5, false, false, true,
+ SELECT_WIN_4 },
+ { ui::ET_TRANSLATED_KEY_PRESS, ui::VKEY_6, false, false, true,
+ SELECT_WIN_5 },
+ { ui::ET_TRANSLATED_KEY_PRESS, ui::VKEY_7, false, false, true,
+ SELECT_WIN_6 },
+ { ui::ET_TRANSLATED_KEY_PRESS, ui::VKEY_8, false, false, true,
+ SELECT_WIN_7 },
+ { ui::ET_TRANSLATED_KEY_PRESS, ui::VKEY_9, false, false, true,
+ SELECT_WIN_8 },
+
#if !defined(NDEBUG)
{ ui::ET_TRANSLATED_KEY_PRESS, ui::VKEY_HOME, false, true, false,
ROTATE_SCREEN },
@@ -316,6 +345,7 @@ bool AcceleratorController::AcceleratorPressed(
std::map<ui::Accelerator, int>::const_iterator it =
accelerators_.find(accelerator);
DCHECK(it != accelerators_.end());
+ unsigned int window = 0;
switch (static_cast<AcceleratorAction>(it->second)) {
case CYCLE_BACKWARD:
return HandleCycleWindow(WindowCycleController::BACKWARD,
@@ -379,6 +409,33 @@ bool AcceleratorController::AcceleratorPressed(
if (ime_control_delegate_.get())
return ime_control_delegate_->HandleSwitchIme(accelerator);
break;
+ case SELECT_WIN_8:
+ window++;
+ // Fallthrough.
+ case SELECT_WIN_7:
+ window++;
+ // Fallthrough.
+ case SELECT_WIN_6:
+ window++;
+ // Fallthrough.
+ case SELECT_WIN_5:
+ window++;
+ // Fallthrough.
+ case SELECT_WIN_4:
+ window++;
+ // Fallthrough.
+ case SELECT_WIN_3:
+ window++;
+ // Fallthrough.
+ case SELECT_WIN_2:
+ window++;
+ // Fallthrough.
+ case SELECT_WIN_1:
+ window++;
+ // Fallthrough.
+ case SELECT_WIN_0:
+ SwitchToWindow(window);
+ break;
#if !defined(NDEBUG)
case ROTATE_SCREEN:
return HandleRotateScreen();
@@ -397,6 +454,29 @@ bool AcceleratorController::AcceleratorPressed(
return false;
}
+void AcceleratorController::SwitchToWindow(const unsigned int window) {
+ const std::vector<aura::Window*>& windows =
+ Shell::GetInstance()->delegate()->GetCycleWindowList(
+ ShellDelegate::SOURCE_LAUNCHER,
+ ShellDelegate::ORDER_LINEAR);
+ if (window < windows.size()) {
+ aura::client::ActivationClient* activation_client =
+ aura::client::GetActivationClient(Shell::GetRootWindow());
+ aura::Window* window_to_activate = windows[window];
+ aura::Window* current_window = wm::GetActiveWindow();
+ if (window_to_activate != current_window) {
+ bool maximized = wm::IsWindowMaximized(current_window);
+ if (maximized) {
+ wm::RestoreWindow(current_window);
+ }
+ activation_client->ActivateWindow(window_to_activate);
+ if (maximized) {
+ wm::MaximizeWindow(window_to_activate);
+ }
+ }
+ }
+}
+
bool AcceleratorController::CanHandleAccelerators() const {
return true;
}
« no previous file with comments | « ash/accelerators/accelerator_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698