Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <X11/keysym.h> | 5 #include <X11/keysym.h> |
| 6 #include <X11/Xlib.h> | 6 #include <X11/Xlib.h> |
| 7 | 7 |
| 8 // X macro fail. | 8 // X macro fail. |
| 9 #if defined(RootWindow) | 9 #if defined(RootWindow) |
| 10 #undef RootWindow | 10 #undef RootWindow |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 160 | 160 |
| 161 // Simulate a mouse move. (x,y) are absolute screen coordinates. | 161 // Simulate a mouse move. (x,y) are absolute screen coordinates. |
| 162 virtual bool SendMouseMove(long x, long y) OVERRIDE { | 162 virtual bool SendMouseMove(long x, long y) OVERRIDE { |
| 163 return SendMouseMoveNotifyWhenDone(x, y, base::Closure()); | 163 return SendMouseMoveNotifyWhenDone(x, y, base::Closure()); |
| 164 } | 164 } |
| 165 virtual bool SendMouseMoveNotifyWhenDone( | 165 virtual bool SendMouseMoveNotifyWhenDone( |
| 166 long x, | 166 long x, |
| 167 long y, | 167 long y, |
| 168 const base::Closure& closure) OVERRIDE { | 168 const base::Closure& closure) OVERRIDE { |
| 169 gfx::Point screen_point(x, y); | 169 gfx::Point screen_point(x, y); |
| 170 gfx::Point window_point = screen_point; | 170 gfx::Point root_point = screen_point; |
| 171 aura::Window* root_window = RootWindowForPoint(screen_point); | 171 aura::Window* root_window = RootWindowForPoint(screen_point); |
| 172 | 172 |
| 173 aura::client::ScreenPositionClient* screen_position_client = | 173 aura::client::ScreenPositionClient* screen_position_client = |
| 174 aura::client::GetScreenPositionClient(root_window); | 174 aura::client::GetScreenPositionClient(root_window); |
| 175 if (screen_position_client) { | 175 if (screen_position_client) |
| 176 screen_position_client->ConvertPointFromScreen(root_window, | 176 screen_position_client->ConvertPointFromScreen(root_window, &root_point); |
| 177 &window_point); | 177 |
| 178 aura::WindowEventDispatcher* dispatcher = root_window->GetDispatcher(); | |
| 179 gfx::Point root_current_location; | |
| 180 dispatcher->host()->QueryMouseLocation(&root_current_location); | |
| 181 dispatcher->host()->ConvertPointFromHost(&root_current_location); | |
| 182 | |
| 183 if (root_point != root_current_location) { | |
| 184 // Move the cursor because EnterNotify/LeaveNotify are generated with the | |
| 185 // current mouse position as a result of XGrabPointer() | |
| 186 dispatcher->MoveCursorTo(root_point); | |
| 187 | |
| 188 // MoveCursorTo() always generates a mouse move event. The test's | |
| 189 // intention may be to generate a mouse drag event so dispatch an event | |
| 190 // with the correct XMotionEvent state below. | |
| 178 } | 191 } |
| 179 | 192 |
| 180 XEvent xevent = {0}; | 193 XEvent xevent = {0}; |
| 181 XMotionEvent* xmotion = &xevent.xmotion; | 194 XMotionEvent* xmotion = &xevent.xmotion; |
| 182 xmotion->type = MotionNotify; | 195 xmotion->type = MotionNotify; |
| 183 xmotion->x = window_point.x(); | 196 xmotion->x = root_point.x(); |
| 184 xmotion->y = window_point.y(); | 197 xmotion->y = root_point.y(); |
| 185 xmotion->state = button_down_mask; | 198 xmotion->state = button_down_mask; |
| 186 xmotion->same_screen = True; | 199 xmotion->same_screen = True; |
| 187 // RootWindow will take care of other necessary fields. | 200 // RootWindow will take care of other necessary fields. |
| 188 root_window->GetDispatcher()->host()->PostNativeEvent(&xevent); | 201 dispatcher->host()->PostNativeEvent(&xevent); |
|
sadrul
2014/02/11 19:09:37
We are potentially sending two mouse-move events h
| |
| 189 RunClosureAfterAllPendingUIEvents(closure); | 202 RunClosureAfterAllPendingUIEvents(closure); |
| 190 return true; | 203 return true; |
| 191 } | 204 } |
| 192 virtual bool SendMouseEvents(MouseButton type, int state) OVERRIDE { | 205 virtual bool SendMouseEvents(MouseButton type, int state) OVERRIDE { |
| 193 return SendMouseEventsNotifyWhenDone(type, state, base::Closure()); | 206 return SendMouseEventsNotifyWhenDone(type, state, base::Closure()); |
| 194 } | 207 } |
| 195 virtual bool SendMouseEventsNotifyWhenDone( | 208 virtual bool SendMouseEventsNotifyWhenDone( |
| 196 MouseButton type, | 209 MouseButton type, |
| 197 int state, | 210 int state, |
| 198 const base::Closure& closure) OVERRIDE { | 211 const base::Closure& closure) OVERRIDE { |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 304 }; | 317 }; |
| 305 | 318 |
| 306 } // namespace | 319 } // namespace |
| 307 | 320 |
| 308 UIControlsAura* CreateUIControlsDesktopAura() { | 321 UIControlsAura* CreateUIControlsDesktopAura() { |
| 309 return new UIControlsDesktopX11(); | 322 return new UIControlsDesktopX11(); |
| 310 } | 323 } |
| 311 | 324 |
| 312 } // namespace test | 325 } // namespace test |
| 313 } // namespace views | 326 } // namespace views |
| OLD | NEW |