diff options
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/gtk/tabs/tab_gtk.cc | 47 | ||||
-rw-r--r-- | chrome/browser/gtk/tabs/tab_gtk.h | 12 |
2 files changed, 28 insertions, 31 deletions
diff --git a/chrome/browser/gtk/tabs/tab_gtk.cc b/chrome/browser/gtk/tabs/tab_gtk.cc index 10144b6..667cd8a 100644 --- a/chrome/browser/gtk/tabs/tab_gtk.cc +++ b/chrome/browser/gtk/tabs/tab_gtk.cc @@ -200,34 +200,11 @@ gboolean TabGtk::OnButtonReleaseEvent(GtkWidget* widget, GdkEventButton* event, } // static -void TabGtk::OnDragEnd(GtkWidget* widget, GdkDragContext* context, - TabGtk* tab) { - // We must let gtk clean up after we handle the drag operation, otherwise - // there will be outstanding references to the drag widget when we try to - // destroy it. - MessageLoop::current()->PostTask(FROM_HERE, - tab->destroy_factory_.NewRunnableMethod(&TabGtk::DestroyDragWidget)); - - if (tab->last_mouse_down_) { - gdk_event_free(tab->last_mouse_down_); - tab->last_mouse_down_ = NULL; - } - - // Notify the drag helper that we're done with any potential drag operations. - // Clean up the drag helper, which is re-created on the next mouse press. - tab->delegate_->EndDrag(false); - - MessageLoopForUI::current()->RemoveObserver(tab); -} - -// static gboolean TabGtk::OnDragFailed(GtkWidget* widget, GdkDragContext* context, GtkDragResult result, TabGtk* tab) { - // TODO(jhawkins): Implement an EndDrag method that wraps up functionality - // of OnDragEnd and OnDragFailed. Take |result| into account for a canceled - // drag action. - OnDragEnd(widget, context, tab); + bool canceled = (result == GTK_DRAG_RESULT_USER_CANCELLED); + tab->EndDrag(canceled); return TRUE; } @@ -320,7 +297,6 @@ void TabGtk::CreateDragWidget() { drag_widget_ = gtk_invisible_new(); g_signal_connect(drag_widget_, "drag-failed", G_CALLBACK(OnDragFailed), this); - g_signal_connect(drag_widget_, "drag-end", G_CALLBACK(OnDragEnd), this); } void TabGtk::DestroyDragWidget() { @@ -341,3 +317,22 @@ void TabGtk::StartDragging(gfx::Point drag_offset) { delegate_->MaybeStartDrag(this, drag_offset); } + +void TabGtk::EndDrag(bool canceled) { + // We must let gtk clean up after we handle the drag operation, otherwise + // there will be outstanding references to the drag widget when we try to + // destroy it. + MessageLoop::current()->PostTask(FROM_HERE, + destroy_factory_.NewRunnableMethod(&TabGtk::DestroyDragWidget)); + + if (last_mouse_down_) { + gdk_event_free(last_mouse_down_); + last_mouse_down_ = NULL; + } + + // Notify the drag helper that we're done with any potential drag operations. + // Clean up the drag helper, which is re-created on the next mouse press. + delegate_->EndDrag(canceled); + + MessageLoopForUI::current()->RemoveObserver(this); +} diff --git a/chrome/browser/gtk/tabs/tab_gtk.h b/chrome/browser/gtk/tabs/tab_gtk.h index 8772d55..2cd6d93 100644 --- a/chrome/browser/gtk/tabs/tab_gtk.h +++ b/chrome/browser/gtk/tabs/tab_gtk.h @@ -111,11 +111,9 @@ class TabGtk : public TabRendererGtk, static gboolean OnButtonReleaseEvent(GtkWidget* widget, GdkEventButton* event, TabGtk* tab); - // drag-end handler that signals when a drag action ends. - static void OnDragEnd(GtkWidget* widget, GdkDragContext* context, - TabGtk* tab); - - // drag-failed handler that is emitted when the drag fails. + // drag-failed handler that is emitted when the drag is finished. The signal + // is drag-failed, but that is only in the gtk sense in that we never used + // the drag-n-drop API to transfer drop data. static gboolean OnDragFailed(GtkWidget* widget, GdkDragContext* context, GtkDragResult result, TabGtk* tab); @@ -139,6 +137,10 @@ class TabGtk : public TabRendererGtk, // bounds where the grab occurred. void StartDragging(gfx::Point drag_offset); + // Ends the dragging operations. |canceled| is true if the operation was + // canceled. + void EndDrag(bool canceled); + // An instance of a delegate object that can perform various actions based on // user gestures. TabDelegate* delegate_; |