Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/workspace/workspace_layout_manager2.h" | 5 #include "ash/wm/workspace/workspace_layout_manager2.h" |
| 6 | 6 |
| 7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/screen_ash.h" | 8 #include "ash/screen_ash.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/wm/always_on_top_controller.h" | 10 #include "ash/wm/always_on_top_controller.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 46 void ResetBoundsIfNecessary(const BoundsMap& bounds_map, aura::Window* window) { | 46 void ResetBoundsIfNecessary(const BoundsMap& bounds_map, aura::Window* window) { |
| 47 if (window->bounds().IsEmpty() && window->GetTargetBounds().IsEmpty()) { | 47 if (window->bounds().IsEmpty() && window->GetTargetBounds().IsEmpty()) { |
| 48 BoundsMap::const_iterator i = bounds_map.find(window); | 48 BoundsMap::const_iterator i = bounds_map.find(window); |
| 49 if (i != bounds_map.end()) | 49 if (i != bounds_map.end()) |
| 50 window->SetBounds(i->second); | 50 window->SetBounds(i->second); |
| 51 } | 51 } |
| 52 for (size_t i = 0; i < window->children().size(); ++i) | 52 for (size_t i = 0; i < window->children().size(); ++i) |
| 53 ResetBoundsIfNecessary(bounds_map, window->children()[i]); | 53 ResetBoundsIfNecessary(bounds_map, window->children()[i]); |
| 54 } | 54 } |
| 55 | 55 |
| 56 // Resets |window|s bounds from |bounds_map| if |window| is marked as a | |
| 57 // constrained window. Recusively invokes this for all children. | |
| 58 // TODO(sky): this should key off window type. | |
| 59 void ResetConstrainedWindowBoundsIfNecessary(const BoundsMap& bounds_map, | |
| 60 aura::Window* window) { | |
| 61 if (window->GetProperty(aura::client::kConstrainedWindowKey)) { | |
| 62 BoundsMap::const_iterator i = bounds_map.find(window); | |
|
Mr4D (OOO till 08-26)
2012/09/26 04:25:08
It is a bit confusing to have to 'i' variables in
sky
2012/09/26 04:51:15
They have totally different scopes. It's no differ
| |
| 63 if (i != bounds_map.end()) | |
| 64 window->SetBounds(i->second); | |
| 65 } | |
| 66 for (size_t i = 0; i < window->children().size(); ++i) | |
| 67 ResetConstrainedWindowBoundsIfNecessary(bounds_map, window->children()[i]); | |
| 68 } | |
| 69 | |
| 56 } // namespace | 70 } // namespace |
| 57 | 71 |
| 58 WorkspaceLayoutManager2::WorkspaceLayoutManager2(Workspace2* workspace) | 72 WorkspaceLayoutManager2::WorkspaceLayoutManager2(Workspace2* workspace) |
| 59 : root_window_(workspace->window()->GetRootWindow()), | 73 : root_window_(workspace->window()->GetRootWindow()), |
| 60 workspace_(workspace), | 74 workspace_(workspace), |
| 61 work_area_(ScreenAsh::GetDisplayWorkAreaBoundsInParent( | 75 work_area_(ScreenAsh::GetDisplayWorkAreaBoundsInParent( |
| 62 workspace->window()->parent())) { | 76 workspace->window()->parent())) { |
| 63 Shell::GetInstance()->AddShellObserver(this); | 77 Shell::GetInstance()->AddShellObserver(this); |
| 64 root_window_->AddRootWindowObserver(this); | 78 root_window_->AddRootWindowObserver(this); |
| 65 root_window_->AddObserver(this); | 79 root_window_->AddObserver(this); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 169 ui::Layer* cloned_layer = NULL; | 183 ui::Layer* cloned_layer = NULL; |
| 170 BoundsMap bounds_map; | 184 BoundsMap bounds_map; |
| 171 if (wm::IsActiveWindow(window) && | 185 if (wm::IsActiveWindow(window) && |
| 172 ((WorkspaceManager2::IsMaximizedState(new_state) && | 186 ((WorkspaceManager2::IsMaximizedState(new_state) && |
| 173 wm::IsWindowStateNormal(old_state)) || | 187 wm::IsWindowStateNormal(old_state)) || |
| 174 (!WorkspaceManager2::IsMaximizedState(new_state) && | 188 (!WorkspaceManager2::IsMaximizedState(new_state) && |
| 175 WorkspaceManager2::IsMaximizedState(old_state) && | 189 WorkspaceManager2::IsMaximizedState(old_state) && |
| 176 new_state != ui::SHOW_STATE_MINIMIZED))) { | 190 new_state != ui::SHOW_STATE_MINIMIZED))) { |
| 177 BuildWindowBoundsMap(window, &bounds_map); | 191 BuildWindowBoundsMap(window, &bounds_map); |
| 178 cloned_layer = wm::RecreateWindowLayers(window, false); | 192 cloned_layer = wm::RecreateWindowLayers(window, false); |
| 193 // Constrained windows don't get their bounds reset when we update the | |
| 194 // window bounds. Leaving them empty is unexpected, so we reset them now. | |
| 195 ResetConstrainedWindowBoundsIfNecessary(bounds_map, window); | |
| 179 } | 196 } |
| 180 UpdateBoundsFromShowState(window); | 197 UpdateBoundsFromShowState(window); |
| 181 | 198 |
| 182 if (cloned_layer) { | 199 if (cloned_layer) { |
| 183 // Even though we just set the bounds not all descendants may have valid | 200 // Even though we just set the bounds not all descendants may have valid |
| 184 // bounds. For example, constrained windows don't resize with the parent. | 201 // bounds. For example, constrained windows don't resize with the parent. |
| 185 // Ensure that all windows that had a bounds before we cloned the layer | 202 // Ensure that all windows that had a bounds before we cloned the layer |
| 186 // have a bounds now. | 203 // have a bounds now. |
| 187 ResetBoundsIfNecessary(bounds_map, window); | 204 ResetBoundsIfNecessary(bounds_map, window); |
| 188 } | 205 } |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 339 } | 356 } |
| 340 return false; | 357 return false; |
| 341 } | 358 } |
| 342 | 359 |
| 343 WorkspaceManager2* WorkspaceLayoutManager2::workspace_manager() { | 360 WorkspaceManager2* WorkspaceLayoutManager2::workspace_manager() { |
| 344 return workspace_->workspace_manager(); | 361 return workspace_->workspace_manager(); |
| 345 } | 362 } |
| 346 | 363 |
| 347 } // namespace internal | 364 } // namespace internal |
| 348 } // namespace ash | 365 } // namespace ash |
| OLD | NEW |