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:
chrome/browser/gtk/tabs
@ -76,8 +76,10 @@ void TabStripGtk::Init() {
|
|||||||
G_CALLBACK(OnMotionNotify), this);
|
G_CALLBACK(OnMotionNotify), this);
|
||||||
g_signal_connect(G_OBJECT(tabstrip_.get()), "button-press-event",
|
g_signal_connect(G_OBJECT(tabstrip_.get()), "button-press-event",
|
||||||
G_CALLBACK(OnButtonPress), this);
|
G_CALLBACK(OnButtonPress), this);
|
||||||
|
g_signal_connect(G_OBJECT(tabstrip_.get()), "leave-notify-event",
|
||||||
|
G_CALLBACK(OnLeaveNotify), this);
|
||||||
gtk_widget_add_events(tabstrip_.get(),
|
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());
|
gtk_widget_show_all(tabstrip_.get());
|
||||||
|
|
||||||
bounds_ = GetInitialWidgetBounds(tabstrip_.get());
|
bounds_ = GetInitialWidgetBounds(tabstrip_.get());
|
||||||
@ -383,9 +385,9 @@ void TabStripGtk::GetDesiredTabWidths(int tab_count,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
gboolean TabStripGtk::OnExpose(GtkWidget* widget, GdkEventExpose* e,
|
gboolean TabStripGtk::OnExpose(GtkWidget* widget, GdkEventExpose* event,
|
||||||
TabStripGtk* tabstrip) {
|
TabStripGtk* tabstrip) {
|
||||||
ChromeCanvasPaint canvas(e);
|
ChromeCanvasPaint canvas(event);
|
||||||
if (canvas.isEmpty())
|
if (canvas.isEmpty())
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
@ -487,3 +489,18 @@ gboolean TabStripGtk::OnButtonPress(GtkWidget* widget, GdkEventButton* event,
|
|||||||
|
|
||||||
return TRUE;
|
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,
|
static gboolean OnButtonPress(GtkWidget* widget, GdkEventButton* event,
|
||||||
TabStripGtk* tabstrip);
|
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.
|
// Gets the number of Tabs in the collection.
|
||||||
int GetTabCount() const;
|
int GetTabCount() const;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user