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