| 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 "ui/views/widget/desktop_aura/desktop_screen_position_client.h" | 5 #include "ui/views/widget/desktop_aura/desktop_screen_position_client.h" |
| 6 | 6 |
| 7 #include "ui/aura/window_tree_host.h" | 7 #include "ui/aura/window_tree_host.h" |
| 8 #include "ui/gfx/display.h" | 8 #include "ui/gfx/display.h" |
| 9 #include "ui/gfx/point_conversions.h" | 9 #include "ui/gfx/point_conversions.h" |
| 10 #include "ui/gfx/screen.h" | 10 #include "ui/gfx/screen.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 ConvertPointToScreen(root_window, point); | 68 ConvertPointToScreen(root_window, point); |
| 69 } | 69 } |
| 70 | 70 |
| 71 void DesktopScreenPositionClient::SetBounds( | 71 void DesktopScreenPositionClient::SetBounds( |
| 72 aura::Window* window, | 72 aura::Window* window, |
| 73 const gfx::Rect& bounds, | 73 const gfx::Rect& bounds, |
| 74 const gfx::Display& display) { | 74 const gfx::Display& display) { |
| 75 // TODO: Use the 3rd parameter, |display|. | 75 // TODO: Use the 3rd parameter, |display|. |
| 76 aura::Window* root = window->GetRootWindow(); | 76 aura::Window* root = window->GetRootWindow(); |
| 77 | 77 |
| 78 // This method assumes that |window| does not have an associated |
| 79 // DesktopNativeWidgetAura. |
| 80 internal::NativeWidgetPrivate* desktop_native_widget = |
| 81 DesktopNativeWidgetAura::ForWindow(root); |
| 82 DCHECK(!desktop_native_widget || |
| 83 desktop_native_widget->GetNativeView() != window); |
| 84 |
| 78 if (PositionWindowInScreenCoordinates(window)) { | 85 if (PositionWindowInScreenCoordinates(window)) { |
| 79 // The caller expects windows we consider "embedded" to be placed in the | 86 // The caller expects windows we consider "embedded" to be placed in the |
| 80 // screen coordinate system. So we need to offset the root window's | 87 // screen coordinate system. So we need to offset the root window's |
| 81 // position (which is in screen coordinates) from these bounds. | 88 // position (which is in screen coordinates) from these bounds. |
| 82 | 89 |
| 83 gfx::Point origin = bounds.origin(); | 90 gfx::Point origin = bounds.origin(); |
| 84 aura::Window::ConvertPointToTarget(window->parent(), root, &origin); | 91 aura::Window::ConvertPointToTarget(window->parent(), root, &origin); |
| 85 | 92 |
| 86 gfx::Point host_origin = GetOrigin(root); | 93 gfx::Point host_origin = GetOrigin(root); |
| 87 origin.Offset(-host_origin.x(), -host_origin.y()); | 94 origin.Offset(-host_origin.x(), -host_origin.y()); |
| 88 window->SetBounds(gfx::Rect(origin, bounds.size())); | 95 window->SetBounds(gfx::Rect(origin, bounds.size())); |
| 89 return; | 96 return; |
| 90 } | 97 } |
| 91 | 98 |
| 92 internal::NativeWidgetPrivate* desktop_native_widget = | 99 window->SetBounds(bounds); |
| 93 DesktopNativeWidgetAura::ForWindow(root); | |
| 94 if (desktop_native_widget && | |
| 95 desktop_native_widget->GetNativeView() == window) { | |
| 96 // |window| is the content_window. | |
| 97 // Setting bounds of root resizes |window|. | |
| 98 root->GetHost()->SetBounds(bounds); | |
| 99 } else { | |
| 100 window->SetBounds(bounds); | |
| 101 } | |
| 102 } | 100 } |
| 103 | 101 |
| 104 } // namespace views | 102 } // namespace views |
| OLD | NEW |