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

Unified Diff: ash/display/mouse_cursor_event_filter.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/display/mouse_cursor_event_filter.cc
diff --git a/ash/display/mouse_cursor_event_filter.cc b/ash/display/mouse_cursor_event_filter.cc
index 469db416c15aa664b9d6f859830ff0a6ea29da36..51d30379bdf51cdee5447dc641e8b10fc13a51d9 100644
--- a/ash/display/mouse_cursor_event_filter.cc
+++ b/ash/display/mouse_cursor_event_filter.cc
@@ -85,10 +85,10 @@ bool MouseCursorEventFilter::PreHandleMouseEvent(aura::Window* target,
return false;
}
- aura::RootWindow* current_root = target->GetRootWindow();
- gfx::Point location_in_root(event->location());
- aura::Window::ConvertPointToTarget(target, current_root, &location_in_root);
- return WarpMouseCursorIfNecessary(current_root, location_in_root);
+ gfx::Point point_in_screen(event->location());
+ wm::ConvertPointToScreen(target, &point_in_screen);
oshima 2012/09/18 23:10:15 does this work when this target is a capture windo
mazda 2012/09/18 23:44:57 Yes, it works. event->location() is converted in R
+ return
+ WarpMouseCursorIfNecessary(target->GetRootWindow(), point_in_screen);
}
ui::TouchStatus MouseCursorEventFilter::PreHandleTouchEvent(
@@ -104,38 +104,31 @@ ui::EventResult MouseCursorEventFilter::PreHandleGestureEvent(
}
bool MouseCursorEventFilter::WarpMouseCursorIfNecessary(
- aura::RootWindow* current_root,
- const gfx::Point& point_in_root) {
+ aura::RootWindow* target_root,
+ const gfx::Point& point_in_screen) {
if (gfx::Screen::GetNumDisplays() <= 1 || mouse_warp_mode_ == WARP_NONE)
return false;
- const float scale = ui::GetDeviceScaleFactor(current_root->layer());
+ const float scale = ui::GetDeviceScaleFactor(target_root->layer());
- // The pointer might be outside the |current_root|. Get the root window where
- // the pointer is currently on.
- std::pair<aura::RootWindow*, gfx::Point> actual_location =
- wm::GetRootWindowRelativeToWindow(current_root, point_in_root);
- current_root = actual_location.first;
- // Don't use |point_in_root| below. Instead, use |actual_location.second|
- // which is in |actual_location.first|'s coordinates.
-
- gfx::Rect root_bounds = current_root->bounds();
+ aura::RootWindow* root_at_point = wm::GetRootWindowAt(point_in_screen);
+ gfx::Point point_in_root = point_in_screen;
+ wm::ConvertPointFromScreen(root_at_point, &point_in_root);
+ gfx::Rect root_bounds = root_at_point->bounds();
int offset_x = 0;
int offset_y = 0;
- if (actual_location.second.x() <= root_bounds.x()) {
+ if (point_in_root.x() <= root_bounds.x()) {
// Use -2, not -1, to avoid infinite loop of pointer warp.
offset_x = -2 * scale;
- } else if (actual_location.second.x() >= root_bounds.right() - 1) {
+ } else if (point_in_root.x() >= root_bounds.right() - 1) {
offset_x = 2 * scale;
- } else if (actual_location.second.y() <= root_bounds.y()) {
+ } else if (point_in_root.y() <= root_bounds.y()) {
offset_y = -2 * scale;
- } else if (actual_location.second.y() >= root_bounds.bottom() - 1) {
+ } else if (point_in_root.y() >= root_bounds.bottom() - 1) {
offset_y = 2 * scale;
} else {
return false;
}
- gfx::Point point_in_screen(actual_location.second);
- wm::ConvertPointToScreen(current_root, &point_in_screen);
gfx::Point point_in_dst_screen(point_in_screen);
point_in_dst_screen.Offset(offset_x, offset_y);
aura::RootWindow* dst_root = wm::GetRootWindowAt(point_in_dst_screen);
@@ -151,7 +144,7 @@ bool MouseCursorEventFilter::WarpMouseCursorIfNecessary(
wm::ConvertPointFromScreen(dst_root, &point_in_dst_screen);
if (dst_root->bounds().Contains(point_in_dst_screen)) {
- DCHECK_NE(dst_root, current_root);
+ DCHECK_NE(dst_root, root_at_point);
dst_root->MoveCursorTo(point_in_dst_screen);
ash::Shell::GetInstance()->cursor_manager()->SetDeviceScaleFactor(
dst_root->AsRootWindowHostDelegate()->GetDeviceScaleFactor());

Powered by Google App Engine
This is Rietveld 408576698