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

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: Address CL feedback 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
« no previous file with comments | « ui/events/ozone/evdev/input_injector_evdev.h ('k') | ui/events/ozone/events_ozone.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 void InputInjectorEvdev::InjectMouseButton(EventFlags button, bool down) {
27 int changed_button = 0;
28
29 switch(button) {
30 case EF_LEFT_MOUSE_BUTTON:
31 changed_button = EVDEV_MODIFIER_LEFT_MOUSE_BUTTON;
32 break;
33 case EF_RIGHT_MOUSE_BUTTON:
34 changed_button = EVDEV_MODIFIER_RIGHT_MOUSE_BUTTON;
35 break;
36 case EF_MIDDLE_MOUSE_BUTTON:
37 changed_button = EVDEV_MODIFIER_MIDDLE_MOUSE_BUTTON;
38 default:
39 LOG(WARNING) << "Invalid flag: " << button << " for the button parameter";
40 return;
41 }
42
43 modifiers_->UpdateModifier(changed_button, down);
44 int changed_button_flag =
45 EventModifiersEvdev::GetEventFlagFromModifier(changed_button);
46 callback_.Run(make_scoped_ptr(new MouseEvent(
spang 2014/11/25 21:47:06 bad indent
47 (down) ? ET_MOUSE_PRESSED : ET_MOUSE_RELEASED,
48 cursor_->location(),
49 cursor_->location(),
50 modifiers_->GetModifierFlags() | changed_button_flag,
51 changed_button_flag)));
52 }
53
54 void InputInjectorEvdev::InjectMouseWheel(int delta_x, int delta_y) {
55 callback_.Run(make_scoped_ptr(new MouseWheelEvent(
56 gfx::Vector2d(delta_x, delta_y),
57 cursor_->location(),
58 cursor_->location(),
59 modifiers_->GetModifierFlags(),
60 0 /* changed_button_flags */)));
61 }
62
63 void InputInjectorEvdev::MoveCursorTo(const gfx::PointF& location) {
64 if (cursor_) {
65 cursor_->MoveCursorTo(location);
66 callback_.Run(make_scoped_ptr(new MouseEvent(
67 ET_MOUSE_MOVED,
68 cursor_->location(),
69 cursor_->location(),
70 modifiers_->GetModifierFlags(),
71 0 /* changed_button_flags */)));
72 }
73 }
74
75 void InputInjectorEvdev::InjectKeyPress(DomCode physical_key, bool down) {
76 NOTIMPLEMENTED();
77 }
78
79 } // namespace ui
80
OLDNEW
« no previous file with comments | « ui/events/ozone/evdev/input_injector_evdev.h ('k') | ui/events/ozone/events_ozone.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698