OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 } | 319 } |
320 | 320 |
321 void TabGtk::DestroyDragWidget() { | 321 void TabGtk::DestroyDragWidget() { |
322 if (drag_widget_) { | 322 if (drag_widget_) { |
323 gtk_widget_destroy(drag_widget_); | 323 gtk_widget_destroy(drag_widget_); |
324 drag_widget_ = NULL; | 324 drag_widget_ = NULL; |
325 } | 325 } |
326 } | 326 } |
327 | 327 |
328 void TabGtk::StartDragging(gfx::Point drag_offset) { | 328 void TabGtk::StartDragging(gfx::Point drag_offset) { |
| 329 // If the drag is processed after the selection change it's possible |
| 330 // that the tab has been deselected, in which case we don't want to drag. |
| 331 if (!IsSelected()) |
| 332 return; |
| 333 |
329 CreateDragWidget(); | 334 CreateDragWidget(); |
330 | 335 |
331 GtkTargetList* list = ui::GetTargetListFromCodeMask(ui::CHROME_TAB); | 336 GtkTargetList* list = ui::GetTargetListFromCodeMask(ui::CHROME_TAB); |
332 gtk_drag_begin(drag_widget_, list, GDK_ACTION_MOVE, | 337 gtk_drag_begin(drag_widget_, list, GDK_ACTION_MOVE, |
333 1, // Drags are always initiated by the left button. | 338 1, // Drags are always initiated by the left button. |
334 last_mouse_down_); | 339 last_mouse_down_); |
335 // gtk_drag_begin adds a reference to list, so unref it here. | 340 // gtk_drag_begin adds a reference to list, so unref it here. |
336 gtk_target_list_unref(list); | 341 gtk_target_list_unref(list); |
337 delegate_->MaybeStartDrag(this, drag_offset); | 342 delegate_->MaybeStartDrag(this, drag_offset); |
338 } | 343 } |
(...skipping 14 matching lines...) Expand all Loading... |
353 gdk_event_free(last_mouse_down_); | 358 gdk_event_free(last_mouse_down_); |
354 last_mouse_down_ = NULL; | 359 last_mouse_down_ = NULL; |
355 } | 360 } |
356 | 361 |
357 // Notify the drag helper that we're done with any potential drag operations. | 362 // Notify the drag helper that we're done with any potential drag operations. |
358 // Clean up the drag helper, which is re-created on the next mouse press. | 363 // Clean up the drag helper, which is re-created on the next mouse press. |
359 delegate_->EndDrag(canceled); | 364 delegate_->EndDrag(canceled); |
360 | 365 |
361 observer_.reset(); | 366 observer_.reset(); |
362 } | 367 } |
OLD | NEW |