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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 return true; | 134 return true; |
135 } | 135 } |
136 | 136 |
137 virtual bool SendMouseMove(long screen_x, long screen_y) OVERRIDE { | 137 virtual bool SendMouseMove(long screen_x, long screen_y) OVERRIDE { |
138 return SendMouseMoveNotifyWhenDone(screen_x, screen_y, base::Closure()); | 138 return SendMouseMoveNotifyWhenDone(screen_x, screen_y, base::Closure()); |
139 } | 139 } |
140 virtual bool SendMouseMoveNotifyWhenDone( | 140 virtual bool SendMouseMoveNotifyWhenDone( |
141 long screen_x, | 141 long screen_x, |
142 long screen_y, | 142 long screen_y, |
143 const base::Closure& closure) OVERRIDE { | 143 const base::Closure& closure) OVERRIDE { |
144 gfx::Point root_point(screen_x, screen_y); | 144 gfx::Point root_location(screen_x, screen_y); |
145 aura::client::ScreenPositionClient* screen_position_client = | 145 aura::client::ScreenPositionClient* screen_position_client = |
146 aura::client::GetScreenPositionClient(root_window_->window()); | 146 aura::client::GetScreenPositionClient(root_window_->window()); |
147 if (screen_position_client) { | 147 if (screen_position_client) { |
148 screen_position_client->ConvertPointFromScreen(root_window_->window(), | 148 screen_position_client->ConvertPointFromScreen(root_window_->window(), |
149 &root_point); | 149 &root_location); |
150 } | 150 } |
| 151 gfx::Point root_current_location; |
| 152 root_window_->host()->QueryMouseLocation(&root_current_location); |
| 153 root_window_->host()->ConvertPointFromHost(&root_current_location); |
151 | 154 |
152 XEvent xevent = {0}; | 155 if (root_location != root_current_location && button_down_mask == 0) { |
153 XMotionEvent* xmotion = &xevent.xmotion; | 156 // Move the cursor because EnterNotify/LeaveNotify are generated with the |
154 xmotion->type = MotionNotify; | 157 // current mouse position as a result of XGrabPointer() |
155 xmotion->x = root_point.x(); | 158 root_window_->window()->MoveCursorTo(root_location); |
156 xmotion->y = root_point.y(); | 159 } else { |
157 xmotion->state = button_down_mask; | 160 XEvent xevent = {0}; |
158 xmotion->same_screen = True; | 161 XMotionEvent* xmotion = &xevent.xmotion; |
159 // RootWindow will take care of other necessary fields. | 162 xmotion->type = MotionNotify; |
160 root_window_->host()->PostNativeEvent(&xevent); | 163 xmotion->x = root_location.x(); |
| 164 xmotion->y = root_location.y(); |
| 165 xmotion->state = button_down_mask; |
| 166 xmotion->same_screen = True; |
| 167 // RootWindow will take care of other necessary fields. |
| 168 root_window_->host()->PostNativeEvent(&xevent); |
| 169 } |
161 RunClosureAfterAllPendingUIEvents(closure); | 170 RunClosureAfterAllPendingUIEvents(closure); |
162 return true; | 171 return true; |
163 } | 172 } |
164 virtual bool SendMouseEvents(MouseButton type, int state) OVERRIDE { | 173 virtual bool SendMouseEvents(MouseButton type, int state) OVERRIDE { |
165 return SendMouseEventsNotifyWhenDone(type, state, base::Closure()); | 174 return SendMouseEventsNotifyWhenDone(type, state, base::Closure()); |
166 } | 175 } |
167 virtual bool SendMouseEventsNotifyWhenDone( | 176 virtual bool SendMouseEventsNotifyWhenDone( |
168 MouseButton type, | 177 MouseButton type, |
169 int state, | 178 int state, |
170 const base::Closure& closure) OVERRIDE { | 179 const base::Closure& closure) OVERRIDE { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 }; | 261 }; |
253 | 262 |
254 } // namespace | 263 } // namespace |
255 | 264 |
256 UIControlsAura* CreateUIControlsAura(aura::RootWindow* root_window) { | 265 UIControlsAura* CreateUIControlsAura(aura::RootWindow* root_window) { |
257 return new UIControlsX11(root_window); | 266 return new UIControlsX11(root_window); |
258 } | 267 } |
259 | 268 |
260 } // namespace test | 269 } // namespace test |
261 } // namespace aura | 270 } // namespace aura |
OLD | NEW |