OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ash/wm/overview/window_grid.h" | 5 #include "ash/wm/overview/window_grid.h" |
6 | 6 |
7 #include "ash/screen_util.h" | 7 #include "ash/screen_util.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "ash/shell_window_ids.h" | 9 #include "ash/shell_window_ids.h" |
10 #include "ash/wm/overview/scoped_transform_overview_window.h" | 10 #include "ash/wm/overview/scoped_transform_overview_window.h" |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 WindowSelector* window_selector) | 129 WindowSelector* window_selector) |
130 : root_window_(root_window), | 130 : root_window_(root_window), |
131 window_selector_(window_selector) { | 131 window_selector_(window_selector) { |
132 WindowSelectorPanels* panels_item = NULL; | 132 WindowSelectorPanels* panels_item = NULL; |
133 for (aura::Window::Windows::const_iterator iter = windows.begin(); | 133 for (aura::Window::Windows::const_iterator iter = windows.begin(); |
134 iter != windows.end(); ++iter) { | 134 iter != windows.end(); ++iter) { |
135 if ((*iter)->GetRootWindow() != root_window) | 135 if ((*iter)->GetRootWindow() != root_window) |
136 continue; | 136 continue; |
137 (*iter)->AddObserver(this); | 137 (*iter)->AddObserver(this); |
138 observed_windows_.insert(*iter); | 138 observed_windows_.insert(*iter); |
139 WindowSelectorItem* item = NULL; | |
140 | 139 |
141 if ((*iter)->type() == ui::wm::WINDOW_TYPE_PANEL && | 140 if ((*iter)->type() == ui::wm::WINDOW_TYPE_PANEL && |
142 wm::GetWindowState(*iter)->panel_attached()) { | 141 wm::GetWindowState(*iter)->panel_attached()) { |
143 // Attached panel windows are grouped into a single overview item per | 142 // Attached panel windows are grouped into a single overview item per |
144 // grid. | 143 // grid. |
145 if (!panels_item) { | 144 if (!panels_item) { |
146 panels_item = new WindowSelectorPanels(root_window_); | 145 panels_item = new WindowSelectorPanels(root_window_); |
147 window_list_.push_back(panels_item); | 146 window_list_.push_back(panels_item); |
148 } | 147 } |
149 panels_item->AddWindow(*iter); | 148 panels_item->AddWindow(*iter); |
150 item = panels_item; | |
151 } else { | 149 } else { |
152 item = new WindowSelectorWindow(*iter); | 150 window_list_.push_back(new WindowSelectorWindow(*iter)); |
153 item->PrepareForOverview(); | |
154 window_list_.push_back(item); | |
155 } | 151 } |
156 } | 152 } |
157 if (window_list_.empty()) | 153 if (window_list_.empty()) |
158 return; | 154 return; |
159 | |
160 if (panels_item) | |
161 panels_item->PrepareForOverview(); | |
162 | |
163 PositionWindows(true); | |
164 } | 155 } |
165 | 156 |
166 WindowGrid::~WindowGrid() { | 157 WindowGrid::~WindowGrid() { |
167 for (std::set<aura::Window*>::iterator iter = observed_windows_.begin(); | 158 for (std::set<aura::Window*>::iterator iter = observed_windows_.begin(); |
168 iter != observed_windows_.end(); iter++) { | 159 iter != observed_windows_.end(); iter++) { |
169 (*iter)->RemoveObserver(this); | 160 (*iter)->RemoveObserver(this); |
170 } | 161 } |
171 } | 162 } |
172 | 163 |
| 164 void WindowGrid::PrepareForOverview() { |
| 165 for (ScopedVector<WindowSelectorItem>::iterator iter = window_list_.begin(); |
| 166 iter != window_list_.end(); ++iter) { |
| 167 (*iter)->PrepareForOverview(); |
| 168 } |
| 169 } |
| 170 |
173 void WindowGrid::PositionWindows(bool animate) { | 171 void WindowGrid::PositionWindows(bool animate) { |
174 CHECK(!window_list_.empty()); | 172 CHECK(!window_list_.empty()); |
175 | 173 |
176 gfx::Size window_size; | 174 gfx::Size window_size; |
177 gfx::Rect total_bounds = ScreenUtil::ConvertRectToScreen( | 175 gfx::Rect total_bounds = ScreenUtil::ConvertRectToScreen( |
178 root_window_, | 176 root_window_, |
179 ScreenUtil::GetDisplayWorkAreaBoundsInParent( | 177 ScreenUtil::GetDisplayWorkAreaBoundsInParent( |
180 Shell::GetContainer(root_window_, kShellWindowId_DefaultContainer))); | 178 Shell::GetContainer(root_window_, kShellWindowId_DefaultContainer))); |
181 | 179 |
182 // Find the minimum number of windows per row that will fit all of the | 180 // Find the minimum number of windows per row that will fit all of the |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 432 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
435 selection_widget_->SetBounds(SelectedWindow()->target_bounds()); | 433 selection_widget_->SetBounds(SelectedWindow()->target_bounds()); |
436 selection_widget_->SetOpacity(kWindowOverviewSelectorOpacity); | 434 selection_widget_->SetOpacity(kWindowOverviewSelectorOpacity); |
437 return; | 435 return; |
438 } | 436 } |
439 selection_widget_->SetBounds(SelectedWindow()->target_bounds()); | 437 selection_widget_->SetBounds(SelectedWindow()->target_bounds()); |
440 selection_widget_->SetOpacity(kWindowOverviewSelectorOpacity); | 438 selection_widget_->SetOpacity(kWindowOverviewSelectorOpacity); |
441 } | 439 } |
442 | 440 |
443 } // namespace ash | 441 } // namespace ash |
OLD | NEW |