diff options
author | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-22 17:29:31 +0000 |
---|---|---|
committer | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-22 17:29:31 +0000 |
commit | 2d209edb29c44fda75e3816e8170c565ef104f23 (patch) | |
tree | 0fffad85b4c9adc5dc7e47c58af4e0fc644567be /chrome | |
parent | 8c66c5ae2f67738941f4476fd7d5111a89c337ba (diff) | |
download | chromium_src-2d209edb29c44fda75e3816e8170c565ef104f23.zip chromium_src-2d209edb29c44fda75e3816e8170c565ef104f23.tar.gz chromium_src-2d209edb29c44fda75e3816e8170c565ef104f23.tar.bz2 |
gtk: Fix a regression from r20404 which keeps a drag into the tabstrip from working. Only destroy the container widget and not the drop info itself when the drag leaves the tab strip; otherwise, we'll lose the drop information used to open the link.
BUG=none
TEST=Drag a link into the tab strip. The drop arrow should appear and disappear as the mouse enters and leaves the tab strip. Drop the link into the tab strip. The link should be opened in the new tab (or the current tab).
Review URL: http://codereview.chromium.org/159178
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21285 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/gtk/tabs/tab_strip_gtk.cc | 55 | ||||
-rw-r--r-- | chrome/browser/gtk/tabs/tab_strip_gtk.h | 6 |
2 files changed, 34 insertions, 27 deletions
diff --git a/chrome/browser/gtk/tabs/tab_strip_gtk.cc b/chrome/browser/gtk/tabs/tab_strip_gtk.cc index 2a884fc..3be68f3 100644 --- a/chrome/browser/gtk/tabs/tab_strip_gtk.cc +++ b/chrome/browser/gtk/tabs/tab_strip_gtk.cc @@ -1471,26 +1471,19 @@ void TabStripGtk::UpdateDropIndex(GdkDragContext* context, gint x, gint y) { } void TabStripGtk::SetDropIndex(int index, bool drop_before) { - if (index == -1) { - if (drop_info_.get()) - gtk_widget_hide(drop_info_->container); - return; - } - - if (drop_info_.get() && !GTK_WIDGET_VISIBLE(drop_info_->container)) - gtk_widget_show(drop_info_->container); - - if (drop_info_.get() && drop_info_->drop_index == index && - drop_info_->drop_before == drop_before) { - return; - } - bool is_beneath; gfx::Rect drop_bounds = GetDropBounds(index, drop_before, &is_beneath); if (!drop_info_.get()) { drop_info_.reset(new DropInfo(index, drop_before, !is_beneath)); } else { + if (!GTK_IS_WIDGET(drop_info_->container)) { + drop_info_->CreateContainer(); + } else if (drop_info_->drop_index == index && + drop_info_->drop_before == drop_before) { + return; + } + drop_info_->drop_index = index; drop_info_->drop_before = drop_before; if (is_beneath == drop_info_->point_down) { @@ -1549,22 +1542,12 @@ TabStripGtk::DropInfo::DropInfo(int drop_index, bool drop_before, : drop_index(drop_index), drop_before(drop_before), point_down(point_down) { - container = gtk_window_new(GTK_WINDOW_POPUP); - SetContainerColorMap(); - gtk_widget_set_app_paintable(container, TRUE); - g_signal_connect(G_OBJECT(container), "expose-event", - G_CALLBACK(OnExposeEvent), this); - gtk_widget_add_events(container, GDK_STRUCTURE_MASK); - gtk_window_move(GTK_WINDOW(container), 0, 0); - gtk_window_resize(GTK_WINDOW(container), - drop_indicator_width, drop_indicator_height); - gtk_widget_show_all(container); - + CreateContainer(); drop_arrow = GetDropArrowImage(point_down); } TabStripGtk::DropInfo::~DropInfo() { - gtk_widget_destroy(container); + DestroyContainer(); } // static @@ -1644,6 +1627,24 @@ void TabStripGtk::DropInfo::SetContainerShapeMask() { g_object_unref(pixmap); } +void TabStripGtk::DropInfo::CreateContainer() { + container = gtk_window_new(GTK_WINDOW_POPUP); + SetContainerColorMap(); + gtk_widget_set_app_paintable(container, TRUE); + g_signal_connect(G_OBJECT(container), "expose-event", + G_CALLBACK(OnExposeEvent), this); + gtk_widget_add_events(container, GDK_STRUCTURE_MASK); + gtk_window_move(GTK_WINDOW(container), 0, 0); + gtk_window_resize(GTK_WINDOW(container), + drop_indicator_width, drop_indicator_height); + gtk_widget_show_all(container); +} + +void TabStripGtk::DropInfo::DestroyContainer() { + if (GTK_IS_WIDGET(container)) + gtk_widget_destroy(container); +} + // Called from: // - animation tick void TabStripGtk::AnimationLayout(double unselected_width) { @@ -1852,7 +1853,7 @@ gboolean TabStripGtk::OnDragDrop(GtkWidget* widget, GdkDragContext* context, gboolean TabStripGtk::OnDragLeave(GtkWidget* widget, GdkDragContext* context, guint time, TabStripGtk* tabstrip) { // Destroy the drop indicator. - tabstrip->drop_info_.reset(); + tabstrip->drop_info_->DestroyContainer(); return FALSE; } diff --git a/chrome/browser/gtk/tabs/tab_strip_gtk.h b/chrome/browser/gtk/tabs/tab_strip_gtk.h index e4ae4ac..5890e4a 100644 --- a/chrome/browser/gtk/tabs/tab_strip_gtk.h +++ b/chrome/browser/gtk/tabs/tab_strip_gtk.h @@ -176,6 +176,12 @@ class TabStripGtk : public TabStripModelObserver, // screen. void SetContainerShapeMask(); + // Creates the container widget. + void CreateContainer(); + + // Destroys the container widget. + void DestroyContainer(); + // Index of the tab to drop on. If drop_before is true, the drop should // occur between the tab at drop_index - 1 and drop_index. // WARNING: if drop_before is true it is possible this will == tab_count, |