| 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/common/wm/window_positioner.h" | 5 #include "ash/common/wm/window_positioner.h" |
| 6 | 6 |
| 7 #include "ash/common/wm/mru_window_tracker.h" | 7 #include "ash/common/wm/mru_window_tracker.h" |
| 8 #include "ash/common/wm/window_positioning_utils.h" | 8 #include "ash/common/wm/window_positioning_utils.h" |
| 9 #include "ash/common/wm/window_state.h" | 9 #include "ash/common/wm/window_state.h" |
| 10 #include "ash/common/wm/wm_screen_util.h" | 10 #include "ash/common/wm/wm_screen_util.h" |
| 11 #include "ash/common/wm_shell.h" | 11 #include "ash/common/wm_shell.h" |
| 12 #include "ash/common/wm_window.h" | 12 #include "ash/common/wm_window.h" |
| 13 #include "ash/shell.h" |
| 13 #include "ui/compositor/layer.h" | 14 #include "ui/compositor/layer.h" |
| 14 #include "ui/display/display.h" | 15 #include "ui/display/display.h" |
| 15 #include "ui/display/screen.h" | 16 #include "ui/display/screen.h" |
| 16 #include "ui/gfx/geometry/insets.h" | 17 #include "ui/gfx/geometry/insets.h" |
| 17 | 18 |
| 18 namespace ash { | 19 namespace ash { |
| 19 | 20 |
| 20 const int WindowPositioner::kMinimumWindowOffset = 32; | 21 const int WindowPositioner::kMinimumWindowOffset = 32; |
| 21 | 22 |
| 22 // The number of pixels which are kept free top, left and right when a window | 23 // The number of pixels which are kept free top, left and right when a window |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 } | 211 } |
| 211 | 212 |
| 212 // static | 213 // static |
| 213 void WindowPositioner::GetBoundsAndShowStateForNewWindow( | 214 void WindowPositioner::GetBoundsAndShowStateForNewWindow( |
| 214 const WmWindow* new_window, | 215 const WmWindow* new_window, |
| 215 bool is_saved_bounds, | 216 bool is_saved_bounds, |
| 216 ui::WindowShowState show_state_in, | 217 ui::WindowShowState show_state_in, |
| 217 gfx::Rect* bounds_in_out, | 218 gfx::Rect* bounds_in_out, |
| 218 ui::WindowShowState* show_state_out) { | 219 ui::WindowShowState* show_state_out) { |
| 219 // Always open new window in the target display. | 220 // Always open new window in the target display. |
| 220 WmWindow* target = WmShell::Get()->GetRootWindowForNewWindows(); | 221 WmWindow* target = Shell::GetWmRootWindowForNewWindows(); |
| 221 | 222 |
| 222 WmWindow* top_window = GetReferenceWindow(target, nullptr, nullptr); | 223 WmWindow* top_window = GetReferenceWindow(target, nullptr, nullptr); |
| 223 // Our window should not have any impact if we are already on top. | 224 // Our window should not have any impact if we are already on top. |
| 224 if (top_window == new_window) | 225 if (top_window == new_window) |
| 225 top_window = nullptr; | 226 top_window = nullptr; |
| 226 | 227 |
| 227 // If there is no valid other window we take and adjust the passed coordinates | 228 // If there is no valid other window we take and adjust the passed coordinates |
| 228 // and show state. | 229 // and show state. |
| 229 if (!top_window) { | 230 if (!top_window) { |
| 230 gfx::Rect work_area = target->GetDisplayNearestWindow().work_area(); | 231 gfx::Rect work_area = target->GetDisplayNearestWindow().work_area(); |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 // If the alignment was pushing the window out of the screen, we ignore the | 556 // If the alignment was pushing the window out of the screen, we ignore the |
| 556 // alignment for that call. | 557 // alignment for that call. |
| 557 if (abs(pos.right() - work_area.right()) < grid) | 558 if (abs(pos.right() - work_area.right()) < grid) |
| 558 x = work_area.right() - w; | 559 x = work_area.right() - w; |
| 559 if (abs(pos.bottom() - work_area.bottom()) < grid) | 560 if (abs(pos.bottom() - work_area.bottom()) < grid) |
| 560 y = work_area.bottom() - h; | 561 y = work_area.bottom() - h; |
| 561 return gfx::Rect(x, y, w, h); | 562 return gfx::Rect(x, y, w, h); |
| 562 } | 563 } |
| 563 | 564 |
| 564 } // namespace ash | 565 } // namespace ash |
| OLD | NEW |