Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
Fix stale keyboard bounds on login screen
Browse files Browse the repository at this point in the history
BUG=401667

Review URL: https://codereview.chromium.org/495923002

Cr-Commit-Position: refs/heads/master@{#291281}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@291281 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
nkostylev@chromium.org committed Aug 22, 2014
1 parent b20c322 commit bd7e97a
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 3 deletions.
28 changes: 27 additions & 1 deletion ash/wm/lock_layout_manager_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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);
Expand All @@ -203,15 +205,39 @@ 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(
keyboard::KEYBOARD_OVERSCROLL_OVERRIDE_DISABLED);
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());
Expand Down
7 changes: 6 additions & 1 deletion ash/wm/lock_window_state.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 2 additions & 0 deletions ui/keyboard/keyboard_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,8 @@ void KeyboardController::NotifyKeyboardBoundsChanging(
} else {
ResetWindowInsets();
}
} else {
current_keyboard_bounds_ = gfx::Rect();
}
}

Expand Down
5 changes: 4 additions & 1 deletion ui/keyboard/keyboard_layout_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down

0 comments on commit bd7e97a

Please sign in to comment.