Chromium Code Reviews| Index: ash/shell.cc |
| diff --git a/ash/shell.cc b/ash/shell.cc |
| index ef6557a6ed77ce77f83a0a7b65151c08f9208493..2d131b7c8749e48dff7d5b5f0bd06b287ee68201 100644 |
| --- a/ash/shell.cc |
| +++ b/ash/shell.cc |
| @@ -788,4 +788,45 @@ void Shell::ShowCursor(bool visible) { |
| (*iter)->ShowCursor(visible); |
| } |
| +std::pair<aura::RootWindow*, gfx::Point> Shell::NormalizeLocationInDragEvent( |
|
sky
2012/08/02 23:28:31
This feels like the wrong place for this too. Mayb
Yusuke Sato
2012/08/03 01:52:11
Moved to wm/coordinate_conversion.cc.
|
| + aura::RootWindow* root_window, |
| + gfx::Point location_in_root) { |
| + // This is necessary for dealing with the "pointer warp" feature in |
| + // ash/display/display_controller.cc. For example, if we have two displays, |
| + // say 1000x1000 (primary) and 500x500 (extended one on the right), and start |
| + // dragging a window at (999, 123), and then move the cursor to the right, the |
| + // cursor suddenly warps to the extended display. The destination is (0, 123) |
| + // in the secondary root window's coordinates, or (1000, 123) in the screen |
| + // coordinates. However, since the mouse cursor is captured during drag, a |
| + // weird LocatedEvent, something like (0, 1123) in the *primary* root window's |
| + // coordinates, is sent to Chrome (Remember that in the native X11 world, the |
| + // two root windows are always stacked vertically regardless of the display |
| + // layout in Ash). We need to figure out that (0, 1123) in the primary root |
| + // window's coordinates is actually (0, 123) in the extended root window's |
| + // coordinates. |
| + if (!root_window->ContainsPointInRoot(location_in_root)) { |
| + gfx::Point location_in_native = location_in_root; |
| + root_window->ConvertPointToNativeScreen(&location_in_native); |
| + |
| + internal::DisplayController* controller = |
| + Shell::GetInstance()->display_controller(); |
| + std::vector<aura::RootWindow*> root_windows = |
| + controller->GetAllRootWindows(); |
| + for (size_t i = 0; i < root_windows.size(); ++i) { |
| + gfx::Point native_origin = root_windows[i]->bounds().origin(); |
| + root_windows[i]->ConvertPointToNativeScreen(&native_origin); |
| + gfx::Rect native_bounds = root_windows[i]->bounds(); |
| + native_bounds.set_origin(native_origin); |
| + if (native_bounds.Contains(location_in_native)) { |
| + root_window = root_windows[i]; |
| + location_in_root = location_in_native; |
| + location_in_root.Offset(-native_bounds.x(), -native_bounds.y()); |
| + break; |
| + } |
| + } |
| + } |
| + |
| + return std::make_pair(root_window, location_in_root); |
| +} |
| + |
| } // namespace ash |