| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/window_positioner.h" | 5 #include "ash/wm/window_positioner.h" |
| 6 | 6 |
| 7 #include "ash/screen_util.h" | 7 #include "ash/screen_util.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/shell_port.h" | 9 #include "ash/shell_port.h" |
| 10 #include "ash/wm/mru_window_tracker.h" | 10 #include "ash/wm/mru_window_tracker.h" |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 } | 212 } |
| 213 | 213 |
| 214 // static | 214 // static |
| 215 void WindowPositioner::GetBoundsAndShowStateForNewWindow( | 215 void WindowPositioner::GetBoundsAndShowStateForNewWindow( |
| 216 const WmWindow* new_window, | 216 const WmWindow* new_window, |
| 217 bool is_saved_bounds, | 217 bool is_saved_bounds, |
| 218 ui::WindowShowState show_state_in, | 218 ui::WindowShowState show_state_in, |
| 219 gfx::Rect* bounds_in_out, | 219 gfx::Rect* bounds_in_out, |
| 220 ui::WindowShowState* show_state_out) { | 220 ui::WindowShowState* show_state_out) { |
| 221 // Always open new window in the target display. | 221 // Always open new window in the target display. |
| 222 WmWindow* target = Shell::GetWmRootWindowForNewWindows(); | 222 aura::Window* target = Shell::GetRootWindowForNewWindows(); |
| 223 | 223 |
| 224 WmWindow* top_window = GetReferenceWindow(target, nullptr, nullptr); | 224 WmWindow* top_window = |
| 225 GetReferenceWindow(WmWindow::Get(target), nullptr, nullptr); |
| 225 // Our window should not have any impact if we are already on top. | 226 // Our window should not have any impact if we are already on top. |
| 226 if (top_window == new_window) | 227 if (top_window == new_window) |
| 227 top_window = nullptr; | 228 top_window = nullptr; |
| 228 | 229 |
| 229 // If there is no valid other window we take and adjust the passed coordinates | 230 // If there is no valid other window we take and adjust the passed coordinates |
| 230 // and show state. | 231 // and show state. |
| 231 if (!top_window) { | 232 if (!top_window) { |
| 232 gfx::Rect work_area = target->GetDisplayNearestWindow().work_area(); | 233 gfx::Rect work_area = display::Screen::GetScreen() |
| 234 ->GetDisplayNearestWindow(target) |
| 235 .work_area(); |
| 233 | 236 |
| 234 bounds_in_out->AdjustToFit(work_area); | 237 bounds_in_out->AdjustToFit(work_area); |
| 235 // Use adjusted saved bounds, if there is one. | 238 // Use adjusted saved bounds, if there is one. |
| 236 if (is_saved_bounds) | 239 if (is_saved_bounds) |
| 237 return; | 240 return; |
| 238 | 241 |
| 239 if (show_state_in == ui::SHOW_STATE_DEFAULT) { | 242 if (show_state_in == ui::SHOW_STATE_DEFAULT) { |
| 240 const bool maximize_first_window_on_first_run = | 243 const bool maximize_first_window_on_first_run = |
| 241 ShellPort::Get()->IsForceMaximizeOnFirstRun(); | 244 ShellPort::Get()->IsForceMaximizeOnFirstRun(); |
| 242 // We want to always open maximized on "small screens" or when policy | 245 // We want to always open maximized on "small screens" or when policy |
| (...skipping 24 matching lines...) Expand all Loading... |
| 267 if (has_restore_bounds) { | 270 if (has_restore_bounds) { |
| 268 // For a maximized/fullscreen window ignore the real bounds of | 271 // For a maximized/fullscreen window ignore the real bounds of |
| 269 // the top level window and use its restore bounds | 272 // the top level window and use its restore bounds |
| 270 // instead. Offset the bounds to prevent the windows from | 273 // instead. Offset the bounds to prevent the windows from |
| 271 // overlapping exactly when restored. | 274 // overlapping exactly when restored. |
| 272 *bounds_in_out = | 275 *bounds_in_out = |
| 273 top_window_state->GetRestoreBoundsInScreen() + | 276 top_window_state->GetRestoreBoundsInScreen() + |
| 274 gfx::Vector2d(kMinimumWindowOffset, kMinimumWindowOffset); | 277 gfx::Vector2d(kMinimumWindowOffset, kMinimumWindowOffset); |
| 275 } | 278 } |
| 276 if (is_saved_bounds || has_restore_bounds) { | 279 if (is_saved_bounds || has_restore_bounds) { |
| 277 gfx::Rect work_area = target->GetDisplayNearestWindow().work_area(); | 280 gfx::Rect work_area = display::Screen::GetScreen() |
| 281 ->GetDisplayNearestWindow(target) |
| 282 .work_area(); |
| 278 bounds_in_out->AdjustToFit(work_area); | 283 bounds_in_out->AdjustToFit(work_area); |
| 279 // Use adjusted saved bounds or restore bounds, if there is one. | 284 // Use adjusted saved bounds or restore bounds, if there is one. |
| 280 return; | 285 return; |
| 281 } | 286 } |
| 282 } | 287 } |
| 283 | 288 |
| 284 // Use the size of the other window. The window's bound will be rearranged | 289 // Use the size of the other window. The window's bound will be rearranged |
| 285 // in ash::WorkspaceLayoutManager using this location. | 290 // in ash::WorkspaceLayoutManager using this location. |
| 286 *bounds_in_out = top_window->GetBoundsInScreen(); | 291 *bounds_in_out = top_window->GetBoundsInScreen(); |
| 287 } | 292 } |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 // If the alignment was pushing the window out of the screen, we ignore the | 563 // If the alignment was pushing the window out of the screen, we ignore the |
| 559 // alignment for that call. | 564 // alignment for that call. |
| 560 if (abs(pos.right() - work_area.right()) < grid) | 565 if (abs(pos.right() - work_area.right()) < grid) |
| 561 x = work_area.right() - w; | 566 x = work_area.right() - w; |
| 562 if (abs(pos.bottom() - work_area.bottom()) < grid) | 567 if (abs(pos.bottom() - work_area.bottom()) < grid) |
| 563 y = work_area.bottom() - h; | 568 y = work_area.bottom() - h; |
| 564 return gfx::Rect(x, y, w, h); | 569 return gfx::Rect(x, y, w, h); |
| 565 } | 570 } |
| 566 | 571 |
| 567 } // namespace ash | 572 } // namespace ash |
| OLD | NEW |