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 "chrome/browser/ui/window_sizer/window_sizer.h" | 5 #include "chrome/browser/ui/window_sizer/window_sizer.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/wm/window_cycle_controller.h" | 8 #include "ash/wm/window_cycle_controller.h" |
9 #include "ash/wm/window_util.h" | 9 #include "ash/wm/window_util.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 // We ignore the saved show state, but look instead for the top level | 149 // We ignore the saved show state, but look instead for the top level |
150 // window's show state. | 150 // window's show state. |
151 if (passed_show_state == ui::SHOW_STATE_DEFAULT) { | 151 if (passed_show_state == ui::SHOW_STATE_DEFAULT) { |
152 *show_state = maximized ? ui::SHOW_STATE_MAXIMIZED : | 152 *show_state = maximized ? ui::SHOW_STATE_MAXIMIZED : |
153 ui::SHOW_STATE_DEFAULT; | 153 ui::SHOW_STATE_DEFAULT; |
154 } | 154 } |
155 | 155 |
156 if (maximized) | 156 if (maximized) |
157 return true; | 157 return true; |
158 | 158 |
| 159 gfx::Rect other_bounds_in_screen = top_window->GetBoundsInScreen(); |
| 160 bool move_right = |
| 161 other_bounds_in_screen.CenterPoint().x() < work_area.CenterPoint().x(); |
| 162 |
| 163 // In case we have only one window, we move the other window fully to the |
| 164 // "other side" - making room for this new window. |
| 165 if (count == 1) { |
| 166 gfx::Display display = ash::Shell::GetScreen()->GetDisplayMatching( |
| 167 top_window->GetRootWindow()->GetBoundsInScreen()); |
| 168 if (MoveRect(work_area, other_bounds_in_screen, !move_right)) |
| 169 top_window->SetBoundsInScreen(other_bounds_in_screen, display); |
| 170 } |
159 // Use the size of the other window, and mirror the location to the | 171 // Use the size of the other window, and mirror the location to the |
160 // opposite side. Then make sure that it is inside our work area | 172 // opposite side. Then make sure that it is inside our work area |
161 // (if possible). | 173 // (if possible). |
162 *bounds_in_screen = top_window->GetBoundsInScreen(); | 174 *bounds_in_screen = other_bounds_in_screen; |
163 | |
164 bool move_right = | |
165 bounds_in_screen->CenterPoint().x() < work_area.CenterPoint().x(); | |
166 | |
167 MoveRect(work_area, *bounds_in_screen, move_right); | 175 MoveRect(work_area, *bounds_in_screen, move_right); |
168 if (bounds_in_screen->bottom() > work_area.bottom()) | 176 if (bounds_in_screen->bottom() > work_area.bottom()) |
169 bounds_in_screen->set_y(std::max(work_area.y(), | 177 bounds_in_screen->set_y(std::max(work_area.y(), |
170 work_area.bottom() - bounds_in_screen->height())); | 178 work_area.bottom() - bounds_in_screen->height())); |
171 return true; | 179 return true; |
172 } | 180 } |
173 | 181 |
174 return false; | 182 return false; |
175 } | 183 } |
176 | 184 |
(...skipping 17 matching lines...) Expand all Loading... |
194 if (default_width > kMaximumWindowWidth) { | 202 if (default_width > kMaximumWindowWidth) { |
195 // The window should get centered on the screen and not follow the grid. | 203 // The window should get centered on the screen and not follow the grid. |
196 offset_x = (work_area.width() - kMaximumWindowWidth) / 2; | 204 offset_x = (work_area.width() - kMaximumWindowWidth) / 2; |
197 default_width = kMaximumWindowWidth; | 205 default_width = kMaximumWindowWidth; |
198 } | 206 } |
199 default_bounds->SetRect(work_area.x() + offset_x, | 207 default_bounds->SetRect(work_area.x() + offset_x, |
200 work_area.y() + kDesktopBorderSize, | 208 work_area.y() + kDesktopBorderSize, |
201 default_width, | 209 default_width, |
202 default_height); | 210 default_height); |
203 } | 211 } |
OLD | NEW |