| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_positioning_utils.h" | 5 #include "ash/common/wm/window_positioning_utils.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "ash/common/wm/system_modal_container_layout_manager.h" | 9 #include "ash/common/wm/system_modal_container_layout_manager.h" |
| 10 #include "ash/common/wm/window_state.h" | 10 #include "ash/common/wm/window_state.h" |
| 11 #include "ash/common/wm/wm_event.h" | 11 #include "ash/common/wm/wm_event.h" |
| 12 #include "ash/common/wm/wm_screen_util.h" | 12 #include "ash/common/wm/wm_screen_util.h" |
| 13 #include "ash/common/wm_lookup.h" | 13 #include "ash/common/wm_lookup.h" |
| 14 #include "ash/common/wm_root_window_controller.h" | 14 #include "ash/common/wm_root_window_controller.h" |
| 15 #include "ash/common/wm_shell.h" | 15 #include "ash/common/wm_shell.h" |
| 16 #include "ash/common/wm_window.h" | 16 #include "ash/common/wm_window.h" |
| 17 #include "ash/common/wm_window_tracker.h" | 17 #include "ash/common/wm_window_tracker.h" |
| 18 #include "ui/display/display.h" | 18 #include "ui/display/display.h" |
| 19 #include "ui/display/types/display_constants.h" |
| 19 #include "ui/gfx/geometry/rect.h" | 20 #include "ui/gfx/geometry/rect.h" |
| 20 #include "ui/gfx/geometry/size.h" | 21 #include "ui/gfx/geometry/size.h" |
| 21 | 22 |
| 22 namespace ash { | 23 namespace ash { |
| 23 namespace wm { | 24 namespace wm { |
| 24 | 25 |
| 25 namespace { | 26 namespace { |
| 26 | 27 |
| 27 // Returns the default width of a snapped window. | 28 // Returns the default width of a snapped window. |
| 28 int GetDefaultSnappedWindowWidth(WmWindow* window) { | 29 int GetDefaultSnappedWindowWidth(WmWindow* window) { |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 } | 122 } |
| 122 | 123 |
| 123 void CenterWindow(WmWindow* window) { | 124 void CenterWindow(WmWindow* window) { |
| 124 WMEvent event(WM_EVENT_CENTER); | 125 WMEvent event(WM_EVENT_CENTER); |
| 125 window->GetWindowState()->OnWMEvent(&event); | 126 window->GetWindowState()->OnWMEvent(&event); |
| 126 } | 127 } |
| 127 | 128 |
| 128 void SetBoundsInScreen(WmWindow* window, | 129 void SetBoundsInScreen(WmWindow* window, |
| 129 const gfx::Rect& bounds_in_screen, | 130 const gfx::Rect& bounds_in_screen, |
| 130 const display::Display& display) { | 131 const display::Display& display) { |
| 131 DCHECK_NE(display::Display::kInvalidDisplayID, display.id()); | 132 DCHECK_NE(display::kInvalidDisplayId, display.id()); |
| 132 // Don't move a window to other root window if: | 133 // Don't move a window to other root window if: |
| 133 // a) the window is a transient window. It moves when its | 134 // a) the window is a transient window. It moves when its |
| 134 // transient parent moves. | 135 // transient parent moves. |
| 135 // b) if the window or its ancestor has IsLockedToRoot(). It's intentionally | 136 // b) if the window or its ancestor has IsLockedToRoot(). It's intentionally |
| 136 // kept in the same root window even if the bounds is outside of the | 137 // kept in the same root window even if the bounds is outside of the |
| 137 // display. | 138 // display. |
| 138 if (!window->GetTransientParent() && | 139 if (!window->GetTransientParent() && |
| 139 !IsWindowOrAncestorLockedToRoot(window)) { | 140 !IsWindowOrAncestorLockedToRoot(window)) { |
| 140 WmRootWindowController* dst_root_window_controller = | 141 WmRootWindowController* dst_root_window_controller = |
| 141 WmLookup::Get()->GetRootWindowControllerWithDisplayId(display.id()); | 142 WmLookup::Get()->GetRootWindowControllerWithDisplayId(display.id()); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 } | 193 } |
| 193 gfx::Point origin(bounds_in_screen.origin()); | 194 gfx::Point origin(bounds_in_screen.origin()); |
| 194 const gfx::Point display_origin = | 195 const gfx::Point display_origin = |
| 195 window->GetDisplayNearestWindow().bounds().origin(); | 196 window->GetDisplayNearestWindow().bounds().origin(); |
| 196 origin.Offset(-display_origin.x(), -display_origin.y()); | 197 origin.Offset(-display_origin.x(), -display_origin.y()); |
| 197 window->SetBounds(gfx::Rect(origin, bounds_in_screen.size())); | 198 window->SetBounds(gfx::Rect(origin, bounds_in_screen.size())); |
| 198 } | 199 } |
| 199 | 200 |
| 200 } // namespace wm | 201 } // namespace wm |
| 201 } // namespace ash | 202 } // namespace ash |
| OLD | NEW |