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 fd690c3339091c63309980637be68a86bfd3c5d6..1fa89ce8ce172cceced871627597644f07d05aba 100644 |
--- a/chrome/browser/ui/views/tabs/tab_drag_controller.cc |
+++ b/chrome/browser/ui/views/tabs/tab_drag_controller.cc |
@@ -484,7 +484,8 @@ void TabDragController::Drag(const gfx::Point& point_in_screen) { |
Attach(source_tabstrip_, gfx::Point()); |
if (detach_into_browser_ && static_cast<int>(drag_data_.size()) == |
GetModel(source_tabstrip_)->count()) { |
- RunMoveLoop(); // Runs a nested loop, returning when done. |
+ gfx::Point dragged_view_point = GetWindowOffset(point_in_screen); |
+ RunMoveLoop(dragged_view_point); |
return; |
} |
} |
@@ -1166,6 +1167,11 @@ void TabDragController::Attach(TabStrip* attached_tabstrip, |
tabs[source_tab_index_]->width()); |
mouse_offset_.set_x(new_x); |
+ views::View* toplevel_view = |
+ attached_tabstrip->GetWidget()->GetContentsView(); |
+ window_mouse_offset_ = point_in_screen; |
+ views::View::ConvertPointFromScreen(toplevel_view, &window_mouse_offset_); |
+ |
// 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. |
@@ -1266,7 +1272,8 @@ void TabDragController::DetachIntoNewBrowserAndRunMoveLoop( |
// All the tabs in a browser are being dragged but all the tabs weren't |
// initially being dragged. For this to happen the user would have to |
// start dragging a set of tabs, the other tabs close, then detach. |
- RunMoveLoop(); |
+ gfx::Point dragged_view_point = GetWindowOffset(point_in_screen); |
+ RunMoveLoop(dragged_view_point); |
return; |
} |
@@ -1280,8 +1287,9 @@ void TabDragController::DetachIntoNewBrowserAndRunMoveLoop( |
std::vector<gfx::Rect> drag_bounds = |
CalculateBoundsForDraggedTabs(attached_point.x()); |
+ gfx::Point drag_offset; |
Browser* browser = CreateBrowserForDrag( |
- attached_tabstrip_, point_in_screen, &drag_bounds); |
+ attached_tabstrip_, point_in_screen, &drag_offset, &drag_bounds); |
Detach(DONT_RELEASE_CAPTURE); |
BrowserView* dragged_browser_view = |
BrowserView::GetBrowserViewForBrowser(browser); |
@@ -1295,10 +1303,10 @@ void TabDragController::DetachIntoNewBrowserAndRunMoveLoop( |
browser->window()->Activate(); |
dragged_browser_view->GetWidget()->SetVisibilityChangedAnimationsEnabled( |
true); |
- RunMoveLoop(); |
+ RunMoveLoop(drag_offset); |
} |
-void TabDragController::RunMoveLoop() { |
+void TabDragController::RunMoveLoop(const gfx::Point& drag_offset) { |
// If the user drags the whole window we'll assume they are going to attach to |
// another window and therefor want to reorder. |
move_behavior_ = REORDER; |
@@ -1317,7 +1325,8 @@ void TabDragController::RunMoveLoop() { |
attached_tabstrip_->GetWidget()->ReleaseCapture(); |
attached_tabstrip_->OwnDragController(this); |
#endif |
- views::Widget::MoveLoopResult result = move_loop_widget_->RunMoveLoop(); |
+ views::Widget::MoveLoopResult result = |
+ move_loop_widget_->RunMoveLoop(drag_offset); |
content::NotificationService::current()->Notify( |
chrome::NOTIFICATION_TAB_DRAG_LOOP_DONE, |
content::NotificationService::AllBrowserContextsAndSources(), |
@@ -1915,6 +1924,7 @@ bool TabDragController::AreTabsConsecutive() { |
Browser* TabDragController::CreateBrowserForDrag( |
TabStrip* source, |
const gfx::Point& point_in_screen, |
+ gfx::Point* drag_offset, |
std::vector<gfx::Rect>* drag_bounds) { |
Browser* browser = new Browser( |
Browser::CreateParams(drag_data_[0].contents->profile())); |
@@ -1943,6 +1953,8 @@ Browser* TabDragController::CreateBrowserForDrag( |
break; // Nothing to do for DETACH_ABOVE_OR_BELOW. |
} |
+ *drag_offset = point_in_screen.Subtract(new_bounds.origin()); |
+ |
SetTrackedByWorkspace(browser->window()->GetNativeWindow(), false); |
browser->window()->SetBounds(new_bounds); |
return browser; |
@@ -1965,3 +1977,14 @@ gfx::Point TabDragController::GetCursorScreenPoint() { |
#endif |
return gfx::Screen::GetCursorScreenPoint(); |
} |
+ |
+gfx::Point TabDragController::GetWindowOffset( |
+ const gfx::Point& point_in_screen) { |
+ TabStrip* owning_tabstrip = (attached_tabstrip_ && detach_into_browser_) ? |
+ attached_tabstrip_ : source_tabstrip_; |
+ views::View* toplevel_view = owning_tabstrip->GetWidget()->GetContentsView(); |
+ |
+ gfx::Point offset = point_in_screen; |
+ views::View::ConvertPointFromScreen(toplevel_view, &offset); |
+ return offset; |
+} |