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

Side by Side Diff: chrome/browser/automation/ui_controls_gtk.cc

Issue 8585015: Implement ui_controls for aura (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: no mask for xsendevent Created 9 years, 1 month 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
OLDNEW
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 <gdk/gdkkeysyms.h> 7 #include <gdk/gdkkeysyms.h>
8 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 // MessageLoop::Observer implementation: 46 // MessageLoop::Observer implementation:
47 virtual base::EventStatus WillProcessEvent(const base::NativeEvent& event) { 47 virtual base::EventStatus WillProcessEvent(const base::NativeEvent& event) {
48 NOTIMPLEMENTED(); 48 NOTIMPLEMENTED();
49 return base::EVENT_CONTINUE; 49 return base::EVENT_CONTINUE;
50 } 50 }
51 51
52 virtual void DidProcessEvent(const base::NativeEvent& event) { 52 virtual void DidProcessEvent(const base::NativeEvent& event) {
53 } 53 }
54 #else 54 #else
55 // MessageLoop::Observer implementation: 55 // MessageLoop::Observer implementation:
56 virtual void WillProcessEvent(GdkEvent* event) { 56 virtual void WillProcessEvent(GdkEvent* event) OVERRIDE {
57 if ((event->type == type_) && (--count_ == 0)) { 57 if ((event->type == type_) && (--count_ == 0)) {
58 // At the time we're invoked the event has not actually been processed. 58 // At the time we're invoked the event has not actually been processed.
59 // Use PostTask to make sure the event has been processed before 59 // Use PostTask to make sure the event has been processed before
60 // notifying. 60 // notifying.
61 // NOTE: if processing a message results in running a nested message 61 // NOTE: if processing a message results in running a nested message
62 // loop, then DidProcessEvent isn't immediately sent. As such, we do 62 // loop, then DidProcessEvent isn't immediately sent. As such, we do
63 // the processing in WillProcessEvent rather than DidProcessEvent. 63 // the processing in WillProcessEvent rather than DidProcessEvent.
64 MessageLoop::current()->PostTask(FROM_HERE, task_); 64 MessageLoop::current()->PostTask(FROM_HERE, task_);
65 delete this; 65 delete this;
66 } 66 }
67 } 67 }
68 68
69 virtual void DidProcessEvent(GdkEvent* event) { 69 virtual void DidProcessEvent(GdkEvent* event) OVERRIDE {
70 // No-op. 70 // No-op.
71 } 71 }
72 #endif 72 #endif
73 73
74 private: 74 private:
75 base::Closure task_; 75 base::Closure task_;
76 GdkEventType type_; 76 GdkEventType type_;
77 // The number of events of this type to wait for. 77 // The number of events of this type to wait for.
78 int count_; 78 int count_;
79 }; 79 };
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 release_event->button.time++; 233 release_event->button.time++;
234 if (state & UP) 234 if (state & UP)
235 gdk_event_put(release_event); 235 gdk_event_put(release_event);
236 236
237 gdk_event_free(event); 237 gdk_event_free(event);
238 gdk_event_free(release_event); 238 gdk_event_free(release_event);
239 239
240 return false; 240 return false;
241 } 241 }
242 242
243 bool SendMouseEventsNotifyWhenDone(MouseButton type, int state, 243 bool SendMouseEventsNotifyWhenDone(MouseButton type,
244 int state,
244 const base::Closure& task) { 245 const base::Closure& task) {
245 bool rv = SendMouseEvents(type, state); 246 bool rv = SendMouseEvents(type, state);
246 GdkEventType wait_type; 247 GdkEventType wait_type;
247 if (state & UP) { 248 if (state & UP) {
248 wait_type = GDK_BUTTON_RELEASE; 249 wait_type = GDK_BUTTON_RELEASE;
249 } else { 250 } else {
250 if (type == LEFT) 251 if (type == LEFT)
251 wait_type = GDK_BUTTON_PRESS; 252 wait_type = GDK_BUTTON_PRESS;
252 else if (type == MIDDLE) 253 else if (type == MIDDLE)
253 wait_type = GDK_2BUTTON_PRESS; 254 wait_type = GDK_2BUTTON_PRESS;
(...skipping 29 matching lines...) Expand all
283 // Listen to configure-event that is emitted when an window gets 284 // Listen to configure-event that is emitted when an window gets
284 // resized. 285 // resized.
285 GtkWidget* gtk_widget = widget->GetNativeView(); 286 GtkWidget* gtk_widget = widget->GetNativeView();
286 g_signal_connect(gtk_widget, "configure-event", 287 g_signal_connect(gtk_widget, "configure-event",
287 G_CALLBACK(&OnConfigure), widget); 288 G_CALLBACK(&OnConfigure), widget);
288 MessageLoop::current()->Run(); 289 MessageLoop::current()->Run();
289 } 290 }
290 } 291 }
291 #endif 292 #endif
292 293
293 void MoveMouseToCenterAndPress(views::View* view, MouseButton button, 294 void MoveMouseToCenterAndPress(views::View* view,
294 int state, const base::Closure& task) { 295 MouseButton button,
296 int state,
297 const base::Closure& task) {
295 #if defined(OS_LINUX) 298 #if defined(OS_LINUX)
296 // X is asynchronous and we need to wait until the window gets 299 // X is asynchronous and we need to wait until the window gets
297 // resized to desired size. 300 // resized to desired size.
298 SynchronizeWidgetSize(view->GetWidget()); 301 SynchronizeWidgetSize(view->GetWidget());
299 #endif 302 #endif
300 303
301 gfx::Point view_center(view->width() / 2, view->height() / 2); 304 gfx::Point view_center(view->width() / 2, view->height() / 2);
302 views::View::ConvertPointToScreen(view, &view_center); 305 views::View::ConvertPointToScreen(view, &view_center);
303 SendMouseMoveNotifyWhenDone( 306 SendMouseMoveNotifyWhenDone(
304 view_center.x(), view_center.y(), 307 view_center.x(), view_center.y(),
305 base::Bind(&ui_controls::ClickTask, button, state, task)); 308 base::Bind(&ui_controls::internal::ClickTask, button, state, task));
306 } 309 }
307 #else 310 #else
308 void MoveMouseToCenterAndPress(GtkWidget* widget, 311 void MoveMouseToCenterAndPress(GtkWidget* widget,
309 MouseButton button, 312 MouseButton button,
310 int state, 313 int state,
311 const base::Closure& task) { 314 const base::Closure& task) {
312 gfx::Rect bounds = gtk_util::GetWidgetScreenBounds(widget); 315 gfx::Rect bounds = gtk_util::GetWidgetScreenBounds(widget);
313 SendMouseMoveNotifyWhenDone( 316 SendMouseMoveNotifyWhenDone(
314 bounds.x() + bounds.width() / 2, 317 bounds.x() + bounds.width() / 2,
315 bounds.y() + bounds.height() / 2, 318 bounds.y() + bounds.height() / 2,
316 base::Bind(&ui_controls::ClickTask, button, state, task)); 319 base::Bind(&ui_controls::internal::ClickTask, button, state, task));
317 } 320 }
318 #endif 321 #endif
319 322
320 } // namespace ui_controls 323 } // namespace ui_controls
OLDNEW
« no previous file with comments | « chrome/browser/automation/ui_controls_aurax11.cc ('k') | chrome/browser/automation/ui_controls_internal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698