Skip to content

Commit

Permalink
Moving coordinate conversion methods from ash/wm to ui/wm.
Browse files Browse the repository at this point in the history
Re-submit of https://codereview.chromium.org/425363002/

TBR=sky, oshima
BUG=NONE

Review URL: https://codereview.chromium.org/445173002

Cr-Commit-Position: refs/heads/master@{#288449}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@288449 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
mfomitchev@chromium.org committed Aug 8, 2014
1 parent 2df1ae8 commit bebe141
Show file tree
Hide file tree
Showing 25 changed files with 124 additions and 80 deletions.
8 changes: 4 additions & 4 deletions ash/autoclick/autoclick_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "ui/events/event_processor.h"
#include "ui/gfx/point.h"
#include "ui/gfx/vector2d.h"
#include "ui/wm/core/coordinate_conversion.h"

namespace ash {

Expand Down Expand Up @@ -128,9 +129,8 @@ void AutoclickControllerImpl::OnMouseEvent(ui::MouseEvent* event) {
mouse_event_flags_ = event->flags();

gfx::Point mouse_location = event->root_location();
ash::wm::ConvertPointToScreen(
wm::GetRootWindowAt(mouse_location),
&mouse_location);
::wm::ConvertPointToScreen(wm::GetRootWindowAt(mouse_location),
&mouse_location);

// The distance between the mouse location and the anchor location
// must exceed a certain threshold to initiate a new autoclick countdown.
Expand Down Expand Up @@ -185,7 +185,7 @@ void AutoclickControllerImpl::DoAutoclick() {

gfx::Point click_location(screen_location);
anchor_location_ = click_location;
wm::ConvertPointFromScreen(root_window, &click_location);
::wm::ConvertPointFromScreen(root_window, &click_location);

aura::WindowTreeHost* host = root_window->GetHost();
host->ConvertPointToHost(&click_location);
Expand Down
4 changes: 2 additions & 2 deletions ash/display/event_transformation_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
#include "ash/display/display_info.h"
#include "ash/display/display_manager.h"
#include "ash/shell.h"
#include "ash/wm/coordinate_conversion.h"
#include "ash/wm/window_util.h"
#include "ui/aura/window.h"
#include "ui/aura/window_event_dispatcher.h"
#include "ui/compositor/dip_util.h"
#include "ui/events/event.h"
#include "ui/gfx/display.h"
#include "ui/gfx/screen.h"
#include "ui/wm/core/coordinate_conversion.h"

namespace ash {
namespace {
Expand All @@ -41,7 +41,7 @@ void EventTransformationHandler::OnScrollEvent(ui::ScrollEvent* event) {
// the event locations etc. are already in DIP.
gfx::Point point_in_screen(event->location());
aura::Window* target = static_cast<aura::Window*>(event->target());
wm::ConvertPointToScreen(target, &point_in_screen);
::wm::ConvertPointToScreen(target, &point_in_screen);
const gfx::Display& display =
Shell::GetScreen()->GetDisplayNearestPoint(point_in_screen);

Expand Down
10 changes: 5 additions & 5 deletions ash/display/mouse_cursor_event_filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "ash/root_window_controller.h"
#include "ash/screen_util.h"
#include "ash/shell.h"
#include "ash/wm/coordinate_conversion.h"
#include "ash/wm/window_util.h"
#include "ui/aura/env.h"
#include "ui/aura/window.h"
Expand All @@ -25,6 +24,7 @@
#include "ui/events/event.h"
#include "ui/events/event_utils.h"
#include "ui/gfx/screen.h"
#include "ui/wm/core/coordinate_conversion.h"

namespace ash {
namespace {
Expand All @@ -42,7 +42,7 @@ const int kIndicatorThickness = 1;

void ConvertPointFromScreenToNative(const aura::Window* root_window,
gfx::Point* point) {
wm::ConvertPointFromScreen(root_window, point);
::wm::ConvertPointFromScreen(root_window, point);
root_window->GetHost()->ConvertPointToNativeScreen(point);
}

Expand Down Expand Up @@ -204,7 +204,7 @@ void MouseCursorEventFilter::OnMouseEvent(ui::MouseEvent* event) {
void MouseCursorEventFilter::MoveCursorTo(aura::Window* root,
const gfx::Point& point_in_screen) {
gfx::Point point_in_native = point_in_screen;
wm::ConvertPointFromScreen(root, &point_in_native);
::wm::ConvertPointFromScreen(root, &point_in_native);
root->GetHost()->ConvertPointToNativeScreen(&point_in_native);

// now fit the point inside the native bounds.
Expand Down Expand Up @@ -234,7 +234,7 @@ bool MouseCursorEventFilter::WarpMouseCursorIfNecessary(ui::MouseEvent* event) {

gfx::Point point_in_screen = event->location();
aura::Window* target = static_cast<aura::Window*>(event->target());
wm::ConvertPointToScreen(target, &point_in_screen);
::wm::ConvertPointToScreen(target, &point_in_screen);

return WarpMouseCursorInNativeCoords(point_in_native, point_in_screen);
}
Expand Down Expand Up @@ -379,7 +379,7 @@ bool MouseCursorEventFilter::WarpMouseCursorIfNecessaryForTest(
aura::Window* target_root,
const gfx::Point& point_in_screen) {
gfx::Point native = point_in_screen;
wm::ConvertPointFromScreen(target_root, &native);
::wm::ConvertPointFromScreen(target_root, &native);
target_root->GetHost()->ConvertPointToNativeScreen(&native);
return WarpMouseCursorInNativeCoords(native, point_in_screen);
}
Expand Down
7 changes: 4 additions & 3 deletions ash/display/mouse_cursor_event_filter_ozone.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "ash/shell.h"
#include "ash/wm/coordinate_conversion.h"
#include "ash/wm/window_util.h"
#include "ui/wm/core/coordinate_conversion.h"

namespace ash {

Expand All @@ -21,7 +22,7 @@ bool MouseCursorEventFilter::WarpMouseCursorIfNecessary(ui::MouseEvent* event) {

gfx::Point point_in_screen(event->location());
aura::Window* target = static_cast<aura::Window*>(event->target());
wm::ConvertPointToScreen(target, &point_in_screen);
::wm::ConvertPointToScreen(target, &point_in_screen);
return WarpMouseCursorInScreenCoords(target->GetRootWindow(),
point_in_screen);
}
Expand All @@ -45,7 +46,7 @@ bool MouseCursorEventFilter::WarpMouseCursorInScreenCoords(

aura::Window* root_at_point = wm::GetRootWindowAt(point_in_screen);
gfx::Point point_in_root = point_in_screen;
wm::ConvertPointFromScreen(root_at_point, &point_in_root);
::wm::ConvertPointFromScreen(root_at_point, &point_in_root);
gfx::Rect root_bounds = root_at_point->bounds();
int offset_x = 0;
int offset_y = 0;
Expand Down Expand Up @@ -86,7 +87,7 @@ bool MouseCursorEventFilter::WarpMouseCursorInScreenCoords(
return false;
}

wm::ConvertPointFromScreen(dst_root, &point_in_dst_screen);
::wm::ConvertPointFromScreen(dst_root, &point_in_dst_screen);

if (dst_root->bounds().Contains(point_in_dst_screen)) {
DCHECK_NE(dst_root, root_at_point);
Expand Down
8 changes: 4 additions & 4 deletions ash/drag_drop/drag_drop_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "ash/drag_drop/drag_drop_tracker.h"
#include "ash/drag_drop/drag_image_view.h"
#include "ash/shell.h"
#include "ash/wm/coordinate_conversion.h"
#include "base/bind.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
Expand All @@ -28,6 +27,7 @@
#include "ui/gfx/rect_conversions.h"
#include "ui/views/views_delegate.h"
#include "ui/views/widget/native_widget_aura.h"
#include "ui/wm/core/coordinate_conversion.h"
#include "ui/wm/public/drag_drop_delegate.h"

namespace ash {
Expand Down Expand Up @@ -198,7 +198,7 @@ int DragDropController::StartDragAndDrop(
drag_image_vertical_offset = kTouchDragImageVerticalOffset;
}
gfx::Point start_location = root_location;
ash::wm::ConvertPointToScreen(root_window, &start_location);
::wm::ConvertPointToScreen(root_window, &start_location);
drag_image_final_bounds_for_cancel_animation_ = gfx::Rect(
start_location - provider->GetDragImageOffset(),
provider->GetDragImage().size());
Expand Down Expand Up @@ -292,8 +292,8 @@ void DragDropController::DragUpdate(aura::Window* target,
DCHECK(drag_image_.get());
if (drag_image_->visible()) {
gfx::Point root_location_in_screen = event.root_location();
ash::wm::ConvertPointToScreen(target->GetRootWindow(),
&root_location_in_screen);
::wm::ConvertPointToScreen(target->GetRootWindow(),
&root_location_in_screen);
drag_image_->SetScreenPosition(
root_location_in_screen - drag_image_offset_);
drag_image_->SetTouchDragOperation(op);
Expand Down
8 changes: 4 additions & 4 deletions ash/drag_drop/drag_drop_tracker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "ui/aura/window_event_dispatcher.h"
#include "ui/events/event.h"
#include "ui/gfx/screen.h"
#include "ui/wm/core/coordinate_conversion.h"
#include "ui/wm/public/activation_delegate.h"

namespace ash {
Expand Down Expand Up @@ -68,12 +69,11 @@ void DragDropTracker::TakeCapture() {
aura::Window* DragDropTracker::GetTarget(const ui::LocatedEvent& event) {
DCHECK(capture_window_.get());
gfx::Point location_in_screen = event.location();
wm::ConvertPointToScreen(capture_window_.get(),
&location_in_screen);
::wm::ConvertPointToScreen(capture_window_.get(), &location_in_screen);
aura::Window* root_window_at_point =
wm::GetRootWindowAt(location_in_screen);
gfx::Point location_in_root = location_in_screen;
wm::ConvertPointFromScreen(root_window_at_point, &location_in_root);
::wm::ConvertPointFromScreen(root_window_at_point, &location_in_root);
return root_window_at_point->GetEventHandlerForPoint(location_in_root);
}

Expand All @@ -85,7 +85,7 @@ ui::LocatedEvent* DragDropTracker::ConvertEvent(
aura::Window::ConvertPointToTarget(capture_window_.get(), target,
&target_location);
gfx::Point location_in_screen = event.location();
ash::wm::ConvertPointToScreen(capture_window_.get(), &location_in_screen);
::wm::ConvertPointToScreen(capture_window_.get(), &location_in_screen);
gfx::Point target_root_location = event.root_location();
aura::Window::ConvertPointToTarget(
capture_window_->GetRootWindow(),
Expand Down
4 changes: 2 additions & 2 deletions ash/shelf/shelf_bezel_event_filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

#include "ash/shelf/shelf_layout_manager.h"
#include "ash/shell.h"
#include "ash/wm/coordinate_conversion.h"
#include "ui/aura/window.h"
#include "ui/wm/core/coordinate_conversion.h"

namespace ash {

Expand All @@ -26,7 +26,7 @@ void ShelfBezelEventFilter::OnGestureEvent(
ui::GestureEvent* event) {
gfx::Point point_in_screen(event->location());
aura::Window* target = static_cast<aura::Window*>(event->target());
wm::ConvertPointToScreen(target, &point_in_screen);
::wm::ConvertPointToScreen(target, &point_in_screen);
gfx::Rect screen =
Shell::GetScreen()->GetDisplayNearestPoint(point_in_screen).bounds();
if ((!screen.Contains(point_in_screen) &&
Expand Down
15 changes: 7 additions & 8 deletions ash/shelf/shelf_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
#include "ui/views/view_model.h"
#include "ui/views/view_model_utils.h"
#include "ui/views/widget/widget.h"
#include "ui/wm/core/coordinate_conversion.h"

using gfx::Animation;
using views::View;
Expand Down Expand Up @@ -617,9 +618,8 @@ bool ShelfView::StartDrag(const std::string& app_id,
gfx::Point pt = drag_and_drop_view->GetBoundsInScreen().CenterPoint();
views::View::ConvertPointFromScreen(drag_and_drop_view, &pt);
gfx::Point point_in_root = location_in_screen_coordinates;
ash::wm::ConvertPointFromScreen(
ash::wm::GetRootWindowAt(location_in_screen_coordinates),
&point_in_root);
::wm::ConvertPointFromScreen(
ash::wm::GetRootWindowAt(location_in_screen_coordinates), &point_in_root);
ui::MouseEvent event(ui::ET_MOUSE_PRESSED, pt, point_in_root, 0, 0);
PointerPressedOnButton(drag_and_drop_view,
ShelfButtonHost::DRAG_AND_DROP,
Expand All @@ -640,9 +640,8 @@ bool ShelfView::Drag(const gfx::Point& location_in_screen_coordinates) {
model_->ItemIndexByID(drag_and_drop_shelf_id_));
ConvertPointFromScreen(drag_and_drop_view, &pt);
gfx::Point point_in_root = location_in_screen_coordinates;
ash::wm::ConvertPointFromScreen(
ash::wm::GetRootWindowAt(location_in_screen_coordinates),
&point_in_root);
::wm::ConvertPointFromScreen(
ash::wm::GetRootWindowAt(location_in_screen_coordinates), &point_in_root);
ui::MouseEvent event(ui::ET_MOUSE_DRAGGED, pt, point_in_root, 0, 0);
PointerDraggedOnButton(drag_and_drop_view,
ShelfButtonHost::DRAG_AND_DROP,
Expand Down Expand Up @@ -1010,8 +1009,8 @@ bool ShelfView::HandleRipOffDrag(const ui::LocatedEvent& event) {
delegate_->GetAppIDForShelfID(model_->items()[current_index].id);

gfx::Point screen_location = event.root_location();
ash::wm::ConvertPointToScreen(GetWidget()->GetNativeWindow()->GetRootWindow(),
&screen_location);
::wm::ConvertPointToScreen(GetWidget()->GetNativeWindow()->GetRootWindow(),
&screen_location);

// To avoid ugly forwards and backwards flipping we use different constants
// for ripping off / re-inserting the items.
Expand Down
4 changes: 2 additions & 2 deletions ash/shelf/shelf_view_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include "ash/test/shell_test_api.h"
#include "ash/test/test_shelf_delegate.h"
#include "ash/test/test_shelf_item_delegate.h"
#include "ash/wm/coordinate_conversion.h"
#include "base/basictypes.h"
#include "base/command_line.h"
#include "base/compiler_specific.h"
Expand All @@ -47,6 +46,7 @@
#include "ui/views/view_model.h"
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_delegate.h"
#include "ui/wm/core/coordinate_conversion.h"

namespace ash {
namespace test {
Expand Down Expand Up @@ -1604,7 +1604,7 @@ TEST_F(ShelfViewTest, CheckRipOffFromLeftShelfAlignmentWithMultiMonitor) {

// Fetch the start point of dragging.
gfx::Point start_point = button->GetBoundsInScreen().CenterPoint();
wm::ConvertPointFromScreen(second_root, &start_point);
::wm::ConvertPointFromScreen(second_root, &start_point);

ui::test::EventGenerator generator(second_root, start_point);

Expand Down
4 changes: 2 additions & 2 deletions ash/test/ash_test_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include "ash/test/test_session_state_delegate.h"
#include "ash/test/test_shell_delegate.h"
#include "ash/test/test_system_tray_delegate.h"
#include "ash/wm/coordinate_conversion.h"
#include "ash/wm/window_positioner.h"
#include "base/command_line.h"
#include "ui/aura/client/aura_constants.h"
Expand All @@ -32,6 +31,7 @@
#include "ui/gfx/display.h"
#include "ui/gfx/point.h"
#include "ui/gfx/screen.h"
#include "ui/wm/core/coordinate_conversion.h"

#if defined(OS_CHROMEOS)
#include "ash/system/chromeos/tray_display.h"
Expand Down Expand Up @@ -262,7 +262,7 @@ aura::Window* AshTestBase::CreateTestWindowInShellWithDelegateAndType(
aura::Window* root = ash::Shell::GetInstance()->display_controller()->
GetRootWindowForDisplayId(display.id());
gfx::Point origin = bounds.origin();
wm::ConvertPointFromScreen(root, &origin);
::wm::ConvertPointFromScreen(root, &origin);
window->SetBounds(gfx::Rect(origin, bounds.size()));
aura::client::ParentWindowWithContext(window, root, bounds);
}
Expand Down
12 changes: 0 additions & 12 deletions ash/wm/coordinate_conversion.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,5 @@ aura::Window* GetRootWindowMatching(const gfx::Rect& rect) {
GetRootWindowForDisplayId(display.id());
}

void ConvertPointToScreen(const aura::Window* window, gfx::Point* point) {
CHECK(aura::client::GetScreenPositionClient(window->GetRootWindow()));
aura::client::GetScreenPositionClient(window->GetRootWindow())->
ConvertPointToScreen(window, point);
}

void ConvertPointFromScreen(const aura::Window* window,
gfx::Point* point_in_screen) {
aura::client::GetScreenPositionClient(window->GetRootWindow())->
ConvertPointFromScreen(window, point_in_screen);
}

} // namespace wm
} // namespace ash
10 changes: 0 additions & 10 deletions ash/wm/coordinate_conversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,6 @@ ASH_EXPORT aura::Window* GetRootWindowAt(const gfx::Point& point);
// the virtual scren coordinates.
ASH_EXPORT aura::Window* GetRootWindowMatching(const gfx::Rect& rect);

// Converts the |point| from a given |window|'s coordinates into the screen
// coordinates.
ASH_EXPORT void ConvertPointToScreen(const aura::Window* window,
gfx::Point* point);

// Converts the |point| from the screen coordinates to a given |window|'s
// coordinates.
ASH_EXPORT void ConvertPointFromScreen(const aura::Window* window,
gfx::Point* point_in_screen);

} // namespace wm
} // namespace ash

Expand Down
3 changes: 2 additions & 1 deletion ash/wm/dock/docked_window_layout_manager_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "ui/base/hit_test.h"
#include "ui/gfx/screen.h"
#include "ui/views/widget/widget.h"
#include "ui/wm/core/coordinate_conversion.h"

namespace ash {

Expand Down Expand Up @@ -188,7 +189,7 @@ class DockedWindowLayoutManagerTest
gfx::Rect work_area =
Shell::GetScreen()->GetDisplayNearestWindow(window).work_area();
gfx::Point initial_location_in_screen = initial_location_in_parent_;
wm::ConvertPointToScreen(window->parent(), &initial_location_in_screen);
::wm::ConvertPointToScreen(window->parent(), &initial_location_in_screen);
// Drag the window left or right to the edge (or almost to it).
if (edge == DOCKED_EDGE_LEFT)
dx += work_area.x() - initial_location_in_screen.x();
Expand Down
4 changes: 2 additions & 2 deletions ash/wm/dock/docked_window_resizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include "ash/shelf/shelf_widget.h"
#include "ash/shell.h"
#include "ash/shell_window_ids.h"
#include "ash/wm/coordinate_conversion.h"
#include "ash/wm/dock/docked_window_layout_manager.h"
#include "ash/wm/window_state.h"
#include "ash/wm/window_util.h"
Expand All @@ -30,6 +29,7 @@
#include "ui/base/ui_base_types.h"
#include "ui/gfx/screen.h"
#include "ui/views/widget/widget.h"
#include "ui/wm/core/coordinate_conversion.h"

namespace ash {
namespace {
Expand Down Expand Up @@ -61,7 +61,7 @@ DockedWindowResizer::Create(WindowResizer* next_window_resizer,

void DockedWindowResizer::Drag(const gfx::Point& location, int event_flags) {
last_location_ = location;
wm::ConvertPointToScreen(GetTarget()->parent(), &last_location_);
::wm::ConvertPointToScreen(GetTarget()->parent(), &last_location_);
if (!did_move_or_resize_) {
did_move_or_resize_ = true;
StartedDragging();
Expand Down
Loading

0 comments on commit bebe141

Please sign in to comment.