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/views/widget/desktop_aura/desktop_native_widget_aura.h" | 7 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" |
8 | 8 |
9 namespace views { | 9 namespace views { |
10 | 10 |
(...skipping 20 matching lines...) Expand all Loading... |
31 DesktopScreenPositionClient::~DesktopScreenPositionClient() { | 31 DesktopScreenPositionClient::~DesktopScreenPositionClient() { |
32 aura::client::SetScreenPositionClient(root_window_, NULL); | 32 aura::client::SetScreenPositionClient(root_window_, NULL); |
33 } | 33 } |
34 | 34 |
35 void DesktopScreenPositionClient::SetBounds(aura::Window* window, | 35 void DesktopScreenPositionClient::SetBounds(aura::Window* window, |
36 const gfx::Rect& bounds, | 36 const gfx::Rect& bounds, |
37 const display::Display& display) { | 37 const display::Display& display) { |
38 // TODO(jam): Use the 3rd parameter, |display|. | 38 // TODO(jam): Use the 3rd parameter, |display|. |
39 aura::Window* root = window->GetRootWindow(); | 39 aura::Window* root = window->GetRootWindow(); |
40 | 40 |
41 // This method assumes that |window| does not have an associated | |
42 // DesktopNativeWidgetAura. | |
43 internal::NativeWidgetPrivate* desktop_native_widget = | 41 internal::NativeWidgetPrivate* desktop_native_widget = |
44 DesktopNativeWidgetAura::ForWindow(root); | 42 DesktopNativeWidgetAura::ForWindow(root); |
| 43 // The screen bounds request to the content_window_ should be interpreted as |
| 44 // a widget bounds change. |
| 45 if (desktop_native_widget && |
| 46 desktop_native_widget->GetNativeView() == window) { |
| 47 desktop_native_widget->GetWidget()->SetBounds(bounds); |
| 48 return; |
| 49 } |
| 50 // The following logic assumes that |window| does not have an associated |
| 51 // DesktopNativeWidgetAura. |
45 DCHECK(!desktop_native_widget || | 52 DCHECK(!desktop_native_widget || |
46 desktop_native_widget->GetNativeView() != window); | 53 desktop_native_widget->GetNativeView() != window); |
47 | 54 |
48 if (PositionWindowInScreenCoordinates(window)) { | 55 if (PositionWindowInScreenCoordinates(window)) { |
49 // The caller expects windows we consider "embedded" to be placed in the | 56 // The caller expects windows we consider "embedded" to be placed in the |
50 // screen coordinate system. So we need to offset the root window's | 57 // screen coordinate system. So we need to offset the root window's |
51 // position (which is in screen coordinates) from these bounds. | 58 // position (which is in screen coordinates) from these bounds. |
52 | 59 |
53 gfx::Point origin = bounds.origin(); | 60 gfx::Point origin = bounds.origin(); |
54 aura::Window::ConvertPointToTarget(window->parent(), root, &origin); | 61 aura::Window::ConvertPointToTarget(window->parent(), root, &origin); |
55 | 62 |
56 gfx::Point host_origin = GetOriginInScreen(root); | 63 gfx::Point host_origin = GetOriginInScreen(root); |
57 origin.Offset(-host_origin.x(), -host_origin.y()); | 64 origin.Offset(-host_origin.x(), -host_origin.y()); |
58 window->SetBounds(gfx::Rect(origin, bounds.size())); | 65 window->SetBounds(gfx::Rect(origin, bounds.size())); |
59 return; | 66 return; |
60 } | 67 } |
61 | 68 |
62 window->SetBounds(bounds); | 69 window->SetBounds(bounds); |
63 } | 70 } |
64 | 71 |
65 } // namespace views | 72 } // namespace views |
OLD | NEW |