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 <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 24 matching lines...) Expand all Loading... |
35 EventWaiter(const base::Closure& task, GdkEventType type, int count) | 35 EventWaiter(const base::Closure& task, GdkEventType type, int count) |
36 : task_(task), | 36 : task_(task), |
37 type_(type), | 37 type_(type), |
38 count_(count) { | 38 count_(count) { |
39 MessageLoopForUI::current()->AddObserver(this); | 39 MessageLoopForUI::current()->AddObserver(this); |
40 } | 40 } |
41 | 41 |
42 virtual ~EventWaiter() { | 42 virtual ~EventWaiter() { |
43 MessageLoopForUI::current()->RemoveObserver(this); | 43 MessageLoopForUI::current()->RemoveObserver(this); |
44 } | 44 } |
45 #if defined(TOUCH_UI) | |
46 // MessageLoop::Observer implementation: | |
47 virtual base::EventStatus WillProcessEvent(const base::NativeEvent& event) { | |
48 NOTIMPLEMENTED(); | |
49 return base::EVENT_CONTINUE; | |
50 } | |
51 | 45 |
52 virtual void DidProcessEvent(const base::NativeEvent& event) { | |
53 } | |
54 #else | |
55 // MessageLoop::Observer implementation: | 46 // MessageLoop::Observer implementation: |
56 virtual void WillProcessEvent(GdkEvent* event) { | 47 virtual void WillProcessEvent(GdkEvent* event) { |
57 if ((event->type == type_) && (--count_ == 0)) { | 48 if ((event->type == type_) && (--count_ == 0)) { |
58 // At the time we're invoked the event has not actually been processed. | 49 // 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 | 50 // Use PostTask to make sure the event has been processed before |
60 // notifying. | 51 // notifying. |
61 // NOTE: if processing a message results in running a nested message | 52 // NOTE: if processing a message results in running a nested message |
62 // loop, then DidProcessEvent isn't immediately sent. As such, we do | 53 // loop, then DidProcessEvent isn't immediately sent. As such, we do |
63 // the processing in WillProcessEvent rather than DidProcessEvent. | 54 // the processing in WillProcessEvent rather than DidProcessEvent. |
64 MessageLoop::current()->PostTask(FROM_HERE, task_); | 55 MessageLoop::current()->PostTask(FROM_HERE, task_); |
65 delete this; | 56 delete this; |
66 } | 57 } |
67 } | 58 } |
68 | 59 |
69 virtual void DidProcessEvent(GdkEvent* event) { | 60 virtual void DidProcessEvent(GdkEvent* event) { |
70 // No-op. | 61 // No-op. |
71 } | 62 } |
72 #endif | |
73 | 63 |
74 private: | 64 private: |
75 base::Closure task_; | 65 base::Closure task_; |
76 GdkEventType type_; | 66 GdkEventType type_; |
77 // The number of events of this type to wait for. | 67 // The number of events of this type to wait for. |
78 int count_; | 68 int count_; |
79 }; | 69 }; |
80 | 70 |
81 void FakeAMouseMotionEvent(gint x, gint y) { | 71 void FakeAMouseMotionEvent(gint x, gint y) { |
82 GdkEvent* event = gdk_event_new(GDK_MOTION_NOTIFY); | 72 GdkEvent* event = gdk_event_new(GDK_MOTION_NOTIFY); |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 const base::Closure& task) { | 301 const base::Closure& task) { |
312 gfx::Rect bounds = gtk_util::GetWidgetScreenBounds(widget); | 302 gfx::Rect bounds = gtk_util::GetWidgetScreenBounds(widget); |
313 SendMouseMoveNotifyWhenDone( | 303 SendMouseMoveNotifyWhenDone( |
314 bounds.x() + bounds.width() / 2, | 304 bounds.x() + bounds.width() / 2, |
315 bounds.y() + bounds.height() / 2, | 305 bounds.y() + bounds.height() / 2, |
316 base::Bind(&ui_controls::ClickTask, button, state, task)); | 306 base::Bind(&ui_controls::ClickTask, button, state, task)); |
317 } | 307 } |
318 #endif | 308 #endif |
319 | 309 |
320 } // namespace ui_controls | 310 } // namespace ui_controls |
OLD | NEW |