Commit cd446c6c authored by sadrul@chromium.org's avatar sadrul@chromium.org

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
parent baff1d04
...@@ -28,7 +28,20 @@ DesktopWindowRootView::~DesktopWindowRootView() { ...@@ -28,7 +28,20 @@ DesktopWindowRootView::~DesktopWindowRootView() {
// DesktopWindowRootView, internal::RootView overrides: // DesktopWindowRootView, internal::RootView overrides:
bool DesktopWindowRootView::OnMousePressed(const MouseEvent& event) { 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) { if (target->GetClassName() == internal::NativeWidgetView::kViewClassName) {
internal::NativeWidgetView* native_widget_view = internal::NativeWidgetView* native_widget_view =
static_cast<internal::NativeWidgetView*>(target); static_cast<internal::NativeWidgetView*>(target);
...@@ -37,7 +50,6 @@ bool DesktopWindowRootView::OnMousePressed(const MouseEvent& event) { ...@@ -37,7 +50,6 @@ bool DesktopWindowRootView::OnMousePressed(const MouseEvent& event) {
} else { } else {
desktop_window_view_->ActivateWidget(NULL); desktop_window_view_->ActivateWidget(NULL);
} }
return RootView::OnMousePressed(event);
} }
} // namespace desktop } // namespace desktop
......
...@@ -20,6 +20,11 @@ class DesktopWindowRootView : public internal::RootView { ...@@ -20,6 +20,11 @@ class DesktopWindowRootView : public internal::RootView {
private: private:
// Overridden from RootView: // Overridden from RootView:
virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE; 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_; DesktopWindowView* desktop_window_view_;
......
...@@ -273,6 +273,7 @@ class VIEWS_API TouchEvent : public LocatedEvent { ...@@ -273,6 +273,7 @@ class VIEWS_API TouchEvent : public LocatedEvent {
float force() const { return force_; } float force() const { return force_; }
private: private:
friend class internal::NativeWidgetView;
friend class internal::RootView; friend class internal::RootView;
TouchEvent(const TouchEvent& model, View* root); TouchEvent(const TouchEvent& model, View* root);
......
...@@ -32,9 +32,12 @@ bool GestureManager::ProcessTouchEventForGesture(const TouchEvent& event, ...@@ -32,9 +32,12 @@ bool GestureManager::ProcessTouchEventForGesture(const TouchEvent& event,
// event distribution code works by turning all touch inputs into // event distribution code works by turning all touch inputs into
// mouse approximations. // 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; Event::FromNativeEvent2 from_native;
MouseEvent mouseev(event, from_native); MouseEvent mouseev(event, from_native);
source->GetWidget()->OnMouseEvent(mouseev); source->GetWidget()->GetTopLevelWidget()->OnMouseEvent(mouseev);
return true; return true;
} }
......
...@@ -104,7 +104,8 @@ void NativeWidgetView::OnMouseExited(const MouseEvent& event) { ...@@ -104,7 +104,8 @@ void NativeWidgetView::OnMouseExited(const MouseEvent& event) {
} }
ui::TouchStatus NativeWidgetView::OnTouchEvent(const TouchEvent& 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) { bool NativeWidgetView::OnKeyPressed(const KeyEvent& event) {
......
...@@ -367,6 +367,10 @@ bool RootView::OnMouseWheel(const MouseWheelEvent& event) { ...@@ -367,6 +367,10 @@ bool RootView::OnMouseWheel(const MouseWheelEvent& event) {
ui::TouchStatus RootView::OnTouchEvent(const TouchEvent& event) { ui::TouchStatus RootView::OnTouchEvent(const TouchEvent& event) {
TouchEvent e(event, this); 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 // If touch_pressed_handler_ is non null, we are currently processing
// a touch down on the screen situation. In that case we send the // a touch down on the screen situation. In that case we send the
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment