diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-02 20:33:47 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-02 20:33:47 +0000 |
commit | 50a441d8fcc68babce2a7dc1fc373569c8326a2a (patch) | |
tree | 5ffb68606a726f7e22032b96606f061f9bf06216 | |
parent | 2fc90935ee2fb798829265ad145a15a36a56105a (diff) | |
download | chromium_src-50a441d8fcc68babce2a7dc1fc373569c8326a2a.zip chromium_src-50a441d8fcc68babce2a7dc1fc373569c8326a2a.tar.gz chromium_src-50a441d8fcc68babce2a7dc1fc373569c8326a2a.tar.bz2 |
GTK: when doing a drag from a web page, pass a recent mouse down to gtk_drag_begin() so it has a better idea what time to pass to gdk_grab_pointer().
I believe the following was happening:
- render view gets mouse down, forwards to webkit
- render view gets motion, forwards to webkit
- user releases mouse button, that event is added to the queue
- browser gets message from webkit that a drag has begun, calls gtk_drag_begin() with no event
- gtk_drag_begin initiates a cursor grab, but it only applies to events that have not yet been added to the queue
- mouse release comes up in queue; passed to render view rather than the drag widget
TEST=You can't get stuck in really short render view drags. Whereas it was really easy to repro before (especially in Xephyr), I can repro no longer.
BUG=http://crbug.com/15768
Review URL: http://codereview.chromium.org/150204
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19839 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/tab_contents/tab_contents_view_gtk.cc | 12 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents_view_gtk.h | 6 |
2 files changed, 12 insertions, 6 deletions
diff --git a/chrome/browser/tab_contents/tab_contents_view_gtk.cc b/chrome/browser/tab_contents/tab_contents_view_gtk.cc index 84aa955..2792639 100644 --- a/chrome/browser/tab_contents/tab_contents_view_gtk.cc +++ b/chrome/browser/tab_contents/tab_contents_view_gtk.cc @@ -350,7 +350,7 @@ void TabContentsViewGtk::Observe(NotificationType type, void TabContentsViewGtk::ShowContextMenu(const ContextMenuParams& params) { context_menu_.reset(new RenderViewContextMenuGtk(tab_contents(), params, - last_mouse_down_time_)); + last_mouse_down_.time)); context_menu_->Init(); context_menu_->Popup(); } @@ -392,7 +392,13 @@ void TabContentsViewGtk::StartDragging(const WebDropData& drop_data) { 0, GtkDndUtil::X_CHROME_WEBDROP_FILE_CONTENTS); } - gtk_drag_begin(GetContentNativeView(), list, GDK_ACTION_COPY, 1, NULL); + // If we don't pass an event, GDK won't know what event time to start grabbing + // mouse events. Technically it's the mouse motion event and not the mouse + // down event that causes the drag, but there's no reliable way to know + // *which* motion event initiated the drag, so this will have to do. + gtk_drag_begin(GetContentNativeView(), list, GDK_ACTION_COPY, + last_mouse_down_.button, + reinterpret_cast<GdkEvent*>(&last_mouse_down_)); // The drag adds a ref; let it own the list. gtk_target_list_unref(list); } @@ -459,7 +465,7 @@ void TabContentsViewGtk::InsertIntoContentArea(GtkWidget* widget) { gboolean TabContentsViewGtk::OnMouseDown(GtkWidget* widget, GdkEventButton* event, TabContentsViewGtk* view) { - view->last_mouse_down_time_ = event->time; + view->last_mouse_down_ = *event; return FALSE; } diff --git a/chrome/browser/tab_contents/tab_contents_view_gtk.h b/chrome/browser/tab_contents/tab_contents_view_gtk.h index be2b74d..b1d56d0 100644 --- a/chrome/browser/tab_contents/tab_contents_view_gtk.h +++ b/chrome/browser/tab_contents/tab_contents_view_gtk.h @@ -116,9 +116,9 @@ class TabContentsViewGtk : public TabContentsView, // between uses so that it won't go out of scope before we're done with it. scoped_ptr<RenderViewContextMenuGtk> context_menu_; - // The event time for the last mouse down we handled. We need this to properly - // show context menus. - guint32 last_mouse_down_time_; + // The event for the last mouse down we handled. We need this for context + // menus and drags. + GdkEventButton last_mouse_down_; // Used to get notifications about renderers coming and going. NotificationRegistrar registrar_; |