summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-26 19:49:40 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-26 19:49:40 +0000
commitd942a8925ca595f551db2cce689749000959550d (patch)
tree851ff383e53c7743d3a3926d5b714e6713fa41c4 /chrome
parentd73c1d9bdb8afbf61858a7e0341d1407253aaaf3 (diff)
downloadchromium_src-d942a8925ca595f551db2cce689749000959550d.zip
chromium_src-d942a8925ca595f551db2cce689749000959550d.tar.gz
chromium_src-d942a8925ca595f551db2cce689749000959550d.tar.bz2
Fix two issues with Drag-N-Drop in gtk tabstrip:
* Handle drag-leave and drag-failed by hiding or destroying the drag arrow respectively. * Hide the drop arrow instead of destroying the drop info when we set the drop index to -1. This compensates for the fact that gtk emits the drag-leave signal before the drag-data-received signal. BUG=none TEST=Drag a URL in and out of the tabstrip. The drop arrow should disappear when the dragged mouse leaves the tabstrip or when the drag fails. Review URL: http://codereview.chromium.org/149093 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19399 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rwxr-xr-xchrome/browser/gtk/tabs/tab_strip_gtk.cc30
-rw-r--r--chrome/browser/gtk/tabs/tab_strip_gtk.h9
2 files changed, 37 insertions, 2 deletions
diff --git a/chrome/browser/gtk/tabs/tab_strip_gtk.cc b/chrome/browser/gtk/tabs/tab_strip_gtk.cc
index 4399a3b..d5ec368 100755
--- a/chrome/browser/gtk/tabs/tab_strip_gtk.cc
+++ b/chrome/browser/gtk/tabs/tab_strip_gtk.cc
@@ -4,6 +4,8 @@
#include "chrome/browser/gtk/tabs/tab_strip_gtk.h"
+#include <algorithm>
+
#include "app/gfx/canvas_paint.h"
#include "app/l10n_util.h"
#include "app/resource_bundle.h"
@@ -497,6 +499,10 @@ void TabStripGtk::Init() {
G_CALLBACK(OnDragMotion), this);
g_signal_connect(G_OBJECT(tabstrip_.get()), "drag-drop",
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);
@@ -1125,7 +1131,7 @@ void TabStripGtk::RemoveMessageLoopObserver() {
gfx::Rect TabStripGtk::GetDropBounds(int drop_index,
bool drop_before,
bool* is_beneath) {
- DCHECK(drop_index != -1);
+ DCHECK_NE(drop_index, -1);
int center_x;
if (drop_index < GetTabCount()) {
TabGtk* tab = GetTabAt(drop_index);
@@ -1180,10 +1186,13 @@ void TabStripGtk::UpdateDropIndex(GdkDragContext* context, gint x, gint y) {
void TabStripGtk::SetDropIndex(int index, bool drop_before) {
if (index == -1) {
if (drop_info_.get())
- drop_info_.reset(NULL);
+ 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;
@@ -1537,6 +1546,23 @@ 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);
+ return FALSE;
+}
+
+// static
gboolean TabStripGtk::OnDragDataReceived(GtkWidget* widget,
GdkDragContext* context,
gint x, gint y,
diff --git a/chrome/browser/gtk/tabs/tab_strip_gtk.h b/chrome/browser/gtk/tabs/tab_strip_gtk.h
index aa731e8..6cb6ef1 100644
--- a/chrome/browser/gtk/tabs/tab_strip_gtk.h
+++ b/chrome/browser/gtk/tabs/tab_strip_gtk.h
@@ -200,6 +200,15 @@ class TabStripGtk : public TabStripModelObserver,
gint x, gint y, guint time,
TabStripGtk* tabstrip);
+ // drag-leave handler that is signaled when the mouse leaves the tabstrip
+ // during a drag.
+ static gboolean OnDragLeave(GtkWidget* widget, GdkDragContext* context,
+ guint time, TabStripGtk* tabstrip);
+
+ // drag-failed handler that is signaled when the drag fails or is canceled.
+ static gboolean OnDragFailed(GtkWidget* widget, GdkDragContext* context,
+ GtkDragResult result, TabStripGtk* tabstrip);
+
// drag-data-received handler that receives the data assocated with the drag.
static gboolean OnDragDataReceived(GtkWidget* widget, GdkDragContext* context,
gint x, gint y, GtkSelectionData* data,