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

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

Issue 1975533002: Change ui::Event::time_stamp from TimeDelta to TimeTicks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 6 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/event_converter_evdev_impl.h" 5 #include "ui/events/ozone/evdev/event_converter_evdev_impl.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <linux/input.h> 8 #include <linux/input.h>
9 #include <stddef.h> 9 #include <stddef.h>
10 10
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 } 93 }
94 94
95 blocked_keys_.set(); 95 blocked_keys_.set();
96 for (const DomCode& it : allowed_keys) { 96 for (const DomCode& it : allowed_keys) {
97 int evdev_code = 97 int evdev_code =
98 NativeCodeToEvdevCode(KeycodeConverter::DomCodeToNativeKeycode(it)); 98 NativeCodeToEvdevCode(KeycodeConverter::DomCodeToNativeKeycode(it));
99 blocked_keys_.reset(evdev_code); 99 blocked_keys_.reset(evdev_code);
100 } 100 }
101 101
102 // Release any pressed blocked keys. 102 // Release any pressed blocked keys.
103 base::TimeDelta timestamp = ui::EventTimeForNow(); 103 base::TimeTicks timestamp = ui::EventTimeForNow();
104 for (int key = 0; key < KEY_CNT; ++key) { 104 for (int key = 0; key < KEY_CNT; ++key) {
105 if (blocked_keys_.test(key)) 105 if (blocked_keys_.test(key))
106 OnKeyChange(key, false /* down */, timestamp); 106 OnKeyChange(key, false /* down */, timestamp);
107 } 107 }
108 } 108 }
109 109
110 void EventConverterEvdevImpl::OnDisabled() { 110 void EventConverterEvdevImpl::OnDisabled() {
111 ReleaseKeys(); 111 ReleaseKeys();
112 ReleaseMouseButtons(); 112 ReleaseMouseButtons();
113 } 113 }
(...skipping 25 matching lines...) Expand all
139 return; 139 return;
140 140
141 // Mouse processing. 141 // Mouse processing.
142 if (input.code >= BTN_MOUSE && input.code < BTN_JOYSTICK) { 142 if (input.code >= BTN_MOUSE && input.code < BTN_JOYSTICK) {
143 DispatchMouseButton(input); 143 DispatchMouseButton(input);
144 return; 144 return;
145 } 145 }
146 146
147 // Keyboard processing. 147 // Keyboard processing.
148 OnKeyChange(input.code, input.value != kKeyReleaseValue, 148 OnKeyChange(input.code, input.value != kKeyReleaseValue,
149 TimeDeltaFromInputEvent(input)); 149 TimeTicksFromInputEvent(input));
150 } 150 }
151 151
152 void EventConverterEvdevImpl::ConvertMouseMoveEvent(const input_event& input) { 152 void EventConverterEvdevImpl::ConvertMouseMoveEvent(const input_event& input) {
153 if (!cursor_) 153 if (!cursor_)
154 return; 154 return;
155 switch (input.code) { 155 switch (input.code) {
156 case REL_X: 156 case REL_X:
157 x_offset_ = input.value; 157 x_offset_ = input.value;
158 break; 158 break;
159 case REL_Y: 159 case REL_Y:
160 y_offset_ = input.value; 160 y_offset_ = input.value;
161 break; 161 break;
162 } 162 }
163 } 163 }
164 164
165 void EventConverterEvdevImpl::OnKeyChange(unsigned int key, 165 void EventConverterEvdevImpl::OnKeyChange(unsigned int key,
166 bool down, 166 bool down,
167 const base::TimeDelta& timestamp) { 167 const base::TimeTicks& timestamp) {
168 if (key > KEY_MAX) 168 if (key > KEY_MAX)
169 return; 169 return;
170 170
171 if (down == key_state_.test(key)) 171 if (down == key_state_.test(key))
172 return; 172 return;
173 173
174 // Apply key filter (releases for previously pressed keys are excepted). 174 // Apply key filter (releases for previously pressed keys are excepted).
175 if (down && blocked_keys_.test(key)) 175 if (down && blocked_keys_.test(key))
176 return; 176 return;
177 177
178 // State transition: !(down) -> (down) 178 // State transition: !(down) -> (down)
179 key_state_.set(key, down); 179 key_state_.set(key, down);
180 180
181 dispatcher_->DispatchKeyEvent(KeyEventParams(input_device_.id, key, down, 181 dispatcher_->DispatchKeyEvent(KeyEventParams(input_device_.id, key, down,
182 false /* suppress_auto_repeat */, 182 false /* suppress_auto_repeat */,
183 timestamp)); 183 timestamp));
184 } 184 }
185 185
186 void EventConverterEvdevImpl::ReleaseKeys() { 186 void EventConverterEvdevImpl::ReleaseKeys() {
187 base::TimeDelta timestamp = ui::EventTimeForNow(); 187 base::TimeTicks timestamp = ui::EventTimeForNow();
188 for (int key = 0; key < KEY_CNT; ++key) 188 for (int key = 0; key < KEY_CNT; ++key)
189 OnKeyChange(key, false /* down */, timestamp); 189 OnKeyChange(key, false /* down */, timestamp);
190 } 190 }
191 191
192 void EventConverterEvdevImpl::ReleaseMouseButtons() { 192 void EventConverterEvdevImpl::ReleaseMouseButtons() {
193 base::TimeDelta timestamp = ui::EventTimeForNow(); 193 base::TimeTicks timestamp = ui::EventTimeForNow();
194 for (int code = BTN_MOUSE; code < BTN_JOYSTICK; ++code) 194 for (int code = BTN_MOUSE; code < BTN_JOYSTICK; ++code)
195 OnButtonChange(code, false /* down */, timestamp); 195 OnButtonChange(code, false /* down */, timestamp);
196 } 196 }
197 197
198 void EventConverterEvdevImpl::OnLostSync() { 198 void EventConverterEvdevImpl::OnLostSync() {
199 LOG(WARNING) << "kernel dropped input events"; 199 LOG(WARNING) << "kernel dropped input events";
200 200
201 // We may have missed key releases. Release everything. 201 // We may have missed key releases. Release everything.
202 // TODO(spang): Use EVIOCGKEY to avoid releasing keys that are still held. 202 // TODO(spang): Use EVIOCGKEY to avoid releasing keys that are still held.
203 ReleaseKeys(); 203 ReleaseKeys();
204 ReleaseMouseButtons(); 204 ReleaseMouseButtons();
205 } 205 }
206 206
207 void EventConverterEvdevImpl::DispatchMouseButton(const input_event& input) { 207 void EventConverterEvdevImpl::DispatchMouseButton(const input_event& input) {
208 if (!cursor_) 208 if (!cursor_)
209 return; 209 return;
210 210
211 OnButtonChange(input.code, input.value, TimeDeltaFromInputEvent(input)); 211 OnButtonChange(input.code, input.value, TimeTicksFromInputEvent(input));
212 } 212 }
213 213
214 void EventConverterEvdevImpl::OnButtonChange(int code, 214 void EventConverterEvdevImpl::OnButtonChange(int code,
215 bool down, 215 bool down,
216 const base::TimeDelta& timestamp) { 216 base::TimeTicks timestamp) {
217 if (code == BTN_SIDE) 217 if (code == BTN_SIDE)
218 code = BTN_BACK; 218 code = BTN_BACK;
219 else if (code == BTN_EXTRA) 219 else if (code == BTN_EXTRA)
220 code = BTN_FORWARD; 220 code = BTN_FORWARD;
221 221
222 int button_offset = code - BTN_MOUSE; 222 int button_offset = code - BTN_MOUSE;
223 if (mouse_button_state_.test(button_offset) == down) 223 if (mouse_button_state_.test(button_offset) == down)
224 return; 224 return;
225 225
226 mouse_button_state_.set(button_offset, down); 226 mouse_button_state_.set(button_offset, down);
227 227
228 dispatcher_->DispatchMouseButtonEvent(MouseButtonEventParams( 228 dispatcher_->DispatchMouseButtonEvent(MouseButtonEventParams(
229 input_device_.id, cursor_->GetLocation(), code, down, 229 input_device_.id, cursor_->GetLocation(), code, down,
230 /* allow_remap */ true, 230 /* allow_remap */ true,
231 PointerDetails(EventPointerType::POINTER_TYPE_MOUSE), timestamp)); 231 PointerDetails(EventPointerType::POINTER_TYPE_MOUSE), timestamp));
232 } 232 }
233 233
234 void EventConverterEvdevImpl::FlushEvents(const input_event& input) { 234 void EventConverterEvdevImpl::FlushEvents(const input_event& input) {
235 if (!cursor_ || (x_offset_ == 0 && y_offset_ == 0)) 235 if (!cursor_ || (x_offset_ == 0 && y_offset_ == 0))
236 return; 236 return;
237 237
238 cursor_->MoveCursor(gfx::Vector2dF(x_offset_, y_offset_)); 238 cursor_->MoveCursor(gfx::Vector2dF(x_offset_, y_offset_));
239 239
240 dispatcher_->DispatchMouseMoveEvent( 240 dispatcher_->DispatchMouseMoveEvent(
241 MouseMoveEventParams(input_device_.id, cursor_->GetLocation(), 241 MouseMoveEventParams(input_device_.id, cursor_->GetLocation(),
242 PointerDetails(EventPointerType::POINTER_TYPE_MOUSE), 242 PointerDetails(EventPointerType::POINTER_TYPE_MOUSE),
243 TimeDeltaFromInputEvent(input))); 243 TimeTicksFromInputEvent(input)));
244 244
245 x_offset_ = 0; 245 x_offset_ = 0;
246 y_offset_ = 0; 246 y_offset_ = 0;
247 } 247 }
248 248
249 } // namespace ui 249 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/ozone/evdev/event_converter_evdev_impl.h ('k') | ui/events/ozone/evdev/keyboard_evdev.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698