Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2229)

Unified Diff: chrome/browser/ui/views/tabs/tab_drag_controller.cc

Issue 2550533002: Revert of Reenable Tabdragging tests failing because of IsWindowPositionManaged() (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 3cecca31206c72790719ba6182b526dc3480f496..52d3b4baa578791dc7ee93fc4c5d08c680d3518c 100644
--- a/chrome/browser/ui/views/tabs/tab_drag_controller.cc
+++ b/chrome/browser/ui/views/tabs/tab_drag_controller.cc
@@ -86,6 +86,10 @@
const int kMaximizedWindowInset = 10; // DIPs.
#if defined(USE_ASH)
+void SetWindowPositionManaged(gfx::NativeWindow window, bool value) {
+ ash::wm::GetWindowState(window)->set_window_position_managed(value);
+}
+
// Returns true if |tab_strip| browser window is docked.
bool IsDockedOrSnapped(const TabStrip* tab_strip) {
DCHECK(tab_strip);
@@ -94,6 +98,9 @@
return window_state->IsDocked() || window_state->IsSnapped();
}
#else
+void SetWindowPositionManaged(gfx::NativeWindow window, bool value) {
+}
+
bool IsDockedOrSnapped(const TabStrip* tab_strip) {
return false;
}
@@ -129,6 +136,18 @@
for (size_t i = 0; i < rects->size(); ++i)
(*rects)[i].set_x((*rects)[i].x() + x_offset);
}
+
+// WidgetObserver implementation that resets the window position managed
+// property on Show.
+// We're forced to do this here since BrowserFrameAsh resets the 'window
+// position managed' property during a show and we need the property set to
+// false before WorkspaceLayoutManager sees the visibility change.
+class WindowPositionManagedUpdater : public views::WidgetObserver {
+ public:
+ void OnWidgetVisibilityChanged(views::Widget* widget, bool visible) override {
+ SetWindowPositionManaged(widget->GetNativeWindow(), false);
+ }
+};
// EscapeTracker installs an event monitor and runs a callback when it receives
// the escape key.
@@ -217,6 +236,7 @@
if (move_loop_widget_) {
if (added_observer_to_move_loop_widget_)
move_loop_widget_->RemoveObserver(this);
+ SetWindowPositionManaged(move_loop_widget_->GetNativeWindow(), true);
}
if (source_tabstrip_)
@@ -596,6 +616,10 @@
else
target_tabstrip->GetWidget()->SetCapture(attached_tabstrip_);
+ // 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->GetNativeWindow(), false);
+
#if !defined(OS_LINUX) || defined(OS_CHROMEOS)
// EndMoveLoop is going to snap the window back to its original location.
// Hide it so users don't see this. Hiding a window in Linux aura causes
@@ -1035,7 +1059,10 @@
AdjustBrowserAndTabBoundsForDrag(last_tabstrip_width,
point_in_screen,
&drag_bounds);
+ WindowPositionManagedUpdater updater;
+ dragged_widget->AddObserver(&updater);
browser->window()->Show();
+ dragged_widget->RemoveObserver(&updater);
dragged_widget->SetVisibilityChangedAnimationsEnabled(true);
// Activate may trigger a focus loss, destroying us.
{
@@ -1086,7 +1113,7 @@
return;
if (move_loop_widget_) {
move_loop_widget_->RemoveObserver(this);
- move_loop_widget_ = nullptr;
+ move_loop_widget_ = NULL;
}
is_dragging_window_ = false;
waiting_for_run_loop_to_exit_ = false;
@@ -1325,6 +1352,11 @@
if (is_dragging_window_) {
waiting_for_run_loop_to_exit_ = true;
+
+ if (type == NORMAL || (type == TAB_DESTROYED && drag_data_.size() > 1)) {
+ SetWindowPositionManaged(GetAttachedBrowserWidget()->GetNativeWindow(),
+ true);
+ }
// End the nested drag loop.
GetAttachedBrowserWidget()->EndMoveLoop();
@@ -1736,6 +1768,7 @@
create_params.initial_bounds = new_bounds;
Browser* browser = new Browser(create_params);
is_dragging_new_browser_ = true;
+ 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);

Powered by Google App Engine
This is Rietveld 408576698