summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-29 23:43:26 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-29 23:43:26 +0000
commitcd446c6cb4acd4afba06e18c0b84f6f8e1ba2ca3 (patch)
treed0d41dd262a3d4a069f37651a4e640ba39f1390f
parentbaff1d0461a2d10eb9f99b64d3fd724e7b363a44 (diff)
downloadchromium_src-cd446c6cb4acd4afba06e18c0b84f6f8e1ba2ca3.zip
chromium_src-cd446c6cb4acd4afba06e18c0b84f6f8e1ba2ca3.tar.gz
chromium_src-cd446c6cb4acd4afba06e18c0b84f6f8e1ba2ca3.tar.bz2
Fix a few issues with touch-events and views-desktop.
* Activate a widget when it is touched. * Drop a synthetic mouse event on the toplevel widget instead of the immediate parent widget. * Send touch-events to the captured view if there is one. BUG=none TEST=manually Review URL: http://codereview.chromium.org/7540002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@94796 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--views/desktop/desktop_window_root_view.cc16
-rw-r--r--views/desktop/desktop_window_root_view.h5
-rw-r--r--views/events/event.h1
-rw-r--r--views/touchui/gesture_manager.cc5
-rw-r--r--views/widget/native_widget_view.cc3
-rw-r--r--views/widget/root_view.cc4
6 files changed, 30 insertions, 4 deletions
diff --git a/views/desktop/desktop_window_root_view.cc b/views/desktop/desktop_window_root_view.cc
index f8311ae..4f1d5ca 100644
--- a/views/desktop/desktop_window_root_view.cc
+++ b/views/desktop/desktop_window_root_view.cc
@@ -28,7 +28,20 @@ DesktopWindowRootView::~DesktopWindowRootView() {
// DesktopWindowRootView, internal::RootView overrides:
bool DesktopWindowRootView::OnMousePressed(const MouseEvent& event) {
- View* target = GetEventHandlerForPoint(event.location());
+ ActivateWidgetAtLocation(event.location());
+ return RootView::OnMousePressed(event);
+}
+
+ui::TouchStatus DesktopWindowRootView::OnTouchEvent(const TouchEvent& event) {
+ ActivateWidgetAtLocation(event.location());
+ return RootView::OnTouchEvent(event);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// DesktopWindowRootView, private
+
+void DesktopWindowRootView::ActivateWidgetAtLocation(const gfx::Point& point) {
+ View* target = GetEventHandlerForPoint(point);
if (target->GetClassName() == internal::NativeWidgetView::kViewClassName) {
internal::NativeWidgetView* native_widget_view =
static_cast<internal::NativeWidgetView*>(target);
@@ -37,7 +50,6 @@ bool DesktopWindowRootView::OnMousePressed(const MouseEvent& event) {
} else {
desktop_window_view_->ActivateWidget(NULL);
}
- return RootView::OnMousePressed(event);
}
} // namespace desktop
diff --git a/views/desktop/desktop_window_root_view.h b/views/desktop/desktop_window_root_view.h
index c46010d..67c74e3 100644
--- a/views/desktop/desktop_window_root_view.h
+++ b/views/desktop/desktop_window_root_view.h
@@ -20,6 +20,11 @@ class DesktopWindowRootView : public internal::RootView {
private:
// Overridden from RootView:
virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE;
+ virtual ui::TouchStatus OnTouchEvent(const TouchEvent& event) OVERRIDE;
+
+ // Activates the widget at the specified location and deactivates the
+ // currently selected widget.
+ void ActivateWidgetAtLocation(const gfx::Point& point);
DesktopWindowView* desktop_window_view_;
diff --git a/views/events/event.h b/views/events/event.h
index 07a86b0..c0fabbb 100644
--- a/views/events/event.h
+++ b/views/events/event.h
@@ -273,6 +273,7 @@ class VIEWS_API TouchEvent : public LocatedEvent {
float force() const { return force_; }
private:
+ friend class internal::NativeWidgetView;
friend class internal::RootView;
TouchEvent(const TouchEvent& model, View* root);
diff --git a/views/touchui/gesture_manager.cc b/views/touchui/gesture_manager.cc
index 3f70f30..830ce04 100644
--- a/views/touchui/gesture_manager.cc
+++ b/views/touchui/gesture_manager.cc
@@ -32,9 +32,12 @@ bool GestureManager::ProcessTouchEventForGesture(const TouchEvent& event,
// event distribution code works by turning all touch inputs into
// mouse approximations.
+ // Conver the touch-event into a mouse-event. This mouse-event gets its
+ // location information from the native-event, so it needs to drop on the
+ // toplevel widget instead of just source->GetWidget.
Event::FromNativeEvent2 from_native;
MouseEvent mouseev(event, from_native);
- source->GetWidget()->OnMouseEvent(mouseev);
+ source->GetWidget()->GetTopLevelWidget()->OnMouseEvent(mouseev);
return true;
}
diff --git a/views/widget/native_widget_view.cc b/views/widget/native_widget_view.cc
index 911170d..85cb30e 100644
--- a/views/widget/native_widget_view.cc
+++ b/views/widget/native_widget_view.cc
@@ -104,7 +104,8 @@ void NativeWidgetView::OnMouseExited(const MouseEvent& event) {
}
ui::TouchStatus NativeWidgetView::OnTouchEvent(const TouchEvent& event) {
- return delegate()->OnTouchEvent(event);
+ TouchEvent e(event, this);
+ return delegate()->OnTouchEvent(e);
}
bool NativeWidgetView::OnKeyPressed(const KeyEvent& event) {
diff --git a/views/widget/root_view.cc b/views/widget/root_view.cc
index 64142f4..85cb537 100644
--- a/views/widget/root_view.cc
+++ b/views/widget/root_view.cc
@@ -367,6 +367,10 @@ bool RootView::OnMouseWheel(const MouseWheelEvent& event) {
ui::TouchStatus RootView::OnTouchEvent(const TouchEvent& event) {
TouchEvent e(event, this);
+ if (capture_view_) {
+ TouchEvent ce(e, this, capture_view_);
+ return capture_view_->OnTouchEvent(ce);
+ }
// If touch_pressed_handler_ is non null, we are currently processing
// a touch down on the screen situation. In that case we send the