0

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
This commit is contained in:
jhawkins@chromium.org
2009-04-06 21:13:29 +00:00
parent 4d9c341c7e
commit 01cbfd37b9
2 changed files with 24 additions and 3 deletions
chrome/browser/gtk/tabs

@ -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;
}

@ -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;