summaryrefslogtreecommitdiffstats
path: root/ui/aura
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-26 20:38:42 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-26 20:38:42 +0000
commit4aeda5795fa3d1a3b3e5f7ed71c2acbc41d94a6d (patch)
tree45221c6258e7a1f8fe407645373f9a18b0e811f7 /ui/aura
parentd33f0067c151a55b38ebe687727ed2d3a34affee (diff)
downloadchromium_src-4aeda5795fa3d1a3b3e5f7ed71c2acbc41d94a6d.zip
chromium_src-4aeda5795fa3d1a3b3e5f7ed71c2acbc41d94a6d.tar.gz
chromium_src-4aeda5795fa3d1a3b3e5f7ed71c2acbc41d94a6d.tar.bz2
aura: Add event queues in the GestureRecognizer.
Event-queues allow the GestureRecognizer to maintain multiple states for different gestures. Especially, this makes it possible to correctly process queued up (asynchronous) touch-events at the same time it processes synchronous touch-events. Throttling/filtering touch-events that go to the renderer is now removed. This may be added back at a later time. BUG=110230 TEST=none (will be added in a future CL: http://codereview.chromium.org/9129012/) Review URL: https://chromiumcodereview.appspot.com/9150046 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@119278 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/aura')
-rw-r--r--ui/aura/gestures/gesture_recognizer.cc18
-rw-r--r--ui/aura/gestures/gesture_recognizer.h13
-rw-r--r--ui/aura/root_window.cc40
-rw-r--r--ui/aura/root_window.h23
4 files changed, 79 insertions, 15 deletions
diff --git a/ui/aura/gestures/gesture_recognizer.cc b/ui/aura/gestures/gesture_recognizer.cc
index 1c9294d..5de5ebc4 100644
--- a/ui/aura/gestures/gesture_recognizer.cc
+++ b/ui/aura/gestures/gesture_recognizer.cc
@@ -95,6 +95,24 @@ GestureRecognizer::Gestures* GestureRecognizer::ProcessTouchEventForGesture(
return gestures.release();
}
+void GestureRecognizer::QueueTouchEventForGesture(Window* window,
+ const TouchEvent& event) {
+ // TODO(sad):
+ NOTIMPLEMENTED();
+}
+
+GestureRecognizer::Gestures* GestureRecognizer::AdvanceTouchQueue(
+ Window* window, bool processed) {
+ // TODO(sad):
+ NOTIMPLEMENTED();
+ return NULL;
+}
+
+void GestureRecognizer::FlushTouchQueue(Window* window) {
+ // TODO(sad):
+ NOTIMPLEMENTED();
+}
+
void GestureRecognizer::Reset() {
first_touch_time_ = 0.0;
state_ = GestureRecognizer::GS_NO_GESTURE;
diff --git a/ui/aura/gestures/gesture_recognizer.h b/ui/aura/gestures/gesture_recognizer.h
index 68932773..28c472c 100644
--- a/ui/aura/gestures/gesture_recognizer.h
+++ b/ui/aura/gestures/gesture_recognizer.h
@@ -52,6 +52,19 @@ class AURA_EXPORT GestureRecognizer {
virtual Gestures* ProcessTouchEventForGesture(const TouchEvent& event,
ui::TouchStatus status);
+ // Touch-events can be queued to be played back at a later time. The queues
+ // are identified by the target window.
+ virtual void QueueTouchEventForGesture(Window* window,
+ const TouchEvent& event);
+
+ // Process the touch-event in the queue for the window. Returns a list of
+ // zero or more GestureEvents identified after processing the queueud
+ // TouchEvent. Caller is responsible for freeing up Gestures.
+ virtual Gestures* AdvanceTouchQueue(Window* window, bool processed);
+
+ // Reset the touch events in the queue for the window.
+ virtual void FlushTouchQueue(Window* window);
+
// Clears the GestureRecognizer to its initial state.
virtual void Reset();
diff --git a/ui/aura/root_window.cc b/ui/aura/root_window.cc
index 573e8e93..304f738 100644
--- a/ui/aura/root_window.cc
+++ b/ui/aura/root_window.cc
@@ -227,19 +227,17 @@ bool RootWindow::DispatchTouchEvent(TouchEvent* event) {
status == ui::TOUCH_STATUS_CANCEL)
touch_event_handler_ = NULL;
handled = status != ui::TOUCH_STATUS_UNKNOWN;
+
+ if (status == ui::TOUCH_STATUS_QUEUED)
+ gesture_recognizer_->QueueTouchEventForGesture(target, *event);
}
// Get the list of GestureEvents from GestureRecognizer.
scoped_ptr<GestureRecognizer::Gestures> gestures;
gestures.reset(gesture_recognizer_->ProcessTouchEventForGesture(*event,
status));
- if (gestures.get()) {
- for (unsigned int i = 0; i < gestures->size(); i++) {
- GestureEvent* gesture = gestures->at(i).get();
- if (DispatchGestureEvent(gesture) != ui::GESTURE_STATUS_UNKNOWN)
- handled = true;
- }
- }
+ if (ProcessGestures(gestures.get()))
+ handled = true;
return handled;
}
@@ -298,6 +296,8 @@ void RootWindow::WindowDestroying(Window* window) {
touch_event_handler_ = NULL;
if (gesture_handler_ == window)
gesture_handler_ = NULL;
+
+ gesture_recognizer_->FlushTouchQueue(window);
}
#if !defined(OS_MACOSX)
@@ -364,6 +364,16 @@ void RootWindow::ReleaseCapture(Window* window) {
SetCapture(NULL);
}
+void RootWindow::AdvanceQueuedTouchEvent(Window* window, bool processed) {
+ scoped_ptr<GestureRecognizer::Gestures> gestures;
+ gestures.reset(gesture_recognizer_->AdvanceTouchQueue(window, processed));
+ ProcessGestures(gestures.get());
+}
+
+void RootWindow::SetGestureRecognizerForTesting(GestureRecognizer* gr) {
+ gesture_recognizer_.reset(gr);
+}
+
void RootWindow::SetTransform(const ui::Transform& transform) {
Window::SetTransform(transform);
@@ -379,10 +389,6 @@ void RootWindow::ToggleFullScreen() {
}
#endif
-void RootWindow::SetGestureRecognizerForTesting(GestureRecognizer* gr) {
- gesture_recognizer_.reset(gr);
-}
-
////////////////////////////////////////////////////////////////////////////////
// RootWindow, private:
@@ -549,6 +555,18 @@ ui::GestureStatus RootWindow::ProcessGestureEvent(Window* target,
return status;
}
+bool RootWindow::ProcessGestures(GestureRecognizer::Gestures* gestures) {
+ if (!gestures)
+ return false;
+ bool handled = false;
+ for (unsigned int i = 0; i < gestures->size(); i++) {
+ GestureEvent* gesture = gestures->at(i).get();
+ if (DispatchGestureEvent(gesture) != ui::GESTURE_STATUS_UNKNOWN)
+ handled = true;
+ }
+ return handled;
+}
+
void RootWindow::ScheduleDraw() {
if (!schedule_paint_factory_.HasWeakPtrs()) {
MessageLoop::current()->PostTask(
diff --git a/ui/aura/root_window.h b/ui/aura/root_window.h
index b4f7c0d..af471c7 100644
--- a/ui/aura/root_window.h
+++ b/ui/aura/root_window.h
@@ -13,6 +13,7 @@
#include "ui/aura/aura_export.h"
#include "ui/aura/cursor.h"
#include "ui/aura/focus_manager.h"
+#include "ui/aura/gestures/gesture_recognizer.h"
#include "ui/aura/window.h"
#include "ui/base/events.h"
#include "ui/gfx/compositor/compositor.h"
@@ -40,7 +41,6 @@ class StackingClient;
class ScrollEvent;
class TouchEvent;
class GestureEvent;
-class GestureRecognizer;
// RootWindow is responsible for hosting a set of windows.
class AURA_EXPORT RootWindow : public ui::CompositorDelegate,
@@ -151,6 +151,23 @@ class AURA_EXPORT RootWindow : public ui::CompositorDelegate,
// If |window| has mouse capture, the current capture window is set to NULL.
void ReleaseCapture(Window* window);
+ // Gesture Recognition -------------------------------------------------------
+
+ // When a touch event is dispatched to a Window, it can notify the RootWindow
+ // to queue the touch event for asynchronous gesture recognition. These are
+ // the entry points for the asynchronous processing of the queued touch
+ // events.
+ // Process the next touch event for gesture recognition. |processed| indicates
+ // whether the queued event was processed by the window or not.
+ void AdvanceQueuedTouchEvent(Window* window, bool processed);
+
+ GestureRecognizer* gesture_recognizer() const {
+ return gesture_recognizer_.get();
+ }
+
+ // Provided only for testing:
+ void SetGestureRecognizerForTesting(GestureRecognizer* gr);
+
// Overridden from Window:
virtual void SetTransform(const ui::Transform& transform) OVERRIDE;
@@ -159,9 +176,6 @@ class AURA_EXPORT RootWindow : public ui::CompositorDelegate,
void ToggleFullScreen();
#endif
- // Provided only for testing:
- void SetGestureRecognizerForTesting(GestureRecognizer* gr);
-
// Overridden from ui::CompositorDelegate:
virtual void ScheduleDraw() OVERRIDE;
@@ -177,6 +191,7 @@ class AURA_EXPORT RootWindow : public ui::CompositorDelegate,
bool ProcessKeyEvent(Window* target, KeyEvent* event);
ui::TouchStatus ProcessTouchEvent(Window* target, TouchEvent* event);
ui::GestureStatus ProcessGestureEvent(Window* target, GestureEvent* event);
+ bool ProcessGestures(GestureRecognizer::Gestures* gestures);
// Overridden from Window:
virtual bool CanFocus() const OVERRIDE;