diff --git a/ash/wm/lock_layout_manager_unittest.cc b/ash/wm/lock_layout_manager_unittest.cc index 70984c49f9f19..b680ba21a9718 100644 --- a/ash/wm/lock_layout_manager_unittest.cc +++ b/ash/wm/lock_layout_manager_unittest.cc @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "ash/display/display_manager.h" #include "ash/root_window_controller.h" #include "ash/screen_util.h" #include "ash/shell.h" @@ -187,7 +188,8 @@ TEST_F(LockLayoutManagerTest, MaximizedFullscreenWindowBoundsAreEqualToScreen) { } TEST_F(LockLayoutManagerTest, KeyboardBounds) { - gfx::Rect screen_bounds = Shell::GetScreen()->GetPrimaryDisplay().bounds(); + gfx::Display primary_display = Shell::GetScreen()->GetPrimaryDisplay(); + gfx::Rect screen_bounds = primary_display.bounds(); views::Widget::InitParams widget_params( views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); @@ -203,8 +205,30 @@ TEST_F(LockLayoutManagerTest, KeyboardBounds) { keyboard::KEYBOARD_OVERSCROLL_OVERRIDE_ENABLED); ShowKeyboard(true); EXPECT_EQ(screen_bounds.ToString(), window->GetBoundsInScreen().ToString()); + gfx::Rect keyboard_bounds = + keyboard::KeyboardController::GetInstance()->current_keyboard_bounds(); + EXPECT_NE(keyboard_bounds, gfx::Rect()); ShowKeyboard(false); + // When keyboard is hidden make sure that rotating the screen gives 100% of + // screen size to window. + // Repro steps for http://crbug.com/401667: + // 1. Set up login screen defaults: VK override disabled + // 2. Show/hide keyboard, make sure that no stale keyboard bounds are cached. + keyboard::SetKeyboardOverscrollOverride( + keyboard::KEYBOARD_OVERSCROLL_OVERRIDE_DISABLED); + ShowKeyboard(true); + ShowKeyboard(false); + ash::DisplayManager* display_manager = + Shell::GetInstance()->display_manager(); + display_manager->SetDisplayRotation(primary_display.id(), + gfx::Display::ROTATE_90); + primary_display = Shell::GetScreen()->GetPrimaryDisplay(); + screen_bounds = primary_display.bounds(); + EXPECT_EQ(screen_bounds.ToString(), window->GetBoundsInScreen().ToString()); + display_manager->SetDisplayRotation(primary_display.id(), + gfx::Display::ROTATE_0); + // When virtual keyboard overscroll is disabled keyboard bounds do // affect window bounds. keyboard::SetKeyboardOverscrollOverride( @@ -212,6 +236,8 @@ TEST_F(LockLayoutManagerTest, KeyboardBounds) { ShowKeyboard(true); keyboard::KeyboardController* keyboard = keyboard::KeyboardController::GetInstance(); + primary_display = Shell::GetScreen()->GetPrimaryDisplay(); + screen_bounds = primary_display.bounds(); gfx::Rect target_bounds(screen_bounds); target_bounds.set_height(target_bounds.height() - keyboard->proxy()->GetKeyboardWindow()->bounds().height()); diff --git a/ash/wm/lock_window_state.cc b/ash/wm/lock_window_state.cc index 5d38b59e8e51b..fa1684fda80da 100644 --- a/ash/wm/lock_window_state.cc +++ b/ash/wm/lock_window_state.cc @@ -167,12 +167,17 @@ void LockWindowState::UpdateBounds(wm::WindowState* window_state) { keyboard::KeyboardController::GetInstance(); gfx::Rect keyboard_bounds; - if (keyboard_controller && !keyboard::IsKeyboardOverscrollEnabled()) + if (keyboard_controller && + !keyboard::IsKeyboardOverscrollEnabled() && + keyboard_controller->keyboard_visible()) { keyboard_bounds = keyboard_controller->current_keyboard_bounds(); + } gfx::Rect bounds = ScreenUtil::GetDisplayBoundsInParent(window_state->window()); bounds.set_height(bounds.height() - keyboard_bounds.height()); + + VLOG(1) << "Updating window bounds to: " << bounds.ToString(); window_state->SetBoundsDirect(bounds); } diff --git a/ui/keyboard/keyboard_controller.cc b/ui/keyboard/keyboard_controller.cc index f74ff7a612e1b..029a5a43d4b1b 100644 --- a/ui/keyboard/keyboard_controller.cc +++ b/ui/keyboard/keyboard_controller.cc @@ -305,6 +305,8 @@ void KeyboardController::NotifyKeyboardBoundsChanging( } else { ResetWindowInsets(); } + } else { + current_keyboard_bounds_ = gfx::Rect(); } } diff --git a/ui/keyboard/keyboard_layout_manager.cc b/ui/keyboard/keyboard_layout_manager.cc index d7faf0fa7ab27..9946060cd9668 100644 --- a/ui/keyboard/keyboard_layout_manager.cc +++ b/ui/keyboard/keyboard_layout_manager.cc @@ -56,7 +56,10 @@ void KeyboardLayoutManager::SetChildBounds(aura::Window* child, // case the show keyboard request is called before the height is set. controller_->ShowKeyboard(false); } else { - controller_->NotifyKeyboardBoundsChanging(requested_bounds); + // We need to send out this notification only if keyboard is visible since + // keyboard window is resized even if keyboard is hidden. + if (controller_->keyboard_visible()) + controller_->NotifyKeyboardBoundsChanging(requested_bounds); } }