summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser')
-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,