summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
Diffstat (limited to 'ui')
-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
-rw-r--r--ui/base/events.h4
5 files changed, 82 insertions, 16 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;
diff --git a/ui/base/events.h b/ui/base/events.h
index d9cac3d..2adf436 100644
--- a/ui/base/events.h
+++ b/ui/base/events.h
@@ -81,9 +81,11 @@ enum TouchStatus {
TOUCH_STATUS_END, // The touch event ended the touch sequence.
TOUCH_STATUS_CANCEL, // The touch event was cancelled, but didn't
// terminate the touch sequence.
- TOUCH_STATUS_SYNTH_MOUSE // The touch event was not processed, but a
+ TOUCH_STATUS_SYNTH_MOUSE, // The touch event was not processed, but a
// synthetic mouse event generated from the
// unused touch event was handled.
+ TOUCH_STATUS_QUEUED, // The touch event has not been processed yet, but
+ // may be processed asynchronously later.
};
// Updates the list of devices for cached properties.