summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ash/wm/toplevel_window_event_filter.cc23
-rw-r--r--chrome/browser/ui/views/tabs/tab_drag_controller.cc27
-rw-r--r--chrome/browser/ui/views/tabs/tab_drag_controller.h4
-rw-r--r--ui/base/gestures/gesture_recognizer.h6
-rw-r--r--ui/base/gestures/gesture_recognizer_impl.cc10
-rw-r--r--ui/base/gestures/gesture_recognizer_impl.h2
-rw-r--r--ui/base/gestures/gesture_sequence.cc1
-rw-r--r--ui/base/gestures/gesture_sequence.h5
8 files changed, 69 insertions, 9 deletions
diff --git a/ash/wm/toplevel_window_event_filter.cc b/ash/wm/toplevel_window_event_filter.cc
index 7d33647..b53f786 100644
--- a/ash/wm/toplevel_window_event_filter.cc
+++ b/ash/wm/toplevel_window_event_filter.cc
@@ -19,6 +19,7 @@
#include "ui/aura/window.h"
#include "ui/aura/window_delegate.h"
#include "ui/base/cursor/cursor.h"
+#include "ui/base/gestures/gesture_recognizer.h"
#include "ui/base/hit_test.h"
#include "ui/base/ui_base_types.h"
#include "ui/compositor/layer.h"
@@ -152,6 +153,10 @@ ui::GestureStatus ToplevelWindowEventFilter::PreHandleGestureEvent(
if (!in_gesture_resize_)
return ui::GESTURE_STATUS_UNKNOWN;
CompleteDrag(DRAG_COMPLETE, event->flags());
+ if (in_move_loop_) {
+ MessageLoop::current()->Quit();
+ in_move_loop_ = false;
+ }
in_gesture_resize_ = false;
break;
@@ -196,20 +201,28 @@ ui::GestureStatus ToplevelWindowEventFilter::PreHandleGestureEvent(
void ToplevelWindowEventFilter::RunMoveLoop(aura::Window* source) {
DCHECK(!in_move_loop_); // Can only handle one nested loop at a time.
in_move_loop_ = true;
- gfx::Point parent_mouse_location(gfx::Screen::GetCursorScreenPoint());
aura::RootWindow* root_window = source->GetRootWindow();
DCHECK(root_window);
- aura::Window::ConvertPointToWindow(
- root_window, source->parent(), &parent_mouse_location);
+ gfx::Point drag_location;
+ if (aura::Env::GetInstance()->is_touch_down()) {
+ in_gesture_resize_ = true;
+ bool has_point = root_window->gesture_recognizer()->
+ GetLastTouchPointForTarget(source, &drag_location);
+ DCHECK(has_point);
+ } else {
+ drag_location = gfx::Screen::GetCursorScreenPoint();
+ aura::Window::ConvertPointToWindow(
+ root_window, source->parent(), &drag_location);
+ }
window_resizer_.reset(
- CreateWindowResizer(source, parent_mouse_location, HTCAPTION));
+ CreateWindowResizer(source, drag_location, HTCAPTION));
source->GetRootWindow()->SetCursor(ui::kCursorPointer);
#if !defined(OS_MACOSX)
MessageLoopForUI* loop = MessageLoopForUI::current();
MessageLoop::ScopedNestableTaskAllower allow_nested(loop);
loop->RunWithDispatcher(aura::Env::GetInstance()->GetDispatcher());
#endif // !defined(OS_MACOSX)
- in_move_loop_ = false;
+ in_gesture_resize_ = in_move_loop_ = false;
}
void ToplevelWindowEventFilter::EndMoveLoop() {
diff --git a/chrome/browser/ui/views/tabs/tab_drag_controller.cc b/chrome/browser/ui/views/tabs/tab_drag_controller.cc
index 5b2763e..6d1f35d 100644
--- a/chrome/browser/ui/views/tabs/tab_drag_controller.cc
+++ b/chrome/browser/ui/views/tabs/tab_drag_controller.cc
@@ -46,6 +46,9 @@
#if defined(USE_ASH)
#include "ash/shell.h"
#include "ash/wm/property_util.h"
+#include "ui/aura/env.h"
+#include "ui/aura/root_window.h"
+#include "ui/base/gestures/gesture_recognizer.h"
#endif
using content::OpenURLParams;
@@ -593,8 +596,7 @@ void TabDragController::DidProcessEvent(const base::NativeEvent& event) {
}
void TabDragController::OnWidgetMoved(views::Widget* widget) {
- // TODO: this needs to query event.
- Drag(gfx::Screen::GetCursorScreenPoint());
+ Drag(GetCursorScreenPoint());
}
void TabDragController::TabStripEmpty() {
@@ -1273,9 +1275,8 @@ void TabDragController::RunMoveLoop() {
if (end_run_loop_behavior_ == END_RUN_LOOP_CONTINUE_DRAGGING) {
end_run_loop_behavior_ = END_RUN_LOOP_STOP_DRAGGING;
if (tab_strip_to_attach_to_after_exit_) {
+ gfx::Point screen_point(GetCursorScreenPoint());
Detach();
- // TODO: this needs to query the event.
- gfx::Point screen_point(gfx::Screen::GetCursorScreenPoint());
Attach(tab_strip_to_attach_to_after_exit_, screen_point);
// Move the tabs into position.
MoveAttached(screen_point);
@@ -1883,3 +1884,21 @@ Browser* TabDragController::CreateBrowserForDrag(
browser->window()->SetBounds(new_bounds);
return browser;
}
+
+gfx::Point TabDragController::GetCursorScreenPoint() {
+#if defined(USE_ASH)
+ views::Widget* widget = GetAttachedBrowserWidget();
+ DCHECK(widget);
+ if (aura::Env::GetInstance()->is_touch_down()) {
+ aura::Window* widget_window = widget->GetNativeWindow();
+ DCHECK(widget_window->GetRootWindow());
+ gfx::Point touch_point;
+ bool got_touch_point = widget_window->GetRootWindow()->
+ gesture_recognizer()->GetLastTouchPointForTarget(widget_window,
+ &touch_point);
+ DCHECK(got_touch_point);
+ return touch_point;
+ }
+#endif
+ return gfx::Screen::GetCursorScreenPoint();
+}
diff --git a/chrome/browser/ui/views/tabs/tab_drag_controller.h b/chrome/browser/ui/views/tabs/tab_drag_controller.h
index f3e265b..109d81c 100644
--- a/chrome/browser/ui/views/tabs/tab_drag_controller.h
+++ b/chrome/browser/ui/views/tabs/tab_drag_controller.h
@@ -421,6 +421,10 @@ class TabDragController : public content::WebContentsDelegate,
// Returns the TabStripModel for the specified tabstrip.
TabStripModel* GetModel(TabStrip* tabstrip) const;
+ // Returns the location of the cursor. This is either the location of the
+ // mouse or the location of the current touch point.
+ gfx::Point GetCursorScreenPoint();
+
// Returns true if moving the mouse only changes the visible tabs.
bool move_only() const {
return (move_behavior_ == MOVE_VISIBILE_TABS) != 0;
diff --git a/ui/base/gestures/gesture_recognizer.h b/ui/base/gestures/gesture_recognizer.h
index 6a4392b..a820824 100644
--- a/ui/base/gestures/gesture_recognizer.h
+++ b/ui/base/gestures/gesture_recognizer.h
@@ -65,6 +65,12 @@ class UI_EXPORT GestureRecognizer {
// NULL, all targets are cancelled.
virtual void TransferEventsTo(GestureConsumer* current_consumer,
GestureConsumer* new_consumer) = 0;
+
+ // If a gesture is underway for |consumer| |point| is set to the last touch
+ // point and true is returned. If no touch events have been processed for
+ // |consumer| false is returned and |point| is untouched.
+ virtual bool GetLastTouchPointForTarget(GestureConsumer* consumer,
+ gfx::Point* point) = 0;
};
} // namespace ui
diff --git a/ui/base/gestures/gesture_recognizer_impl.cc b/ui/base/gestures/gesture_recognizer_impl.cc
index 350488d..20b88d4 100644
--- a/ui/base/gestures/gesture_recognizer_impl.cc
+++ b/ui/base/gestures/gesture_recognizer_impl.cc
@@ -245,6 +245,16 @@ void GestureRecognizerImpl::TransferEventsTo(GestureConsumer* current_consumer,
}
}
+bool GestureRecognizerImpl::GetLastTouchPointForTarget(
+ GestureConsumer* consumer,
+ gfx::Point* point) {
+ if (consumer_sequence_.count(consumer) == 0)
+ return false;
+
+ *point = consumer_sequence_[consumer]->last_touch_location();
+ return true;
+}
+
////////////////////////////////////////////////////////////////////////////////
// GestureRecognizerImpl, protected:
diff --git a/ui/base/gestures/gesture_recognizer_impl.h b/ui/base/gestures/gesture_recognizer_impl.h
index 18030b7..fbd82d4 100644
--- a/ui/base/gestures/gesture_recognizer_impl.h
+++ b/ui/base/gestures/gesture_recognizer_impl.h
@@ -39,6 +39,8 @@ class UI_EXPORT GestureRecognizerImpl : public GestureRecognizer {
const gfx::Point& location) OVERRIDE;
virtual void TransferEventsTo(GestureConsumer* current_consumer,
GestureConsumer* new_consumer) OVERRIDE;
+ virtual bool GetLastTouchPointForTarget(GestureConsumer* consumer,
+ gfx::Point* point) OVERRIDE;
protected:
virtual GestureSequence* CreateSequence(GestureEventHelper* helper);
diff --git a/ui/base/gestures/gesture_sequence.cc b/ui/base/gestures/gesture_sequence.cc
index 586d792..3dd82d7 100644
--- a/ui/base/gestures/gesture_sequence.cc
+++ b/ui/base/gestures/gesture_sequence.cc
@@ -219,6 +219,7 @@ GestureSequence::~GestureSequence() {
GestureSequence::Gestures* GestureSequence::ProcessTouchEventForGesture(
const TouchEvent& event,
ui::TouchStatus status) {
+ last_touch_location_ = event.GetLocation();
if (status != ui::TOUCH_STATUS_UNKNOWN)
return NULL; // The event was consumed by a touch sequence.
diff --git a/ui/base/gestures/gesture_sequence.h b/ui/base/gestures/gesture_sequence.h
index 07d8cc4..78e9bb1 100644
--- a/ui/base/gestures/gesture_sequence.h
+++ b/ui/base/gestures/gesture_sequence.h
@@ -51,6 +51,8 @@ class UI_EXPORT GestureSequence {
const GesturePoint* points() const { return points_; }
int point_count() const { return point_count_; }
+ const gfx::Point& last_touch_location() const { return last_touch_location_; }
+
protected:
virtual base::OneShotTimer<GestureSequence>* CreateTimer();
base::OneShotTimer<GestureSequence>* long_press_timer() {
@@ -194,6 +196,9 @@ class UI_EXPORT GestureSequence {
GesturePoint points_[kMaxGesturePoints];
int point_count_;
+ // Location of the last touch event.
+ gfx::Point last_touch_location_;
+
GestureEventHelper* helper_;
DISALLOW_COPY_AND_ASSIGN(GestureSequence);