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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
244 move->dy, | 244 move->dy, |
245 move->ordinal_dx, | 245 move->ordinal_dx, |
246 move->ordinal_dy); | 246 move->ordinal_dy); |
247 if (!cursor_) | 247 if (!cursor_) |
248 return; // No cursor! | 248 return; // No cursor! |
249 | 249 |
250 cursor_->MoveCursor(gfx::Vector2dF(move->dx, move->dy)); | 250 cursor_->MoveCursor(gfx::Vector2dF(move->dx, move->dy)); |
251 // TODO(spang): Use move->ordinal_dx, move->ordinal_dy | 251 // TODO(spang): Use move->ordinal_dx, move->ordinal_dy |
252 // TODO(spang): Use move->start_time, move->end_time | 252 // TODO(spang): Use move->start_time, move->end_time |
253 Dispatch(make_scoped_ptr(new MouseEvent(ET_MOUSE_MOVED, | 253 Dispatch(make_scoped_ptr(new MouseEvent(ET_MOUSE_MOVED, |
254 cursor_->location(), | 254 cursor_->GetLocation(), |
255 cursor_->location(), | 255 cursor_->GetRootLocation(), |
256 modifiers_->GetModifierFlags(), | 256 modifiers_->GetModifierFlags(), |
257 /* changed_button_flags */ 0))); | 257 /* changed_button_flags */ 0))); |
258 } | 258 } |
259 | 259 |
260 void GestureInterpreterLibevdevCros::OnGestureScroll( | 260 void GestureInterpreterLibevdevCros::OnGestureScroll( |
261 const Gesture* gesture, | 261 const Gesture* gesture, |
262 const GestureScroll* scroll) { | 262 const GestureScroll* scroll) { |
263 DVLOG(3) << base::StringPrintf("Gesture Scroll: (%f, %f) [%f, %f]", | 263 DVLOG(3) << base::StringPrintf("Gesture Scroll: (%f, %f) [%f, %f]", |
264 scroll->dx, | 264 scroll->dx, |
265 scroll->dy, | 265 scroll->dy, |
266 scroll->ordinal_dx, | 266 scroll->ordinal_dx, |
267 scroll->ordinal_dy); | 267 scroll->ordinal_dy); |
268 if (!cursor_) | 268 if (!cursor_) |
269 return; // No cursor! | 269 return; // No cursor! |
270 | 270 |
271 // TODO(spang): Support SetNaturalScroll | 271 // TODO(spang): Support SetNaturalScroll |
272 // TODO(spang): Use scroll->start_time | 272 // TODO(spang): Use scroll->start_time |
273 Dispatch(make_scoped_ptr(new ScrollEvent(ET_SCROLL, | 273 Dispatch(make_scoped_ptr(new ScrollEvent(ET_SCROLL, |
274 cursor_->location(), | 274 cursor_->GetLocation(), |
275 cursor_->GetRootLocation(), | |
275 StimeToTimedelta(gesture->end_time), | 276 StimeToTimedelta(gesture->end_time), |
276 modifiers_->GetModifierFlags(), | 277 modifiers_->GetModifierFlags(), |
277 scroll->dx, | 278 scroll->dx, |
278 scroll->dy, | 279 scroll->dy, |
279 scroll->ordinal_dx, | 280 scroll->ordinal_dx, |
280 scroll->ordinal_dy, | 281 scroll->ordinal_dy, |
281 kGestureScrollFingerCount))); | 282 kGestureScrollFingerCount))); |
282 } | 283 } |
283 | 284 |
284 void GestureInterpreterLibevdevCros::OnGestureButtonsChange( | 285 void GestureInterpreterLibevdevCros::OnGestureButtonsChange( |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
331 | 332 |
332 if (!cursor_) | 333 if (!cursor_) |
333 return; // No cursor! | 334 return; // No cursor! |
334 | 335 |
335 EventType type = | 336 EventType type = |
336 (fling->fling_state == GESTURES_FLING_START ? ET_SCROLL_FLING_START | 337 (fling->fling_state == GESTURES_FLING_START ? ET_SCROLL_FLING_START |
337 : ET_SCROLL_FLING_CANCEL); | 338 : ET_SCROLL_FLING_CANCEL); |
338 | 339 |
339 // Fling is like 2-finger scrolling but with velocity instead of displacement. | 340 // Fling is like 2-finger scrolling but with velocity instead of displacement. |
340 Dispatch(make_scoped_ptr(new ScrollEvent(type, | 341 Dispatch(make_scoped_ptr(new ScrollEvent(type, |
341 cursor_->location(), | 342 cursor_->GetLocation(), |
343 cursor_->GetRootLocation(), | |
342 StimeToTimedelta(gesture->end_time), | 344 StimeToTimedelta(gesture->end_time), |
343 modifiers_->GetModifierFlags(), | 345 modifiers_->GetModifierFlags(), |
344 fling->vx, | 346 fling->vx, |
345 fling->vy, | 347 fling->vy, |
346 fling->ordinal_vx, | 348 fling->ordinal_vx, |
347 fling->ordinal_vy, | 349 fling->ordinal_vy, |
348 kGestureScrollFingerCount))); | 350 kGestureScrollFingerCount))); |
349 } | 351 } |
350 | 352 |
351 void GestureInterpreterLibevdevCros::OnGestureSwipe(const Gesture* gesture, | 353 void GestureInterpreterLibevdevCros::OnGestureSwipe(const Gesture* gesture, |
352 const GestureSwipe* swipe) { | 354 const GestureSwipe* swipe) { |
353 DVLOG(3) << base::StringPrintf("Gesture Swipe: (%f, %f) [%f, %f]", | 355 DVLOG(3) << base::StringPrintf("Gesture Swipe: (%f, %f) [%f, %f]", |
354 swipe->dx, | 356 swipe->dx, |
355 swipe->dy, | 357 swipe->dy, |
356 swipe->ordinal_dx, | 358 swipe->ordinal_dx, |
357 swipe->ordinal_dy); | 359 swipe->ordinal_dy); |
358 | 360 |
359 if (!cursor_) | 361 if (!cursor_) |
360 return; // No cursor! | 362 return; // No cursor! |
361 | 363 |
362 // Swipe is 3-finger scrolling. | 364 // Swipe is 3-finger scrolling. |
363 Dispatch(make_scoped_ptr(new ScrollEvent(ET_SCROLL, | 365 Dispatch(make_scoped_ptr(new ScrollEvent(ET_SCROLL, |
364 cursor_->location(), | 366 cursor_->GetLocation(), |
367 cursor_->GetRootLocation(), | |
365 StimeToTimedelta(gesture->end_time), | 368 StimeToTimedelta(gesture->end_time), |
366 modifiers_->GetModifierFlags(), | 369 modifiers_->GetModifierFlags(), |
367 swipe->dx, | 370 swipe->dx, |
368 swipe->dy, | 371 swipe->dy, |
369 swipe->ordinal_dx, | 372 swipe->ordinal_dx, |
370 swipe->ordinal_dy, | 373 swipe->ordinal_dy, |
371 kGestureSwipeFingerCount))); | 374 kGestureSwipeFingerCount))); |
372 } | 375 } |
373 | 376 |
374 void GestureInterpreterLibevdevCros::OnGestureSwipeLift( | 377 void GestureInterpreterLibevdevCros::OnGestureSwipeLift( |
375 const Gesture* gesture, | 378 const Gesture* gesture, |
376 const GestureSwipeLift* swipelift) { | 379 const GestureSwipeLift* swipelift) { |
377 DVLOG(3) << base::StringPrintf("Gesture Swipe Lift"); | 380 DVLOG(3) << base::StringPrintf("Gesture Swipe Lift"); |
378 | 381 |
379 if (!cursor_) | 382 if (!cursor_) |
380 return; // No cursor! | 383 return; // No cursor! |
381 | 384 |
382 // Turn a swipe lift into a fling start. | 385 // Turn a swipe lift into a fling start. |
383 // TODO(spang): Figure out why and put it in this comment. | 386 // TODO(spang): Figure out why and put it in this comment. |
384 | 387 |
385 Dispatch(make_scoped_ptr(new ScrollEvent(ET_SCROLL_FLING_START, | 388 Dispatch(make_scoped_ptr(new ScrollEvent(ET_SCROLL_FLING_START, |
386 cursor_->location(), | 389 cursor_->GetLocation(), |
390 cursor_->GetRootLocation(), | |
387 StimeToTimedelta(gesture->end_time), | 391 StimeToTimedelta(gesture->end_time), |
388 modifiers_->GetModifierFlags(), | 392 modifiers_->GetModifierFlags(), |
389 /* x_offset */ 0, | 393 /* x_offset */ 0, |
390 /* y_offset */ 0, | 394 /* y_offset */ 0, |
391 /* x_offset_ordinal */ 0, | 395 /* x_offset_ordinal */ 0, |
392 /* y_offset_ordinal */ 0, | 396 /* y_offset_ordinal */ 0, |
393 kGestureScrollFingerCount))); | 397 kGestureScrollFingerCount))); |
394 } | 398 } |
395 | 399 |
396 void GestureInterpreterLibevdevCros::OnGesturePinch(const Gesture* gesture, | 400 void GestureInterpreterLibevdevCros::OnGesturePinch(const Gesture* gesture, |
(...skipping 16 matching lines...) Expand all Loading... | |
413 metrics->type); | 417 metrics->type); |
414 NOTIMPLEMENTED(); | 418 NOTIMPLEMENTED(); |
415 } | 419 } |
416 | 420 |
417 void GestureInterpreterLibevdevCros::Dispatch(scoped_ptr<Event> event) { | 421 void GestureInterpreterLibevdevCros::Dispatch(scoped_ptr<Event> event) { |
418 dispatch_callback_.Run(event.Pass()); | 422 dispatch_callback_.Run(event.Pass()); |
419 } | 423 } |
420 | 424 |
421 void GestureInterpreterLibevdevCros::DispatchMouseButton(unsigned int modifier, | 425 void GestureInterpreterLibevdevCros::DispatchMouseButton(unsigned int modifier, |
422 bool down) { | 426 bool down) { |
423 const gfx::PointF& loc = cursor_->location(); | 427 const gfx::PointF& loc = cursor_->GetLocation(); |
428 const gfx::PointF& root_loc = cursor_->GetRootLocation(); | |
sadrul
2014/11/24 22:27:04
Do these need to be &?
| |
424 int flag = modifiers_->GetEventFlagFromModifier(modifier); | 429 int flag = modifiers_->GetEventFlagFromModifier(modifier); |
425 EventType type = (down ? ET_MOUSE_PRESSED : ET_MOUSE_RELEASED); | 430 EventType type = (down ? ET_MOUSE_PRESSED : ET_MOUSE_RELEASED); |
426 modifiers_->UpdateModifier(modifier, down); | 431 modifiers_->UpdateModifier(modifier, down); |
427 Dispatch(make_scoped_ptr(new MouseEvent( | 432 Dispatch(make_scoped_ptr(new MouseEvent( |
428 type, loc, loc, modifiers_->GetModifierFlags() | flag, flag))); | 433 type, loc, root_loc, modifiers_->GetModifierFlags() | flag, flag))); |
429 } | 434 } |
430 | 435 |
431 void GestureInterpreterLibevdevCros::DispatchChangedKeys(Evdev* evdev, | 436 void GestureInterpreterLibevdevCros::DispatchChangedKeys(Evdev* evdev, |
432 const timeval& time) { | 437 const timeval& time) { |
433 unsigned long key_state_diff[EVDEV_BITS_TO_LONGS(KEY_CNT)]; | 438 unsigned long key_state_diff[EVDEV_BITS_TO_LONGS(KEY_CNT)]; |
434 | 439 |
435 // Find changed keys. | 440 // Find changed keys. |
436 for (unsigned long i = 0; i < arraysize(key_state_diff); ++i) | 441 for (unsigned long i = 0; i < arraysize(key_state_diff); ++i) |
437 key_state_diff[i] = evdev->key_state_bitmask[i] ^ prev_key_state_[i]; | 442 key_state_diff[i] = evdev->key_state_bitmask[i] ^ prev_key_state_[i]; |
438 | 443 |
(...skipping 14 matching lines...) Expand all Loading... | |
453 keyboard_->OnKeyChange(key, value); | 458 keyboard_->OnKeyChange(key, value); |
454 } | 459 } |
455 } | 460 } |
456 | 461 |
457 // Update internal key state. | 462 // Update internal key state. |
458 for (unsigned long i = 0; i < EVDEV_BITS_TO_LONGS(KEY_CNT); ++i) | 463 for (unsigned long i = 0; i < EVDEV_BITS_TO_LONGS(KEY_CNT); ++i) |
459 prev_key_state_[i] = evdev->key_state_bitmask[i]; | 464 prev_key_state_[i] = evdev->key_state_bitmask[i]; |
460 } | 465 } |
461 | 466 |
462 } // namespace ui | 467 } // namespace ui |
OLD | NEW |