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

Unified Diff: ash/drag_drop/drag_drop_tracker.cc

Issue 10948020: Convert native mouse locations to the locations in screen coordinate in RootWindowHostLinux. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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: ash/drag_drop/drag_drop_tracker.cc
diff --git a/ash/drag_drop/drag_drop_tracker.cc b/ash/drag_drop/drag_drop_tracker.cc
index d71c6984428f47ddee7c35430a5bd36d7bd33fb8..04ef9258fcd314f54126c0c4c3391287c0df6d49 100644
--- a/ash/drag_drop/drag_drop_tracker.cc
+++ b/ash/drag_drop/drag_drop_tracker.cc
@@ -25,6 +25,14 @@ aura::Window* CreateCaptureWindow(aura::RootWindow* root_window) {
return window;
}
+// Returns the root window at |location| in |window|'s coordinate.
+aura::RootWindow* GetRootWindowAt(aura::Window* window,
+ const gfx::Point& location) {
+ gfx::Point location_in_screen = location;
+ ash::wm::ConvertPointToScreen(window, &location_in_screen);
+ return ash::wm::GetRootWindowAt(location_in_screen);
oshima 2012/09/18 23:10:15 I'd prefer this to be different name than GetRootW
mazda 2012/09/18 23:44:57 Removed the function.
+}
+
} // namespace
namespace ash {
@@ -40,27 +48,32 @@ DragDropTracker::~DragDropTracker() {
}
aura::Window* DragDropTracker::GetTarget(const ui::LocatedEvent& event) {
- std::pair<aura::RootWindow*, gfx::Point> pair =
- ash::wm::GetRootWindowRelativeToWindow(capture_window_.get(),
- event.location());
- return pair.first->GetEventHandlerForPoint(pair.second);
+ DCHECK(capture_window_.get());
+ gfx::Point location_in_screen = event.location();
+ wm::ConvertPointToScreen(capture_window_.get(),
+ &location_in_screen);
+ aura::RootWindow* 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);
+ return root_window_at_point->GetEventHandlerForPoint(location_in_root);
}
ui::MouseEvent* DragDropTracker::ConvertMouseEvent(
aura::Window* target,
const ui::MouseEvent& event) {
DCHECK(capture_window_.get());
- std::pair<aura::RootWindow*, gfx::Point> location_pair =
- ash::wm::GetRootWindowRelativeToWindow(capture_window_.get(),
- event.location());
- aura::Window::ConvertPointToTarget(location_pair.first, target,
- &location_pair.second);
- std::pair<aura::RootWindow*, gfx::Point> root_location_pair =
- ash::wm::GetRootWindowRelativeToWindow(capture_window_->GetRootWindow(),
- event.root_location());
+ gfx::Point target_location = event.location();
+ aura::Window::ConvertPointToTarget(capture_window_.get(), target,
+ &target_location);
+ gfx::Point target_root_location = event.root_location();
+ aura::Window::ConvertPointToTarget(capture_window_->GetRootWindow(),
+ GetRootWindowAt(capture_window_.get(),
+ event.location()),
+ &target_root_location);
return new ui::MouseEvent(event.type(),
- location_pair.second,
- root_location_pair.second,
+ target_location,
+ target_root_location,
event.flags());
}

Powered by Google App Engine
This is Rietveld 408576698