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

Unified Diff: ui/events/gestures/gesture_event_queue.h

Issue 101933004: Eager Gesture Recognizer (WIP) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Starting work on Android. Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/events/events.gyp ('k') | ui/events/gestures/gesture_event_queue.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/events/gestures/gesture_event_queue.h
diff --git a/ui/events/gestures/gesture_event_queue.h b/ui/events/gestures/gesture_event_queue.h
new file mode 100644
index 0000000000000000000000000000000000000000..c43c97a46b4820b6887b6365c59a7a4490658f13
--- /dev/null
+++ b/ui/events/gestures/gesture_event_queue.h
@@ -0,0 +1,104 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_EVENTS_GESTURES_GESTURE_EVENT_QUEUE_H_
+#define UI_EVENTS_GESTURES_GESTURE_EVENT_QUEUE_H_
+
+#include <list>
+#include <set>
+
+#include "base/basictypes.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/memory/scoped_vector.h"
+#include "ui/events/event.h"
+#include "ui/events/gestures/touch_point_state.h"
+
+namespace ui {
+class TouchEvent;
+
+class GestureEventQueueDelegate {
+ public:
+ virtual ~GestureEventQueueDelegate() {};
+ virtual void DispatchGestureEvent(GestureEvent* event) = 0;
+};
+
+class GestureEventQueueTimerInterface {
+ public:
+ virtual void TimerFired() = 0;
+ virtual void TimerCancelled() = 0;
+};
+
+// A GestureEventQueue consumes a stream of gestures, and a stream of touch
+// acks. It sends the |GestureEventQueueDelegate| a filtered stream of gestures,
+// with some gestures removed due to touches having been consumed.
+class EVENTS_EXPORT GestureEventQueue : public GestureEventQueueTimerInterface {
+ public:
+ GestureEventQueue(GestureEventQueueDelegate* geqd);
+ virtual ~GestureEventQueue();
+
+ void OnTouchEvent(const TouchEvent& event);
+
+ void OnTouchEventAck(const TouchEvent& event,
+ EventResult result);
+
+ // Takes ownership of event.
+ void QueueGestureEvent(GestureEvent* event,
+ TouchPointState::RequiresAck requires_ack);
+
+ virtual void TimerFired() OVERRIDE;
+ virtual void TimerCancelled() OVERRIDE;
+
+ protected:
+ void QueueGestureEvent(
+ GestureEvent* event,
+ std::vector<TouchPointState*>& touch_point_states);
+
+ class GestureWithState {
+ public:
+ // Clears touch_point_states, and takes ownership of its members.
+ GestureWithState(GestureEvent* event,
+ std::vector<TouchPointState*>& touch_point_states);
+ ~GestureWithState();
+ GestureEvent* event() { return event_.get(); }
+ std::vector<TouchPointState*>& touch_point_states() {
+ return touch_point_states_.get();
+ }
+
+ private:
+ scoped_ptr<GestureEvent> event_;
+ ScopedVector<TouchPointState> touch_point_states_;
+ DISALLOW_COPY_AND_ASSIGN(GestureWithState);
+ };
+
+ typedef ScopedVector<GestureWithState> Sequence;
+ // sequences_ owns all of the TouchPointState objects keeping tracking of
+ // which acks a given event depends on.
+ std::list<Sequence*> sequences_;
+
+ private:
+ void SendGestureEvent(GestureEvent* event);
+
+ // Returns true if we've seen unconsumed acks in the current sequence for
+ // every touch contributing to |gesture_touches|.
+ bool CanSend(const std::vector<TouchPointState*>& gesture_touches) const;
+
+ // Returns true if we've seen consumed acks in the current sequence for any
+ // touch contributing to |gesture_touches|.
+ bool CanDelete(const std::vector<TouchPointState*>& gesture_touches) const;
+
+ void SendAckedEvents();
+ void DeleteConsumedEvents();
+ void RemoveEmptyFirstSequence();
+
+ ScopedVector<TouchPointState> touch_point_states_;
+ ScopedVector<TouchPointState> acked_touch_point_states_;
+ ScopedVector<TouchPointState> consumed_touch_point_states_;
+ GestureEventQueueDelegate* gesture_event_queue_delegate_;
+
+ DISALLOW_COPY_AND_ASSIGN(GestureEventQueue);
+};
+
+} // namespace ui
+
+#endif // UI_EVENTS_GESTURES_GESTURE_EVENT_QUEUE_H_
« no previous file with comments | « ui/events/events.gyp ('k') | ui/events/gestures/gesture_event_queue.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698