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/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/wm/property_util.h" | 8 #include "ash/wm/property_util.h" |
9 #include "ash/wm/window_util.h" | 9 #include "ash/wm/window_util.h" |
10 #include "ui/aura/client/aura_constants.h" | 10 #include "ui/aura/client/aura_constants.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 child_bounds = gfx::Screen::GetMonitorWorkAreaNearestWindow(child); | 60 child_bounds = gfx::Screen::GetMonitorWorkAreaNearestWindow(child); |
61 else if (wm::IsWindowFullscreen(child)) | 61 else if (wm::IsWindowFullscreen(child)) |
62 child_bounds = gfx::Screen::GetMonitorAreaNearestWindow(child); | 62 child_bounds = gfx::Screen::GetMonitorAreaNearestWindow(child); |
63 SetChildBoundsDirect(child, child_bounds); | 63 SetChildBoundsDirect(child, child_bounds); |
64 } | 64 } |
65 | 65 |
66 ///////////////////////////////////////////////////////////////////////////// | 66 ///////////////////////////////////////////////////////////////////////////// |
67 // BaseLayoutManager, RootWindowObserver overrides: | 67 // BaseLayoutManager, RootWindowObserver overrides: |
68 | 68 |
69 void BaseLayoutManager::OnRootWindowResized(const gfx::Size& new_size) { | 69 void BaseLayoutManager::OnRootWindowResized(const gfx::Size& new_size) { |
70 // If a user plugs an external monitor into a laptop running Aura the | 70 AdjustWindowSizesForScreenChange(); |
71 // monitor size will change. Maximized windows need to resize to match. | 71 } |
72 // We also do this when developers running Aura on a desktop manually resize | 72 |
73 // the host window. | 73 void BaseLayoutManager::OnScreenWorkAreaInsetsChanged() { |
74 for (WindowSet::const_iterator it = windows_.begin(); | 74 AdjustWindowSizesForScreenChange(); |
75 it != windows_.end(); | |
76 ++it) { | |
77 aura::Window* window = *it; | |
78 // The work area may be smaller than the full screen. | |
79 gfx::Rect monitor_rect = wm::IsWindowFullscreen(window) ? | |
80 gfx::Screen::GetMonitorAreaNearestWindow(window) : | |
81 gfx::Screen::GetMonitorWorkAreaNearestWindow(window); | |
82 // Put as much of the window as possible within the monitor area. | |
83 window->SetBounds(window->bounds().AdjustToFit(monitor_rect)); | |
84 } | |
85 } | 75 } |
86 | 76 |
87 ///////////////////////////////////////////////////////////////////////////// | 77 ///////////////////////////////////////////////////////////////////////////// |
88 // BaseLayoutManager, WindowObserver overrides: | 78 // BaseLayoutManager, WindowObserver overrides: |
89 | 79 |
90 void BaseLayoutManager::OnWindowPropertyChanged(aura::Window* window, | 80 void BaseLayoutManager::OnWindowPropertyChanged(aura::Window* window, |
91 const void* key, | 81 const void* key, |
92 intptr_t old) { | 82 intptr_t old) { |
93 if (key == aura::client::kShowStateKey) | 83 if (key == aura::client::kShowStateKey) |
94 UpdateBoundsFromShowState(window); | 84 UpdateBoundsFromShowState(window); |
(...skipping 22 matching lines...) Expand all Loading... |
117 case ui::SHOW_STATE_FULLSCREEN: | 107 case ui::SHOW_STATE_FULLSCREEN: |
118 SetRestoreBoundsIfNotSet(window); | 108 SetRestoreBoundsIfNotSet(window); |
119 window->SetBounds(gfx::Screen::GetMonitorAreaNearestWindow(window)); | 109 window->SetBounds(gfx::Screen::GetMonitorAreaNearestWindow(window)); |
120 break; | 110 break; |
121 | 111 |
122 default: | 112 default: |
123 break; | 113 break; |
124 } | 114 } |
125 } | 115 } |
126 | 116 |
| 117 void BaseLayoutManager::AdjustWindowSizesForScreenChange() { |
| 118 // If a user plugs an external monitor into a laptop running Aura the |
| 119 // monitor size will change. Maximized windows need to resize to match. |
| 120 // We also do this when developers running Aura on a desktop manually resize |
| 121 // the host window. |
| 122 // We also need to do this when the work area insets changes. |
| 123 for (WindowSet::const_iterator it = windows_.begin(); |
| 124 it != windows_.end(); |
| 125 ++it) { |
| 126 aura::Window* window = *it; |
| 127 // The work area may be smaller than the full screen. |
| 128 gfx::Rect monitor_rect = wm::IsWindowFullscreen(window) ? |
| 129 gfx::Screen::GetMonitorAreaNearestWindow(window) : |
| 130 gfx::Screen::GetMonitorWorkAreaNearestWindow(window); |
| 131 // Put as much of the window as possible within the monitor area. |
| 132 window->SetBounds(window->bounds().AdjustToFit(monitor_rect)); |
| 133 } |
| 134 } |
| 135 |
127 } // namespace internal | 136 } // namespace internal |
128 } // namespace ash | 137 } // namespace ash |
OLD | NEW |