Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(573)

Unified Diff: ui/views/widget/desktop_aura/desktop_screen_position_client.cc

Issue 686513004: Creating default implementation for aura::client::ScreenPositionClient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removing unwanted change. Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/views/widget/desktop_aura/desktop_screen_position_client.cc
diff --git a/ui/views/widget/desktop_aura/desktop_screen_position_client.cc b/ui/views/widget/desktop_aura/desktop_screen_position_client.cc
index 96deaf4205c58fdb47424eb823a50cb99104bd4b..1769e7c0cfc2ae59e308c462b78918d6cd33baf9 100644
--- a/ui/views/widget/desktop_aura/desktop_screen_position_client.cc
+++ b/ui/views/widget/desktop_aura/desktop_screen_position_client.cc
@@ -4,39 +4,13 @@
#include "ui/views/widget/desktop_aura/desktop_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 {
-
-gfx::Point GetOrigin(const aura::Window* root_window) {
- gfx::Point origin_in_pixels = root_window->GetHost()->GetBounds().origin();
- aura::Window* window = const_cast<aura::Window*>(root_window);
- float scale = gfx::Screen::GetScreenFor(window)->
- GetDisplayNearestWindow(window).device_scale_factor();
- 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;
-
- Widget* widget = Widget::GetWidgetForNativeView(window);
- return widget && widget->is_top_level();
-}
-
-} // namespace
-
DesktopScreenPositionClient::DesktopScreenPositionClient(
aura::Window* root_window)
- : root_window_(root_window) {
+ : wm::DefaultScreenPositionClient(), root_window_(root_window) {
aura::client::SetScreenPositionClient(root_window_, this);
}
@@ -44,58 +18,28 @@ DesktopScreenPositionClient::~DesktopScreenPositionClient() {
aura::client::SetScreenPositionClient(root_window_, NULL);
}
-void DesktopScreenPositionClient::ConvertPointToScreen(
- const aura::Window* window,
- gfx::Point* point) {
- const aura::Window* root_window = window->GetRootWindow();
- aura::Window::ConvertPointToTarget(window, root_window, point);
- gfx::Point origin = GetOrigin(root_window);
- point->Offset(origin.x(), origin.y());
-}
-
-void DesktopScreenPositionClient::ConvertPointFromScreen(
- const aura::Window* window,
- gfx::Point* point) {
- const aura::Window* root_window = window->GetRootWindow();
- gfx::Point origin = GetOrigin(root_window);
- point->Offset(-origin.x(), -origin.y());
- aura::Window::ConvertPointToTarget(root_window, window, point);
-}
+bool DesktopScreenPositionClient::PositionWindowInScreenCoordinates(
+ aura::Window* window) {
+ if (DefaultScreenPositionClient::PositionWindowInScreenCoordinates(window))
+ return true;
-void DesktopScreenPositionClient::ConvertHostPointToScreen(aura::Window* window,
- gfx::Point* point) {
- aura::Window* root_window = window->GetRootWindow();
- ConvertPointToScreen(root_window, point);
+ Widget* widget = Widget::GetWidgetForNativeView(window);
+ return widget && widget->is_top_level();
}
void DesktopScreenPositionClient::SetBounds(aura::Window* window,
const gfx::Rect& bounds,
const gfx::Display& display) {
- // TODO: Use the 3rd parameter, |display|.
- aura::Window* root = window->GetRootWindow();
+ // TODO(jam): Use the 3rd parameter, |display|.
// This method assumes that |window| does not have an associated
// DesktopNativeWidgetAura.
internal::NativeWidgetPrivate* desktop_native_widget =
- DesktopNativeWidgetAura::ForWindow(root);
+ DesktopNativeWidgetAura::ForWindow(window->GetRootWindow());
DCHECK(!desktop_native_widget ||
desktop_native_widget->GetNativeView() != window);
- if (PositionWindowInScreenCoordinates(window)) {
- // 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);
-
- gfx::Point host_origin = GetOrigin(root);
- origin.Offset(-host_origin.x(), -host_origin.y());
- window->SetBounds(gfx::Rect(origin, bounds.size()));
- return;
- }
-
- window->SetBounds(bounds);
+ wm::DefaultScreenPositionClient::SetBounds(window, bounds, display);
}
} // namespace views

Powered by Google App Engine
This is Rietveld 408576698