diff options
-rw-r--r-- | views/desktop/desktop_window_root_view.cc | 16 | ||||
-rw-r--r-- | views/desktop/desktop_window_root_view.h | 5 | ||||
-rw-r--r-- | views/events/event.h | 1 | ||||
-rw-r--r-- | views/touchui/gesture_manager.cc | 5 | ||||
-rw-r--r-- | views/widget/native_widget_view.cc | 3 | ||||
-rw-r--r-- | views/widget/root_view.cc | 4 |
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 |