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 0b48e712542b09efa7c1b3bc54b65cbf6a85d841..7fff1e9c3df45449a880f33580f733ee1c381380 100644 |
--- a/chrome/browser/ui/views/tabs/tab_drag_controller.cc |
+++ b/chrome/browser/ui/views/tabs/tab_drag_controller.cc |
@@ -47,6 +47,7 @@ |
#if defined(USE_ASH) |
#include "ash/shell.h" |
#include "ash/wm/property_util.h" |
+#include "ash/wm/window_util.h" |
#include "ui/aura/env.h" |
#include "ui/aura/root_window.h" |
#include "ui/base/gestures/gesture_recognizer.h" |
@@ -191,6 +192,12 @@ void SetTrackedByWorkspace(gfx::NativeWindow window, bool value) { |
#endif |
} |
+void SetWindowPositionManaged(gfx::NativeWindow window, bool value) { |
+#if defined(USE_ASH) |
+ ash::wm::SetWindowPositionManaged(window, value); |
+#endif |
+} |
+ |
bool ShouldDetachIntoNewBrowser() { |
#if defined(USE_AURA) |
return true; |
@@ -211,6 +218,19 @@ bool DoesRectContainVerticalPointExpanded( |
return y >= lower_threshold && y <= upper_threshold; |
} |
+// WidgetObserver implementation that resets the window position managed |
+// property on Show. |
+// We're forced to do this here since BrowserFrameAura resets the 'window |
+// position managed' property during a show and we need the property set to |
+// false before WorkspaceLayoutManager2 sees the visibility change. |
+class WindowPositionManagedUpdater : public views::WidgetObserver { |
+ public: |
+ virtual void OnWidgetVisibilityChanged(views::Widget* widget, |
+ bool visible) OVERRIDE { |
+ SetWindowPositionManaged(widget->GetNativeView(), false); |
+ } |
+}; |
+ |
} // namespace |
/////////////////////////////////////////////////////////////////////////////// |
@@ -373,6 +393,7 @@ TabDragController::~TabDragController() { |
if (move_loop_widget_) { |
move_loop_widget_->RemoveObserver(this); |
SetTrackedByWorkspace(move_loop_widget_->GetNativeView(), true); |
+ SetWindowPositionManaged(move_loop_widget_->GetNativeView(), true); |
} |
if (source_tabstrip_ && detach_into_browser_) |
@@ -829,6 +850,10 @@ TabDragController::DragBrowserToNewTabStrip( |
#else |
target_tabstrip->GetWidget()->SetCapture(attached_tabstrip_); |
#endif |
+ // The window is going away. Since the drag is still on going we don't want |
+ // that to effect the position of any windows. |
+ SetWindowPositionManaged(browser_widget->GetNativeView(), false); |
+ |
// EndMoveLoop is going to snap the window back to its original location. |
// Hide it so users don't see this. |
browser_widget->Hide(); |
@@ -1299,7 +1324,11 @@ void TabDragController::DetachIntoNewBrowserAndRunMoveLoop( |
// TODO: come up with a cleaner way to do this. |
attached_tabstrip_->SetTabBoundsForDrag(drag_bounds); |
+ WindowPositionManagedUpdater updater; |
+ dragged_browser_view->GetWidget()->AddObserver(&updater); |
browser->window()->Show(); |
+ dragged_browser_view->GetWidget()->RemoveObserver(&updater); |
+ |
browser->window()->Activate(); |
dragged_browser_view->GetWidget()->SetVisibilityChangedAnimationsEnabled( |
true); |
@@ -1556,8 +1585,11 @@ void TabDragController::EndDragImpl(EndDragType type) { |
// happens we ignore it. |
waiting_for_run_loop_to_exit_ = true; |
- if (type == NORMAL || (type == TAB_DESTROYED && drag_data_.size() > 1)) |
+ if (type == NORMAL || (type == TAB_DESTROYED && drag_data_.size() > 1)) { |
SetTrackedByWorkspace(GetAttachedBrowserWidget()->GetNativeView(), true); |
+ SetWindowPositionManaged(GetAttachedBrowserWidget()->GetNativeView(), |
+ true); |
+ } |
// End the nested drag loop. |
GetAttachedBrowserWidget()->EndMoveLoop(); |
@@ -1970,6 +2002,7 @@ Browser* TabDragController::CreateBrowserForDrag( |
create_params.initial_bounds = new_bounds; |
Browser* browser = new Browser(create_params); |
SetTrackedByWorkspace(browser->window()->GetNativeWindow(), false); |
+ SetWindowPositionManaged(browser->window()->GetNativeWindow(), false); |
// If the window is created maximized then the bounds we supplied are ignored. |
// We need to reset them again so they are honored. |
browser->window()->SetBounds(new_bounds); |