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/window_state.h" | |
15 #include "ui/aura/client/activation_client.h" | 14 #include "ui/aura/client/activation_client.h" |
16 #include "ui/aura/client/capture_client.h" | 15 #include "ui/aura/client/capture_client.h" |
17 #include "ui/aura/client/focus_client.h" | 16 #include "ui/aura/client/focus_client.h" |
18 #include "ui/aura/root_window.h" | 17 #include "ui/aura/root_window.h" |
19 #include "ui/aura/window_tracker.h" | 18 #include "ui/aura/window_tracker.h" |
20 #include "ui/compositor/dip_util.h" | 19 #include "ui/compositor/dip_util.h" |
21 #include "ui/gfx/display.h" | 20 #include "ui/gfx/display.h" |
22 #include "ui/gfx/screen.h" | 21 #include "ui/gfx/screen.h" |
23 #include "ui/views/corewm/window_util.h" | 22 #include "ui/views/corewm/window_util.h" |
24 | 23 |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 aura::client::ActivationClient* activation_client = | 186 aura::client::ActivationClient* activation_client = |
188 aura::client::GetActivationClient(window->GetRootWindow()); | 187 aura::client::GetActivationClient(window->GetRootWindow()); |
189 aura::Window* active = activation_client->GetActiveWindow(); | 188 aura::Window* active = activation_client->GetActiveWindow(); |
190 | 189 |
191 aura::WindowTracker tracker; | 190 aura::WindowTracker tracker; |
192 if (focused) | 191 if (focused) |
193 tracker.Add(focused); | 192 tracker.Add(focused); |
194 if (active && focused != active) | 193 if (active && focused != active) |
195 tracker.Add(active); | 194 tracker.Add(active); |
196 | 195 |
197 window->parent()->RemoveChild(window); | |
198 | |
199 // Set new bounds now so that the container's layout manager | |
200 // can adjust the bounds if necessary. | |
201 gfx::Point origin = bounds.origin(); | |
202 const gfx::Point display_origin = display.bounds().origin(); | |
203 origin.Offset(-display_origin.x(), -display_origin.y()); | |
204 gfx::Rect new_bounds = gfx::Rect(origin, bounds.size()); | |
205 | |
206 window->SetBounds(new_bounds); | |
207 | |
208 dst_container->AddChild(window); | 196 dst_container->AddChild(window); |
209 | 197 |
210 MoveAllTransientChildrenToNewRoot(display, window); | 198 MoveAllTransientChildrenToNewRoot(display, window); |
211 | 199 |
212 // Restore focused/active window. | 200 // Restore focused/active window. |
213 if (tracker.Contains(focused)) { | 201 if (tracker.Contains(focused)) { |
214 aura::client::GetFocusClient(window)->FocusWindow(focused); | 202 aura::client::GetFocusClient(window)->FocusWindow(focused); |
215 // TODO(beng): replace with GetRootWindow(). | 203 // TODO(beng): replace with GetRootWindow(). |
216 ash::Shell::GetInstance()->set_target_root_window( | 204 ash::Shell::GetInstance()->set_target_root_window( |
217 focused->GetRootWindow()); | 205 focused->GetRootWindow()); |
218 } else if (tracker.Contains(active)) { | 206 } else if (tracker.Contains(active)) { |
219 activation_client->ActivateWindow(active); | 207 activation_client->ActivateWindow(active); |
220 } | 208 } |
221 // TODO(oshima): We should not have to update the bounds again | |
222 // below in theory, but we currently do need as there is a code | |
223 // that assumes that the bounds will never be overridden by the | |
224 // layout mananger. We should have more explicit control how | |
225 // constraints are applied by the layout manager. | |
226 } | 209 } |
227 } | 210 } |
| 211 |
228 gfx::Point origin(bounds.origin()); | 212 gfx::Point origin(bounds.origin()); |
229 const gfx::Point display_origin = Shell::GetScreen()->GetDisplayNearestWindow( | 213 const gfx::Point display_origin = Shell::GetScreen()->GetDisplayNearestWindow( |
230 window).bounds().origin(); | 214 window).bounds().origin(); |
231 origin.Offset(-display_origin.x(), -display_origin.y()); | 215 origin.Offset(-display_origin.x(), -display_origin.y()); |
232 window->SetBounds(gfx::Rect(origin, bounds.size())); | 216 window->SetBounds(gfx::Rect(origin, bounds.size())); |
233 } | 217 } |
234 | 218 |
235 } // internal | 219 } // internal |
236 } // ash | 220 } // ash |
OLD | NEW |