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

Unified Diff: athena/wm/window_manager_impl.cc

Issue 635223004: Refactor SetInOverview (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix error Created 6 years, 2 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 | « athena/wm/window_manager_impl.h ('k') | athena/wm/window_manager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..59e726f13fa6395c12997c748684f958bfacab97 100644
--- a/athena/wm/window_manager_impl.cc
+++ b/athena/wm/window_manager_impl.cc
@@ -193,23 +193,35 @@ void WindowManagerImpl::ToggleSplitView() {
}
}
-void WindowManagerImpl::ToggleOverview() {
- if (IsOverviewModeActive()) {
- SetInOverview(false);
-
- // Activate the window which was active prior to entering overview.
- const aura::Window::Windows windows =
- window_list_provider_->GetWindowList();
- if (!windows.empty()) {
- aura::Window* window = windows.back();
- // Show the window in case the exit overview animation has finished and
- // |window| was hidden.
- window->Show();
-
- wm::ActivateWindow(window);
- }
- } else {
- SetInOverview(true);
+void WindowManagerImpl::EnterOverview() {
+ if (IsOverviewModeActive())
+ return;
+
+ bezel_controller_->set_left_right_delegate(NULL);
+ FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnOverviewModeEnter());
+
+ // Note: The window_list_provider_ resembles the exact window list of the
+ // container, so no re-stacking is required before showing the OverviewMode.
+ overview_ = WindowOverviewMode::Create(
+ container_.get(), window_list_provider_.get(),
+ split_view_controller_.get(), this);
+}
+
+void WindowManagerImpl::ExitOverview() {
+ if (!IsOverviewModeActive())
+ return;
+
+ ExitOverviewNoActivate();
+
+ // Activate the window which was active prior to entering overview.
+ const aura::Window::Windows windows = window_list_provider_->GetWindowList();
+ if (!windows.empty()) {
+ aura::Window* window_to_activate = windows.back();
+
+ // Show the window in case the exit overview animation has finished and
+ // |window| was hidden.
+ window_to_activate->Show();
+ wm::ActivateWindow(window_to_activate);
}
}
@@ -217,25 +229,13 @@ bool WindowManagerImpl::IsOverviewModeActive() {
return overview_;
}
-void WindowManagerImpl::SetInOverview(bool active) {
- bool in_overview = !!overview_;
- if (active == in_overview)
+void WindowManagerImpl::ExitOverviewNoActivate() {
+ if (!IsOverviewModeActive())
return;
- bezel_controller_->set_left_right_delegate(
- active ? NULL : split_view_controller_.get());
- if (active) {
- FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnOverviewModeEnter());
-
- // Note: The window_list_provider_ resembles the exact window list of the
- // container, so no re-stacking is required before showing the OverviewMode.
- overview_ = WindowOverviewMode::Create(
- container_.get(), window_list_provider_.get(),
- split_view_controller_.get(), this);
- } else {
- overview_.reset();
- FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnOverviewModeExit());
- }
+ bezel_controller_->set_left_right_delegate(split_view_controller_.get());
+ overview_.reset();
+ FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnOverviewModeExit());
}
void WindowManagerImpl::InstallAccelerators() {
@@ -266,7 +266,7 @@ WindowListProvider* WindowManagerImpl::GetWindowListProvider() {
}
void WindowManagerImpl::OnSelectWindow(aura::Window* window) {
- SetInOverview(false);
+ ExitOverviewNoActivate();
// Show the window in case the exit overview animation has finished and
// |window| was hidden.
@@ -305,7 +305,7 @@ void WindowManagerImpl::OnSelectWindow(aura::Window* window) {
void WindowManagerImpl::OnSelectSplitViewWindow(aura::Window* left,
aura::Window* right,
aura::Window* to_activate) {
- SetInOverview(false);
+ ExitOverviewNoActivate();
FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnSplitViewModeEnter());
split_view_controller_->ActivateSplitMode(left, right, to_activate);
}
@@ -323,7 +323,10 @@ bool WindowManagerImpl::OnAcceleratorFired(int command_id,
const ui::Accelerator& accelerator) {
switch (command_id) {
case CMD_TOGGLE_OVERVIEW:
- ToggleOverview();
+ if (IsOverviewModeActive())
+ ExitOverview();
+ else
+ EnterOverview();
break;
case CMD_TOGGLE_SPLIT_VIEW:
ToggleSplitView();
« no previous file with comments | « athena/wm/window_manager_impl.h ('k') | athena/wm/window_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698