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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 return true; | 158 return true; |
159 } | 159 } |
160 | 160 |
161 virtual bool SendMouseMove(long screen_x, long screen_y) OVERRIDE { | 161 virtual bool SendMouseMove(long screen_x, long screen_y) OVERRIDE { |
162 return SendMouseMoveNotifyWhenDone(screen_x, screen_y, base::Closure()); | 162 return SendMouseMoveNotifyWhenDone(screen_x, screen_y, base::Closure()); |
163 } | 163 } |
164 virtual bool SendMouseMoveNotifyWhenDone( | 164 virtual bool SendMouseMoveNotifyWhenDone( |
165 long screen_x, | 165 long screen_x, |
166 long screen_y, | 166 long screen_y, |
167 const base::Closure& closure) OVERRIDE { | 167 const base::Closure& closure) OVERRIDE { |
168 gfx::Point screen_point(screen_x, screen_y); | 168 gfx::Point screen_location(screen_x, screen_y); |
169 gfx::Point root_point = screen_point; | 169 gfx::Point root_location = screen_location; |
170 aura::Window* root_window = RootWindowForPoint(screen_point); | 170 aura::Window* root_window = RootWindowForPoint(screen_location); |
171 | 171 |
172 aura::client::ScreenPositionClient* screen_position_client = | 172 aura::client::ScreenPositionClient* screen_position_client = |
173 aura::client::GetScreenPositionClient(root_window); | 173 aura::client::GetScreenPositionClient(root_window); |
174 if (screen_position_client) | 174 if (screen_position_client) { |
175 screen_position_client->ConvertPointFromScreen(root_window, &root_point); | 175 screen_position_client->ConvertPointFromScreen(root_window, |
| 176 &root_location); |
| 177 } |
176 | 178 |
177 XEvent xevent = {0}; | 179 aura::WindowEventDispatcher* dispatcher = root_window->GetDispatcher(); |
178 XMotionEvent* xmotion = &xevent.xmotion; | 180 gfx::Point root_current_location; |
179 xmotion->type = MotionNotify; | 181 dispatcher->host()->QueryMouseLocation(&root_current_location); |
180 xmotion->x = root_point.x(); | 182 dispatcher->host()->ConvertPointFromHost(&root_current_location); |
181 xmotion->y = root_point.y(); | 183 |
182 xmotion->state = button_down_mask; | 184 if (root_location != root_current_location && button_down_mask == 0) { |
183 xmotion->same_screen = True; | 185 // Move the cursor because EnterNotify/LeaveNotify are generated with the |
184 // RootWindow will take care of other necessary fields. | 186 // current mouse position as a result of XGrabPointer() |
185 root_window->GetDispatcher()->host()->PostNativeEvent(&xevent); | 187 root_window->MoveCursorTo(root_location); |
| 188 } else { |
| 189 XEvent xevent = {0}; |
| 190 XMotionEvent* xmotion = &xevent.xmotion; |
| 191 xmotion->type = MotionNotify; |
| 192 xmotion->x = root_location.x(); |
| 193 xmotion->y = root_location.y(); |
| 194 xmotion->state = button_down_mask; |
| 195 xmotion->same_screen = True; |
| 196 // RootWindow will take care of other necessary fields. |
| 197 dispatcher->host()->PostNativeEvent(&xevent); |
| 198 } |
186 RunClosureAfterAllPendingUIEvents(closure); | 199 RunClosureAfterAllPendingUIEvents(closure); |
187 return true; | 200 return true; |
188 } | 201 } |
189 virtual bool SendMouseEvents(MouseButton type, int state) OVERRIDE { | 202 virtual bool SendMouseEvents(MouseButton type, int state) OVERRIDE { |
190 return SendMouseEventsNotifyWhenDone(type, state, base::Closure()); | 203 return SendMouseEventsNotifyWhenDone(type, state, base::Closure()); |
191 } | 204 } |
192 virtual bool SendMouseEventsNotifyWhenDone( | 205 virtual bool SendMouseEventsNotifyWhenDone( |
193 MouseButton type, | 206 MouseButton type, |
194 int state, | 207 int state, |
195 const base::Closure& closure) OVERRIDE { | 208 const base::Closure& closure) OVERRIDE { |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 }; | 314 }; |
302 | 315 |
303 } // namespace | 316 } // namespace |
304 | 317 |
305 UIControlsAura* CreateUIControlsDesktopAura() { | 318 UIControlsAura* CreateUIControlsDesktopAura() { |
306 return new UIControlsDesktopX11(); | 319 return new UIControlsDesktopX11(); |
307 } | 320 } |
308 | 321 |
309 } // namespace test | 322 } // namespace test |
310 } // namespace views | 323 } // namespace views |
OLD | NEW |