| 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" |
| 11 #include "ash/wm/coordinate_conversion.h" | 11 #include "ash/wm/coordinate_conversion.h" |
| 12 #include "ash/wm/system_modal_container_layout_manager.h" | 12 #include "ash/wm/system_modal_container_layout_manager.h" |
| 13 #include "ash/wm/window_properties.h" | 13 #include "ash/wm/window_properties.h" |
| 14 #include "ui/aura/client/activation_client.h" | 14 #include "ui/aura/client/activation_client.h" |
| 15 #include "ui/aura/client/capture_client.h" | 15 #include "ui/aura/client/capture_client.h" |
| 16 #include "ui/aura/client/focus_client.h" | 16 #include "ui/aura/client/focus_client.h" |
| 17 #include "ui/aura/root_window.h" | 17 #include "ui/aura/root_window.h" |
| 18 #include "ui/aura/window_tracker.h" | 18 #include "ui/aura/window_tracker.h" |
| 19 #include "ui/compositor/dip_util.h" | 19 #include "ui/compositor/dip_util.h" |
| 20 #include "ui/gfx/display.h" | 20 #include "ui/gfx/display.h" |
| 21 #include "ui/gfx/screen.h" | 21 #include "ui/gfx/screen.h" |
| 22 #include "ui/views/corewm/window_util.h" |
| 22 | 23 |
| 23 namespace ash { | 24 namespace ash { |
| 24 namespace { | 25 namespace { |
| 25 | 26 |
| 26 // Return true if the window or its ancestor has |kStayInSameRootWindowkey| | 27 // Return true if the window or its ancestor has |kStayInSameRootWindowkey| |
| 27 // property. | 28 // property. |
| 28 bool ShouldStayInSameRootWindow(const aura::Window* window) { | 29 bool ShouldStayInSameRootWindow(const aura::Window* window) { |
| 29 return window && | 30 return window && |
| 30 (window->GetProperty(internal::kStayInSameRootWindowKey) || | 31 (window->GetProperty(internal::kStayInSameRootWindowKey) || |
| 31 ShouldStayInSameRootWindow(window->parent())); | 32 ShouldStayInSameRootWindow(window->parent())); |
| 32 } | 33 } |
| 33 | 34 |
| 34 // Move all transient children to |dst_root|, including the ones in | 35 // Move all transient children to |dst_root|, including the ones in |
| 35 // the child windows and transient children of the transient children. | 36 // the child windows and transient children of the transient children. |
| 36 void MoveAllTransientChildrenToNewRoot(const gfx::Display& display, | 37 void MoveAllTransientChildrenToNewRoot(const gfx::Display& display, |
| 37 aura::Window* window) { | 38 aura::Window* window) { |
| 38 aura::Window* dst_root = Shell::GetInstance()->display_controller()-> | 39 aura::Window* dst_root = Shell::GetInstance()->display_controller()-> |
| 39 GetRootWindowForDisplayId(display.id()); | 40 GetRootWindowForDisplayId(display.id()); |
| 40 aura::Window::Windows transient_children = window->transient_children(); | 41 aura::Window::Windows transient_children = |
| 42 views::corewm::GetTransientChildren(window); |
| 41 for (aura::Window::Windows::iterator iter = transient_children.begin(); | 43 for (aura::Window::Windows::iterator iter = transient_children.begin(); |
| 42 iter != transient_children.end(); ++iter) { | 44 iter != transient_children.end(); ++iter) { |
| 43 aura::Window* transient_child = *iter; | 45 aura::Window* transient_child = *iter; |
| 44 int container_id = transient_child->parent()->id(); | 46 int container_id = transient_child->parent()->id(); |
| 45 DCHECK_GE(container_id, 0); | 47 DCHECK_GE(container_id, 0); |
| 46 aura::Window* container = Shell::GetContainer(dst_root, container_id); | 48 aura::Window* container = Shell::GetContainer(dst_root, container_id); |
| 47 gfx::Rect parent_bounds_in_screen = transient_child->GetBoundsInScreen(); | 49 gfx::Rect parent_bounds_in_screen = transient_child->GetBoundsInScreen(); |
| 48 container->AddChild(transient_child); | 50 container->AddChild(transient_child); |
| 49 transient_child->SetBoundsInScreen(parent_bounds_in_screen, display); | 51 transient_child->SetBoundsInScreen(parent_bounds_in_screen, display); |
| 50 | 52 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 window->SetBounds(bounds); | 157 window->SetBounds(bounds); |
| 156 return; | 158 return; |
| 157 } | 159 } |
| 158 | 160 |
| 159 // Don't move a window to other root window if: | 161 // Don't move a window to other root window if: |
| 160 // a) the window is a transient window. It moves when its | 162 // a) the window is a transient window. It moves when its |
| 161 // transient_parent moves. | 163 // transient_parent moves. |
| 162 // b) if the window or its ancestor has kStayInSameRootWindowkey. It's | 164 // b) if the window or its ancestor has kStayInSameRootWindowkey. It's |
| 163 // intentionally kept in the same root window even if the bounds is | 165 // intentionally kept in the same root window even if the bounds is |
| 164 // outside of the display. | 166 // outside of the display. |
| 165 if (!window->transient_parent() && | 167 if (!views::corewm::GetTransientParent(window) && |
| 166 !ShouldStayInSameRootWindow(window)) { | 168 !ShouldStayInSameRootWindow(window)) { |
| 167 aura::Window* dst_root = | 169 aura::Window* dst_root = |
| 168 Shell::GetInstance()->display_controller()->GetRootWindowForDisplayId( | 170 Shell::GetInstance()->display_controller()->GetRootWindowForDisplayId( |
| 169 display.id()); | 171 display.id()); |
| 170 DCHECK(dst_root); | 172 DCHECK(dst_root); |
| 171 aura::Window* dst_container = NULL; | 173 aura::Window* dst_container = NULL; |
| 172 if (dst_root != window->GetRootWindow()) { | 174 if (dst_root != window->GetRootWindow()) { |
| 173 int container_id = window->parent()->id(); | 175 int container_id = window->parent()->id(); |
| 174 // All containers that uses screen coordinates must have valid window ids. | 176 // All containers that uses screen coordinates must have valid window ids. |
| 175 DCHECK_GE(container_id, 0); | 177 DCHECK_GE(container_id, 0); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 | 211 |
| 210 gfx::Point origin(bounds.origin()); | 212 gfx::Point origin(bounds.origin()); |
| 211 const gfx::Point display_origin = Shell::GetScreen()->GetDisplayNearestWindow( | 213 const gfx::Point display_origin = Shell::GetScreen()->GetDisplayNearestWindow( |
| 212 window).bounds().origin(); | 214 window).bounds().origin(); |
| 213 origin.Offset(-display_origin.x(), -display_origin.y()); | 215 origin.Offset(-display_origin.x(), -display_origin.y()); |
| 214 window->SetBounds(gfx::Rect(origin, bounds.size())); | 216 window->SetBounds(gfx::Rect(origin, bounds.size())); |
| 215 } | 217 } |
| 216 | 218 |
| 217 } // internal | 219 } // internal |
| 218 } // ash | 220 } // ash |
| OLD | NEW |