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..a9647501885c86f4f3ff372a5a6e99517d7d9884 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,27 @@ 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_fullscreen_ || was_source_maximized_) { |
+ views::Widget* widget = GetAttachedBrowserWidget(); |
+ WindowPositionManagedUpdater updater; |
+ widget->AddObserver(&updater); |
+ widget->SetVisibilityChangedAnimationsEnabled(false); |
+ widget->Hide(); |
varkha
2013/11/21 16:59:35
I need to see if this breaks non-metro Windows.
|
+ std::vector<gfx::Rect> drag_bounds = CalculateBoundsForDraggedTabs(); |
+ gfx::Rect new_bounds(CalculateDraggedBrowserBounds(source_tabstrip_, |
+ point_in_screen, |
+ &drag_bounds)); |
+ widget->Restore(); |
+ widget->SetBounds(new_bounds); |
+ widget->Show(); |
+ widget->RemoveObserver(&updater); |
+ widget->SetVisibilityChangedAnimationsEnabled(true); |
+ |
+ // Mouse handler was lost when the browser widget was hidden. |
+ // Reestablish the event handler. |
+ static_cast<views::internal::RootView*>( |
+ widget->GetRootView())->SetMouseHandler(attached_tabstrip_); |
+ } |
RunMoveLoop(GetWindowOffset(point_in_screen)); |
return; |
} |
@@ -1934,32 +1958,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 +2262,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); |
@@ -2269,10 +2282,6 @@ Browser* TabDragController::CreateBrowserForDrag( |
} |
new_bounds.set_y(point_in_screen.y() - center.y()); |
switch (GetDetachPosition(point_in_screen)) { |
- case DETACH_BEFORE: |
- new_bounds.set_x(point_in_screen.x() - center.x()); |
- new_bounds.Offset(-mouse_offset_.x(), 0); |
- break; |
case DETACH_AFTER: { |
gfx::Point right_edge(source->width(), 0); |
views::View::ConvertPointToWidget(source, &right_edge); |
@@ -2281,8 +2290,11 @@ Browser* TabDragController::CreateBrowserForDrag( |
OffsetX(-(*drag_bounds)[0].x(), drag_bounds); |
break; |
} |
+ case DETACH_BEFORE: |
sky
2013/11/21 16:43:07
Why are you changing this?
varkha
2013/11/21 16:59:35
It does not seem to break the existing case and ma
sky
2013/11/21 17:15:35
I wanted dragging up/down to appear to tear a new
varkha
2013/11/21 17:23:10
That is what it seems to be doing (still in the ol
varkha
2013/11/21 20:34:48
I understand now - the case I broke was dragging t
|
default: |
- break; // Nothing to do for DETACH_ABOVE_OR_BELOW. |
+ new_bounds.set_x(point_in_screen.x() - center.x()); |
+ new_bounds.Offset(-mouse_offset_.x(), 0); |
+ break; |
} |
// To account for the extra vertical on restored windows that is absent on |
@@ -2290,7 +2302,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 = |