| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ui/gtk/tabs/tab_gtk.h" | 5 #include "chrome/browser/ui/gtk/tabs/tab_gtk.h" |
| 6 | 6 |
| 7 #include <gdk/gdkkeysyms.h> | 7 #include <gdk/gdkkeysyms.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 delegate_->ActivateTab(this); | 150 delegate_->ActivateTab(this); |
| 151 } | 151 } |
| 152 observer_.reset(); | 152 observer_.reset(); |
| 153 | 153 |
| 154 if (last_mouse_down_) { | 154 if (last_mouse_down_) { |
| 155 gdk_event_free(last_mouse_down_); | 155 gdk_event_free(last_mouse_down_); |
| 156 last_mouse_down_ = NULL; | 156 last_mouse_down_ = NULL; |
| 157 } | 157 } |
| 158 } | 158 } |
| 159 | 159 |
| 160 GtkAllocation allocation; |
| 161 gtk_widget_get_allocation(widget, &allocation); |
| 162 |
| 160 // Middle mouse up means close the tab, but only if the mouse is over it | 163 // Middle mouse up means close the tab, but only if the mouse is over it |
| 161 // (like a button). | 164 // (like a button). |
| 162 if (event->button == 2 && | 165 if (event->button == 2 && |
| 163 event->x >= 0 && event->y >= 0 && | 166 event->x >= 0 && event->y >= 0 && |
| 164 event->x < widget->allocation.width && | 167 event->x < allocation.width && |
| 165 event->y < widget->allocation.height) { | 168 event->y < allocation.height) { |
| 166 // If the user is currently holding the left mouse button down but hasn't | 169 // If the user is currently holding the left mouse button down but hasn't |
| 167 // moved the mouse yet, a drag hasn't started yet. In that case, clean up | 170 // moved the mouse yet, a drag hasn't started yet. In that case, clean up |
| 168 // some state before closing the tab to avoid a crash. Once the drag has | 171 // some state before closing the tab to avoid a crash. Once the drag has |
| 169 // started, we don't get the middle mouse click here. | 172 // started, we don't get the middle mouse click here. |
| 170 if (last_mouse_down_) { | 173 if (last_mouse_down_) { |
| 171 DCHECK(!drag_widget_); | 174 DCHECK(!drag_widget_); |
| 172 observer_.reset(); | 175 observer_.reset(); |
| 173 gdk_event_free(last_mouse_down_); | 176 gdk_event_free(last_mouse_down_); |
| 174 last_mouse_down_ = NULL; | 177 last_mouse_down_ = NULL; |
| 175 } | 178 } |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 gdk_event_free(last_mouse_down_); | 351 gdk_event_free(last_mouse_down_); |
| 349 last_mouse_down_ = NULL; | 352 last_mouse_down_ = NULL; |
| 350 } | 353 } |
| 351 | 354 |
| 352 // Notify the drag helper that we're done with any potential drag operations. | 355 // Notify the drag helper that we're done with any potential drag operations. |
| 353 // Clean up the drag helper, which is re-created on the next mouse press. | 356 // Clean up the drag helper, which is re-created on the next mouse press. |
| 354 delegate_->EndDrag(canceled); | 357 delegate_->EndDrag(canceled); |
| 355 | 358 |
| 356 observer_.reset(); | 359 observer_.reset(); |
| 357 } | 360 } |
| OLD | NEW |