OLD | NEW |
(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/gestures/gesture_provider_aura.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 #include "ui/events/event.h" |
| 9 #include "ui/events/gesture_detection/gesture_config_helper.h" |
| 10 #include "ui/events/gesture_detection/gesture_event_data.h" |
| 11 |
| 12 namespace ui { |
| 13 |
| 14 GestureProviderAura::GestureProviderAura(GestureProviderAuraClient* client) |
| 15 : client_(client), |
| 16 filtered_gesture_provider_(ui::DefaultGestureProviderConfig(), this) { |
| 17 filtered_gesture_provider_.SetDoubleTapSupportForPlatformEnabled(false); |
| 18 } |
| 19 |
| 20 GestureProviderAura::~GestureProviderAura() {} |
| 21 |
| 22 bool GestureProviderAura::OnTouchEvent(const TouchEvent& event) { |
| 23 last_touch_event_flags_ = event.flags(); |
| 24 bool pointer_id_is_active = false; |
| 25 for (size_t i = 0; i < pointer_state_.GetPointerCount(); ++i) { |
| 26 if (event.touch_id() != pointer_state_.GetPointerId(i)) |
| 27 continue; |
| 28 pointer_id_is_active = true; |
| 29 break; |
| 30 } |
| 31 |
| 32 if (event.type() == ET_TOUCH_PRESSED && pointer_id_is_active) { |
| 33 // Ignore touch press events if we already believe the pointer is down. |
| 34 return false; |
| 35 } else if (event.type() != ET_TOUCH_PRESSED && !pointer_id_is_active) { |
| 36 // We could have an active touch stream transfered to us, resulting in touch |
| 37 // move or touch up events without associated touch down events. Ignore |
| 38 // them. |
| 39 return false; |
| 40 } |
| 41 |
| 42 pointer_state_.OnTouch(event); |
| 43 bool result = filtered_gesture_provider_.OnTouchEvent(pointer_state_); |
| 44 pointer_state_.CleanupRemovedTouchPoints(event); |
| 45 return result; |
| 46 } |
| 47 |
| 48 void GestureProviderAura::OnTouchEventAck(bool event_consumed) { |
| 49 filtered_gesture_provider_.OnTouchEventAck(event_consumed); |
| 50 } |
| 51 |
| 52 void GestureProviderAura::OnGestureEvent( |
| 53 const GestureEventData& gesture) { |
| 54 ui::GestureEvent event(gesture.type, |
| 55 gesture.x, |
| 56 gesture.y, |
| 57 last_touch_event_flags_, |
| 58 gesture.time - base::TimeTicks(), |
| 59 gesture.details, |
| 60 // ui::GestureEvent stores a bitfield indicating the |
| 61 // ids of active touch points. This is currently only |
| 62 // used when one finger is down, and will eventually |
| 63 // be cleaned up. See crbug.com/366707. |
| 64 1 << gesture.motion_event_id); |
| 65 client_->OnGestureEvent(&event); |
| 66 } |
| 67 |
| 68 } // namespace content |
OLD | NEW |