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
Esse commit está contido em:
jhawkins@chromium.org
2009-07-10 19:59:02 +00:00
commit a51d431c69
2 arquivos alterados com 19 adições e 26 exclusões
+16 -24
Ver Arquivo
@@ -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;
}
+3 -2
Ver Arquivo
@@ -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.