Skip to content

Commit

Permalink
Revert of Moving coordinate conversion methods from ash/wm to ui/wm. (h…
Browse files Browse the repository at this point in the history
…ttps://codereview.chromium.org/425363002/)

Reason for revert:
Build break.

../../ash/display/mouse_cursor_event_filter_ozone.cc:21:7:error: no member named 'ConvertPointToScreen' in namespace 'ash::wm'
  wm::ConvertPointToScreen(target, &point_in_screen);
  ~~~~^
../../ash/display/mouse_cursor_event_filter_ozone.cc:45:7:error: no member named 'ConvertPointFromScreen' in namespace 'ash::wm'
  wm::ConvertPointFromScreen(root_at_point, &point_in_root);
  ~~~~^
../../ash/display/mouse_cursor_event_filter_ozone.cc:86:7:error: no member named 'ConvertPointFromScreen' in namespace 'ash::wm'
  wm::ConvertPointFromScreen(dst_root, &point_in_dst_screen);
  ~~~~^


Original issue's description:
> Moving coordinate conversion methods from ash/wm to ui/wm.
> 
> Moving ConvertPointToScreen and ConvertPointFromScreen from ash::wm into
> aura::Window. The suggestion to do this was made here:
> https://codereview.chromium.org/420603011/diff/1/athena/wm/coordinate_conversion.h
> 
> BUG=NONE
> 
> Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=287609

TBR=oshima@chromium.org,ben@chromium.org,sky@chromium.org,mfomitchev@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=NONE

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@287626 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
robliao@chromium.org committed Aug 5, 2014
1 parent b315e83 commit 7804332
Show file tree
Hide file tree
Showing 24 changed files with 77 additions and 120 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,7 +15,6 @@
#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 @@ -129,8 +128,9 @@ void AutoclickControllerImpl::OnMouseEvent(ui::MouseEvent* event) {
mouse_event_flags_ = event->flags();

gfx::Point mouse_location = event->root_location();
::wm::ConvertPointToScreen(wm::GetRootWindowAt(mouse_location),
&mouse_location);
ash::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,6 +14,7 @@
#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 @@ -24,7 +25,6 @@
#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
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,6 +7,7 @@
#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 @@ -27,7 +28,6 @@
#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;
::wm::ConvertPointToScreen(root_window, &start_location);
ash::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();
::wm::ConvertPointToScreen(target->GetRootWindow(),
&root_location_in_screen);
ash::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,7 +12,6 @@
#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 @@ -69,11 +68,12 @@ 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();
::wm::ConvertPointToScreen(capture_window_.get(), &location_in_screen);
ash::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: 8 additions & 7 deletions ash/shelf/shelf_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
#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 @@ -618,8 +617,9 @@ 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;
::wm::ConvertPointFromScreen(
ash::wm::GetRootWindowAt(location_in_screen_coordinates), &point_in_root);
ash::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,8 +640,9 @@ 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;
::wm::ConvertPointFromScreen(
ash::wm::GetRootWindowAt(location_in_screen_coordinates), &point_in_root);
ash::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 @@ -1009,8 +1010,8 @@ bool ShelfView::HandleRipOffDrag(const ui::LocatedEvent& event) {
delegate_->GetAppIDForShelfID(model_->items()[current_index].id);

gfx::Point screen_location = event.root_location();
::wm::ConvertPointToScreen(GetWidget()->GetNativeWindow()->GetRootWindow(),
&screen_location);
ash::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,6 +29,7 @@
#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 @@ -46,7 +47,6 @@
#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,6 +16,7 @@
#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 @@ -31,7 +32,6 @@
#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: 12 additions & 0 deletions ash/wm/coordinate_conversion.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,17 @@ 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: 10 additions & 0 deletions ash/wm/coordinate_conversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ 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: 1 addition & 2 deletions ash/wm/dock/docked_window_layout_manager_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
#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 @@ -189,7 +188,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,6 +12,7 @@
#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 @@ -29,7 +30,6 @@
#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
6 changes: 3 additions & 3 deletions ash/wm/dock/docked_window_resizer_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "ash/test/cursor_manager_test_api.h"
#include "ash/test/shell_test_api.h"
#include "ash/test/test_shelf_delegate.h"
#include "ash/wm/coordinate_conversion.h"
#include "ash/wm/dock/docked_window_layout_manager.h"
#include "ash/wm/drag_window_resizer.h"
#include "ash/wm/panels/panel_layout_manager.h"
Expand All @@ -33,7 +34,6 @@
#include "ui/base/ui_base_types.h"
#include "ui/events/test/event_generator.h"
#include "ui/views/widget/widget.h"
#include "ui/wm/core/coordinate_conversion.h"
#include "ui/wm/core/window_util.h"

namespace ash {
Expand Down Expand Up @@ -105,7 +105,7 @@ class DockedWindowResizerTest
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 Expand Up @@ -216,7 +216,7 @@ class DockedWindowResizerTest
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
Loading

0 comments on commit 7804332

Please sign in to comment.