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

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

Issue 755883002: Input Injection API on Ozone (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
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
+

Powered by Google App Engine
This is Rietveld 408576698