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 9b6d2973cde40375253e5cd909298ce5305d84bc..f958ce791a1649ba465b7d612940175bf289db05 100644 |
--- a/ash/display/mouse_cursor_event_filter.cc |
+++ b/ash/display/mouse_cursor_event_filter.cc |
@@ -7,6 +7,7 @@ |
#include "ash/display/display_controller.h" |
#include "ash/shell.h" |
#include "ash/wm/cursor_manager.h" |
+#include "ui/aura/client/screen_position_client.h" |
#include "ui/aura/env.h" |
#include "ui/aura/event.h" |
#include "ui/aura/root_window.h" |
@@ -31,14 +32,33 @@ bool MouseCursorEventFilter::PreHandleKeyEvent(aura::Window* target, |
bool MouseCursorEventFilter::PreHandleMouseEvent(aura::Window* target, |
aura::MouseEvent* event) { |
- if (event->type() != ui::ET_MOUSE_MOVED || |
- ash::Shell::GetInstance()->cursor_manager()->is_cursor_locked()) |
- return false; |
- aura::RootWindow* current_root = target->GetRootWindow(); |
+ const bool is_cursor_locked = |
+ Shell::GetInstance()->cursor_manager()->is_cursor_locked(); |
+ |
+ // When the cursor is not locked (i.e., nothing is dragged), we only handle |
+ // ET_MOUSE_MOVED events. When it's locked, we only handle ET_MOUSE_DRAGGED |
+ // events. This is because when the cursor enters the other root window while |
+ // dragging, the underlying window system (at least X11) stops generating an |
+ // ET_MOUSE_MOVED event. |
+ if (!is_cursor_locked) { |
+ if (event->type() != ui::ET_MOUSE_MOVED) |
+ return false; |
+ } else { |
+ if (event->type() != ui::ET_MOUSE_DRAGGED) |
+ return false; |
+ } |
+ |
gfx::Point location_in_root(event->location()); |
- aura::Window::ConvertPointToWindow(target, current_root, &location_in_root); |
+ aura::Window::ConvertPointToWindow( |
+ target, target->GetRootWindow(), &location_in_root); |
+ |
+ // Get the root window where the cursor is currently on, then pass the window |
+ // and the location in the window's coordinates to ash::DisplayController. |
+ std::pair<aura::RootWindow*, gfx::Point> actual_location = |
+ Shell::GetInstance()->NormalizeLocationInDragEvent( |
+ target->GetRootWindow(), location_in_root); |
return display_controller_->WarpMouseCursorIfNecessary( |
- current_root, location_in_root); |
+ actual_location.first, actual_location.second, is_cursor_locked); |
} |
ui::TouchStatus MouseCursorEventFilter::PreHandleTouchEvent( |