Commit 9b6d3278 authored by sky@chromium.org's avatar sky@chromium.org

Fixes bug where maximized window wasn't getting resized when toggling

auto-hide behavior of launcher.

BUG=120407
TEST=see bug, covered by unit tests now too
R=ben@chromium.org

Review URL: https://chromiumcodereview.appspot.com/9784010

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@129410 0039d316-1c4b-4281-b951-d872f2087c98
parent 4ee4b055
...@@ -345,8 +345,13 @@ void ShelfLayoutManager::CalculateTargetBounds( ...@@ -345,8 +345,13 @@ void ShelfLayoutManager::CalculateTargetBounds(
target_bounds->opacity = target_bounds->opacity =
(state.visibility_state == VISIBLE || (state.visibility_state == VISIBLE ||
state.visibility_state == AUTO_HIDE) ? 1.0f : 0.0f; state.visibility_state == AUTO_HIDE) ? 1.0f : 0.0f;
target_bounds->work_area_insets =
gfx::Insets(0, 0, shelf_height, 0); int work_area_bottom = 0;
if (state.visibility_state == VISIBLE)
work_area_bottom = shelf_height_;
else if (state.visibility_state == AUTO_HIDE)
work_area_bottom = kAutoHideHeight;
target_bounds->work_area_insets.Set(0, 0, work_area_bottom, 0);
} }
void ShelfLayoutManager::UpdateShelfBackground( void ShelfLayoutManager::UpdateShelfBackground(
......
...@@ -172,7 +172,11 @@ TEST_F(ShelfLayoutManagerTest, DontReferenceLauncherAfterDeletion) { ...@@ -172,7 +172,11 @@ TEST_F(ShelfLayoutManagerTest, DontReferenceLauncherAfterDeletion) {
} }
// Various assertions around auto-hide. // Various assertions around auto-hide.
TEST_F(ShelfLayoutManagerTest, DISABLED_AutoHide) { TEST_F(ShelfLayoutManagerTest, AutoHide) {
aura::RootWindow* root = Shell::GetRootWindow();
aura::test::EventGenerator generator(root, root);
generator.MoveMouseTo(0, 0);
ShelfLayoutManager* shelf = GetShelfLayoutManager(); ShelfLayoutManager* shelf = GetShelfLayoutManager();
views::Widget* widget = new views::Widget; views::Widget* widget = new views::Widget;
views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
...@@ -184,26 +188,28 @@ TEST_F(ShelfLayoutManagerTest, DISABLED_AutoHide) { ...@@ -184,26 +188,28 @@ TEST_F(ShelfLayoutManagerTest, DISABLED_AutoHide) {
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
aura::RootWindow* root = Shell::GetRootWindow();
// LayoutShelf() forces the animation to completion, at which point the // LayoutShelf() forces the animation to completion, at which point the
// launcher should go off the screen. // launcher should go off the screen.
shelf->LayoutShelf(); shelf->LayoutShelf();
EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideHeight, EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideHeight,
shelf->launcher_widget()->GetWindowScreenBounds().y()); shelf->launcher_widget()->GetWindowScreenBounds().y());
EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideHeight,
gfx::Screen::GetMonitorWorkAreaNearestWindow(root).bottom());
// Move the mouse to the bottom of the screen. // Move the mouse to the bottom of the screen.
aura::test::EventGenerator generator(root, root); generator.MoveMouseTo(0, root->bounds().bottom() - 1);
generator.MoveMouseTo(gfx::Point(0, root->bounds().bottom() - 1));
// Shelf should be shown again. // Shelf should be shown again (but it shouldn't have changed the work area).
SetState(shelf, ShelfLayoutManager::AUTO_HIDE); SetState(shelf, ShelfLayoutManager::AUTO_HIDE);
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_SHOWN, shelf->auto_hide_state()); EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_SHOWN, shelf->auto_hide_state());
shelf->LayoutShelf(); shelf->LayoutShelf();
EXPECT_EQ(root->bounds().bottom() - shelf->shelf_height(), EXPECT_EQ(root->bounds().bottom() - shelf->shelf_height(),
shelf->launcher_widget()->GetWindowScreenBounds().y()); shelf->launcher_widget()->GetWindowScreenBounds().y());
EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideHeight,
gfx::Screen::GetMonitorWorkAreaNearestWindow(root).bottom());
// Move mouse back up. // Move mouse back up.
generator.MoveMouseTo(gfx::Point(0, 0)); generator.MoveMouseTo(0, 0);
SetState(shelf, ShelfLayoutManager::AUTO_HIDE); SetState(shelf, ShelfLayoutManager::AUTO_HIDE);
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
shelf->LayoutShelf(); shelf->LayoutShelf();
...@@ -263,6 +269,12 @@ TEST_F(ShelfLayoutManagerTest, VisibleWhenLockScreenShowing) { ...@@ -263,6 +269,12 @@ TEST_F(ShelfLayoutManagerTest, VisibleWhenLockScreenShowing) {
// Assertions around SetAutoHideBehavior. // Assertions around SetAutoHideBehavior.
TEST_F(ShelfLayoutManagerTest, SetAutoHideBehavior) { TEST_F(ShelfLayoutManagerTest, SetAutoHideBehavior) {
// Since ShelfLayoutManager queries for mouse location, move the mouse so
// it isn't over the shelf.
aura::test::EventGenerator generator(
Shell::GetInstance()->GetRootWindow(), gfx::Point());
generator.MoveMouseTo(0, 0);
ShelfLayoutManager* shelf = GetShelfLayoutManager(); ShelfLayoutManager* shelf = GetShelfLayoutManager();
views::Widget* widget = new views::Widget; views::Widget* widget = new views::Widget;
views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
...@@ -293,6 +305,18 @@ TEST_F(ShelfLayoutManagerTest, SetAutoHideBehavior) { ...@@ -293,6 +305,18 @@ TEST_F(ShelfLayoutManagerTest, SetAutoHideBehavior) {
widget->Maximize(); widget->Maximize();
EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
EXPECT_EQ(gfx::Screen::GetMonitorWorkAreaNearestWindow(window).bottom(),
widget->GetWorkAreaBoundsInScreen().bottom());
shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
EXPECT_EQ(gfx::Screen::GetMonitorWorkAreaNearestWindow(window).bottom(),
widget->GetWorkAreaBoundsInScreen().bottom());
shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
EXPECT_EQ(gfx::Screen::GetMonitorWorkAreaNearestWindow(window).bottom(),
widget->GetWorkAreaBoundsInScreen().bottom());
} }
} // namespace internal } // namespace internal
......
...@@ -100,12 +100,6 @@ void WorkspaceLayoutManager::SetChildBounds( ...@@ -100,12 +100,6 @@ void WorkspaceLayoutManager::SetChildBounds(
workspace_manager_->UpdateShelfVisibility(); workspace_manager_->UpdateShelfVisibility();
} }
void WorkspaceLayoutManager::OnMonitorWorkAreaInsetsChanged() {
// The workspace is currently the only one that updates the shelf, so we can
// safely ignore this. If we don't there are timing issues when transitioning
// between maximized/fullscreen windows and normal windows.
}
void WorkspaceLayoutManager::OnWindowPropertyChanged(aura::Window* window, void WorkspaceLayoutManager::OnWindowPropertyChanged(aura::Window* window,
const void* key, const void* key,
intptr_t old) { intptr_t old) {
......
...@@ -48,7 +48,6 @@ class ASH_EXPORT WorkspaceLayoutManager : public BaseLayoutManager { ...@@ -48,7 +48,6 @@ class ASH_EXPORT WorkspaceLayoutManager : public BaseLayoutManager {
bool visibile) OVERRIDE; bool visibile) OVERRIDE;
virtual void SetChildBounds(aura::Window* child, virtual void SetChildBounds(aura::Window* child,
const gfx::Rect& requested_bounds) OVERRIDE; const gfx::Rect& requested_bounds) OVERRIDE;
virtual void OnMonitorWorkAreaInsetsChanged() OVERRIDE;
// Overriden from aura::WindowObserver: // Overriden from aura::WindowObserver:
virtual void OnWindowPropertyChanged(aura::Window* window, virtual void OnWindowPropertyChanged(aura::Window* window,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment