| Index: ui/events/ozone/evdev/input_injector_evdev.cc
|
| diff --git a/ui/events/ozone/evdev/input_injector_evdev.cc b/ui/events/ozone/evdev/input_injector_evdev.cc
|
| index e3da90b58dc51853a4f6451903f242e9a0aa5d1d..dcc1aa311a1ecf8659efc8d11cfc9758efb74631 100644
|
| --- a/ui/events/ozone/evdev/input_injector_evdev.cc
|
| +++ b/ui/events/ozone/evdev/input_injector_evdev.cc
|
| @@ -5,6 +5,7 @@
|
| #include "ui/events/event.h"
|
| #include "ui/events/keycodes/dom3/dom_code.h"
|
| #include "ui/events/ozone/evdev/cursor_delegate_evdev.h"
|
| +#include "ui/events/ozone/evdev/device_event_dispatcher_evdev.h"
|
| #include "ui/events/ozone/evdev/event_modifiers_evdev.h"
|
| #include "ui/events/ozone/evdev/input_injector_evdev.h"
|
| #include "ui/events/ozone/evdev/keyboard_evdev.h"
|
| @@ -12,69 +13,56 @@
|
|
|
| namespace ui {
|
|
|
| -InputInjectorEvdev::InputInjectorEvdev(EventModifiersEvdev* modifiers,
|
| - CursorDelegateEvdev* cursor,
|
| - KeyboardEvdev* keyboard,
|
| - const EventDispatchCallback& callback)
|
| - : modifiers_(modifiers),
|
| - cursor_(cursor),
|
| - keyboard_(keyboard),
|
| - callback_(callback) {
|
| - DCHECK(modifiers_);
|
| - DCHECK(cursor_);
|
| - DCHECK(keyboard_);
|
| +namespace {
|
| +
|
| +const int kDeviceIdForInjection = -1;
|
| +
|
| +} // namespace
|
| +
|
| +InputInjectorEvdev::InputInjectorEvdev(
|
| + scoped_ptr<DeviceEventDispatcherEvdev> dispatcher,
|
| + CursorDelegateEvdev* cursor)
|
| + : cursor_(cursor), dispatcher_(dispatcher.Pass()) {
|
| }
|
|
|
| InputInjectorEvdev::~InputInjectorEvdev() {
|
| }
|
|
|
| void InputInjectorEvdev::InjectMouseButton(EventFlags button, bool down) {
|
| - int changed_button = 0;
|
| -
|
| - switch(button) {
|
| + unsigned int code;
|
| + switch (button) {
|
| case EF_LEFT_MOUSE_BUTTON:
|
| - changed_button = EVDEV_MODIFIER_LEFT_MOUSE_BUTTON;
|
| + code = BTN_LEFT;
|
| break;
|
| case EF_RIGHT_MOUSE_BUTTON:
|
| - changed_button = EVDEV_MODIFIER_RIGHT_MOUSE_BUTTON;
|
| + code = BTN_RIGHT;
|
| break;
|
| case EF_MIDDLE_MOUSE_BUTTON:
|
| - changed_button = EVDEV_MODIFIER_MIDDLE_MOUSE_BUTTON;
|
| + code = BTN_MIDDLE;
|
| default:
|
| LOG(WARNING) << "Invalid flag: " << button << " for the button parameter";
|
| return;
|
| }
|
|
|
| - modifiers_->UpdateModifier(changed_button, down);
|
| - int changed_button_flag =
|
| - EventModifiersEvdev::GetEventFlagFromModifier(changed_button);
|
| - callback_.Run(make_scoped_ptr(new MouseEvent(
|
| - (down) ? ET_MOUSE_PRESSED : ET_MOUSE_RELEASED,
|
| - cursor_->GetLocation(),
|
| - cursor_->GetLocation(),
|
| - modifiers_->GetModifierFlags() | changed_button_flag,
|
| - changed_button_flag)));
|
| + dispatcher_->DispatchMouseButtonEvent(
|
| + MouseButtonEventParams(kDeviceIdForInjection, cursor_->GetLocation(),
|
| + code, down, false /* allow_remap */));
|
| }
|
|
|
| void InputInjectorEvdev::InjectMouseWheel(int delta_x, int delta_y) {
|
| - callback_.Run(make_scoped_ptr(new MouseWheelEvent(
|
| - gfx::Vector2d(delta_x, delta_y),
|
| - cursor_->GetLocation(),
|
| - cursor_->GetLocation(),
|
| - modifiers_->GetModifierFlags(),
|
| - 0 /* changed_button_flags */)));
|
| + dispatcher_->DispatchMouseWheelEvent(
|
| + MouseWheelEventParams(kDeviceIdForInjection, cursor_->GetLocation(),
|
| + gfx::Vector2d(delta_x, delta_y)));
|
| }
|
|
|
| void InputInjectorEvdev::MoveCursorTo(const gfx::PointF& location) {
|
| - if (cursor_) {
|
| - cursor_->MoveCursorTo(location);
|
| - callback_.Run(make_scoped_ptr(new MouseEvent(
|
| - ET_MOUSE_MOVED,
|
| - cursor_->GetLocation(),
|
| - cursor_->GetLocation(),
|
| - modifiers_->GetModifierFlags(),
|
| - 0 /* changed_button_flags */)));
|
| - }
|
| + if (!cursor_)
|
| + return;
|
| +
|
| + cursor_->MoveCursorTo(location);
|
| +
|
| + dispatcher_->DispatchMouseMoveEvent(
|
| + MouseMoveEventParams(kDeviceIdForInjection, cursor_->GetLocation()));
|
| }
|
|
|
| void InputInjectorEvdev::InjectKeyPress(DomCode physical_key, bool down) {
|
| @@ -84,7 +72,9 @@ void InputInjectorEvdev::InjectKeyPress(DomCode physical_key, bool down) {
|
|
|
| int native_keycode = KeycodeConverter::DomCodeToNativeKeycode(physical_key);
|
| int evdev_code = NativeCodeToEvdevCode(native_keycode);
|
| - keyboard_->OnKeyChange(evdev_code, down);
|
| +
|
| + dispatcher_->DispatchKeyEvent(
|
| + KeyEventParams(kDeviceIdForInjection, evdev_code, down));
|
| }
|
|
|
| } // namespace ui
|
|
|