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/base_layout_manager.h" | 5 #include "ash/wm/base_layout_manager.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/shelf_layout_manager.h" | 10 #include "ash/wm/shelf_layout_manager.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 // maximized window creates enough space that the resize handles are easily | 27 // maximized window creates enough space that the resize handles are easily |
28 // clickable. We get into this state when updating Chrome OS R18 to R19, as | 28 // clickable. We get into this state when updating Chrome OS R18 to R19, as |
29 // Chrome OS R18 and earlier used only maximized windows and set their restore | 29 // Chrome OS R18 and earlier used only maximized windows and set their restore |
30 // bounds to the size of the screen. See crbug.com/108073 | 30 // bounds to the size of the screen. See crbug.com/108073 |
31 gfx::Rect BoundsWithScreenEdgeVisible(aura::Window* window, | 31 gfx::Rect BoundsWithScreenEdgeVisible(aura::Window* window, |
32 const gfx::Rect& restore_bounds) { | 32 const gfx::Rect& restore_bounds) { |
33 // If the restore_bounds are more than 1 grid step away from the size the | 33 // If the restore_bounds are more than 1 grid step away from the size the |
34 // window would be when maximized, inset it. | 34 // window would be when maximized, inset it. |
35 int grid_size = ash::Shell::GetInstance()->GetGridSize(); | 35 int grid_size = ash::Shell::GetInstance()->GetGridSize(); |
36 gfx::Rect max_bounds = | 36 gfx::Rect max_bounds = |
37 ash::ScreenAsh::GetMaximizedWindowParentBounds(window); | 37 ash::ScreenAsh::GetMaximizedWindowBoundsInParent(window); |
38 max_bounds.Inset(grid_size, grid_size); | 38 max_bounds.Inset(grid_size, grid_size); |
39 if (restore_bounds.Contains(max_bounds)) | 39 if (restore_bounds.Contains(max_bounds)) |
40 return max_bounds; | 40 return max_bounds; |
41 return restore_bounds; | 41 return restore_bounds; |
42 } | 42 } |
43 | 43 |
44 } // namespace | 44 } // namespace |
45 | 45 |
46 namespace ash { | 46 namespace ash { |
47 namespace internal { | 47 namespace internal { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 child->GetProperty(internal::kRestoreShowStateKey)); | 97 child->GetProperty(internal::kRestoreShowStateKey)); |
98 child->ClearProperty(internal::kRestoreShowStateKey); | 98 child->ClearProperty(internal::kRestoreShowStateKey); |
99 } | 99 } |
100 } | 100 } |
101 | 101 |
102 void BaseLayoutManager::SetChildBounds(aura::Window* child, | 102 void BaseLayoutManager::SetChildBounds(aura::Window* child, |
103 const gfx::Rect& requested_bounds) { | 103 const gfx::Rect& requested_bounds) { |
104 gfx::Rect child_bounds(requested_bounds); | 104 gfx::Rect child_bounds(requested_bounds); |
105 // Some windows rely on this to set their initial bounds. | 105 // Some windows rely on this to set their initial bounds. |
106 if (wm::IsWindowMaximized(child)) | 106 if (wm::IsWindowMaximized(child)) |
107 child_bounds = ScreenAsh::GetMaximizedWindowParentBounds(child); | 107 child_bounds = ScreenAsh::GetMaximizedWindowBoundsInParent(child); |
108 else if (wm::IsWindowFullscreen(child)) | 108 else if (wm::IsWindowFullscreen(child)) |
109 child_bounds = ScreenAsh::GetDisplayParentBounds(child); | 109 child_bounds = ScreenAsh::GetDisplayBoundsInParent(child); |
110 SetChildBoundsDirect(child, child_bounds); | 110 SetChildBoundsDirect(child, child_bounds); |
111 } | 111 } |
112 | 112 |
113 ///////////////////////////////////////////////////////////////////////////// | 113 ///////////////////////////////////////////////////////////////////////////// |
114 // BaseLayoutManager, RootWindowObserver overrides: | 114 // BaseLayoutManager, RootWindowObserver overrides: |
115 | 115 |
116 void BaseLayoutManager::OnRootWindowResized(const aura::RootWindow* root, | 116 void BaseLayoutManager::OnRootWindowResized(const aura::RootWindow* root, |
117 const gfx::Size& old_size) { | 117 const gfx::Size& old_size) { |
118 AdjustWindowSizesForScreenChange(); | 118 AdjustWindowSizesForScreenChange(); |
119 } | 119 } |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 bounds_in_parent)); | 187 bounds_in_parent)); |
188 } | 188 } |
189 window->ClearProperty(aura::client::kRestoreBoundsKey); | 189 window->ClearProperty(aura::client::kRestoreBoundsKey); |
190 break; | 190 break; |
191 } | 191 } |
192 | 192 |
193 case ui::SHOW_STATE_MAXIMIZED: | 193 case ui::SHOW_STATE_MAXIMIZED: |
194 SetRestoreBoundsIfNotSet(window); | 194 SetRestoreBoundsIfNotSet(window); |
195 MaybeAnimateToBounds(window, | 195 MaybeAnimateToBounds(window, |
196 animate, | 196 animate, |
197 ScreenAsh::GetMaximizedWindowParentBounds(window)); | 197 ScreenAsh::GetMaximizedWindowBoundsInParent(window)); |
198 break; | 198 break; |
199 | 199 |
200 case ui::SHOW_STATE_FULLSCREEN: | 200 case ui::SHOW_STATE_FULLSCREEN: |
201 SetRestoreBoundsIfNotSet(window); | 201 SetRestoreBoundsIfNotSet(window); |
202 // Don't animate the full-screen window transition. | 202 // Don't animate the full-screen window transition. |
203 // TODO(jamescook): Use animation here. Be sure the lock screen works. | 203 // TODO(jamescook): Use animation here. Be sure the lock screen works. |
204 SetChildBoundsDirect( | 204 SetChildBoundsDirect( |
205 window, ScreenAsh::GetDisplayParentBounds(window)); | 205 window, ScreenAsh::GetDisplayBoundsInParent(window)); |
206 break; | 206 break; |
207 | 207 |
208 default: | 208 default: |
209 break; | 209 break; |
210 } | 210 } |
211 } | 211 } |
212 | 212 |
213 void BaseLayoutManager::MaybeAnimateToBounds(aura::Window* window, | 213 void BaseLayoutManager::MaybeAnimateToBounds(aura::Window* window, |
214 bool animate, | 214 bool animate, |
215 const gfx::Rect& new_bounds) { | 215 const gfx::Rect& new_bounds) { |
(...skipping 14 matching lines...) Expand all Loading... |
230 // display size will change. Maximized windows need to resize to match. | 230 // display size will change. Maximized windows need to resize to match. |
231 // We also do this when developers running Aura on a desktop manually resize | 231 // We also do this when developers running Aura on a desktop manually resize |
232 // the host window. | 232 // the host window. |
233 // We also need to do this when the work area insets changes. | 233 // We also need to do this when the work area insets changes. |
234 for (WindowSet::const_iterator it = windows_.begin(); | 234 for (WindowSet::const_iterator it = windows_.begin(); |
235 it != windows_.end(); | 235 it != windows_.end(); |
236 ++it) { | 236 ++it) { |
237 aura::Window* window = *it; | 237 aura::Window* window = *it; |
238 if (wm::IsWindowMaximized(window)) { | 238 if (wm::IsWindowMaximized(window)) { |
239 SetChildBoundsDirect( | 239 SetChildBoundsDirect( |
240 window, ScreenAsh::GetMaximizedWindowParentBounds(window)); | 240 window, ScreenAsh::GetMaximizedWindowBoundsInParent(window)); |
241 } else if (wm::IsWindowFullscreen(window)) { | 241 } else if (wm::IsWindowFullscreen(window)) { |
242 SetChildBoundsDirect( | 242 SetChildBoundsDirect( |
243 window, ScreenAsh::GetDisplayParentBounds(window)); | 243 window, ScreenAsh::GetDisplayBoundsInParent(window)); |
244 } else { | 244 } else { |
245 // The work area may be smaller than the full screen. | 245 // The work area may be smaller than the full screen. |
246 gfx::Rect display_rect = | 246 gfx::Rect display_rect = |
247 ScreenAsh::GetDisplayWorkAreaParentBounds(window); | 247 ScreenAsh::GetDisplayWorkAreaBoundsInParent(window); |
248 // Put as much of the window as possible within the display area. | 248 // Put as much of the window as possible within the display area. |
249 window->SetBounds(window->bounds().AdjustToFit(display_rect)); | 249 window->SetBounds(window->bounds().AdjustToFit(display_rect)); |
250 } | 250 } |
251 } | 251 } |
252 } | 252 } |
253 | 253 |
254 } // namespace internal | 254 } // namespace internal |
255 } // namespace ash | 255 } // namespace ash |
OLD | NEW |