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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 } | 135 } |
136 | 136 |
137 // Simulate a mouse move. (x,y) are absolute screen coordinates. | 137 // Simulate a mouse move. (x,y) are absolute screen coordinates. |
138 virtual bool SendMouseMove(long x, long y) OVERRIDE { | 138 virtual bool SendMouseMove(long x, long y) OVERRIDE { |
139 return SendMouseMoveNotifyWhenDone(x, y, base::Closure()); | 139 return SendMouseMoveNotifyWhenDone(x, y, base::Closure()); |
140 } | 140 } |
141 virtual bool SendMouseMoveNotifyWhenDone( | 141 virtual bool SendMouseMoveNotifyWhenDone( |
142 long x, | 142 long x, |
143 long y, | 143 long y, |
144 const base::Closure& closure) OVERRIDE { | 144 const base::Closure& closure) OVERRIDE { |
| 145 gfx::Point root_location(static_cast<int>(x), static_cast<int>(y)); |
| 146 aura::client::ScreenPositionClient* screen_position_client = |
| 147 aura::client::GetScreenPositionClient(root_window_->window()); |
| 148 if (screen_position_client) { |
| 149 screen_position_client->ConvertPointFromScreen(root_window_->window(), |
| 150 &root_location); |
| 151 } |
| 152 |
| 153 // It is unnecessary to move the cursor because XGrabPointer() is not |
| 154 // called in tests. |
| 155 |
145 XEvent xevent = {0}; | 156 XEvent xevent = {0}; |
146 XMotionEvent* xmotion = &xevent.xmotion; | 157 XMotionEvent* xmotion = &xevent.xmotion; |
147 xmotion->type = MotionNotify; | 158 xmotion->type = MotionNotify; |
148 gfx::Point point = ui::ConvertPointToPixel( | 159 xmotion->x = root_location.x(); |
149 root_window_->window()->layer(), | 160 xmotion->y = root_location.y(); |
150 gfx::Point(static_cast<int>(x), static_cast<int>(y))); | |
151 xmotion->x = point.x(); | |
152 xmotion->y = point.y(); | |
153 xmotion->state = button_down_mask; | 161 xmotion->state = button_down_mask; |
154 xmotion->same_screen = True; | 162 xmotion->same_screen = True; |
155 // RootWindow will take care of other necessary fields. | 163 // RootWindow will take care of other necessary fields. |
156 root_window_->host()->PostNativeEvent(&xevent); | 164 root_window_->host()->PostNativeEvent(&xevent); |
157 RunClosureAfterAllPendingUIEvents(closure); | 165 RunClosureAfterAllPendingUIEvents(closure); |
158 return true; | 166 return true; |
159 } | 167 } |
160 virtual bool SendMouseEvents(MouseButton type, int state) OVERRIDE { | 168 virtual bool SendMouseEvents(MouseButton type, int state) OVERRIDE { |
161 return SendMouseEventsNotifyWhenDone(type, state, base::Closure()); | 169 return SendMouseEventsNotifyWhenDone(type, state, base::Closure()); |
162 } | 170 } |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 }; | 256 }; |
249 | 257 |
250 } // namespace | 258 } // namespace |
251 | 259 |
252 UIControlsAura* CreateUIControlsAura(aura::RootWindow* root_window) { | 260 UIControlsAura* CreateUIControlsAura(aura::RootWindow* root_window) { |
253 return new UIControlsX11(root_window); | 261 return new UIControlsX11(root_window); |
254 } | 262 } |
255 | 263 |
256 } // namespace test | 264 } // namespace test |
257 } // namespace aura | 265 } // namespace aura |
OLD | NEW |