| 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/shell.h" | 9 #include "ash/shell.h" |
| 9 #include "ash/shell_window_ids.h" | 10 #include "ash/shell_window_ids.h" |
| 10 #include "ash/wm/system_modal_container_layout_manager.h" | 11 #include "ash/wm/system_modal_container_layout_manager.h" |
| 11 #include "ash/wm/window_properties.h" | 12 #include "ash/wm/window_properties.h" |
| 13 #include "ash/wm/workspace_controller.h" |
| 12 #include "ui/aura/client/activation_client.h" | 14 #include "ui/aura/client/activation_client.h" |
| 13 #include "ui/aura/client/capture_client.h" | 15 #include "ui/aura/client/capture_client.h" |
| 14 #include "ui/aura/client/stacking_client.h" | 16 #include "ui/aura/client/stacking_client.h" |
| 15 #include "ui/aura/focus_manager.h" | 17 #include "ui/aura/focus_manager.h" |
| 16 #include "ui/aura/root_window.h" | 18 #include "ui/aura/root_window.h" |
| 17 #include "ui/aura/window_tracker.h" | 19 #include "ui/aura/window_tracker.h" |
| 18 #include "ui/gfx/display.h" | 20 #include "ui/gfx/display.h" |
| 19 #include "ui/gfx/screen.h" | 21 #include "ui/gfx/screen.h" |
| 20 | 22 |
| 21 namespace ash { | 23 namespace ash { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 | 92 |
| 91 // Don't move a transient windows to other root window. | 93 // Don't move a transient windows to other root window. |
| 92 // It moves when its transient_parent moves. | 94 // It moves when its transient_parent moves. |
| 93 if (!window->transient_parent()) { | 95 if (!window->transient_parent()) { |
| 94 aura::RootWindow* dst_root = | 96 aura::RootWindow* dst_root = |
| 95 Shell::GetInstance()->display_controller()->GetRootWindowForDisplayId( | 97 Shell::GetInstance()->display_controller()->GetRootWindowForDisplayId( |
| 96 display.id()); | 98 display.id()); |
| 97 aura::Window* dst_container = NULL; | 99 aura::Window* dst_container = NULL; |
| 98 if (dst_root != window->GetRootWindow()) { | 100 if (dst_root != window->GetRootWindow()) { |
| 99 int container_id = window->parent()->id(); | 101 int container_id = window->parent()->id(); |
| 100 // All containers that uses screen coordinates must have valid | 102 // All containers that uses screen coordinates must have valid window ids. |
| 101 // window ids. | |
| 102 DCHECK_GE(container_id, 0); | 103 DCHECK_GE(container_id, 0); |
| 103 // Don't move modal screen. | 104 // Don't move modal screen. |
| 104 if (!SystemModalContainerLayoutManager::IsModalScreen(window)) | 105 if (!SystemModalContainerLayoutManager::IsModalScreen(window)) |
| 105 dst_container = Shell::GetContainer(dst_root, container_id); | 106 dst_container = Shell::GetContainer(dst_root, container_id); |
| 106 } | 107 } |
| 107 | 108 |
| 108 if (dst_container && window->parent() != dst_container) { | 109 if (dst_container && window->parent() != dst_container) { |
| 109 aura::Window* focused = window->GetFocusManager()->GetFocusedWindow(); | 110 aura::Window* focused = window->GetFocusManager()->GetFocusedWindow(); |
| 110 aura::client::ActivationClient* activation_client = | 111 aura::client::ActivationClient* activation_client = |
| 111 aura::client::GetActivationClient(window->GetRootWindow()); | 112 aura::client::GetActivationClient(window->GetRootWindow()); |
| 112 aura::Window* active = activation_client->GetActiveWindow(); | 113 aura::Window* active = activation_client->GetActiveWindow(); |
| 113 | 114 |
| 114 aura::WindowTracker tracker; | 115 aura::WindowTracker tracker; |
| 115 if (focused) | 116 if (focused) |
| 116 tracker.Add(focused); | 117 tracker.Add(focused); |
| 117 if (active && focused != active) | 118 if (active && focused != active) |
| 118 tracker.Add(active); | 119 tracker.Add(active); |
| 119 | 120 |
| 121 if (dst_container->id() == kShellWindowId_WorkspaceContainer) { |
| 122 dst_container = |
| 123 GetRootWindowController(dst_root)->workspace_controller()-> |
| 124 GetParentForNewWindow(window); |
| 125 } |
| 126 |
| 120 dst_container->AddChild(window); | 127 dst_container->AddChild(window); |
| 121 | 128 |
| 122 MoveAllTransientChildrenToNewRoot(display, window); | 129 MoveAllTransientChildrenToNewRoot(display, window); |
| 123 | 130 |
| 124 // Restore focused/active window. | 131 // Restore focused/active window. |
| 125 if (tracker.Contains(focused)) | 132 if (tracker.Contains(focused)) |
| 126 window->GetFocusManager()->SetFocusedWindow(focused, NULL); | 133 window->GetFocusManager()->SetFocusedWindow(focused, NULL); |
| 127 else if (tracker.Contains(active)) | 134 else if (tracker.Contains(active)) |
| 128 activation_client->ActivateWindow(active); | 135 activation_client->ActivateWindow(active); |
| 129 } | 136 } |
| 130 } | 137 } |
| 131 | 138 |
| 132 gfx::Point origin(bounds.origin()); | 139 gfx::Point origin(bounds.origin()); |
| 133 const gfx::Point display_origin = | 140 const gfx::Point display_origin = |
| 134 gfx::Screen::GetDisplayNearestWindow(window).bounds().origin(); | 141 gfx::Screen::GetDisplayNearestWindow(window).bounds().origin(); |
| 135 origin.Offset(-display_origin.x(), -display_origin.y()); | 142 origin.Offset(-display_origin.x(), -display_origin.y()); |
| 136 window->SetBounds(gfx::Rect(origin, bounds.size())); | 143 window->SetBounds(gfx::Rect(origin, bounds.size())); |
| 137 } | 144 } |
| 138 | 145 |
| 139 } // internal | 146 } // internal |
| 140 } // ash | 147 } // ash |
| OLD | NEW |