Chromium Code Reviews| Index: chrome/browser/ui/views/tabs/tab_drag_controller.cc |
| diff --git a/chrome/browser/ui/views/tabs/tab_drag_controller.cc b/chrome/browser/ui/views/tabs/tab_drag_controller.cc |
| index eb5dd067822b015bd313fcb34c30eb42867f885c..db5912516131f1df393f5c3c760c0edce35f5dfe 100644 |
| --- a/chrome/browser/ui/views/tabs/tab_drag_controller.cc |
| +++ b/chrome/browser/ui/views/tabs/tab_drag_controller.cc |
| @@ -85,6 +85,15 @@ const int kStackedDistance = 36; |
| // maximized size. |
| const int kMaximizedWindowInset = 10; // DIPs. |
| +// Whether a new browser window created during a drag is destroyed immediately |
| +// once it is associated with a new tab strip. If false, windows created during |
| +// the drag are destroyed only when the drag ends. |
| +#if 0 && defined(OS_MACOSX) |
| +const bool windows_destroy_during_drag = false; |
| +#else |
| +const bool windows_destroy_during_drag = true; |
| +#endif |
| + |
| #if defined(USE_ASH) |
| void SetWindowPositionManaged(gfx::NativeWindow window, bool value) { |
| ash::wm::GetWindowState(window)->set_window_position_managed(value); |
| @@ -381,7 +390,7 @@ void TabDragController::Drag(const gfx::Point& point_in_screen) { |
| &drag_bounds); |
| widget->SetVisibilityChangedAnimationsEnabled(true); |
| } |
| - RunMoveLoop(GetWindowOffset(point_in_screen)); |
| + RunMoveLoop(GetWindowOffset(start_point_in_screen_)); |
|
themblsha
2016/03/03 17:56:51
Without this fix the first mouse move after pressi
|
| return; |
| } |
| } |
| @@ -523,8 +532,9 @@ bool TabDragController::CanStartDrag(const gfx::Point& point_in_screen) const { |
| static const int kMinimumDragDistance = 10; |
| int x_offset = abs(point_in_screen.x() - start_point_in_screen_.x()); |
| int y_offset = abs(point_in_screen.y() - start_point_in_screen_.y()); |
| - return sqrt(pow(static_cast<float>(x_offset), 2) + |
| + bool result = sqrt(pow(static_cast<float>(x_offset), 2) + |
| pow(static_cast<float>(y_offset), 2)) > kMinimumDragDistance; |
| + return result; |
| } |
| void TabDragController::ContinueDragging(const gfx::Point& point_in_screen) { |
| @@ -607,6 +617,14 @@ TabDragController::DragBrowserToNewTabStrip( |
| // going to trigger capture lost, which cancels drag. |
| attached_tabstrip_->ReleaseDragController(); |
| target_tabstrip->OwnDragController(this); |
| + if (!windows_destroy_during_drag) { |
| + Detach(DONT_RELEASE_CAPTURE); |
| + Attach(target_tabstrip, point_in_screen); |
| + // Move the tabs into position. |
| + // MoveAttached(point_in_screen); // assumes !is_dragging_window_ |
| + return DRAG_BROWSER_RESULT_CONTINUE; |
| + } |
| + |
| // Disable animations so that we don't see a close animation on aero. |
| browser_widget->SetVisibilityChangedAnimationsEnabled(false); |
| if (can_release_capture_) |
| @@ -889,6 +907,8 @@ void TabDragController::Attach(TabStrip* attached_tabstrip, |
| std::vector<Tab*> tabs = |
| GetTabsMatchingDraggedContents(attached_tabstrip_); |
| + bool acquire_capture = true; |
| + |
| if (tabs.empty()) { |
| // Transitioning from detached to attached to a new tabstrip. Add tabs to |
| // the new model. |
| @@ -928,6 +948,10 @@ void TabDragController::Attach(TabStrip* attached_tabstrip, |
| } |
| tabs = GetTabsMatchingDraggedContents(attached_tabstrip_); |
| + |
| + // If the windows are kept, there's no need to re-acquire capture. Instead, |
| + // the TabDragController remains in a MoveLoop. |
| + acquire_capture = windows_destroy_during_drag; |
| } |
| DCHECK_EQ(tabs.size(), drag_data_.size()); |
| for (size_t i = 0; i < drag_data_.size(); ++i) |
| @@ -951,7 +975,8 @@ void TabDragController::Attach(TabStrip* attached_tabstrip, |
| // Transfer ownership of us to the new tabstrip as well as making sure the |
| // window has capture. This is important so that if activation changes the |
| // drag isn't prematurely canceled. |
| - attached_tabstrip_->GetWidget()->SetCapture(attached_tabstrip_); |
| + if (acquire_capture) |
| + attached_tabstrip_->GetWidget()->SetCapture(attached_tabstrip_); |
| attached_tabstrip_->OwnDragController(this); |
| } |