summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoroshima@google.com <oshima@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-09 17:43:30 +0000
committeroshima@google.com <oshima@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-09 17:43:30 +0000
commitf922b9dc349b545b09f574452f1b15f85bd197f1 (patch)
tree2783c5610db577a2b4606df93ad6fc31dabe966a
parente1adb9abe412292567c518d5d68c63ef5b605181 (diff)
downloadchromium_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
-rw-r--r--views/touchui/gesture_manager.cc29
-rw-r--r--views/widget/native_widget_view.cc10
2 files changed, 27 insertions, 12 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;
}
diff --git a/views/widget/native_widget_view.cc b/views/widget/native_widget_view.cc
index f3d675b..0b60850 100644
--- a/views/widget/native_widget_view.cc
+++ b/views/widget/native_widget_view.cc
@@ -79,7 +79,6 @@ gfx::NativeCursor NativeWidgetView::GetCursor(const MouseEvent& event) {
}
bool NativeWidgetView::OnMousePressed(const MouseEvent& event) {
- MouseEvent e(event, this);
Widget* hosting_widget = GetAssociatedWidget();
if (hosting_widget->non_client_view()) {
int hittest_code = hosting_widget->non_client_view()->NonClientHitTest(
@@ -115,12 +114,10 @@ bool NativeWidgetView::OnMousePressed(const MouseEvent& event) {
}
bool NativeWidgetView::OnMouseDragged(const MouseEvent& event) {
- MouseEvent e(event, this);
return delegate()->OnMouseEvent(event);
}
void NativeWidgetView::OnMouseReleased(const MouseEvent& event) {
- MouseEvent e(event, this);
delegate()->OnMouseEvent(event);
}
@@ -129,23 +126,19 @@ void NativeWidgetView::OnMouseCaptureLost() {
}
void NativeWidgetView::OnMouseMoved(const MouseEvent& event) {
- MouseEvent e(event, this);
delegate()->OnMouseEvent(event);
}
void NativeWidgetView::OnMouseEntered(const MouseEvent& event) {
- MouseEvent e(event, this);
delegate()->OnMouseEvent(event);
}
void NativeWidgetView::OnMouseExited(const MouseEvent& event) {
- MouseEvent e(event, this);
delegate()->OnMouseEvent(event);
}
ui::TouchStatus NativeWidgetView::OnTouchEvent(const TouchEvent& event) {
- TouchEvent e(event, this);
- return delegate()->OnTouchEvent(e);
+ return delegate()->OnTouchEvent(event);
}
bool NativeWidgetView::OnKeyPressed(const KeyEvent& event) {
@@ -157,7 +150,6 @@ bool NativeWidgetView::OnKeyReleased(const KeyEvent& event) {
}
bool NativeWidgetView::OnMouseWheel(const MouseWheelEvent& event) {
- MouseWheelEvent e(event, this);
return delegate()->OnMouseEvent(event);
}