Chromium Code Reviews| Index: athena/wm/window_overview_mode.cc |
| diff --git a/athena/wm/window_overview_mode.cc b/athena/wm/window_overview_mode.cc |
| index b37339e3cf7cca7b76aad83cc3e4ae66a5508c24..4d95e378003cab9322370daa31f71f366d6780b5 100644 |
| --- a/athena/wm/window_overview_mode.cc |
| +++ b/athena/wm/window_overview_mode.cc |
| @@ -110,10 +110,13 @@ class WindowOverviewModeImpl : public WindowOverviewMode, |
| virtual ~WindowOverviewModeImpl() { |
| container_->set_target_handler(container_->delegate()); |
| - aura::Window::Windows windows = container_->children(); |
| - if (windows.empty()) |
| - return; |
| - std::for_each(windows.begin(), windows.end(), &RestoreWindowState); |
| + const aura::Window::Windows& windows = container_->children(); |
| + for (aura::Window::Windows::const_iterator iter = windows.begin(); |
| + iter != windows.end(); |
| + ++iter) { |
| + if ((*iter)->GetProperty(kWindowOverviewState)) |
| + RestoreWindowState(*iter); |
| + } |
| } |
| private: |
| @@ -121,8 +124,15 @@ class WindowOverviewModeImpl : public WindowOverviewMode, |
| // positions. The transforms are set in the |kWindowOverviewState| property of |
| // the windows. |
| void ComputeTerminalStatesForAllWindows() { |
| - aura::Window::Windows windows = container_->children(); |
| - size_t window_count = windows.size(); |
| + size_t window_count = 0; |
| + const aura::Window::Windows& windows = container_->children(); |
| + for (aura::Window::Windows::const_iterator iter = windows.begin(); |
| + iter != windows.end(); |
| + ++iter) { |
| + if ((*iter)->type() == ui::wm::WINDOW_TYPE_NORMAL) |
| + window_count++; |
| + } |
|
oshima
2014/08/01 23:10:09
I see. you could use count_if, but I'll leave it t
mohsen
2014/08/01 23:36:01
Yep, Done.
|
| + |
| size_t index = 0; |
| const gfx::Size container_size = container_->bounds().size(); |
| @@ -131,10 +141,12 @@ class WindowOverviewModeImpl : public WindowOverviewMode, |
| const float kMinScale = 0.6f; |
| const float kMaxScale = 0.95f; |
| - for (aura::Window::Windows::reverse_iterator iter = windows.rbegin(); |
| + for (aura::Window::Windows::const_reverse_iterator iter = windows.rbegin(); |
| iter != windows.rend(); |
| - ++iter, ++index) { |
| + ++iter) { |
| aura::Window* window = (*iter); |
| + if (window->type() != ui::wm::WINDOW_TYPE_NORMAL) |
| + continue; |
| gfx::Transform top_transform; |
| int top = (window_count - index - 1) * kGapBetweenWindowsTop; |
| @@ -154,20 +166,27 @@ class WindowOverviewModeImpl : public WindowOverviewMode, |
| state->progress = 0.f; |
| state->shadow = CreateShadowForWindow(window); |
| window->SetProperty(kWindowOverviewState, state); |
| + |
| + index++; |
| } |
| } |
| // Sets the initial position for the windows for the overview mode. |
| void SetInitialWindowStates() { |
| - aura::Window::Windows windows = container_->children(); |
| - size_t window_count = windows.size(); |
| // The initial overview state of the topmost three windows. |
| const float kInitialProgress[] = { 0.5f, 0.05f, 0.01f }; |
| - for (size_t i = 0; i < window_count; ++i) { |
| + size_t index = 0; |
| + const aura::Window::Windows& windows = container_->children(); |
| + for (aura::Window::Windows::const_reverse_iterator iter = windows.rbegin(); |
| + iter != windows.rend(); |
| + ++iter) { |
| + aura::Window* window = (*iter); |
| + if (!window->GetProperty(kWindowOverviewState)) |
| + continue; |
| + |
| float progress = 0.f; |
| - aura::Window* window = windows[window_count - 1 - i]; |
| - if (i < arraysize(kInitialProgress)) |
| - progress = kInitialProgress[i]; |
| + if (index < arraysize(kInitialProgress)) |
| + progress = kInitialProgress[index]; |
| scoped_refptr<ui::LayerAnimator> animator = |
| window->layer()->GetAnimator(); |
| @@ -188,6 +207,7 @@ class WindowOverviewModeImpl : public WindowOverviewMode, |
| settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds(250)); |
| SetWindowProgress(window, progress); |
| } |
| + index++; |
| } |
| } |
| @@ -222,16 +242,18 @@ class WindowOverviewModeImpl : public WindowOverviewMode, |
| // scrolling up; and positive when scrolling down. |
| void DoScroll(float delta_y) { |
| const float kEpsilon = 1e-3f; |
| - aura::Window::Windows windows = container_->children(); |
| float delta_y_p = std::abs(delta_y) / GetScrollableHeight(); |
| + const aura::Window::Windows& windows = container_->children(); |
| if (delta_y < 0) { |
| // Scroll up. Start with the top-most (i.e. behind-most in terms of |
| // z-index) window, and try to scroll them up. |
| - for (aura::Window::Windows::iterator iter = windows.begin(); |
| + for (aura::Window::Windows::const_iterator iter = windows.begin(); |
| delta_y_p > kEpsilon && iter != windows.end(); |
| ++iter) { |
| aura::Window* window = (*iter); |
| WindowOverviewState* state = window->GetProperty(kWindowOverviewState); |
| + if (!state) |
| + continue; |
| if (state->progress > kEpsilon) { |
| // It is possible to scroll |window| up. Scroll it up, and update |
| // |delta_y_p| for the next window. |
| @@ -243,11 +265,14 @@ class WindowOverviewModeImpl : public WindowOverviewMode, |
| } else { |
| // Scroll down. Start with the bottom-most (i.e. front-most in terms of |
| // z-index) window, and try to scroll them down. |
| - for (aura::Window::Windows::reverse_iterator iter = windows.rbegin(); |
| + for (aura::Window::Windows::const_reverse_iterator iter = |
| + windows.rbegin(); |
| delta_y_p > kEpsilon && iter != windows.rend(); |
| ++iter) { |
| aura::Window* window = (*iter); |
| WindowOverviewState* state = window->GetProperty(kWindowOverviewState); |
| + if (!state) |
| + continue; |
| if (1.f - state->progress > kEpsilon) { |
| // It is possible to scroll |window| down. Scroll it down, and update |
| // |delta_y_p| for the next window. |