diff options
author | mukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-14 19:41:21 +0000 |
---|---|---|
committer | mukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-14 19:41:21 +0000 |
commit | 5bc75cdaceea2728cfcb5039072886fc0582c848 (patch) | |
tree | 5f40889cc49b17861277914f2a63f12c7927df04 /ash | |
parent | 420493796e9a37887d8b11a34c3d80b8886f680b (diff) | |
download | chromium_src-5bc75cdaceea2728cfcb5039072886fc0582c848.zip chromium_src-5bc75cdaceea2728cfcb5039072886fc0582c848.tar.gz chromium_src-5bc75cdaceea2728cfcb5039072886fc0582c848.tar.bz2 |
Change the window origin if the window isn't shown in the new place.
BUG=147678
Review URL: https://chromiumcodereview.appspot.com/10909219
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@156861 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r-- | ash/wm/workspace/workspace_layout_manager2.cc | 3 | ||||
-rw-r--r-- | ash/wm/workspace/workspace_layout_manager2_unittest.cc | 16 |
2 files changed, 19 insertions, 0 deletions
diff --git a/ash/wm/workspace/workspace_layout_manager2.cc b/ash/wm/workspace/workspace_layout_manager2.cc index 6ffb7015..45a5802 100644 --- a/ash/wm/workspace/workspace_layout_manager2.cc +++ b/ash/wm/workspace/workspace_layout_manager2.cc @@ -76,6 +76,9 @@ WorkspaceLayoutManager2::~WorkspaceLayoutManager2() { } void WorkspaceLayoutManager2::OnWindowAddedToLayout(Window* child) { + // Adjust window bounds in case that the new child is out of the workspace. + AdjustWindowSizeForScreenChange(child, ADJUST_WINDOW_DISPLAY_INSETS_CHANGED); + windows_.insert(child); child->AddObserver(this); diff --git a/ash/wm/workspace/workspace_layout_manager2_unittest.cc b/ash/wm/workspace/workspace_layout_manager2_unittest.cc index aaacd72..59cab50 100644 --- a/ash/wm/workspace/workspace_layout_manager2_unittest.cc +++ b/ash/wm/workspace/workspace_layout_manager2_unittest.cc @@ -118,6 +118,22 @@ TEST_F(WorkspaceLayoutManager2Test, ChildBoundsResetOnMaximize) { EXPECT_EQ("5,6 7x8", child_window->bounds().ToString()); } +TEST_F(WorkspaceLayoutManager2Test, WindowShouldBeOnScreenWhenAdded) { + // Normal window bounds shouldn't be changed. + gfx::Rect window_bounds(100, 100, 200, 200); + scoped_ptr<aura::Window> window(CreateTestWindow(window_bounds)); + EXPECT_EQ(window_bounds, window->bounds()); + + // If the window is out of the workspace, it would be moved on screen. + gfx::Rect root_window_bounds = + ash::Shell::GetInstance()->GetPrimaryRootWindow()->bounds(); + window_bounds.Offset(root_window_bounds.width(), root_window_bounds.height()); + ASSERT_FALSE(window_bounds.Intersects(root_window_bounds)); + scoped_ptr<aura::Window> out_window(CreateTestWindow(window_bounds)); + EXPECT_EQ(window_bounds.size(), out_window->bounds().size()); + EXPECT_TRUE(out_window->bounds().Intersects(root_window_bounds)); +} + } // namespace } // namespace ash |