From 379ca24af3d07223af4f09f5e42f0200d3b268d3 Mon Sep 17 00:00:00 2001 From: "tc@google.com" Date: Fri, 22 May 2009 20:53:00 +0000 Subject: Fix a bug in popup menus where we sent the wrong mouse events coordinates to the renderer. gtk_grab_add() causes us to receive all events. That means we receive mouse events for other widgets with the coordinates relative to the other widget. We actually the coordinates relative to the popup. This caused jankiness with the popup on news.google.com. Since the popup happened to be on the left side of the page, we sent event coordinates that happened to land in the popup, causing us to select stuff. BUG=12025 Review URL: http://codereview.chromium.org/113750 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16791 0039d316-1c4b-4281-b951-d872f2087c98 --- .../renderer_host/render_widget_host_view_gtk.cc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/chrome/browser/renderer_host/render_widget_host_view_gtk.cc b/chrome/browser/renderer_host/render_widget_host_view_gtk.cc index ea5163d..b3324bf 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_gtk.cc +++ b/chrome/browser/renderer_host/render_widget_host_view_gtk.cc @@ -122,6 +122,16 @@ class RenderWidgetHostViewGtkWidget { static gboolean ButtonPressReleaseEvent( GtkWidget* widget, GdkEventButton* event, RenderWidgetHostViewGtk* host_view) { + // We want to translate the coordinates of events that do not originate + // from this widget to be relative to the top left of the widget. + GtkWidget* event_widget = gtk_get_event_widget((GdkEvent*)event); + if (event_widget != widget) { + int x = 0; + int y = 0; + gtk_widget_get_pointer(widget, &x, &y); + event->x = x; + event->y = y; + } host_view->GetRenderWidgetHost()->ForwardMouseEvent( WebInputEventFactory::mouseEvent(event)); @@ -135,6 +145,16 @@ class RenderWidgetHostViewGtkWidget { static gboolean MouseMoveEvent(GtkWidget* widget, GdkEventMotion* event, RenderWidgetHostViewGtk* host_view) { + // We want to translate the coordinates of events that do not originate + // from this widget to be relative to the top left of the widget. + GtkWidget* event_widget = gtk_get_event_widget((GdkEvent*)event); + if (event_widget != widget) { + int x = 0; + int y = 0; + gtk_widget_get_pointer(widget, &x, &y); + event->x = x; + event->y = y; + } host_view->GetRenderWidgetHost()->ForwardMouseEvent( WebInputEventFactory::mouseEvent(event)); return FALSE; -- cgit v1.1