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

Unified Diff: ui/events/ozone/evdev/input_injector_evdev.cc

Issue 882503002: [PATCH 9.2/11] ozone: evdev: Use DeviceEventDispatcherEvdev from InputInjectorEvdev (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 11 months 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 side-by-side diff with in-line comments
Download patch
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
« no previous file with comments | « ui/events/ozone/evdev/input_injector_evdev.h ('k') | ui/events/ozone/evdev/input_injector_evdev_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698