diff options
author | oshima@google.com <oshima@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-09 17:43:30 +0000 |
---|---|---|
committer | oshima@google.com <oshima@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-09 17:43:30 +0000 |
commit | f922b9dc349b545b09f574452f1b15f85bd197f1 (patch) | |
tree | 2783c5610db577a2b4606df93ad6fc31dabe966a /views/touchui | |
parent | e1adb9abe412292567c518d5d68c63ef5b605181 (diff) | |
download | chromium_src-f922b9dc349b545b09f574452f1b15f85bd197f1.zip chromium_src-f922b9dc349b545b09f574452f1b15f85bd197f1.tar.gz chromium_src-f922b9dc349b545b09f574452f1b15f85bd197f1.tar.bz2 |
Fix touch event coordinate conversion
BUG=none
TEST=touch event should work on find bar, wrench menu with/without views-desktop.
Review URL: http://codereview.chromium.org/7841059
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@100432 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/touchui')
-rw-r--r-- | views/touchui/gesture_manager.cc | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/views/touchui/gesture_manager.cc b/views/touchui/gesture_manager.cc index 44bb96c..cf966ae 100644 --- a/views/touchui/gesture_manager.cc +++ b/views/touchui/gesture_manager.cc @@ -10,6 +10,7 @@ #include "base/logging.h" #include "views/events/event.h" #include "views/view.h" +#include "views/views_delegate.h" #include "views/widget/widget.h" namespace views { @@ -33,11 +34,33 @@ bool GestureManager::ProcessTouchEventForGesture(const TouchEvent& event, // 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. + // location information from the native-event, so it needs to convert the + // coordinate to the target widget. Event::FromNativeEvent2 from_native; MouseEvent mouseev(event, from_native); - source->GetWidget()->GetTopLevelWidget()->OnMouseEvent(mouseev); + if (ViewsDelegate::views_delegate->GetDefaultParentView()) { + // TODO(oshima): We may need to send the event back through + // window manager to handle mouse capture correctly. + Widget* desktop = + ViewsDelegate::views_delegate->GetDefaultParentView()->GetWidget(); + Widget* source_widget = source->GetWidget(); + MouseEvent converted( + mouseev, desktop->GetRootView(), source_widget->GetRootView()); + source_widget->OnMouseEvent(converted); + } else { + Widget* source_widget = source->GetWidget(); + Widget* top_widget = source_widget->GetTopLevelWidget(); + if (source_widget != top_widget) { + // This is necessary as TYPE_CHILD widget is still NativeWidgetGtk. + // Fix this once TYPE_CHILD is switched to NativeWidgetViews. + MouseEvent converted(mouseev, + top_widget->GetRootView(), + source_widget->GetRootView()); + source_widget->OnMouseEvent(mouseev); + } else { + source_widget->OnMouseEvent(mouseev); + } + } return true; } |