| 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/shell.h" | 8 #include "ash/shell.h" |
| 8 #include "ash/wm/property_util.h" | 9 #include "ash/wm/property_util.h" |
| 10 #include "ash/wm/shelf_layout_manager.h" |
| 9 #include "ash/wm/window_util.h" | 11 #include "ash/wm/window_util.h" |
| 10 #include "ui/aura/client/aura_constants.h" | 12 #include "ui/aura/client/aura_constants.h" |
| 11 #include "ui/aura/root_window.h" | 13 #include "ui/aura/root_window.h" |
| 12 #include "ui/aura/window.h" | 14 #include "ui/aura/window.h" |
| 13 #include "ui/base/ui_base_types.h" | 15 #include "ui/base/ui_base_types.h" |
| 14 #include "ui/gfx/screen.h" | 16 #include "ui/gfx/screen.h" |
| 15 | 17 |
| 16 namespace ash { | 18 namespace ash { |
| 17 namespace internal { | 19 namespace internal { |
| 18 | 20 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 void BaseLayoutManager::OnChildWindowVisibilityChanged(aura::Window* child, | 55 void BaseLayoutManager::OnChildWindowVisibilityChanged(aura::Window* child, |
| 54 bool visibile) { | 56 bool visibile) { |
| 55 } | 57 } |
| 56 | 58 |
| 57 void BaseLayoutManager::SetChildBounds(aura::Window* child, | 59 void BaseLayoutManager::SetChildBounds(aura::Window* child, |
| 58 const gfx::Rect& requested_bounds) { | 60 const gfx::Rect& requested_bounds) { |
| 59 gfx::Rect child_bounds(requested_bounds); | 61 gfx::Rect child_bounds(requested_bounds); |
| 60 // Avoid a janky resize on startup by ensuring the initial bounds fill the | 62 // Avoid a janky resize on startup by ensuring the initial bounds fill the |
| 61 // screen. | 63 // screen. |
| 62 if (wm::IsWindowMaximized(child)) | 64 if (wm::IsWindowMaximized(child)) |
| 63 child_bounds = gfx::Screen::GetMonitorWorkAreaNearestWindow(child); | 65 child_bounds = ScreenAsh::GetMaximizedWindowBounds(child); |
| 64 else if (wm::IsWindowFullscreen(child)) | 66 else if (wm::IsWindowFullscreen(child)) |
| 65 child_bounds = gfx::Screen::GetMonitorAreaNearestWindow(child); | 67 child_bounds = gfx::Screen::GetMonitorAreaNearestWindow(child); |
| 66 SetChildBoundsDirect(child, child_bounds); | 68 SetChildBoundsDirect(child, child_bounds); |
| 67 } | 69 } |
| 68 | 70 |
| 69 ///////////////////////////////////////////////////////////////////////////// | 71 ///////////////////////////////////////////////////////////////////////////// |
| 70 // BaseLayoutManager, RootWindowObserver overrides: | 72 // BaseLayoutManager, RootWindowObserver overrides: |
| 71 | 73 |
| 72 void BaseLayoutManager::OnRootWindowResized(const gfx::Size& new_size) { | 74 void BaseLayoutManager::OnRootWindowResized(const gfx::Size& new_size) { |
| 73 AdjustWindowSizesForScreenChange(); | 75 AdjustWindowSizesForScreenChange(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 92 | 94 |
| 93 ////////////////////////////////////////////////////////////////////////////// | 95 ////////////////////////////////////////////////////////////////////////////// |
| 94 // BaseLayoutManager, private: | 96 // BaseLayoutManager, private: |
| 95 | 97 |
| 96 void BaseLayoutManager::UpdateBoundsFromShowState(aura::Window* window) { | 98 void BaseLayoutManager::UpdateBoundsFromShowState(aura::Window* window) { |
| 97 switch (window->GetProperty(aura::client::kShowStateKey)) { | 99 switch (window->GetProperty(aura::client::kShowStateKey)) { |
| 98 case ui::SHOW_STATE_DEFAULT: | 100 case ui::SHOW_STATE_DEFAULT: |
| 99 case ui::SHOW_STATE_NORMAL: { | 101 case ui::SHOW_STATE_NORMAL: { |
| 100 const gfx::Rect* restore = GetRestoreBounds(window); | 102 const gfx::Rect* restore = GetRestoreBounds(window); |
| 101 if (restore) | 103 if (restore) |
| 102 window->SetBounds(*restore); | 104 SetChildBoundsDirect(window, *restore); |
| 103 window->ClearProperty(aura::client::kRestoreBoundsKey); | 105 window->ClearProperty(aura::client::kRestoreBoundsKey); |
| 104 break; | 106 break; |
| 105 } | 107 } |
| 106 | 108 |
| 107 case ui::SHOW_STATE_MAXIMIZED: | 109 case ui::SHOW_STATE_MAXIMIZED: |
| 108 SetRestoreBoundsIfNotSet(window); | 110 SetRestoreBoundsIfNotSet(window); |
| 109 window->SetBounds(gfx::Screen::GetMonitorWorkAreaNearestWindow(window)); | 111 SetChildBoundsDirect(window, ScreenAsh::GetMaximizedWindowBounds(window)); |
| 110 break; | 112 break; |
| 111 | 113 |
| 112 case ui::SHOW_STATE_FULLSCREEN: | 114 case ui::SHOW_STATE_FULLSCREEN: |
| 113 SetRestoreBoundsIfNotSet(window); | 115 SetRestoreBoundsIfNotSet(window); |
| 114 window->SetBounds(gfx::Screen::GetMonitorAreaNearestWindow(window)); | 116 SetChildBoundsDirect(window, |
| 117 gfx::Screen::GetMonitorAreaNearestWindow(window)); |
| 115 break; | 118 break; |
| 116 | 119 |
| 117 default: | 120 default: |
| 118 break; | 121 break; |
| 119 } | 122 } |
| 120 } | 123 } |
| 121 | 124 |
| 122 void BaseLayoutManager::AdjustWindowSizesForScreenChange() { | 125 void BaseLayoutManager::AdjustWindowSizesForScreenChange() { |
| 123 // If a user plugs an external monitor into a laptop running Aura the | 126 // If a user plugs an external monitor into a laptop running Aura the |
| 124 // monitor size will change. Maximized windows need to resize to match. | 127 // monitor size will change. Maximized windows need to resize to match. |
| 125 // We also do this when developers running Aura on a desktop manually resize | 128 // We also do this when developers running Aura on a desktop manually resize |
| 126 // the host window. | 129 // the host window. |
| 127 // We also need to do this when the work area insets changes. | 130 // We also need to do this when the work area insets changes. |
| 128 for (WindowSet::const_iterator it = windows_.begin(); | 131 for (WindowSet::const_iterator it = windows_.begin(); |
| 129 it != windows_.end(); | 132 it != windows_.end(); |
| 130 ++it) { | 133 ++it) { |
| 131 aura::Window* window = *it; | 134 aura::Window* window = *it; |
| 132 // The work area may be smaller than the full screen. | 135 if (wm::IsWindowMaximized(window)) { |
| 133 gfx::Rect monitor_rect = wm::IsWindowFullscreen(window) ? | 136 SetChildBoundsDirect(window, ScreenAsh::GetMaximizedWindowBounds(window)); |
| 134 gfx::Screen::GetMonitorAreaNearestWindow(window) : | 137 } else if (wm::IsWindowFullscreen(window)) { |
| 135 gfx::Screen::GetMonitorWorkAreaNearestWindow(window); | 138 SetChildBoundsDirect(window, |
| 136 // Put as much of the window as possible within the monitor area. | 139 gfx::Screen::GetMonitorAreaNearestWindow(window)); |
| 137 window->SetBounds(window->bounds().AdjustToFit(monitor_rect)); | 140 } else { |
| 141 // The work area may be smaller than the full screen. |
| 142 gfx::Rect monitor_rect = |
| 143 gfx::Screen::GetMonitorWorkAreaNearestWindow(window); |
| 144 // Put as much of the window as possible within the monitor area. |
| 145 window->SetBounds(window->bounds().AdjustToFit(monitor_rect)); |
| 146 } |
| 138 } | 147 } |
| 139 } | 148 } |
| 140 | 149 |
| 141 } // namespace internal | 150 } // namespace internal |
| 142 } // namespace ash | 151 } // namespace ash |
| OLD | NEW |