diff options
author | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-06 21:13:29 +0000 |
---|---|---|
committer | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-06 21:13:29 +0000 |
commit | 01cbfd37b9981cb0f0d3bd522932ba699368d844 (patch) | |
tree | 6cc8700caef555e263cc43916273cfb4557d4974 | |
parent | 4d9c341c7ee9a63dae7de2637a6c8796834e3d7a (diff) | |
download | chromium_src-01cbfd37b9981cb0f0d3bd522932ba699368d844.zip chromium_src-01cbfd37b9981cb0f0d3bd522932ba699368d844.tar.gz chromium_src-01cbfd37b9981cb0f0d3bd522932ba699368d844.tar.bz2 |
Un-hover the current highlighted tab when the mouse leaves the tabstrip.
Review URL: http://codereview.chromium.org/62075
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13189 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/gtk/tabs/tab_strip_gtk.cc | 23 | ||||
-rw-r--r-- | chrome/browser/gtk/tabs/tab_strip_gtk.h | 4 |
2 files changed, 24 insertions, 3 deletions
diff --git a/chrome/browser/gtk/tabs/tab_strip_gtk.cc b/chrome/browser/gtk/tabs/tab_strip_gtk.cc index 1dd8cd8..7e9a153 100644 --- a/chrome/browser/gtk/tabs/tab_strip_gtk.cc +++ b/chrome/browser/gtk/tabs/tab_strip_gtk.cc @@ -76,8 +76,10 @@ void TabStripGtk::Init() { G_CALLBACK(OnMotionNotify), this); g_signal_connect(G_OBJECT(tabstrip_.get()), "button-press-event", G_CALLBACK(OnButtonPress), this); + g_signal_connect(G_OBJECT(tabstrip_.get()), "leave-notify-event", + G_CALLBACK(OnLeaveNotify), this); gtk_widget_add_events(tabstrip_.get(), - GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK); + GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_LEAVE_NOTIFY_MASK); gtk_widget_show_all(tabstrip_.get()); bounds_ = GetInitialWidgetBounds(tabstrip_.get()); @@ -383,9 +385,9 @@ void TabStripGtk::GetDesiredTabWidths(int tab_count, } // static -gboolean TabStripGtk::OnExpose(GtkWidget* widget, GdkEventExpose* e, +gboolean TabStripGtk::OnExpose(GtkWidget* widget, GdkEventExpose* event, TabStripGtk* tabstrip) { - ChromeCanvasPaint canvas(e); + ChromeCanvasPaint canvas(event); if (canvas.isEmpty()) return TRUE; @@ -487,3 +489,18 @@ gboolean TabStripGtk::OnButtonPress(GtkWidget* widget, GdkEventButton* event, return TRUE; } + +// static +gboolean TabStripGtk::OnLeaveNotify(GtkWidget* widget, GdkEventCrossing* event, + TabStripGtk* tabstrip) { + // A leave-notify-event is generated on mouse click, which sets the mode to + // GDK_CROSSING_GRAB. Ignore this event because it doesn't meant the mouse + // has left the tabstrip. + if (tabstrip->hover_index_ != -1 && event->mode != GDK_CROSSING_GRAB) { + tabstrip->GetTabAt(tabstrip->hover_index_)->SetHovering(false); + tabstrip->hover_index_ = -1; + gtk_widget_queue_draw(tabstrip->tabstrip_.get()); + } + + return TRUE; +} diff --git a/chrome/browser/gtk/tabs/tab_strip_gtk.h b/chrome/browser/gtk/tabs/tab_strip_gtk.h index 9ed9d49..be93e07 100644 --- a/chrome/browser/gtk/tabs/tab_strip_gtk.h +++ b/chrome/browser/gtk/tabs/tab_strip_gtk.h @@ -79,6 +79,10 @@ class TabStripGtk : public TabStripModelObserver, static gboolean OnButtonPress(GtkWidget* widget, GdkEventButton* event, TabStripGtk* tabstrip); + // leave-notify-event handler that signals when the mouse leaves the tabstrip. + static gboolean OnLeaveNotify(GtkWidget* widget, GdkEventCrossing* event, + TabStripGtk* tabstrip); + // Gets the number of Tabs in the collection. int GetTabCount() const; |