summaryrefslogtreecommitdiffstats
path: root/ash/wm/dock
diff options
context:
space:
mode:
authorvarkha <varkha@chromium.org>2015-06-04 15:46:01 -0700
committerCommit bot <commit-bot@chromium.org>2015-06-04 22:46:40 +0000
commit1bd474bdb2edc77733d347ddbbfabe81ef36c09b (patch)
tree75c7995f203c97768fba4acf7ba6fee543fb23c0 /ash/wm/dock
parent5f7fab58725d10b1ccb26f70c3dfcfc19610f259 (diff)
downloadchromium_src-1bd474bdb2edc77733d347ddbbfabe81ef36c09b.zip
chromium_src-1bd474bdb2edc77733d347ddbbfabe81ef36c09b.tar.gz
chromium_src-1bd474bdb2edc77733d347ddbbfabe81ef36c09b.tar.bz2
Doesn't save restore size for dragged docked windows
The code used to save width for the docked window assuming that the user actually intended window resizes while a window is docked to be persistent. This assumption is however wrong in most cases so this CL treats those resizes as temporary - when a window is undocked it gets resized to the restore size that existed before it was docked. This makes entering docked state more like entering maximized mode in which any size changes are not persisted and window gets its restore bounds when it gets restored. BUG=496859 TEST=DockedWindowResizerTest.ResizingKeepsSize Review URL: https://codereview.chromium.org/1155123004 Cr-Commit-Position: refs/heads/master@{#332946}
Diffstat (limited to 'ash/wm/dock')
-rw-r--r--ash/wm/dock/docked_window_resizer.cc7
-rw-r--r--ash/wm/dock/docked_window_resizer_unittest.cc21
2 files changed, 13 insertions, 15 deletions
diff --git a/ash/wm/dock/docked_window_resizer.cc b/ash/wm/dock/docked_window_resizer.cc
index 91486c6..4f92f23 100644
--- a/ash/wm/dock/docked_window_resizer.cc
+++ b/ash/wm/dock/docked_window_resizer.cc
@@ -236,12 +236,11 @@ void DockedWindowResizer::FinishedDragging(
window->SetBounds(bounds);
}
}
- // If a window has restore bounds, update the restore origin and width but not
- // the height (since the height is auto-calculated for the docked windows).
+ // If a window has restore bounds, update the restore origin but not the size.
+ // The size gets restored when a window is undocked.
if (is_resized && is_docked_ && window_state_->HasRestoreBounds()) {
gfx::Rect restore_bounds = window->GetBoundsInScreen();
- restore_bounds.set_height(
- window_state_->GetRestoreBoundsInScreen().height());
+ restore_bounds.set_size(window_state_->GetRestoreBoundsInScreen().size());
window_state_->SetRestoreBoundsInScreen(restore_bounds);
}
diff --git a/ash/wm/dock/docked_window_resizer_unittest.cc b/ash/wm/dock/docked_window_resizer_unittest.cc
index 6316176..6ace192b 100644
--- a/ash/wm/dock/docked_window_resizer_unittest.cc
+++ b/ash/wm/dock/docked_window_resizer_unittest.cc
@@ -1190,14 +1190,17 @@ TEST_P(DockedWindowResizerTest, ResizeOneOfTwoWindows) {
ScreenUtil::GetDisplayWorkAreaBoundsInParent(w1.get()).width());
}
-// Dock a window, resize it and test that undocking it preserves the width.
-TEST_P(DockedWindowResizerTest, ResizingKeepsWidth) {
+// Dock a window, resize it and test that undocking it restores the pre-docked
+// size.
+TEST_P(DockedWindowResizerTest, ResizingKeepsSize) {
if (!SupportsHostWindowResize())
return;
// Wider display to start since panels are limited to half the display width.
UpdateDisplay("1000x600");
- scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
+ const gfx::Size original_size(201, 201);
+ scoped_ptr<aura::Window> w1(
+ CreateTestWindow(gfx::Rect(gfx::Point(), original_size)));
DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20);
// Window should be docked at the right edge.
@@ -1230,10 +1233,8 @@ TEST_P(DockedWindowResizerTest, ResizingKeepsWidth) {
// Undock by dragging almost to the left edge.
DragToVerticalPositionRelativeToEdge(DOCKED_EDGE_LEFT, w1.get(), 100, 20);
- // Width should be preserved.
- EXPECT_EQ(previous_width + kResizeSpan1, w1->bounds().width());
- // Height should be restored to what it was originally.
- EXPECT_EQ(201, w1->bounds().height());
+ // Size should be restored to what it was originally.
+ EXPECT_EQ(original_size.ToString(), w1->bounds().size().ToString());
// Dock again.
DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20);
@@ -1242,10 +1243,8 @@ TEST_P(DockedWindowResizerTest, ResizingKeepsWidth) {
// Undock again by dragging left.
DragToVerticalPositionRelativeToEdge(DOCKED_EDGE_LEFT, w1.get(), 100, 20);
- // Width should be reset to what it was last time the window was not docked.
- EXPECT_EQ(previous_width + kResizeSpan1, w1->bounds().width());
- // Height should be restored to what it was originally.
- EXPECT_EQ(201, w1->bounds().height());
+ // Size should be restored to what it was originally.
+ EXPECT_EQ(original_size.ToString(), w1->bounds().size().ToString());
}
// Dock a window, resize it and test that it stays docked.