summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorpkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-20 17:48:14 +0000
committerpkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-20 17:48:14 +0000
commite1b4c37ed9dc11a4537ba13c887ab29f3dea80c4 (patch)
treec7239bf1fbe62201b7964d88fa9595b4fccafe5a /ui
parent235dac08c0c66d64cdeb983392481db95359a22f (diff)
downloadchromium_src-e1b4c37ed9dc11a4537ba13c887ab29f3dea80c4.zip
chromium_src-e1b4c37ed9dc11a4537ba13c887ab29f3dea80c4.tar.gz
chromium_src-e1b4c37ed9dc11a4537ba13c887ab29f3dea80c4.tar.bz2
Fix crash of OmniboxViewViewsTest.SelectAllOnClick on Linux Aura
XGrabPointer() generates EnterNotify/LeaveNotify events with the mouse cursor's current position which affects: - aura::Env::last_mouse_location() - The position of mouse events sent via ui_controls::SendMouseEventsNotifyWhenDone() This CL moves the mouse cursor such that the EnterNotify/LeaveNotify events have the intended location (as opposed to the position of the mouse cursor before the test began). BUG=163931 TEST=OmniboxViewViewsTest test suite passes Review URL: https://codereview.chromium.org/149743006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@252301 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/aura/test/ui_controls_factory_aurax11.cc31
-rw-r--r--ui/views/test/ui_controls_factory_desktop_aurax11.cc41
2 files changed, 47 insertions, 25 deletions
diff --git a/ui/aura/test/ui_controls_factory_aurax11.cc b/ui/aura/test/ui_controls_factory_aurax11.cc
index dffea4a..d505e36 100644
--- a/ui/aura/test/ui_controls_factory_aurax11.cc
+++ b/ui/aura/test/ui_controls_factory_aurax11.cc
@@ -141,23 +141,32 @@ class UIControlsX11 : public UIControlsAura {
long screen_x,
long screen_y,
const base::Closure& closure) OVERRIDE {
- gfx::Point root_point(screen_x, screen_y);
+ gfx::Point root_location(screen_x, screen_y);
aura::client::ScreenPositionClient* screen_position_client =
aura::client::GetScreenPositionClient(root_window_->window());
if (screen_position_client) {
screen_position_client->ConvertPointFromScreen(root_window_->window(),
- &root_point);
+ &root_location);
}
+ gfx::Point root_current_location;
+ root_window_->host()->QueryMouseLocation(&root_current_location);
+ root_window_->host()->ConvertPointFromHost(&root_current_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_->host()->PostNativeEvent(&xevent);
+ 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_->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.
+ root_window_->host()->PostNativeEvent(&xevent);
+ }
RunClosureAfterAllPendingUIEvents(closure);
return true;
}
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;
}