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 b6660f35767649d7ca8b4b79932e202553a63ebb..6887581439db347a47d39d2033b2ded38aff203f 100644 |
| --- a/chrome/browser/ui/views/tabs/tab_drag_controller.cc |
| +++ b/chrome/browser/ui/views/tabs/tab_drag_controller.cc |
| @@ -210,11 +210,14 @@ void SetWindowPositionManaged(gfx::NativeWindow window, bool value) { |
| } |
| // Returns true if |tab_strip| browser window is docked. |
| -bool IsDocked(const TabStrip* tab_strip) { |
| +bool IsDockedOrSnapped(const TabStrip* tab_strip) { |
| #if defined(USE_ASH) |
| DCHECK(tab_strip); |
| - return ash::wm::GetWindowState( |
| - tab_strip->GetWidget()->GetNativeWindow())->IsDocked(); |
| + ash::wm::WindowState* window_state = |
| + ash::wm::GetWindowState(tab_strip->GetWidget()->GetNativeWindow()); |
| + return window_state->IsDocked() || |
| + window_state->window_show_type() == ash::wm::SHOW_TYPE_LEFT_SNAPPED || |
| + window_state->window_show_type() == ash::wm::SHOW_TYPE_RIGHT_SNAPPED; |
| #endif |
| return false; |
| } |
| @@ -546,6 +549,23 @@ 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()) { |
| + if (was_source_maximized_ || was_source_fullscreen_) { |
| + // When all tabs in a maximized browser are dragged the browser gets |
| + // restored during the drag and maximized back when the drag ends. |
| + views::Widget* widget = GetAttachedBrowserWidget(); |
| + std::vector<gfx::Rect> drag_bounds = CalculateBoundsForDraggedTabs(); |
|
sky
2013/11/21 23:29:29
Does this do the right thing if you have lots of t
varkha
2013/11/22 02:57:16
Thanks for noticing this. I think I was missing a
|
| + OffsetX(GetAttachedDragPoint(point_in_screen).x(), &drag_bounds); |
| + gfx::Rect new_bounds(CalculateDraggedBrowserBounds(source_tabstrip_, |
| + point_in_screen, |
| + &drag_bounds)); |
| + new_bounds.Offset(-widget->GetRestoredBounds().x() + |
| + point_in_screen.x() - |
| + mouse_offset_.x(), 0); |
| + widget->SetVisibilityChangedAnimationsEnabled(false); |
| + widget->Restore(); |
| + widget->SetBounds(new_bounds); |
| + widget->SetVisibilityChangedAnimationsEnabled(true); |
| + } |
| RunMoveLoop(GetWindowOffset(point_in_screen)); |
| return; |
| } |
| @@ -1934,32 +1954,22 @@ void TabDragController::CompleteDrag() { |
| DCHECK(started_drag_); |
| if (attached_tabstrip_) { |
| - if (is_dragging_new_browser_) { |
| - if (IsDocked(attached_tabstrip_)) { |
| - DCHECK_EQ(host_desktop_type_, chrome::HOST_DESKTOP_TYPE_ASH); |
| - was_source_maximized_ = false; |
| - was_source_fullscreen_ = false; |
| - } |
| - // If source window was maximized - maximize the new window as well. |
| - if (was_source_maximized_) |
| - attached_tabstrip_->GetWidget()->Maximize(); |
| + if (IsDockedOrSnapped(attached_tabstrip_)) { |
| + DCHECK_EQ(host_desktop_type_, chrome::HOST_DESKTOP_TYPE_ASH); |
| + was_source_maximized_ = false; |
| + was_source_fullscreen_ = false; |
| + } |
| + // If source window was maximized - maximize the new window as well. |
| + if (was_source_maximized_ || was_source_fullscreen_) |
| + GetAttachedBrowserWidget()->Maximize(); |
| #if defined(USE_ASH) |
| - if (was_source_fullscreen_ && |
| - host_desktop_type_ == chrome::HOST_DESKTOP_TYPE_ASH) { |
| - // In fullscreen mode it is only possible to get here if the source |
| - // was in "immersive fullscreen" mode, so toggle it back on. |
| - ash::accelerators::ToggleFullscreen(); |
| - } |
| -#endif |
| - } else { |
| - // When dragging results in maximized or fullscreen browser window getting |
| - // docked, restore it. |
| - if ((was_source_fullscreen_ || was_source_maximized_) && |
| - (IsDocked(attached_tabstrip_))) { |
| - DCHECK_EQ(host_desktop_type_, chrome::HOST_DESKTOP_TYPE_ASH); |
| - attached_tabstrip_->GetWidget()->Restore(); |
| - } |
| + if (was_source_fullscreen_ && |
| + host_desktop_type_ == chrome::HOST_DESKTOP_TYPE_ASH) { |
| + // In fullscreen mode it is only possible to get here if the source |
| + // was in "immersive fullscreen" mode, so toggle it back on. |
| + ash::accelerators::ToggleFullscreen(); |
| } |
| +#endif |
| attached_tabstrip_->StoppedDraggingTabs( |
| GetTabsMatchingDraggedContents(attached_tabstrip_), |
| initial_tab_positions_, |
| @@ -2248,10 +2258,9 @@ bool TabDragController::AreTabsConsecutive() { |
| return true; |
| } |
| -Browser* TabDragController::CreateBrowserForDrag( |
| +gfx::Rect TabDragController::CalculateDraggedBrowserBounds( |
| TabStrip* source, |
| const gfx::Point& point_in_screen, |
| - gfx::Vector2d* drag_offset, |
| std::vector<gfx::Rect>* drag_bounds) { |
| gfx::Point center(0, source->height() / 2); |
| views::View::ConvertPointToWidget(source, ¢er); |
| @@ -2290,7 +2299,17 @@ Browser* TabDragController::CreateBrowserForDrag( |
| // strip. |
| if (source->GetWidget()->IsMaximized()) |
| new_bounds.Offset(0, -source->button_v_offset()); |
| + return new_bounds; |
| +} |
| +Browser* TabDragController::CreateBrowserForDrag( |
| + TabStrip* source, |
| + const gfx::Point& point_in_screen, |
| + gfx::Vector2d* drag_offset, |
| + std::vector<gfx::Rect>* drag_bounds) { |
| + gfx::Rect new_bounds(CalculateDraggedBrowserBounds(source, |
| + point_in_screen, |
| + drag_bounds)); |
| *drag_offset = point_in_screen - new_bounds.origin(); |
| Profile* profile = |