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 "athena/wm/window_manager_impl.h" | 5 #include "athena/wm/window_manager_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "athena/common/container_priorities.h" | 9 #include "athena/common/container_priorities.h" |
10 #include "athena/screen/public/screen_manager.h" | 10 #include "athena/screen/public/screen_manager.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 }; | 61 }; |
62 | 62 |
63 AthenaContainerLayoutManager::AthenaContainerLayoutManager() { | 63 AthenaContainerLayoutManager::AthenaContainerLayoutManager() { |
64 } | 64 } |
65 | 65 |
66 AthenaContainerLayoutManager::~AthenaContainerLayoutManager() { | 66 AthenaContainerLayoutManager::~AthenaContainerLayoutManager() { |
67 } | 67 } |
68 | 68 |
69 void AthenaContainerLayoutManager::OnWindowResized() { | 69 void AthenaContainerLayoutManager::OnWindowResized() { |
70 // Resize all the existing windows. | 70 // Resize all the existing windows. |
71 aura::Window::Windows list = instance->window_list_provider_->GetWindowList(); | 71 aura::Window::Windows list = |
| 72 instance->window_list_provider_->GetCurrentWindowList(); |
72 const gfx::Size work_area = | 73 const gfx::Size work_area = |
73 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area().size(); | 74 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area().size(); |
74 bool is_splitview = instance->split_view_controller_->IsSplitViewModeActive(); | 75 bool is_splitview = instance->split_view_controller_->IsSplitViewModeActive(); |
75 gfx::Size split_size; | 76 gfx::Size split_size; |
76 if (is_splitview) { | 77 if (is_splitview) { |
77 CHECK(instance->split_view_controller_->left_window()); | 78 CHECK(instance->split_view_controller_->left_window()); |
78 split_size = | 79 split_size = |
79 instance->split_view_controller_->left_window()->bounds().size(); | 80 instance->split_view_controller_->left_window()->bounds().size(); |
80 } | 81 } |
81 | 82 |
82 for (aura::Window::Windows::const_iterator iter = list.begin(); | 83 for (aura::Window::Windows::const_iterator iter = list.begin(); |
83 iter != list.end(); | 84 iter != list.end(); |
84 ++iter) { | 85 ++iter) { |
85 aura::Window* window = *iter; | 86 aura::Window* window = *iter; |
86 if (is_splitview) { | 87 if (is_splitview) { |
87 if (window == instance->split_view_controller_->left_window()) | 88 if (window == instance->split_view_controller_->left_window()) |
88 window->SetBounds(gfx::Rect(split_size)); | 89 window->SetBounds(gfx::Rect(split_size)); |
89 else if (window == instance->split_view_controller_->right_window()) | 90 else if (window == instance->split_view_controller_->right_window()) |
90 window->SetBounds( | 91 window->SetBounds( |
91 gfx::Rect(gfx::Point(split_size.width(), 0), split_size)); | 92 gfx::Rect(gfx::Point(split_size.width(), 0), split_size)); |
92 else | 93 else |
93 window->SetBounds(gfx::Rect(work_area)); | 94 window->SetBounds(gfx::Rect(work_area)); |
94 } else { | 95 } else { |
95 window->SetBounds(gfx::Rect(work_area)); | 96 window->SetBounds(gfx::Rect(work_area)); |
96 } | 97 } |
97 } | 98 } |
98 } | 99 } |
99 | 100 |
100 void AthenaContainerLayoutManager::OnWindowAddedToLayout(aura::Window* child) { | 101 void AthenaContainerLayoutManager::OnWindowAddedToLayout(aura::Window* child) { |
101 aura::Window::Windows list = instance->window_list_provider_->GetWindowList(); | 102 aura::Window::Windows list = |
| 103 instance->window_list_provider_->GetCurrentWindowList(); |
102 if (std::find(list.begin(), list.end(), child) == list.end()) | 104 if (std::find(list.begin(), list.end(), child) == list.end()) |
103 return; | 105 return; |
104 if (instance->split_view_controller_->IsSplitViewModeActive()) { | 106 if (instance->split_view_controller_->IsSplitViewModeActive()) { |
105 instance->split_view_controller_->ReplaceWindow( | 107 instance->split_view_controller_->ReplaceWindow( |
106 instance->split_view_controller_->left_window(), child); | 108 instance->split_view_controller_->left_window(), child); |
107 } else { | 109 } else { |
108 gfx::Size size = | 110 gfx::Size size = |
109 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area().size(); | 111 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area().size(); |
110 child->SetBounds(gfx::Rect(size)); | 112 child->SetBounds(gfx::Rect(size)); |
111 } | 113 } |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 void WindowManagerImpl::SetInOverview(bool active) { | 179 void WindowManagerImpl::SetInOverview(bool active) { |
178 bool in_overview = !!overview_; | 180 bool in_overview = !!overview_; |
179 if (active == in_overview) | 181 if (active == in_overview) |
180 return; | 182 return; |
181 | 183 |
182 bezel_controller_->set_left_right_delegate( | 184 bezel_controller_->set_left_right_delegate( |
183 active ? NULL : split_view_controller_.get()); | 185 active ? NULL : split_view_controller_.get()); |
184 if (active) { | 186 if (active) { |
185 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnOverviewModeEnter()); | 187 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnOverviewModeEnter()); |
186 | 188 |
187 // Re-stack all windows in the order defined by window_list_provider_. | 189 // Note: The window_list_provider_ resembles the exact window list of the |
188 aura::Window::Windows window_list = window_list_provider_->GetWindowList(); | 190 // container, so no re-stacking is required before showing the OverviewMode. |
189 aura::Window::Windows::iterator it; | |
190 for (it = window_list.begin(); it != window_list.end(); ++it) | |
191 container_->StackChildAtTop(*it); | |
192 overview_ = WindowOverviewMode::Create( | 191 overview_ = WindowOverviewMode::Create( |
193 container_.get(), window_list_provider_.get(), | 192 container_.get(), window_list_provider_.get(), |
194 split_view_controller_.get(), this); | 193 split_view_controller_.get(), this); |
195 } else { | 194 } else { |
196 overview_.reset(); | 195 overview_.reset(); |
197 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnOverviewModeExit()); | 196 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnOverviewModeExit()); |
198 } | 197 } |
199 } | 198 } |
200 | 199 |
201 void WindowManagerImpl::InstallAccelerators() { | 200 void WindowManagerImpl::InstallAccelerators() { |
(...skipping 12 matching lines...) Expand all Loading... |
214 } | 213 } |
215 | 214 |
216 void WindowManagerImpl::RemoveObserver(WindowManagerObserver* observer) { | 215 void WindowManagerImpl::RemoveObserver(WindowManagerObserver* observer) { |
217 observers_.RemoveObserver(observer); | 216 observers_.RemoveObserver(observer); |
218 } | 217 } |
219 | 218 |
220 void WindowManagerImpl::ToggleSplitViewForTest() { | 219 void WindowManagerImpl::ToggleSplitViewForTest() { |
221 ToggleSplitview(); | 220 ToggleSplitview(); |
222 } | 221 } |
223 | 222 |
| 223 WindowListProvider* WindowManagerImpl::GetWindowListProvider() { |
| 224 return window_list_provider_.get(); |
| 225 } |
| 226 |
224 void WindowManagerImpl::OnSelectWindow(aura::Window* window) { | 227 void WindowManagerImpl::OnSelectWindow(aura::Window* window) { |
225 if (split_view_controller_->IsSplitViewModeActive()) { | 228 if (split_view_controller_->IsSplitViewModeActive()) { |
226 split_view_controller_->DeactivateSplitMode(); | 229 split_view_controller_->DeactivateSplitMode(); |
227 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnSplitViewModeExit()); | 230 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnSplitViewModeExit()); |
228 } | 231 } |
229 wm::ActivateWindow(window); | 232 wm::ActivateWindow(window); |
230 SetInOverview(false); | 233 SetInOverview(false); |
231 // If |window| does not have the size of the work-area, then make sure it is | 234 // If |window| does not have the size of the work-area, then make sure it is |
232 // resized. | 235 // resized. |
233 const gfx::Size work_area = | 236 const gfx::Size work_area = |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 void WindowManagerImpl::ToggleSplitview() { | 295 void WindowManagerImpl::ToggleSplitview() { |
293 // TODO(oshima): Figure out what to do. | 296 // TODO(oshima): Figure out what to do. |
294 if (IsOverviewModeActive()) | 297 if (IsOverviewModeActive()) |
295 return; | 298 return; |
296 | 299 |
297 if (split_view_controller_->IsSplitViewModeActive()) { | 300 if (split_view_controller_->IsSplitViewModeActive()) { |
298 split_view_controller_->DeactivateSplitMode(); | 301 split_view_controller_->DeactivateSplitMode(); |
299 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnSplitViewModeExit()); | 302 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnSplitViewModeExit()); |
300 // Relayout so that windows are maximzied. | 303 // Relayout so that windows are maximzied. |
301 container_->layout_manager()->OnWindowResized(); | 304 container_->layout_manager()->OnWindowResized(); |
302 } else if (window_list_provider_->GetWindowList().size() > 1) { | 305 } else if (window_list_provider_->GetCurrentWindowList().size() > 1) { |
303 FOR_EACH_OBSERVER(WindowManagerObserver, | 306 FOR_EACH_OBSERVER(WindowManagerObserver, |
304 observers_, | 307 observers_, |
305 OnSplitViewModeEnter()); | 308 OnSplitViewModeEnter()); |
306 split_view_controller_->ActivateSplitMode(NULL, NULL); | 309 split_view_controller_->ActivateSplitMode(NULL, NULL); |
307 } | 310 } |
308 } | 311 } |
309 | 312 |
310 aura::Window* WindowManagerImpl::GetWindowBehind(aura::Window* window) { | 313 aura::Window* WindowManagerImpl::GetWindowBehind(aura::Window* window) { |
311 const aura::Window::Windows& windows = window_list_provider_->GetWindowList(); | 314 const aura::Window::Windows& windows = |
| 315 window_list_provider_->GetCurrentWindowList(); |
312 aura::Window::Windows::const_reverse_iterator iter = | 316 aura::Window::Windows::const_reverse_iterator iter = |
313 std::find(windows.rbegin(), windows.rend(), window); | 317 std::find(windows.rbegin(), windows.rend(), window); |
314 CHECK(iter != windows.rend()); | 318 CHECK(iter != windows.rend()); |
315 ++iter; | 319 ++iter; |
316 aura::Window* behind = NULL; | 320 aura::Window* behind = NULL; |
317 if (iter != windows.rend()) | 321 if (iter != windows.rend()) |
318 behind = *iter++; | 322 behind = *iter++; |
319 | 323 |
320 if (split_view_controller_->IsSplitViewModeActive()) { | 324 if (split_view_controller_->IsSplitViewModeActive()) { |
321 aura::Window* left = split_view_controller_->left_window(); | 325 aura::Window* left = split_view_controller_->left_window(); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 DCHECK(!instance); | 405 DCHECK(!instance); |
402 } | 406 } |
403 | 407 |
404 // static | 408 // static |
405 WindowManager* WindowManager::GetInstance() { | 409 WindowManager* WindowManager::GetInstance() { |
406 DCHECK(instance); | 410 DCHECK(instance); |
407 return instance; | 411 return instance; |
408 } | 412 } |
409 | 413 |
410 } // namespace athena | 414 } // namespace athena |
OLD | NEW |