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

Unified Diff: ui/aura_shell/shell.cc

Issue 8465021: Add ShellAcceleratorController that managers global keyboard accelerators. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Move AcceleratorPressed to Shell from Desktop Created 9 years, 1 month 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
« ui/aura_shell/shell.h ('K') | « ui/aura_shell/shell.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura_shell/shell.cc
diff --git a/ui/aura_shell/shell.cc b/ui/aura_shell/shell.cc
index dc40423beb690ee3840f3c19588454a8548f6f58..65d6e8e10aac8b8fa4924feb8335bf00f7f2b820 100644
--- a/ui/aura_shell/shell.cc
+++ b/ui/aura_shell/shell.cc
@@ -23,6 +23,7 @@
#include "ui/aura_shell/toplevel_layout_manager.h"
#include "ui/aura_shell/toplevel_window_event_filter.h"
#include "ui/aura_shell/workspace_controller.h"
+#include "ui/base/accelerator_manager.h"
#include "ui/gfx/compositor/layer.h"
#include "ui/gfx/compositor/layer_animator.h"
#include "views/widget/native_widget_aura.h"
@@ -34,6 +35,17 @@ namespace {
using views::Widget;
+// Acceleraters handled by Shell.
+struct AcceleratorData {
+ ui::KeyboardCode keycode;
+ bool shift;
+ bool ctrl;
+ bool alt;
+} kAcceleratorData[] = {
+ { ui::VKEY_F11, false, false, false },
+ { ui::VKEY_HOME, false, true, false },
+};
+
// Creates each of the special window containers that holds windows of various
// types in the shell UI. They are added to |containers| from back to front in
// the z-index.
@@ -74,6 +86,17 @@ void CreateSpecialContainers(aura::Window::Windows* containers) {
containers->push_back(menu_container);
}
+void RegisterAccelerators(Shell* shell) {
+ ui::AcceleratorManager* accelerator_manager = shell->accelerator_manager();
+ for (size_t i = 0; i < arraysize(kAcceleratorData); ++i) {
+ accelerator_manager->Register(ui::Accelerator(kAcceleratorData[i].keycode,
+ kAcceleratorData[i].shift,
+ kAcceleratorData[i].ctrl,
+ kAcceleratorData[i].alt),
+ shell);
+ }
+}
+
} // namespace
// static
@@ -84,7 +107,8 @@ Shell* Shell::instance_ = NULL;
Shell::Shell(ShellDelegate* delegate)
: ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)),
- delegate_(delegate) {
+ delegate_(delegate),
+ accelerator_manager_(new ui::AcceleratorManager) {
aura::Desktop::GetInstance()->SetEventFilter(
new internal::DesktopEventFilter);
aura::Desktop::GetInstance()->SetStackingClient(
@@ -167,6 +191,8 @@ void Shell::Init() {
toplevel_layout_manager->set_shelf(shelf_layout_controller_.get());
}
+ RegisterAccelerators(this);
+
// Force a layout.
desktop_layout->OnWindowResized();
}
@@ -185,6 +211,20 @@ void Shell::ToggleOverview() {
workspace_controller_->ToggleOverview();
}
+bool Shell::AcceleratorPressed(const ui::Accelerator& accelerator) {
+#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()) {
+ aura::Desktop::GetInstance()->Rotate();
+ return true;
+ }
+#endif
+ return false;
+}
+
////////////////////////////////////////////////////////////////////////////////
// Shell, private:
« ui/aura_shell/shell.h ('K') | « ui/aura_shell/shell.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698