Chromium Code Reviews| Index: ui/wm/core/default_screen_position_client.cc |
| diff --git a/ui/views/widget/desktop_aura/desktop_screen_position_client.cc b/ui/wm/core/default_screen_position_client.cc |
| similarity index 60% |
| copy from ui/views/widget/desktop_aura/desktop_screen_position_client.cc |
| copy to ui/wm/core/default_screen_position_client.cc |
| index 96deaf4205c58fdb47424eb823a50cb99104bd4b..b4f44101760ae80c3a357477264c20813f8b5159 100644 |
| --- a/ui/views/widget/desktop_aura/desktop_screen_position_client.cc |
| +++ b/ui/wm/core/default_screen_position_client.cc |
| @@ -2,15 +2,14 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#include "ui/views/widget/desktop_aura/desktop_screen_position_client.h" |
| +#include "ui/wm/core/default_screen_position_client.h" |
| #include "ui/aura/window_tree_host.h" |
| #include "ui/gfx/display.h" |
| #include "ui/gfx/point_conversions.h" |
| #include "ui/gfx/screen.h" |
| -#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" |
| -namespace views { |
| +namespace wm { |
| namespace { |
| @@ -22,29 +21,20 @@ gfx::Point GetOrigin(const aura::Window* root_window) { |
| return gfx::ToFlooredPoint(gfx::ScalePoint(origin_in_pixels, 1 / scale)); |
| } |
| -// Returns true if bounds passed to window are treated as though they are in |
| -// screen coordinates. |
| -bool PositionWindowInScreenCoordinates(aura::Window* window) { |
| - if (window->type() == ui::wm::WINDOW_TYPE_POPUP) |
| - return true; |
| +} // namespace |
| - Widget* widget = Widget::GetWidgetForNativeView(window); |
| - return widget && widget->is_top_level(); |
| +DefaultScreenPositionClient::DefaultScreenPositionClient() { |
| } |
| -} // namespace |
| - |
| -DesktopScreenPositionClient::DesktopScreenPositionClient( |
| - aura::Window* root_window) |
| - : root_window_(root_window) { |
| - aura::client::SetScreenPositionClient(root_window_, this); |
| +DefaultScreenPositionClient::~DefaultScreenPositionClient() { |
| } |
| -DesktopScreenPositionClient::~DesktopScreenPositionClient() { |
| - aura::client::SetScreenPositionClient(root_window_, NULL); |
| +bool DefaultScreenPositionClient::PositionWindowInScreenCoordinates( |
| + aura::Window* window) { |
| + return window->type() == ui::wm::WINDOW_TYPE_POPUP; |
|
sadrul
2014/10/30 16:09:11
Why special case POPUP here?
mfomitchev
2014/10/30 20:12:53
I just copied this code from desktop_native_widget
sadrul
2014/10/30 20:20:07
Yeah. I think we can do without PositionWindowInSc
mfomitchev
2014/10/30 22:02:12
Done.
|
| } |
| -void DesktopScreenPositionClient::ConvertPointToScreen( |
| +void DefaultScreenPositionClient::ConvertPointToScreen( |
| const aura::Window* window, |
| gfx::Point* point) { |
| const aura::Window* root_window = window->GetRootWindow(); |
| @@ -53,7 +43,7 @@ void DesktopScreenPositionClient::ConvertPointToScreen( |
| point->Offset(origin.x(), origin.y()); |
| } |
| -void DesktopScreenPositionClient::ConvertPointFromScreen( |
| +void DefaultScreenPositionClient::ConvertPointFromScreen( |
| const aura::Window* window, |
| gfx::Point* point) { |
| const aura::Window* root_window = window->GetRootWindow(); |
| @@ -62,30 +52,21 @@ void DesktopScreenPositionClient::ConvertPointFromScreen( |
| aura::Window::ConvertPointToTarget(root_window, window, point); |
| } |
| -void DesktopScreenPositionClient::ConvertHostPointToScreen(aura::Window* window, |
| +void DefaultScreenPositionClient::ConvertHostPointToScreen(aura::Window* window, |
| gfx::Point* point) { |
| aura::Window* root_window = window->GetRootWindow(); |
| ConvertPointToScreen(root_window, point); |
| } |
| -void DesktopScreenPositionClient::SetBounds(aura::Window* window, |
| +void DefaultScreenPositionClient::SetBounds(aura::Window* window, |
| const gfx::Rect& bounds, |
| const gfx::Display& display) { |
| - // TODO: Use the 3rd parameter, |display|. |
| - aura::Window* root = window->GetRootWindow(); |
| - |
| - // This method assumes that |window| does not have an associated |
| - // DesktopNativeWidgetAura. |
| - internal::NativeWidgetPrivate* desktop_native_widget = |
| - DesktopNativeWidgetAura::ForWindow(root); |
| - DCHECK(!desktop_native_widget || |
| - desktop_native_widget->GetNativeView() != window); |
| - |
| if (PositionWindowInScreenCoordinates(window)) { |
| + aura::Window* root = window->GetRootWindow(); |
| + |
| // The caller expects windows we consider "embedded" to be placed in the |
| // screen coordinate system. So we need to offset the root window's |
| // position (which is in screen coordinates) from these bounds. |
| - |
| gfx::Point origin = bounds.origin(); |
| aura::Window::ConvertPointToTarget(window->parent(), root, &origin); |
| @@ -98,4 +79,4 @@ void DesktopScreenPositionClient::SetBounds(aura::Window* window, |
| window->SetBounds(bounds); |
| } |
| -} // namespace views |
| +} // namespace wm |