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

Side by Side Diff: ui/events/ozone/evdev/tablet_event_converter_evdev.cc

Issue 869613003: [PATCH 5/11] ozone: evdev: Replace dispatch callbacks with an interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: namespace ui Created 5 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/events/ozone/evdev/tablet_event_converter_evdev.h" 5 #include "ui/events/ozone/evdev/tablet_event_converter_evdev.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <linux/input.h> 8 #include <linux/input.h>
9 9
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "ui/events/event.h" 11 #include "ui/events/event.h"
12 #include "ui/events/ozone/evdev/device_event_dispatcher_evdev.h"
12 13
13 namespace ui { 14 namespace ui {
14 15
15 TabletEventConverterEvdev::TabletEventConverterEvdev( 16 TabletEventConverterEvdev::TabletEventConverterEvdev(
16 int fd, 17 int fd,
17 base::FilePath path, 18 base::FilePath path,
18 int id, 19 int id,
19 InputDeviceType type, 20 InputDeviceType type,
20 CursorDelegateEvdev* cursor, 21 CursorDelegateEvdev* cursor,
21 const EventDeviceInfo& info, 22 const EventDeviceInfo& info,
22 const MouseMoveEventDispatchCallback& mouse_move_callback, 23 DeviceEventDispatcherEvdev* dispatcher)
23 const MouseButtonEventDispatchCallback& mouse_button_callback)
24 : EventConverterEvdev(fd, path, id, type), 24 : EventConverterEvdev(fd, path, id, type),
25 cursor_(cursor), 25 cursor_(cursor),
26 mouse_move_callback_(mouse_move_callback), 26 dispatcher_(dispatcher),
27 mouse_button_callback_(mouse_button_callback),
28 stylus_(0), 27 stylus_(0),
29 abs_value_dirty_(false) { 28 abs_value_dirty_(false) {
30 x_abs_min_ = info.GetAbsMinimum(ABS_X); 29 x_abs_min_ = info.GetAbsMinimum(ABS_X);
31 x_abs_range_ = info.GetAbsMaximum(ABS_X) - x_abs_min_ + 1; 30 x_abs_range_ = info.GetAbsMaximum(ABS_X) - x_abs_min_ + 1;
32 y_abs_min_ = info.GetAbsMinimum(ABS_Y); 31 y_abs_min_ = info.GetAbsMinimum(ABS_Y);
33 y_abs_range_ = info.GetAbsMaximum(ABS_Y) - y_abs_min_ + 1; 32 y_abs_range_ = info.GetAbsMaximum(ABS_Y) - y_abs_min_ + 1;
34 } 33 }
35 34
36 TabletEventConverterEvdev::~TabletEventConverterEvdev() { 35 TabletEventConverterEvdev::~TabletEventConverterEvdev() {
37 Stop(); 36 Stop();
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 else 137 else
139 return; 138 return;
140 139
141 if (abs_value_dirty_) { 140 if (abs_value_dirty_) {
142 UpdateCursor(); 141 UpdateCursor();
143 abs_value_dirty_ = false; 142 abs_value_dirty_ = false;
144 } 143 }
145 144
146 bool down = input.value; 145 bool down = input.value;
147 146
148 mouse_button_callback_.Run(MouseButtonEventParams( 147 dispatcher_->DispatchMouseButtonEvent(MouseButtonEventParams(
149 id_, cursor_->GetLocation(), button, down, false /* allow_remap */)); 148 id_, cursor_->GetLocation(), button, down, false /* allow_remap */));
150 } 149 }
151 150
152 void TabletEventConverterEvdev::FlushEvents() { 151 void TabletEventConverterEvdev::FlushEvents() {
153 if (!cursor_) 152 if (!cursor_)
154 return; 153 return;
155 154
156 // Prevent propagation of invalid data on stylus lift off 155 // Prevent propagation of invalid data on stylus lift off
157 if (stylus_ == 0) { 156 if (stylus_ == 0) {
158 abs_value_dirty_ = false; 157 abs_value_dirty_ = false;
159 return; 158 return;
160 } 159 }
161 160
162 if (!abs_value_dirty_) 161 if (!abs_value_dirty_)
163 return; 162 return;
164 163
165 UpdateCursor(); 164 UpdateCursor();
166 165
167 mouse_move_callback_.Run(MouseMoveEventParams(id_, cursor_->GetLocation())); 166 dispatcher_->DispatchMouseMoveEvent(
167 MouseMoveEventParams(id_, cursor_->GetLocation()));
168 168
169 abs_value_dirty_ = false; 169 abs_value_dirty_ = false;
170 } 170 }
171 171
172 } // namespace ui 172 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/ozone/evdev/tablet_event_converter_evdev.h ('k') | ui/events/ozone/evdev/tablet_event_converter_evdev_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698