Chromium Code Reviews| 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 |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..619705be7863c697a538f3acf64478eef6990eee |
| --- /dev/null |
| +++ b/ui/events/ozone/evdev/input_injector_evdev.cc |
| @@ -0,0 +1,81 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "ui/events/event.h" |
| +#include "ui/events/ozone/evdev/cursor_delegate_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" |
| + |
| +namespace ui { |
| + |
| +InputInjectorEvDev::InputInjectorEvDev(EventModifiersEvdev* modifiers, |
|
spang
2014/11/25 19:58:29
I've been spelling this "Evdev" - let's be consist
kelvinp
2014/11/25 21:16:49
Done.
|
| + CursorDelegateEvdev* cursor, |
| + KeyboardEvdev* keyboard, |
| + const EventDispatchCallback& callback) |
| + : modifiers_(modifiers), |
| + cursor_(cursor), |
| + keyboard_(keyboard), |
| + callback_(callback) { |
| + DCHECK(modifiers_); |
| + DCHECK(cursor_); |
| + DCHECK(keyboard_); |
| +} |
| + |
| +void InputInjectorEvDev::InjectMouseButton(EventFlags button, bool down) { |
| + int changed_button = 0; |
| + |
| + switch(button) { |
| + case EF_LEFT_MOUSE_BUTTON: |
| + changed_button = EVDEV_MODIFIER_LEFT_MOUSE_BUTTON; |
| + break; |
| + case EF_RIGHT_MOUSE_BUTTON: |
| + changed_button = EVDEV_MODIFIER_RIGHT_MOUSE_BUTTON; |
| + break; |
| + case EF_MIDDLE_MOUSE_BUTTON: |
| + changed_button = EVDEV_MODIFIER_MIDDLE_MOUSE_BUTTON; |
| + default: |
| + LOG(FATAL) << "Invalid flags: " << button << " for the button parameter"; |
|
spang
2014/11/25 19:58:29
fatal seems a little harsh.. maybe just warn?
kelvinp
2014/11/25 21:16:49
Done.
|
| + return; |
| + } |
| + |
| + modifiers_->UpdateModifier(changed_button, down); |
| + int flags = modifiers_->GetModifierFlags() | |
| + EventModifiersEvdev::GetEventFlagFromModifier(changed_button); |
| + |
| + callback_.Run(make_scoped_ptr(new MouseEvent( |
| + (down) ? ET_MOUSE_PRESSED : ET_MOUSE_RELEASED, |
| + cursor_->location(), |
| + cursor_->location(), |
| + flags, |
| + flags))); |
| +} |
| + |
| +void InputInjectorEvDev::InjectMouseWheel(int delta_x, int delta_y) { |
| + callback_.Run(make_scoped_ptr(new MouseWheelEvent( |
| + gfx::Vector2d(delta_x, delta_y), |
| + cursor_->location(), |
| + cursor_->location(), |
| + modifiers_->GetModifierFlags(), |
| + modifiers_->GetModifierFlags()))); |
|
spang
2014/11/25 19:58:29
Why is changed_button_flags set to all modifiers (
kelvinp
2014/11/25 21:16:49
Done.
|
| +} |
| + |
| +void InputInjectorEvDev::MoveCursorTo(const gfx::PointF& location) { |
| + if (cursor_) { |
| + cursor_->MoveCursorTo(location); |
| + callback_.Run(make_scoped_ptr(new MouseEvent( |
| + ET_MOUSE_MOVED, |
| + cursor_->location(), |
| + cursor_->location(), |
| + modifiers_->GetModifierFlags(), |
| + /* changed_button_flags */ 0))); |
| + } |
| +} |
| + |
| +void InputInjectorEvDev::InjectKeyPress(DomCode physical_key, bool down) { |
| + NOTIMPLEMENTED(); |
| +} |
| + |
| +} // namespace ui |
| + |