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

Side by Side Diff: ui/aura/test/ui_controls_factory_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/aura/test/ui_controls_factory_aurawin.cc ('k') | ui/base/test/ui_controls.h » ('j') | 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 UnmaskAndSetKeycodeThenSend(&xevent, Mod1Mask, XK_Alt_L); 127 UnmaskAndSetKeycodeThenSend(&xevent, Mod1Mask, XK_Alt_L);
128 if (shift) 128 if (shift)
129 UnmaskAndSetKeycodeThenSend(&xevent, ShiftMask, XK_Shift_L); 129 UnmaskAndSetKeycodeThenSend(&xevent, ShiftMask, XK_Shift_L);
130 if (control) 130 if (control)
131 UnmaskAndSetKeycodeThenSend(&xevent, ControlMask, XK_Control_L); 131 UnmaskAndSetKeycodeThenSend(&xevent, ControlMask, XK_Control_L);
132 DCHECK(!xevent.xkey.state); 132 DCHECK(!xevent.xkey.state);
133 RunClosureAfterAllPendingUIEvents(closure); 133 RunClosureAfterAllPendingUIEvents(closure);
134 return true; 134 return true;
135 } 135 }
136 136
137 // Simulate a mouse move. (x,y) are absolute screen coordinates. 137 virtual bool SendMouseMove(long screen_x, long screen_y) OVERRIDE {
138 virtual bool SendMouseMove(long x, long y) OVERRIDE { 138 return SendMouseMoveNotifyWhenDone(screen_x, screen_y, base::Closure());
139 return SendMouseMoveNotifyWhenDone(x, y, base::Closure());
140 } 139 }
141 virtual bool SendMouseMoveNotifyWhenDone( 140 virtual bool SendMouseMoveNotifyWhenDone(
142 long x, 141 long screen_x,
143 long y, 142 long screen_y,
144 const base::Closure& closure) OVERRIDE { 143 const base::Closure& closure) OVERRIDE {
144 gfx::Point root_point(screen_x, screen_y);
145 aura::client::ScreenPositionClient* screen_position_client =
146 aura::client::GetScreenPositionClient(root_window_->window());
sky 2014/02/18 17:35:30 nit: only 4.
147 if (screen_position_client) {
148 screen_position_client->ConvertPointFromScreen(root_window_->window(),
149 &root_point);
150 }
151
145 XEvent xevent = {0}; 152 XEvent xevent = {0};
146 XMotionEvent* xmotion = &xevent.xmotion; 153 XMotionEvent* xmotion = &xevent.xmotion;
147 xmotion->type = MotionNotify; 154 xmotion->type = MotionNotify;
148 gfx::Point point = ui::ConvertPointToPixel( 155 xmotion->x = root_point.x();
149 root_window_->window()->layer(), 156 xmotion->y = root_point.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; 157 xmotion->state = button_down_mask;
154 xmotion->same_screen = True; 158 xmotion->same_screen = True;
155 // RootWindow will take care of other necessary fields. 159 // RootWindow will take care of other necessary fields.
156 root_window_->host()->PostNativeEvent(&xevent); 160 root_window_->host()->PostNativeEvent(&xevent);
157 RunClosureAfterAllPendingUIEvents(closure); 161 RunClosureAfterAllPendingUIEvents(closure);
158 return true; 162 return true;
159 } 163 }
160 virtual bool SendMouseEvents(MouseButton type, int state) OVERRIDE { 164 virtual bool SendMouseEvents(MouseButton type, int state) OVERRIDE {
161 return SendMouseEventsNotifyWhenDone(type, state, base::Closure()); 165 return SendMouseEventsNotifyWhenDone(type, state, base::Closure());
162 } 166 }
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 }; 252 };
249 253
250 } // namespace 254 } // namespace
251 255
252 UIControlsAura* CreateUIControlsAura(aura::RootWindow* root_window) { 256 UIControlsAura* CreateUIControlsAura(aura::RootWindow* root_window) {
253 return new UIControlsX11(root_window); 257 return new UIControlsX11(root_window);
254 } 258 }
255 259
256 } // namespace test 260 } // namespace test
257 } // namespace aura 261 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/test/ui_controls_factory_aurawin.cc ('k') | ui/base/test/ui_controls.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698