diff options
Diffstat (limited to 'ui/views/test/ui_controls_factory_desktop_aurax11.cc')
-rw-r--r-- | ui/views/test/ui_controls_factory_desktop_aurax11.cc | 41 |
1 files changed, 27 insertions, 14 deletions
diff --git a/ui/views/test/ui_controls_factory_desktop_aurax11.cc b/ui/views/test/ui_controls_factory_desktop_aurax11.cc index db6ff96..23a7922 100644 --- a/ui/views/test/ui_controls_factory_desktop_aurax11.cc +++ b/ui/views/test/ui_controls_factory_desktop_aurax11.cc @@ -165,24 +165,37 @@ class UIControlsDesktopX11 : public UIControlsAura { long screen_x, long screen_y, const base::Closure& closure) OVERRIDE { - gfx::Point screen_point(screen_x, screen_y); - gfx::Point root_point = screen_point; - aura::Window* root_window = RootWindowForPoint(screen_point); + gfx::Point screen_location(screen_x, screen_y); + gfx::Point root_location = screen_location; + aura::Window* root_window = RootWindowForPoint(screen_location); aura::client::ScreenPositionClient* screen_position_client = aura::client::GetScreenPositionClient(root_window); - if (screen_position_client) - screen_position_client->ConvertPointFromScreen(root_window, &root_point); + if (screen_position_client) { + screen_position_client->ConvertPointFromScreen(root_window, + &root_location); + } - XEvent xevent = {0}; - XMotionEvent* xmotion = &xevent.xmotion; - xmotion->type = MotionNotify; - xmotion->x = root_point.x(); - xmotion->y = root_point.y(); - xmotion->state = button_down_mask; - xmotion->same_screen = True; - // RootWindow will take care of other necessary fields. - root_window->GetDispatcher()->host()->PostNativeEvent(&xevent); + aura::WindowEventDispatcher* dispatcher = root_window->GetDispatcher(); + gfx::Point root_current_location; + dispatcher->host()->QueryMouseLocation(&root_current_location); + dispatcher->host()->ConvertPointFromHost(&root_current_location); + + if (root_location != root_current_location && button_down_mask == 0) { + // Move the cursor because EnterNotify/LeaveNotify are generated with the + // current mouse position as a result of XGrabPointer() + root_window->MoveCursorTo(root_location); + } else { + XEvent xevent = {0}; + XMotionEvent* xmotion = &xevent.xmotion; + xmotion->type = MotionNotify; + xmotion->x = root_location.x(); + xmotion->y = root_location.y(); + xmotion->state = button_down_mask; + xmotion->same_screen = True; + // RootWindow will take care of other necessary fields. + dispatcher->host()->PostNativeEvent(&xevent); + } RunClosureAfterAllPendingUIEvents(closure); return true; } |