#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop_proxy.h"
#include "ui/aura/client/screen_position_client.h"
-#include "ui/aura/root_window.h"
+#include "ui/aura/window_event_dispatcher.h"
+#include "ui/aura/window_tree_host.h"
#include "ui/events/event.h"
+#include "ui/events/event_source.h"
#include "ui/events/event_utils.h"
+#include "ui/events/test/events_test_utils.h"
#include "ui/gfx/vector2d_conversions.h"
#if defined(USE_X11)
#include <X11/Xlib.h>
#include "ui/base/x/x11_util.h"
+#include "ui/events/event_utils.h"
+#include "ui/events/test/events_test_utils_x11.h"
#endif
#if defined(OS_WIN)
virtual ~DefaultEventGeneratorDelegate() {}
// EventGeneratorDelegate overrides:
- virtual RootWindow* GetRootWindowAt(const gfx::Point& point) const OVERRIDE {
- return root_window_->GetDispatcher();
+ virtual WindowTreeHost* GetHostAt(const gfx::Point& point) const OVERRIDE {
+ return root_window_->GetHost();
}
virtual client::ScreenPositionClient* GetScreenPositionClient(
EventGenerator::EventGenerator(Window* root_window)
: delegate_(new DefaultEventGeneratorDelegate(root_window)),
- current_root_window_(delegate_->GetRootWindowAt(current_location_)),
+ current_host_(delegate_->GetHostAt(current_location_)),
flags_(0),
grab_(false),
async_(false) {
EventGenerator::EventGenerator(Window* root_window, const gfx::Point& point)
: delegate_(new DefaultEventGeneratorDelegate(root_window)),
current_location_(point),
- current_root_window_(delegate_->GetRootWindowAt(current_location_)),
+ current_host_(delegate_->GetHostAt(current_location_)),
flags_(0),
grab_(false),
async_(false) {
EventGenerator::EventGenerator(Window* root_window, Window* window)
: delegate_(new DefaultEventGeneratorDelegate(root_window)),
current_location_(CenterOfWindow(window)),
- current_root_window_(delegate_->GetRootWindowAt(current_location_)),
+ current_host_(delegate_->GetHostAt(current_location_)),
flags_(0),
grab_(false),
async_(false) {
EventGenerator::EventGenerator(EventGeneratorDelegate* delegate)
: delegate_(delegate),
- current_root_window_(delegate_->GetRootWindowAt(current_location_)),
+ current_host_(delegate_->GetHostAt(current_location_)),
flags_(0),
grab_(false),
async_(false) {
void EventGenerator::SendMouseExit() {
gfx::Point exit_location(current_location_);
- ConvertPointToTarget(current_root_window_, &exit_location);
+ ConvertPointToTarget(current_host_->window(), &exit_location);
ui::MouseEvent mouseev(ui::ET_MOUSE_EXITED, exit_location, exit_location,
- flags_);
+ flags_, 0);
Dispatch(&mouseev);
}
void EventGenerator::MoveMouseToInHost(const gfx::Point& point_in_host) {
const ui::EventType event_type = (flags_ & ui::EF_LEFT_MOUSE_BUTTON) ?
ui::ET_MOUSE_DRAGGED : ui::ET_MOUSE_MOVED;
- ui::MouseEvent mouseev(event_type, point_in_host, point_in_host, flags_);
+ ui::MouseEvent mouseev(event_type, point_in_host, point_in_host, flags_, 0);
Dispatch(&mouseev);
current_location_ = point_in_host;
- current_root_window_->ConvertPointFromHost(¤t_location_);
+ current_host_->ConvertPointFromHost(¤t_location_);
}
void EventGenerator::MoveMouseTo(const gfx::Point& point_in_screen,
step.Scale(i / count);
gfx::Point move_point = current_location_ + gfx::ToRoundedVector2d(step);
if (!grab_)
- UpdateCurrentRootWindow(move_point);
- ConvertPointToTarget(current_root_window_, &move_point);
- ui::MouseEvent mouseev(event_type, move_point, move_point, flags_);
+ UpdateCurrentDispatcher(move_point);
+ ConvertPointToTarget(current_host_->window(), &move_point);
+ ui::MouseEvent mouseev(event_type, move_point, move_point, flags_, 0);
Dispatch(&mouseev);
}
current_location_ = point_in_screen;
Dispatch(&touchev);
if (!grab_)
- UpdateCurrentRootWindow(point);
+ UpdateCurrentDispatcher(point);
}
void EventGenerator::ReleaseTouch() {
PressMoveAndReleaseTouchTo(CenterOfWindow(window));
}
+void EventGenerator::GestureEdgeSwipe() {
+ ui::GestureEvent gesture(
+ ui::ET_GESTURE_WIN8_EDGE_SWIPE,
+ 0,
+ 0,
+ 0,
+ ui::EventTimeForNow(),
+ ui::GestureEventDetails(ui::ET_GESTURE_WIN8_EDGE_SWIPE, 0, 0),
+ 0);
+ Dispatch(&gesture);
+}
+
void EventGenerator::GestureTapAt(const gfx::Point& location) {
const int kTouchId = 2;
ui::TouchEvent press(ui::ET_TOUCH_PRESSED,
MSG native_event =
{ NULL, (is_press ? key_press : WM_KEYUP), key_code, 0 };
TestKeyEvent keyev(native_event, flags, key_press == WM_CHAR);
+#elif defined(USE_X11)
+ ui::ScopedXI2Event xevent;
+ xevent.InitKeyEvent(is_press ? ui::ET_KEY_PRESSED : ui::ET_KEY_RELEASED,
+ key_code,
+ flags);
+ ui::KeyEvent keyev(xevent, false);
#else
ui::EventType type = is_press ? ui::ET_KEY_PRESSED : ui::ET_KEY_RELEASED;
ui::KeyEvent keyev(type, key_code, flags, false);
Dispatch(&keyev);
}
-void EventGenerator::UpdateCurrentRootWindow(const gfx::Point& point) {
- current_root_window_ = delegate_->GetRootWindowAt(point);
+void EventGenerator::UpdateCurrentDispatcher(const gfx::Point& point) {
+ current_host_ = delegate_->GetHostAt(point);
}
void EventGenerator::PressButton(int flag) {
flags_ |= flag;
grab_ = flags_ & kAllButtonMask;
gfx::Point location = GetLocationInCurrentRoot();
- ui::MouseEvent mouseev(ui::ET_MOUSE_PRESSED, location, location, flags_);
+ ui::MouseEvent mouseev(ui::ET_MOUSE_PRESSED, location, location, flags_,
+ flag);
Dispatch(&mouseev);
}
}
if (flags_ & flag) {
gfx::Point location = GetLocationInCurrentRoot();
ui::MouseEvent mouseev(ui::ET_MOUSE_RELEASED, location,
- location, flags_);
+ location, flags_, flag);
Dispatch(&mouseev);
flags_ ^= flag;
}
gfx::Point EventGenerator::GetLocationInCurrentRoot() const {
gfx::Point p(current_location_);
- ConvertPointToTarget(current_root_window_, &p);
+ ConvertPointToTarget(current_host_->window(), &p);
return p;
}
}
pending_events_.push_back(pending_event);
} else {
- RootWindowHostDelegate* root_window_host_delegate =
- current_root_window_->AsRootWindowHostDelegate();
- if (event->IsKeyEvent()) {
- root_window_host_delegate->OnHostKeyEvent(
- static_cast<ui::KeyEvent*>(event));
- } else if (event->IsMouseEvent()) {
- root_window_host_delegate->OnHostMouseEvent(
- static_cast<ui::MouseEvent*>(event));
- } else if (event->IsTouchEvent()) {
- root_window_host_delegate->OnHostTouchEvent(
- static_cast<ui::TouchEvent*>(event));
- } else if (event->IsScrollEvent()) {
- root_window_host_delegate->OnHostScrollEvent(
- static_cast<ui::ScrollEvent*>(event));
- } else {
- NOTREACHED() << "Invalid event type";
- }
+ ui::EventSource* event_source = current_host_->GetEventSource();
+ ui::EventSourceTestApi event_source_test(event_source);
+ ui::EventDispatchDetails details =
+ event_source_test.SendEventToProcessor(event);
+ CHECK(!details.dispatcher_destroyed);
}
}