OLD | NEW |
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/libgestures_glue/gesture_interpreter_libevdev_cr
os.h" | 5 #include "ui/events/ozone/evdev/libgestures_glue/gesture_interpreter_libevdev_cr
os.h" |
6 | 6 |
7 #include <gestures/gestures.h> | 7 #include <gestures/gestures.h> |
8 #include <libevdev/libevdev.h> | 8 #include <libevdev/libevdev.h> |
9 | 9 |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 cursor_->location(), | 202 cursor_->location(), |
203 cursor_->location(), | 203 cursor_->location(), |
204 modifiers_->GetModifierFlags(), | 204 modifiers_->GetModifierFlags(), |
205 /* changed_button_flags */ 0); | 205 /* changed_button_flags */ 0); |
206 Dispatch(&event); | 206 Dispatch(&event); |
207 } | 207 } |
208 | 208 |
209 void GestureInterpreterLibevdevCros::OnGestureScroll( | 209 void GestureInterpreterLibevdevCros::OnGestureScroll( |
210 const Gesture* gesture, | 210 const Gesture* gesture, |
211 const GestureScroll* scroll) { | 211 const GestureScroll* scroll) { |
| 212 if (!cursor_) |
| 213 return; // No cursor! |
212 DVLOG(3) << base::StringPrintf("Gesture Scroll: (%f, %f) [%f, %f]", | 214 DVLOG(3) << base::StringPrintf("Gesture Scroll: (%f, %f) [%f, %f]", |
213 scroll->dx, | 215 scroll->dx, |
214 scroll->dy, | 216 scroll->dy, |
215 scroll->ordinal_dx, | 217 scroll->ordinal_dx, |
216 scroll->ordinal_dy); | 218 scroll->ordinal_dy); |
217 // TODO(spang): Support SetNaturalScroll | 219 // TODO(spang): Support SetNaturalScroll |
218 // TODO(spang): Use scroll->start_time | 220 // TODO(spang): Use scroll->start_time |
219 ScrollEvent event(ET_SCROLL, | 221 ScrollEvent event(ET_SCROLL, |
220 cursor_->location(), | 222 cursor_->location(), |
221 StimeToTimedelta(gesture->end_time), | 223 StimeToTimedelta(gesture->end_time), |
(...skipping 26 matching lines...) Expand all Loading... |
248 if (buttons->up & GESTURES_BUTTON_RIGHT) | 250 if (buttons->up & GESTURES_BUTTON_RIGHT) |
249 DispatchMouseButton(EVDEV_MODIFIER_RIGHT_MOUSE_BUTTON, false); | 251 DispatchMouseButton(EVDEV_MODIFIER_RIGHT_MOUSE_BUTTON, false); |
250 } | 252 } |
251 | 253 |
252 void GestureInterpreterLibevdevCros::Dispatch(Event* event) { | 254 void GestureInterpreterLibevdevCros::Dispatch(Event* event) { |
253 dispatch_callback_.Run(event); | 255 dispatch_callback_.Run(event); |
254 } | 256 } |
255 | 257 |
256 void GestureInterpreterLibevdevCros::DispatchMouseButton(unsigned int modifier, | 258 void GestureInterpreterLibevdevCros::DispatchMouseButton(unsigned int modifier, |
257 bool down) { | 259 bool down) { |
| 260 if (!cursor_) |
| 261 return; // No cursor! |
258 const gfx::PointF& loc = cursor_->location(); | 262 const gfx::PointF& loc = cursor_->location(); |
259 int flag = modifiers_->GetEventFlagFromModifier(modifier); | 263 int flag = modifiers_->GetEventFlagFromModifier(modifier); |
260 EventType type = (down ? ET_MOUSE_PRESSED : ET_MOUSE_RELEASED); | 264 EventType type = (down ? ET_MOUSE_PRESSED : ET_MOUSE_RELEASED); |
261 modifiers_->UpdateModifier(modifier, down); | 265 modifiers_->UpdateModifier(modifier, down); |
262 MouseEvent event(type, loc, loc, modifiers_->GetModifierFlags() | flag, flag); | 266 MouseEvent event(type, loc, loc, modifiers_->GetModifierFlags() | flag, flag); |
263 Dispatch(&event); | 267 Dispatch(&event); |
264 } | 268 } |
265 | 269 |
266 } // namespace ui | 270 } // namespace ui |
OLD | NEW |