diff options
author | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-10 19:59:02 +0000 |
---|---|---|
committer | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-10 19:59:02 +0000 |
commit | 75f5f9a1b9764033bec1fe9dcf546c5c5dcb0940 (patch) | |
tree | 690921551b7ab5913f22c11ff2bb3784d3f39719 | |
parent | d995479a4149e65e23f5651a79cf605711ea081d (diff) | |
download | chromium_src-75f5f9a1b9764033bec1fe9dcf546c5c5dcb0940.zip chromium_src-75f5f9a1b9764033bec1fe9dcf546c5c5dcb0940.tar.gz chromium_src-75f5f9a1b9764033bec1fe9dcf546c5c5dcb0940.tar.bz2 |
Fix a few issues with the drop arrow in the Linux tab strip:
* Reset the drop info when completing a drag (successful or otherwise).
* Reset the drop info when the drag leaves the tab strip zone.
* Report success or failure of the drop back to the source widget.
* Move and resize the drop arrow container before showing it to reduce visual jank.
BUG=none
TEST=Drag a image into the tab strip so that the drop arrow appears. Release the drop over the tab strip and then move the window and repeat the process. The drop arrow should be in the correct position. Notice that there is no visual jank when the drop arrow is shown.
Review URL: http://codereview.chromium.org/149426
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20404 0039d316-1c4b-4281-b951-d872f2087c98
-rwxr-xr-x | chrome/browser/gtk/tabs/tab_strip_gtk.cc | 40 | ||||
-rw-r--r-- | chrome/browser/gtk/tabs/tab_strip_gtk.h | 5 |
2 files changed, 19 insertions, 26 deletions
diff --git a/chrome/browser/gtk/tabs/tab_strip_gtk.cc b/chrome/browser/gtk/tabs/tab_strip_gtk.cc index 36d2c0e..2648964 100755 --- a/chrome/browser/gtk/tabs/tab_strip_gtk.cc +++ b/chrome/browser/gtk/tabs/tab_strip_gtk.cc @@ -494,8 +494,6 @@ void TabStripGtk::Init() { G_CALLBACK(OnDragDrop), this); g_signal_connect(G_OBJECT(tabstrip_.get()), "drag-leave", G_CALLBACK(OnDragLeave), this); - g_signal_connect(G_OBJECT(tabstrip_.get()), "drag-failed", - G_CALLBACK(OnDragFailed), this); g_signal_connect(G_OBJECT(tabstrip_.get()), "drag-data-received", G_CALLBACK(OnDragDataReceived), this); @@ -1224,19 +1222,19 @@ void TabStripGtk::SetDropIndex(int index, bool drop_before) { drop_bounds.width(), drop_bounds.height()); } -void TabStripGtk::CompleteDrop(guchar* data) { +bool TabStripGtk::CompleteDrop(guchar* data) { if (!drop_info_.get()) - return; + return false; const int drop_index = drop_info_->drop_index; const bool drop_before = drop_info_->drop_before; - // Hide the drop indicator. - SetDropIndex(-1, false); + // Destroy the drop indicator. + drop_info_.reset(); GURL url(reinterpret_cast<char*>(data)); if (!url.is_valid()) - return; + return false; if (drop_before) { // Insert a new tab. @@ -1251,6 +1249,8 @@ void TabStripGtk::CompleteDrop(guchar* data) { url, GURL(), PageTransition::GENERATED); model_->SelectTabContentsAt(drop_index, true); } + + return true; } // static @@ -1272,13 +1272,12 @@ TabStripGtk::DropInfo::DropInfo(int drop_index, bool drop_before, g_signal_connect(G_OBJECT(container), "expose-event", G_CALLBACK(OnExposeEvent), this); gtk_widget_add_events(container, GDK_STRUCTURE_MASK); - gtk_widget_show_all(container); - - drop_arrow = GetDropArrowImage(point_down); - 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); + + drop_arrow = GetDropArrowImage(point_down); } TabStripGtk::DropInfo::~DropInfo() { @@ -1550,17 +1549,8 @@ gboolean TabStripGtk::OnDragDrop(GtkWidget* widget, GdkDragContext* context, // static gboolean TabStripGtk::OnDragLeave(GtkWidget* widget, GdkDragContext* context, guint time, TabStripGtk* tabstrip) { - // Hide the drop indicator. - tabstrip->SetDropIndex(-1, false); - return FALSE; -} - -// static -gboolean TabStripGtk::OnDragFailed(GtkWidget* widget, GdkDragContext* context, - GtkDragResult result, - TabStripGtk* tabstrip) { - // Hide the drop indicator. - tabstrip->SetDropIndex(-1, false); + // Destroy the drop indicator. + tabstrip->drop_info_.reset(); return FALSE; } @@ -1571,12 +1561,14 @@ gboolean TabStripGtk::OnDragDataReceived(GtkWidget* widget, GtkSelectionData* data, guint info, guint time, TabStripGtk* tabstrip) { + bool success = false; + // TODO(jhawkins): Parse URI lists. if (info == GtkDndUtil::X_CHROME_TEXT_PLAIN) { - tabstrip->CompleteDrop(data->data); - gtk_drag_finish(context, TRUE, TRUE, time); + success = tabstrip->CompleteDrop(data->data); } + gtk_drag_finish(context, success, success, time); return TRUE; } diff --git a/chrome/browser/gtk/tabs/tab_strip_gtk.h b/chrome/browser/gtk/tabs/tab_strip_gtk.h index 0da33f9..3f48263 100644 --- a/chrome/browser/gtk/tabs/tab_strip_gtk.h +++ b/chrome/browser/gtk/tabs/tab_strip_gtk.h @@ -307,8 +307,9 @@ class TabStripGtk : public TabStripModelObserver, void SetDropIndex(int index, bool drop_before); // Determines whether the data is acceptable by the tabstrip and opens a new - // tab with the data as URL if it is. - void CompleteDrop(guchar* data); + // tab with the data as URL if it is. Returns true if the drop was + // successful. + bool CompleteDrop(guchar* data); // Returns the image to use for indicating a drop on a tab. If is_down is // true, this returns an arrow pointing down. |