OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/automation/ui_controls.h" | 5 #include "chrome/browser/automation/ui_controls.h" |
6 | 6 |
7 #include <X11/keysym.h> | 7 #include <X11/keysym.h> |
8 #include <X11/Xlib.h> | 8 #include <X11/Xlib.h> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 bool SendMouseMoveNotifyWhenDone(long x, long y, const base::Closure& closure) { | 141 bool SendMouseMoveNotifyWhenDone(long x, long y, const base::Closure& closure) { |
142 XEvent xevent = {0}; | 142 XEvent xevent = {0}; |
143 XMotionEvent* xmotion = &xevent.xmotion; | 143 XMotionEvent* xmotion = &xevent.xmotion; |
144 xmotion->type = MotionNotify; | 144 xmotion->type = MotionNotify; |
145 g_current_x = xmotion->x = x; | 145 g_current_x = xmotion->x = x; |
146 g_current_y = xmotion->y = y; | 146 g_current_y = xmotion->y = y; |
147 xmotion->same_screen = True; | 147 xmotion->same_screen = True; |
148 // Desktop will take care of other necessary fields. | 148 // Desktop will take care of other necessary fields. |
149 aura::Desktop::GetInstance()->PostNativeEvent(&xevent); | 149 aura::Desktop::GetInstance()->PostNativeEvent(&xevent); |
150 RunClosureAfterAllPendingUIEvents(closure); | 150 RunClosureAfterAllPendingUIEvents(closure); |
151 return false; | 151 return true; |
152 } | 152 } |
153 | 153 |
154 bool SendMouseEvents(MouseButton type, int state) { | 154 bool SendMouseEvents(MouseButton type, int state) { |
155 return SendMouseEventsNotifyWhenDone(type, state, base::Closure()); | 155 return SendMouseEventsNotifyWhenDone(type, state, base::Closure()); |
156 } | 156 } |
157 | 157 |
158 bool SendMouseEventsNotifyWhenDone(MouseButton type, | 158 bool SendMouseEventsNotifyWhenDone(MouseButton type, |
159 int state, | 159 int state, |
160 const base::Closure& closure) { | 160 const base::Closure& closure) { |
161 XEvent xevent = {0}; | 161 XEvent xevent = {0}; |
(...skipping 22 matching lines...) Expand all Loading... |
184 aura::Desktop* desktop = aura::Desktop::GetInstance(); | 184 aura::Desktop* desktop = aura::Desktop::GetInstance(); |
185 if (state & DOWN) { | 185 if (state & DOWN) { |
186 xevent.xbutton.type = ButtonPress; | 186 xevent.xbutton.type = ButtonPress; |
187 desktop->PostNativeEvent(&xevent); | 187 desktop->PostNativeEvent(&xevent); |
188 } | 188 } |
189 if (state & UP) { | 189 if (state & UP) { |
190 xevent.xbutton.type = ButtonRelease; | 190 xevent.xbutton.type = ButtonRelease; |
191 desktop->PostNativeEvent(&xevent); | 191 desktop->PostNativeEvent(&xevent); |
192 } | 192 } |
193 RunClosureAfterAllPendingUIEvents(closure); | 193 RunClosureAfterAllPendingUIEvents(closure); |
194 return false; | 194 return true; |
195 } | 195 } |
196 | 196 |
197 bool SendMouseClick(MouseButton type) { | 197 bool SendMouseClick(MouseButton type) { |
198 return SendMouseEvents(type, UP | DOWN); | 198 return SendMouseEvents(type, UP | DOWN); |
199 } | 199 } |
200 | 200 |
201 void MoveMouseToCenterAndPress(views::View* view, MouseButton button, | 201 void MoveMouseToCenterAndPress(views::View* view, MouseButton button, |
202 int state, const base::Closure& closure) { | 202 int state, const base::Closure& closure) { |
203 DCHECK(view); | 203 DCHECK(view); |
204 DCHECK(view->GetWidget()); | 204 DCHECK(view->GetWidget()); |
(...skipping 13 matching lines...) Expand all Loading... |
218 marker_event->xclient.display = NULL; | 218 marker_event->xclient.display = NULL; |
219 marker_event->xclient.window = None; | 219 marker_event->xclient.window = None; |
220 marker_event->xclient.format = 8; | 220 marker_event->xclient.format = 8; |
221 } | 221 } |
222 marker_event->xclient.message_type = MarkerEventAtom(); | 222 marker_event->xclient.message_type = MarkerEventAtom(); |
223 aura::Desktop::GetInstance()->PostNativeEvent(marker_event); | 223 aura::Desktop::GetInstance()->PostNativeEvent(marker_event); |
224 new EventWaiter(closure, &Matcher); | 224 new EventWaiter(closure, &Matcher); |
225 } | 225 } |
226 | 226 |
227 } // namespace ui_controls | 227 } // namespace ui_controls |
OLD | NEW |