| 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/screen_ash.h" | 7 #include "ash/screen_ash.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/wm/property_util.h" | 9 #include "ash/wm/property_util.h" |
| 10 #include "ash/wm/shelf_layout_manager.h" | 10 #include "ash/wm/shelf_layout_manager.h" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 } | 104 } |
| 105 | 105 |
| 106 void BaseLayoutManager::SetChildBounds(aura::Window* child, | 106 void BaseLayoutManager::SetChildBounds(aura::Window* child, |
| 107 const gfx::Rect& requested_bounds) { | 107 const gfx::Rect& requested_bounds) { |
| 108 gfx::Rect child_bounds(requested_bounds); | 108 gfx::Rect child_bounds(requested_bounds); |
| 109 // Avoid a janky resize on startup by ensuring the initial bounds fill the | 109 // Avoid a janky resize on startup by ensuring the initial bounds fill the |
| 110 // screen. | 110 // screen. |
| 111 if (wm::IsWindowMaximized(child)) | 111 if (wm::IsWindowMaximized(child)) |
| 112 child_bounds = ScreenAsh::GetMaximizedWindowBounds(child); | 112 child_bounds = ScreenAsh::GetMaximizedWindowBounds(child); |
| 113 else if (wm::IsWindowFullscreen(child)) | 113 else if (wm::IsWindowFullscreen(child)) |
| 114 child_bounds = gfx::Screen::GetMonitorAreaNearestWindow(child); | 114 child_bounds = gfx::Screen::GetMonitorNearestWindow(child).bounds(); |
| 115 SetChildBoundsDirect(child, child_bounds); | 115 SetChildBoundsDirect(child, child_bounds); |
| 116 } | 116 } |
| 117 | 117 |
| 118 ///////////////////////////////////////////////////////////////////////////// | 118 ///////////////////////////////////////////////////////////////////////////// |
| 119 // BaseLayoutManager, RootWindowObserver overrides: | 119 // BaseLayoutManager, RootWindowObserver overrides: |
| 120 | 120 |
| 121 void BaseLayoutManager::OnRootWindowResized(const aura::RootWindow* root, | 121 void BaseLayoutManager::OnRootWindowResized(const aura::RootWindow* root, |
| 122 const gfx::Size& old_size) { | 122 const gfx::Size& old_size) { |
| 123 AdjustWindowSizesForScreenChange(); | 123 AdjustWindowSizesForScreenChange(); |
| 124 } | 124 } |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 break; | 187 break; |
| 188 } | 188 } |
| 189 | 189 |
| 190 case ui::SHOW_STATE_MAXIMIZED: | 190 case ui::SHOW_STATE_MAXIMIZED: |
| 191 SetRestoreBoundsIfNotSet(window); | 191 SetRestoreBoundsIfNotSet(window); |
| 192 SetChildBoundsDirect(window, ScreenAsh::GetMaximizedWindowBounds(window)); | 192 SetChildBoundsDirect(window, ScreenAsh::GetMaximizedWindowBounds(window)); |
| 193 break; | 193 break; |
| 194 | 194 |
| 195 case ui::SHOW_STATE_FULLSCREEN: | 195 case ui::SHOW_STATE_FULLSCREEN: |
| 196 SetRestoreBoundsIfNotSet(window); | 196 SetRestoreBoundsIfNotSet(window); |
| 197 SetChildBoundsDirect(window, | 197 SetChildBoundsDirect( |
| 198 gfx::Screen::GetMonitorAreaNearestWindow(window)); | 198 window, gfx::Screen::GetMonitorNearestWindow(window).bounds()); |
| 199 break; | 199 break; |
| 200 | 200 |
| 201 default: | 201 default: |
| 202 break; | 202 break; |
| 203 } | 203 } |
| 204 } | 204 } |
| 205 | 205 |
| 206 void BaseLayoutManager::AdjustWindowSizesForScreenChange() { | 206 void BaseLayoutManager::AdjustWindowSizesForScreenChange() { |
| 207 // If a user plugs an external monitor into a laptop running Aura the | 207 // If a user plugs an external monitor into a laptop running Aura the |
| 208 // monitor size will change. Maximized windows need to resize to match. | 208 // monitor size will change. Maximized windows need to resize to match. |
| 209 // We also do this when developers running Aura on a desktop manually resize | 209 // We also do this when developers running Aura on a desktop manually resize |
| 210 // the host window. | 210 // the host window. |
| 211 // We also need to do this when the work area insets changes. | 211 // We also need to do this when the work area insets changes. |
| 212 for (WindowSet::const_iterator it = windows_.begin(); | 212 for (WindowSet::const_iterator it = windows_.begin(); |
| 213 it != windows_.end(); | 213 it != windows_.end(); |
| 214 ++it) { | 214 ++it) { |
| 215 aura::Window* window = *it; | 215 aura::Window* window = *it; |
| 216 if (wm::IsWindowMaximized(window)) { | 216 if (wm::IsWindowMaximized(window)) { |
| 217 SetChildBoundsDirect(window, ScreenAsh::GetMaximizedWindowBounds(window)); | 217 SetChildBoundsDirect(window, ScreenAsh::GetMaximizedWindowBounds(window)); |
| 218 } else if (wm::IsWindowFullscreen(window)) { | 218 } else if (wm::IsWindowFullscreen(window)) { |
| 219 SetChildBoundsDirect(window, | 219 SetChildBoundsDirect( |
| 220 gfx::Screen::GetMonitorAreaNearestWindow(window)); | 220 window, gfx::Screen::GetMonitorNearestWindow(window).bounds()); |
| 221 } else { | 221 } else { |
| 222 // The work area may be smaller than the full screen. | 222 // The work area may be smaller than the full screen. |
| 223 gfx::Rect monitor_rect = | 223 gfx::Rect monitor_rect = |
| 224 gfx::Screen::GetMonitorWorkAreaNearestWindow(window); | 224 gfx::Screen::GetMonitorNearestWindow(window).work_area(); |
| 225 // Put as much of the window as possible within the monitor area. | 225 // Put as much of the window as possible within the monitor area. |
| 226 window->SetBounds(window->bounds().AdjustToFit(monitor_rect)); | 226 window->SetBounds(window->bounds().AdjustToFit(monitor_rect)); |
| 227 } | 227 } |
| 228 } | 228 } |
| 229 } | 229 } |
| 230 | 230 |
| 231 } // namespace internal | 231 } // namespace internal |
| 232 } // namespace ash | 232 } // namespace ash |
| OLD | NEW |