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

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: 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,
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.
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(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.
40 return;
41 }
42
43 modifiers_->UpdateModifier(changed_button, down);
44 int flags = modifiers_->GetModifierFlags() |
45 EventModifiersEvdev::GetEventFlagFromModifier(changed_button);
46
47 callback_.Run(make_scoped_ptr(new MouseEvent(
48 (down) ? ET_MOUSE_PRESSED : ET_MOUSE_RELEASED,
49 cursor_->location(),
50 cursor_->location(),
51 flags,
52 flags)));
53 }
54
55 void InputInjectorEvDev::InjectMouseWheel(int delta_x, int delta_y) {
56 callback_.Run(make_scoped_ptr(new MouseWheelEvent(
57 gfx::Vector2d(delta_x, delta_y),
58 cursor_->location(),
59 cursor_->location(),
60 modifiers_->GetModifierFlags(),
61 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.
62 }
63
64 void InputInjectorEvDev::MoveCursorTo(const gfx::PointF& location) {
65 if (cursor_) {
66 cursor_->MoveCursorTo(location);
67 callback_.Run(make_scoped_ptr(new MouseEvent(
68 ET_MOUSE_MOVED,
69 cursor_->location(),
70 cursor_->location(),
71 modifiers_->GetModifierFlags(),
72 /* changed_button_flags */ 0)));
73 }
74 }
75
76 void InputInjectorEvDev::InjectKeyPress(DomCode physical_key, bool down) {
77 NOTIMPLEMENTED();
78 }
79
80 } // namespace ui
81
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698