Index: athena/wm/window_manager_impl.cc |
diff --git a/athena/wm/window_manager_impl.cc b/athena/wm/window_manager_impl.cc |
index 35722c1adfa69f27a7743b3c6003d85468c88051..ec15bc2a445b83a6d5e869e51167ebe61e22caf4 100644 |
--- a/athena/wm/window_manager_impl.cc |
+++ b/athena/wm/window_manager_impl.cc |
@@ -193,10 +193,13 @@ void WindowManagerImpl::ToggleSplitView() { |
} |
} |
-void WindowManagerImpl::ToggleOverview() { |
- if (IsOverviewModeActive()) { |
- SetInOverview(false); |
+// Wraps SetInOverview(), and also activates old active window upon deactivation |
+void WindowManagerImpl::ActivateOverview(bool activate) { |
+ if (IsOverviewModeActive() == activate) |
+ return; |
+ SetInOverview(activate); |
+ if (!activate) { |
// Activate the window which was active prior to entering overview. |
const aura::Window::Windows windows = |
window_list_provider_->GetWindowList(); |
@@ -208,8 +211,6 @@ void WindowManagerImpl::ToggleOverview() { |
wm::ActivateWindow(window); |
} |
- } else { |
- SetInOverview(true); |
} |
} |
@@ -222,6 +223,12 @@ void WindowManagerImpl::SetInOverview(bool active) { |
if (active == in_overview) |
return; |
+ const AcceleratorData esc_accelerator_data = {TRIGGER_ON_PRESS, |
+ ui::VKEY_ESCAPE, |
+ ui::EF_NONE, |
+ CMD_EXIT_OVERVIEW, |
+ AF_NONE}; |
+ |
bezel_controller_->set_left_right_delegate( |
active ? NULL : split_view_controller_.get()); |
if (active) { |
@@ -232,9 +239,12 @@ void WindowManagerImpl::SetInOverview(bool active) { |
overview_ = WindowOverviewMode::Create( |
container_.get(), window_list_provider_.get(), |
split_view_controller_.get(), this); |
+ AcceleratorManager::Get()->RegisterAccelerator(esc_accelerator_data, this); |
} else { |
overview_.reset(); |
FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnOverviewModeExit()); |
+ AcceleratorManager::Get()->UnregisterAccelerator(esc_accelerator_data, |
+ this); |
} |
} |
@@ -322,8 +332,11 @@ bool WindowManagerImpl::IsCommandEnabled(int command_id) const { |
bool WindowManagerImpl::OnAcceleratorFired(int command_id, |
const ui::Accelerator& accelerator) { |
switch (command_id) { |
+ case CMD_EXIT_OVERVIEW: |
+ ActivateOverview(false); |
+ break; |
case CMD_TOGGLE_OVERVIEW: |
- ToggleOverview(); |
+ ActivateOverview(!IsOverviewModeActive()); |
break; |
case CMD_TOGGLE_SPLIT_VIEW: |
ToggleSplitView(); |