| 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" | |
| 14 #include "ash/common/wm_shell.h" | 13 #include "ash/common/wm_shell.h" |
| 15 #include "ash/common/wm_window.h" | 14 #include "ash/common/wm_window.h" |
| 16 #include "ash/root_window_controller.h" | 15 #include "ash/root_window_controller.h" |
| 16 #include "ash/shell.h" |
| 17 #include "ui/aura/window_tracker.h" | 17 #include "ui/aura/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/display/types/display_constants.h" |
| 20 #include "ui/gfx/geometry/rect.h" | 20 #include "ui/gfx/geometry/rect.h" |
| 21 #include "ui/gfx/geometry/size.h" | 21 #include "ui/gfx/geometry/size.h" |
| 22 | 22 |
| 23 namespace ash { | 23 namespace ash { |
| 24 namespace wm { | 24 namespace wm { |
| 25 | 25 |
| 26 namespace { | 26 namespace { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 40 // IsLockedToRoot(). | 40 // IsLockedToRoot(). |
| 41 bool IsWindowOrAncestorLockedToRoot(const WmWindow* window) { | 41 bool IsWindowOrAncestorLockedToRoot(const WmWindow* window) { |
| 42 return window && (window->IsLockedToRoot() || | 42 return window && (window->IsLockedToRoot() || |
| 43 IsWindowOrAncestorLockedToRoot(window->GetParent())); | 43 IsWindowOrAncestorLockedToRoot(window->GetParent())); |
| 44 } | 44 } |
| 45 | 45 |
| 46 // Move all transient children to |dst_root|, including the ones in | 46 // Move all transient children to |dst_root|, including the ones in |
| 47 // the child windows and transient children of the transient children. | 47 // the child windows and transient children of the transient children. |
| 48 void MoveAllTransientChildrenToNewRoot(const display::Display& display, | 48 void MoveAllTransientChildrenToNewRoot(const display::Display& display, |
| 49 WmWindow* window) { | 49 WmWindow* window) { |
| 50 WmWindow* dst_root = WmLookup::Get() | 50 WmWindow* dst_root = |
| 51 ->GetRootWindowControllerWithDisplayId(display.id()) | 51 Shell::GetRootWindowControllerWithDisplayId(display.id())->GetWindow(); |
| 52 ->GetWindow(); | |
| 53 for (WmWindow* transient_child : window->GetTransientChildren()) { | 52 for (WmWindow* transient_child : window->GetTransientChildren()) { |
| 54 const int container_id = transient_child->GetParent()->GetShellWindowId(); | 53 const int container_id = transient_child->GetParent()->GetShellWindowId(); |
| 55 DCHECK_GE(container_id, 0); | 54 DCHECK_GE(container_id, 0); |
| 56 WmWindow* container = dst_root->GetChildByShellWindowId(container_id); | 55 WmWindow* container = dst_root->GetChildByShellWindowId(container_id); |
| 57 const gfx::Rect transient_child_bounds_in_screen = | 56 const gfx::Rect transient_child_bounds_in_screen = |
| 58 transient_child->GetBoundsInScreen(); | 57 transient_child->GetBoundsInScreen(); |
| 59 container->AddChild(transient_child); | 58 container->AddChild(transient_child); |
| 60 transient_child->SetBoundsInScreen(transient_child_bounds_in_screen, | 59 transient_child->SetBoundsInScreen(transient_child_bounds_in_screen, |
| 61 display); | 60 display); |
| 62 | 61 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 DCHECK_NE(display::kInvalidDisplayId, display.id()); | 131 DCHECK_NE(display::kInvalidDisplayId, display.id()); |
| 133 // Don't move a window to other root window if: | 132 // Don't move a window to other root window if: |
| 134 // a) the window is a transient window. It moves when its | 133 // a) the window is a transient window. It moves when its |
| 135 // transient parent moves. | 134 // transient parent moves. |
| 136 // b) if the window or its ancestor has IsLockedToRoot(). It's intentionally | 135 // b) if the window or its ancestor has IsLockedToRoot(). It's intentionally |
| 137 // kept in the same root window even if the bounds is outside of the | 136 // kept in the same root window even if the bounds is outside of the |
| 138 // display. | 137 // display. |
| 139 if (!window->GetTransientParent() && | 138 if (!window->GetTransientParent() && |
| 140 !IsWindowOrAncestorLockedToRoot(window)) { | 139 !IsWindowOrAncestorLockedToRoot(window)) { |
| 141 RootWindowController* dst_root_window_controller = | 140 RootWindowController* dst_root_window_controller = |
| 142 WmLookup::Get()->GetRootWindowControllerWithDisplayId(display.id()); | 141 Shell::GetRootWindowControllerWithDisplayId(display.id()); |
| 143 DCHECK(dst_root_window_controller); | 142 DCHECK(dst_root_window_controller); |
| 144 WmWindow* dst_root = dst_root_window_controller->GetWindow(); | 143 WmWindow* dst_root = dst_root_window_controller->GetWindow(); |
| 145 DCHECK(dst_root); | 144 DCHECK(dst_root); |
| 146 WmWindow* dst_container = nullptr; | 145 WmWindow* dst_container = nullptr; |
| 147 if (dst_root != window->GetRootWindow()) { | 146 if (dst_root != window->GetRootWindow()) { |
| 148 int container_id = window->GetParent()->GetShellWindowId(); | 147 int container_id = window->GetParent()->GetShellWindowId(); |
| 149 // All containers that uses screen coordinates must have valid window ids. | 148 // All containers that uses screen coordinates must have valid window ids. |
| 150 DCHECK_GE(container_id, 0); | 149 DCHECK_GE(container_id, 0); |
| 151 // Don't move modal background. | 150 // Don't move modal background. |
| 152 if (!SystemModalContainerLayoutManager::IsModalBackground(window)) | 151 if (!SystemModalContainerLayoutManager::IsModalBackground(window)) |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 } | 192 } |
| 194 gfx::Point origin(bounds_in_screen.origin()); | 193 gfx::Point origin(bounds_in_screen.origin()); |
| 195 const gfx::Point display_origin = | 194 const gfx::Point display_origin = |
| 196 window->GetDisplayNearestWindow().bounds().origin(); | 195 window->GetDisplayNearestWindow().bounds().origin(); |
| 197 origin.Offset(-display_origin.x(), -display_origin.y()); | 196 origin.Offset(-display_origin.x(), -display_origin.y()); |
| 198 window->SetBounds(gfx::Rect(origin, bounds_in_screen.size())); | 197 window->SetBounds(gfx::Rect(origin, bounds_in_screen.size())); |
| 199 } | 198 } |
| 200 | 199 |
| 201 } // namespace wm | 200 } // namespace wm |
| 202 } // namespace ash | 201 } // namespace ash |
| OLD | NEW |