OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/gtk/tabs/tab_strip_gtk.h" | 5 #include "chrome/browser/gtk/tabs/tab_strip_gtk.h" |
6 | 6 |
7 #include "base/gfx/gtk_util.h" | 7 #include "base/gfx/gtk_util.h" |
8 #include "base/gfx/point.h" | 8 #include "base/gfx/point.h" |
9 #include "chrome/browser/browser.h" | 9 #include "chrome/browser/browser.h" |
10 #include "chrome/browser/gtk/tabs/tab_button_gtk.h" | 10 #include "chrome/browser/gtk/tabs/tab_button_gtk.h" |
(...skipping 1161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1172 | 1172 |
1173 if (paint) | 1173 if (paint) |
1174 gtk_widget_queue_draw(tabstrip->tabstrip_.get()); | 1174 gtk_widget_queue_draw(tabstrip->tabstrip_.get()); |
1175 | 1175 |
1176 return TRUE; | 1176 return TRUE; |
1177 } | 1177 } |
1178 | 1178 |
1179 // static | 1179 // static |
1180 gboolean TabStripGtk::OnMousePress(GtkWidget* widget, GdkEventButton* event, | 1180 gboolean TabStripGtk::OnMousePress(GtkWidget* widget, GdkEventButton* event, |
1181 TabStripGtk* tabstrip) { | 1181 TabStripGtk* tabstrip) { |
| 1182 gfx::Point point(event->x, event->y); |
| 1183 |
1182 // Nothing happens on mouse press for middle and right click. | 1184 // Nothing happens on mouse press for middle and right click. |
1183 if (event->button != 1) | 1185 if (event->button != 1) |
1184 return TRUE; | 1186 return TRUE; |
1185 | 1187 |
1186 gfx::Point point(event->x, event->y); | 1188 // The hover index is stale if we're in the middle of an animation and the |
| 1189 // mouse is pressed without any movement. |
| 1190 if (tabstrip->active_animation_.get()) |
| 1191 tabstrip->hover_index_ = tabstrip->FindTabHoverIndexIterative(point); |
| 1192 |
1187 if (tabstrip->hover_index_ == -1) { | 1193 if (tabstrip->hover_index_ == -1) { |
1188 if (tabstrip->newtab_button_.get()->IsPointInBounds(point) && | 1194 if (tabstrip->newtab_button_.get()->IsPointInBounds(point) && |
1189 tabstrip->newtab_button_.get()->OnMousePress()) | 1195 tabstrip->newtab_button_.get()->OnMousePress()) |
1190 gtk_widget_queue_draw(tabstrip->tabstrip_.get()); | 1196 gtk_widget_queue_draw(tabstrip->tabstrip_.get()); |
1191 | 1197 |
1192 return TRUE; | 1198 return TRUE; |
1193 } | 1199 } |
1194 | 1200 |
1195 TabGtk* tab = tabstrip->GetTabAt(tabstrip->hover_index_); | 1201 TabGtk* tab = tabstrip->GetTabAt(tabstrip->hover_index_); |
| 1202 |
| 1203 // If a previous tab is closing, the hover index does not match the model |
| 1204 // index. |
| 1205 tabstrip->hover_index_ = tabstrip->GetIndexOfTab(tab); |
| 1206 |
1196 if (tab->OnMousePress(point)) { | 1207 if (tab->OnMousePress(point)) { |
1197 gtk_widget_queue_draw(tabstrip->tabstrip_.get()); | 1208 gtk_widget_queue_draw(tabstrip->tabstrip_.get()); |
1198 } else if (tabstrip->hover_index_ != tabstrip->model()->selected_index() && | 1209 } else if (tabstrip->hover_index_ != tabstrip->model()->selected_index() && |
1199 !tab->closing()) { | 1210 !tab->closing()) { |
1200 tabstrip->model()->SelectTabContentsAt(tabstrip->hover_index_, true); | 1211 tabstrip->model()->SelectTabContentsAt(tabstrip->hover_index_, true); |
1201 } | 1212 } |
1202 | 1213 |
1203 return TRUE; | 1214 return TRUE; |
1204 } | 1215 } |
1205 | 1216 |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1456 return TabStripModel::kNoTab; | 1467 return TabStripModel::kNoTab; |
1457 } | 1468 } |
1458 | 1469 |
1459 int TabStripGtk::NormalizeIndexToAttachedTabStrip(int index) { | 1470 int TabStripGtk::NormalizeIndexToAttachedTabStrip(int index) { |
1460 if (index >= model_->count()) | 1471 if (index >= model_->count()) |
1461 return model_->count() - 1; | 1472 return model_->count() - 1; |
1462 if (index == TabStripModel::kNoTab) | 1473 if (index == TabStripModel::kNoTab) |
1463 return 0; | 1474 return 0; |
1464 return index; | 1475 return index; |
1465 } | 1476 } |
OLD | NEW |