Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1204)

Side by Side Diff: ui/views/test/ui_controls_factory_desktop_aurax11.cc

Issue 162943004: [Refactor] Always pass in screen coordinates to UIControlsAura::SendMouseMove() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/base/test/ui_controls_internal_win.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 UnmaskAndSetKeycodeThenSend(dispatcher, &xevent, ShiftMask, XK_Shift_L); 151 UnmaskAndSetKeycodeThenSend(dispatcher, &xevent, ShiftMask, XK_Shift_L);
152 if (control) { 152 if (control) {
153 UnmaskAndSetKeycodeThenSend(dispatcher, &xevent, ControlMask, 153 UnmaskAndSetKeycodeThenSend(dispatcher, &xevent, ControlMask,
154 XK_Control_L); 154 XK_Control_L);
155 } 155 }
156 DCHECK(!xevent.xkey.state); 156 DCHECK(!xevent.xkey.state);
157 RunClosureAfterAllPendingUIEvents(closure); 157 RunClosureAfterAllPendingUIEvents(closure);
158 return true; 158 return true;
159 } 159 }
160 160
161 // Simulate a mouse move. (x,y) are absolute screen coordinates. 161 virtual bool SendMouseMove(long screen_x, long screen_y) OVERRIDE {
162 virtual bool SendMouseMove(long x, long y) OVERRIDE { 162 return SendMouseMoveNotifyWhenDone(screen_x, screen_y, base::Closure());
163 return SendMouseMoveNotifyWhenDone(x, y, base::Closure());
164 } 163 }
165 virtual bool SendMouseMoveNotifyWhenDone( 164 virtual bool SendMouseMoveNotifyWhenDone(
166 long x, 165 long screen_x,
167 long y, 166 long screen_y,
168 const base::Closure& closure) OVERRIDE { 167 const base::Closure& closure) OVERRIDE {
169 gfx::Point screen_point(x, y); 168 gfx::Point screen_point(screen_x, screen_y);
170 gfx::Point window_point = screen_point; 169 gfx::Point root_point = screen_point;
171 aura::Window* root_window = RootWindowForPoint(screen_point); 170 aura::Window* root_window = RootWindowForPoint(screen_point);
172 171
173 aura::client::ScreenPositionClient* screen_position_client = 172 aura::client::ScreenPositionClient* screen_position_client =
174 aura::client::GetScreenPositionClient(root_window); 173 aura::client::GetScreenPositionClient(root_window);
175 if (screen_position_client) { 174 if (screen_position_client)
176 screen_position_client->ConvertPointFromScreen(root_window, 175 screen_position_client->ConvertPointFromScreen(root_window, &root_point);
177 &window_point);
178 }
179 176
180 XEvent xevent = {0}; 177 XEvent xevent = {0};
181 XMotionEvent* xmotion = &xevent.xmotion; 178 XMotionEvent* xmotion = &xevent.xmotion;
182 xmotion->type = MotionNotify; 179 xmotion->type = MotionNotify;
183 xmotion->x = window_point.x(); 180 xmotion->x = root_point.x();
184 xmotion->y = window_point.y(); 181 xmotion->y = root_point.y();
185 xmotion->state = button_down_mask; 182 xmotion->state = button_down_mask;
186 xmotion->same_screen = True; 183 xmotion->same_screen = True;
187 // RootWindow will take care of other necessary fields. 184 // RootWindow will take care of other necessary fields.
188 root_window->GetDispatcher()->host()->PostNativeEvent(&xevent); 185 root_window->GetDispatcher()->host()->PostNativeEvent(&xevent);
189 RunClosureAfterAllPendingUIEvents(closure); 186 RunClosureAfterAllPendingUIEvents(closure);
190 return true; 187 return true;
191 } 188 }
192 virtual bool SendMouseEvents(MouseButton type, int state) OVERRIDE { 189 virtual bool SendMouseEvents(MouseButton type, int state) OVERRIDE {
193 return SendMouseEventsNotifyWhenDone(type, state, base::Closure()); 190 return SendMouseEventsNotifyWhenDone(type, state, base::Closure());
194 } 191 }
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 }; 301 };
305 302
306 } // namespace 303 } // namespace
307 304
308 UIControlsAura* CreateUIControlsDesktopAura() { 305 UIControlsAura* CreateUIControlsDesktopAura() {
309 return new UIControlsDesktopX11(); 306 return new UIControlsDesktopX11();
310 } 307 }
311 308
312 } // namespace test 309 } // namespace test
313 } // namespace views 310 } // namespace views
OLDNEW
« no previous file with comments | « ui/base/test/ui_controls_internal_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698