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 "ash/wm/workspace_controller.h" | 14 #include "ash/wm/workspace_controller.h" |
15 #include "ui/aura/client/activation_client.h" | 15 #include "ui/aura/client/activation_client.h" |
16 #include "ui/aura/client/capture_client.h" | 16 #include "ui/aura/client/capture_client.h" |
| 17 #include "ui/aura/client/focus_client.h" |
17 #include "ui/aura/client/stacking_client.h" | 18 #include "ui/aura/client/stacking_client.h" |
18 #include "ui/aura/focus_manager.h" | |
19 #include "ui/aura/root_window.h" | 19 #include "ui/aura/root_window.h" |
20 #include "ui/aura/window_tracker.h" | 20 #include "ui/aura/window_tracker.h" |
21 #include "ui/compositor/dip_util.h" | 21 #include "ui/compositor/dip_util.h" |
22 #include "ui/gfx/display.h" | 22 #include "ui/gfx/display.h" |
23 #include "ui/gfx/screen.h" | 23 #include "ui/gfx/screen.h" |
24 | 24 |
25 namespace ash { | 25 namespace ash { |
26 namespace { | 26 namespace { |
27 | 27 |
28 // Move all transient children to |dst_root|, including the ones in | 28 // Move all transient children to |dst_root|, including the ones in |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 if (dst_root != window->GetRootWindow()) { | 164 if (dst_root != window->GetRootWindow()) { |
165 int container_id = window->parent()->id(); | 165 int container_id = window->parent()->id(); |
166 // All containers that uses screen coordinates must have valid window ids. | 166 // All containers that uses screen coordinates must have valid window ids. |
167 DCHECK_GE(container_id, 0); | 167 DCHECK_GE(container_id, 0); |
168 // Don't move modal background. | 168 // Don't move modal background. |
169 if (!SystemModalContainerLayoutManager::IsModalBackground(window)) | 169 if (!SystemModalContainerLayoutManager::IsModalBackground(window)) |
170 dst_container = Shell::GetContainer(dst_root, container_id); | 170 dst_container = Shell::GetContainer(dst_root, container_id); |
171 } | 171 } |
172 | 172 |
173 if (dst_container && window->parent() != dst_container) { | 173 if (dst_container && window->parent() != dst_container) { |
174 aura::Window* focused = window->GetFocusManager()->GetFocusedWindow(); | 174 aura::Window* focused = aura::client::GetFocusClient(window)-> |
| 175 GetFocusedWindow(); |
175 aura::client::ActivationClient* activation_client = | 176 aura::client::ActivationClient* activation_client = |
176 aura::client::GetActivationClient(window->GetRootWindow()); | 177 aura::client::GetActivationClient(window->GetRootWindow()); |
177 aura::Window* active = activation_client->GetActiveWindow(); | 178 aura::Window* active = activation_client->GetActiveWindow(); |
178 | 179 |
179 aura::WindowTracker tracker; | 180 aura::WindowTracker tracker; |
180 if (focused) | 181 if (focused) |
181 tracker.Add(focused); | 182 tracker.Add(focused); |
182 if (active && focused != active) | 183 if (active && focused != active) |
183 tracker.Add(active); | 184 tracker.Add(active); |
184 | 185 |
185 if (dst_container->id() == kShellWindowId_WorkspaceContainer) { | 186 if (dst_container->id() == kShellWindowId_WorkspaceContainer) { |
186 dst_container = | 187 dst_container = |
187 GetRootWindowController(dst_root)->workspace_controller()-> | 188 GetRootWindowController(dst_root)->workspace_controller()-> |
188 GetParentForNewWindow(window); | 189 GetParentForNewWindow(window); |
189 } | 190 } |
190 | 191 |
191 dst_container->AddChild(window); | 192 dst_container->AddChild(window); |
192 | 193 |
193 MoveAllTransientChildrenToNewRoot(display, window); | 194 MoveAllTransientChildrenToNewRoot(display, window); |
194 | 195 |
195 // Restore focused/active window. | 196 // Restore focused/active window. |
196 if (tracker.Contains(focused)) | 197 if (tracker.Contains(focused)) { |
197 window->GetFocusManager()->SetFocusedWindow(focused, NULL); | 198 aura::client::GetFocusClient(window)->FocusWindow(focused, NULL); |
198 else if (tracker.Contains(active)) | 199 } else if (tracker.Contains(active)) { |
199 activation_client->ActivateWindow(active); | 200 activation_client->ActivateWindow(active); |
| 201 } |
200 } | 202 } |
201 } | 203 } |
202 | 204 |
203 gfx::Point origin(bounds.origin()); | 205 gfx::Point origin(bounds.origin()); |
204 const gfx::Point display_origin = Shell::GetScreen()->GetDisplayNearestWindow( | 206 const gfx::Point display_origin = Shell::GetScreen()->GetDisplayNearestWindow( |
205 window).bounds().origin(); | 207 window).bounds().origin(); |
206 origin.Offset(-display_origin.x(), -display_origin.y()); | 208 origin.Offset(-display_origin.x(), -display_origin.y()); |
207 window->SetBounds(gfx::Rect(origin, bounds.size())); | 209 window->SetBounds(gfx::Rect(origin, bounds.size())); |
208 } | 210 } |
209 | 211 |
210 } // internal | 212 } // internal |
211 } // ash | 213 } // ash |
OLD | NEW |