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 99f12a444d4765c3359dacb32bfdea1fc27277d9..989dd3f957bddd52721bc47b630d2f9d707c202a 100644 |
--- a/ui/aura_shell/shell_accelerator_controller.cc |
+++ b/ui/aura_shell/shell_accelerator_controller.cc |
@@ -4,6 +4,7 @@ |
#include "ui/aura_shell/shell_accelerator_controller.h" |
+#include "base/logging.h" |
#include "ui/aura/desktop.h" |
#include "ui/aura/event.h" |
#include "ui/aura_shell/shell.h" |
@@ -15,31 +16,44 @@ |
namespace { |
+enum AcceleratorAction { |
+ CYCLE_BACKWARD, |
+ CYCLE_FORWRARD, |
+#if !defined(NDEBUG) |
+ ROTATE_SCREEN, |
+ TOGGLE_FULL_SCREEN, |
Daniel Erat
2011/11/29 16:46:00
i don't understand why we need the fullscreen acti
mazda
2011/11/30 14:56:10
This action is a bit different from the fullscreen
Daniel Erat
2011/11/30 16:25:31
Thanks, makes more sense now.
|
+#endif |
+}; |
+ |
// Acceleraters handled by ShellAcceleratorController. |
struct AcceleratorData { |
ui::KeyboardCode keycode; |
bool shift; |
bool ctrl; |
bool alt; |
+ AcceleratorAction action; |
} kAcceleratorData[] = { |
- { ui::VKEY_F11, false, false, false }, |
- { ui::VKEY_HOME, false, true, false }, |
+ { ui::VKEY_TAB, true, false, true, CYCLE_BACKWARD }, |
+ { ui::VKEY_TAB, false, false, true, CYCLE_FORWRARD }, |
+#if !defined(NDEBUG) |
+ { ui::VKEY_HOME, false, true, false, ROTATE_SCREEN }, |
+ { ui::VKEY_F11, false, false, false, TOGGLE_FULL_SCREEN }, |
+#endif |
}; |
-// Registers the accelerators with ShellAcceleratorController. |
-void RegisterAccelerators(aura_shell::ShellAcceleratorController* controller) { |
- for (size_t i = 0; i < arraysize(kAcceleratorData); ++i) { |
- controller->Register(ui::Accelerator(kAcceleratorData[i].keycode, |
- kAcceleratorData[i].shift, |
- kAcceleratorData[i].ctrl, |
- kAcceleratorData[i].alt), |
- controller); |
- } |
+bool CycleBackward() { |
+ NOTIMPLEMENTED(); |
+ return false; |
+} |
+ |
+bool CycleForwrard() { |
+ NOTIMPLEMENTED(); |
+ return false; |
} |
#if !defined(NDEBUG) |
// Rotates the screen. |
-void RotateScreen() { |
+bool RotateScreen() { |
static int i = 0; |
int delta = 0; |
switch (i) { |
@@ -66,6 +80,12 @@ void RotateScreen() { |
screen_rotation->AddObserver(aura::Desktop::GetInstance()); |
aura::Desktop::GetInstance()->layer()->GetAnimator()->ScheduleAnimation( |
screen_rotation.release()); |
+ return true; |
+} |
+ |
+bool ToggleFullScreen() { |
+ aura::Desktop::GetInstance()->ToggleFullScreen(); |
+ return true; |
} |
#endif |
@@ -78,12 +98,24 @@ namespace aura_shell { |
ShellAcceleratorController::ShellAcceleratorController() |
: accelerator_manager_(new ui::AcceleratorManager) { |
- RegisterAccelerators(this); |
+ Init(); |
} |
ShellAcceleratorController::~ShellAcceleratorController() { |
} |
+void ShellAcceleratorController::Init() { |
+ for (size_t i = 0; i < arraysize(kAcceleratorData); ++i) { |
+ ui::Accelerator accelerator(kAcceleratorData[i].keycode, |
+ kAcceleratorData[i].shift, |
+ kAcceleratorData[i].ctrl, |
+ kAcceleratorData[i].alt); |
+ Register(accelerator, this); |
+ accelerators_.insert(std::make_pair(accelerator, |
+ kAcceleratorData[i].action)); |
+ } |
+} |
+ |
void ShellAcceleratorController::Register( |
const ui::Accelerator& accelerator, |
ui::AcceleratorTarget* target) { |
@@ -110,16 +142,23 @@ bool ShellAcceleratorController::Process(const ui::Accelerator& accelerator) { |
bool ShellAcceleratorController::AcceleratorPressed( |
const ui::Accelerator& accelerator) { |
+ std::map<ui::Accelerator, int>::const_iterator i = |
+ accelerators_.find(accelerator); |
+ DCHECK(i != accelerators_.end()); |
+ switch (static_cast<AcceleratorAction>(i->second)) { |
+ case CYCLE_BACKWARD: |
+ return CycleBackward(); |
+ case CYCLE_FORWRARD: |
+ return CycleForwrard(); |
#if !defined(NDEBUG) |
- if (accelerator.key_code() == ui::VKEY_F11) { |
- aura::Desktop::GetInstance()->ToggleFullScreen(); |
- return true; |
- } else if (accelerator.key_code() == ui::VKEY_HOME && |
- accelerator.IsCtrlDown()) { |
- RotateScreen(); |
- return true; |
- } |
+ case ROTATE_SCREEN: |
+ return RotateScreen(); |
+ case TOGGLE_FULL_SCREEN: |
+ return ToggleFullScreen(); |
#endif |
+ default: |
+ NOTREACHED(); |
+ } |
return false; |
} |