| 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 "ash/display/screen_position_controller.h" | 5 #include "ash/display/screen_position_controller.h" |
| 6 | 6 |
| 7 #include "ash/display/display_controller.h" | 7 #include "ash/display/display_controller.h" |
| 8 #include "ash/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/shell_window_ids.h" | 10 #include "ash/shell_window_ids.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 ShouldStayInSameRootWindow(window->parent())); | 33 ShouldStayInSameRootWindow(window->parent())); |
| 34 } | 34 } |
| 35 | 35 |
| 36 // Move all transient children to |dst_root|, including the ones in | 36 // Move all transient children to |dst_root|, including the ones in |
| 37 // the child windows and transient children of the transient children. | 37 // the child windows and transient children of the transient children. |
| 38 void MoveAllTransientChildrenToNewRoot(const gfx::Display& display, | 38 void MoveAllTransientChildrenToNewRoot(const gfx::Display& display, |
| 39 aura::Window* window) { | 39 aura::Window* window) { |
| 40 aura::Window* dst_root = Shell::GetInstance()->display_controller()-> | 40 aura::Window* dst_root = Shell::GetInstance()->display_controller()-> |
| 41 GetRootWindowForDisplayId(display.id()); | 41 GetRootWindowForDisplayId(display.id()); |
| 42 aura::Window::Windows transient_children = | 42 aura::Window::Windows transient_children = |
| 43 views::corewm::GetTransientChildren(window); | 43 ::wm::GetTransientChildren(window); |
| 44 for (aura::Window::Windows::iterator iter = transient_children.begin(); | 44 for (aura::Window::Windows::iterator iter = transient_children.begin(); |
| 45 iter != transient_children.end(); ++iter) { | 45 iter != transient_children.end(); ++iter) { |
| 46 aura::Window* transient_child = *iter; | 46 aura::Window* transient_child = *iter; |
| 47 int container_id = transient_child->parent()->id(); | 47 int container_id = transient_child->parent()->id(); |
| 48 DCHECK_GE(container_id, 0); | 48 DCHECK_GE(container_id, 0); |
| 49 aura::Window* container = Shell::GetContainer(dst_root, container_id); | 49 aura::Window* container = Shell::GetContainer(dst_root, container_id); |
| 50 gfx::Rect parent_bounds_in_screen = transient_child->GetBoundsInScreen(); | 50 gfx::Rect parent_bounds_in_screen = transient_child->GetBoundsInScreen(); |
| 51 container->AddChild(transient_child); | 51 container->AddChild(transient_child); |
| 52 transient_child->SetBoundsInScreen(parent_bounds_in_screen, display); | 52 transient_child->SetBoundsInScreen(parent_bounds_in_screen, display); |
| 53 | 53 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 window->SetBounds(bounds); | 156 window->SetBounds(bounds); |
| 157 return; | 157 return; |
| 158 } | 158 } |
| 159 | 159 |
| 160 // Don't move a window to other root window if: | 160 // Don't move a window to other root window if: |
| 161 // a) the window is a transient window. It moves when its | 161 // a) the window is a transient window. It moves when its |
| 162 // transient_parent moves. | 162 // transient_parent moves. |
| 163 // b) if the window or its ancestor has kStayInSameRootWindowkey. It's | 163 // b) if the window or its ancestor has kStayInSameRootWindowkey. It's |
| 164 // intentionally kept in the same root window even if the bounds is | 164 // intentionally kept in the same root window even if the bounds is |
| 165 // outside of the display. | 165 // outside of the display. |
| 166 if (!views::corewm::GetTransientParent(window) && | 166 if (!::wm::GetTransientParent(window) && |
| 167 !ShouldStayInSameRootWindow(window)) { | 167 !ShouldStayInSameRootWindow(window)) { |
| 168 aura::Window* dst_root = | 168 aura::Window* dst_root = |
| 169 Shell::GetInstance()->display_controller()->GetRootWindowForDisplayId( | 169 Shell::GetInstance()->display_controller()->GetRootWindowForDisplayId( |
| 170 display.id()); | 170 display.id()); |
| 171 DCHECK(dst_root); | 171 DCHECK(dst_root); |
| 172 aura::Window* dst_container = NULL; | 172 aura::Window* dst_container = NULL; |
| 173 if (dst_root != window->GetRootWindow()) { | 173 if (dst_root != window->GetRootWindow()) { |
| 174 int container_id = window->parent()->id(); | 174 int container_id = window->parent()->id(); |
| 175 // All containers that uses screen coordinates must have valid window ids. | 175 // All containers that uses screen coordinates must have valid window ids. |
| 176 DCHECK_GE(container_id, 0); | 176 DCHECK_GE(container_id, 0); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 } | 223 } |
| 224 gfx::Point origin(bounds.origin()); | 224 gfx::Point origin(bounds.origin()); |
| 225 const gfx::Point display_origin = Shell::GetScreen()->GetDisplayNearestWindow( | 225 const gfx::Point display_origin = Shell::GetScreen()->GetDisplayNearestWindow( |
| 226 window).bounds().origin(); | 226 window).bounds().origin(); |
| 227 origin.Offset(-display_origin.x(), -display_origin.y()); | 227 origin.Offset(-display_origin.x(), -display_origin.y()); |
| 228 window->SetBounds(gfx::Rect(origin, bounds.size())); | 228 window->SetBounds(gfx::Rect(origin, bounds.size())); |
| 229 } | 229 } |
| 230 | 230 |
| 231 } // internal | 231 } // internal |
| 232 } // ash | 232 } // ash |
| OLD | NEW |