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

Side by Side 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: Add unit test Created 6 years 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ui/events/event.h"
6 #include "ui/events/ozone/evdev/cursor_delegate_evdev.h"
7 #include "ui/events/ozone/evdev/event_modifiers_evdev.h"
8 #include "ui/events/ozone/evdev/input_injector_evdev.h"
9 #include "ui/events/ozone/evdev/keyboard_evdev.h"
10
11 namespace ui {
12
13 InputInjectorEvdev::InputInjectorEvdev(EventModifiersEvdev* modifiers,
14 CursorDelegateEvdev* cursor,
15 KeyboardEvdev* keyboard,
16 const EventDispatchCallback& callback)
17 : modifiers_(modifiers),
18 cursor_(cursor),
19 keyboard_(keyboard),
20 callback_(callback) {
21 DCHECK(modifiers_);
22 DCHECK(cursor_);
23 DCHECK(keyboard_);
24 }
25
26 InputInjectorEvdev::~InputInjectorEvdev() {
27 }
28
29 void InputInjectorEvdev::InjectMouseButton(EventFlags button, bool down) {
30 int changed_button = 0;
31
32 switch(button) {
33 case EF_LEFT_MOUSE_BUTTON:
34 changed_button = EVDEV_MODIFIER_LEFT_MOUSE_BUTTON;
35 break;
36 case EF_RIGHT_MOUSE_BUTTON:
37 changed_button = EVDEV_MODIFIER_RIGHT_MOUSE_BUTTON;
38 break;
39 case EF_MIDDLE_MOUSE_BUTTON:
40 changed_button = EVDEV_MODIFIER_MIDDLE_MOUSE_BUTTON;
41 default:
42 LOG(WARNING) << "Invalid flag: " << button << " for the button parameter";
43 return;
44 }
45
46 modifiers_->UpdateModifier(changed_button, down);
47 int changed_button_flag =
48 EventModifiersEvdev::GetEventFlagFromModifier(changed_button);
49 callback_.Run(make_scoped_ptr(new MouseEvent(
50 (down) ? ET_MOUSE_PRESSED : ET_MOUSE_RELEASED,
51 cursor_->location(),
52 cursor_->location(),
53 modifiers_->GetModifierFlags() | changed_button_flag,
54 changed_button_flag)));
55 }
56
57 void InputInjectorEvdev::InjectMouseWheel(int delta_x, int delta_y) {
58 callback_.Run(make_scoped_ptr(new MouseWheelEvent(
59 gfx::Vector2d(delta_x, delta_y),
60 cursor_->location(),
61 cursor_->location(),
62 modifiers_->GetModifierFlags(),
63 0 /* changed_button_flags */)));
64 }
65
66 void InputInjectorEvdev::MoveCursorTo(const gfx::PointF& location) {
67 if (cursor_) {
68 cursor_->MoveCursorTo(location);
69 callback_.Run(make_scoped_ptr(new MouseEvent(
70 ET_MOUSE_MOVED,
71 cursor_->location(),
72 cursor_->location(),
73 modifiers_->GetModifierFlags(),
74 0 /* changed_button_flags */)));
75 }
76 }
77
78 void InputInjectorEvdev::InjectKeyPress(DomCode physical_key, bool down) {
79 NOTIMPLEMENTED();
80 }
81
82 } // namespace ui
83
OLDNEW
« 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