| Index: ui/keyboard/keyboard_controller.cc
|
| diff --git a/ui/keyboard/keyboard_controller.cc b/ui/keyboard/keyboard_controller.cc
|
| index 40065d27845179576ccee19a2564195da15f69a0..9e75ab30c6b3a8cc84a53ccb853804b13a74a5ae 100644
|
| --- a/ui/keyboard/keyboard_controller.cc
|
| +++ b/ui/keyboard/keyboard_controller.cc
|
| @@ -441,15 +441,14 @@ void KeyboardController::OnShowImeIfNeeded() {
|
| }
|
|
|
| bool KeyboardController::ShouldEnableInsets(aura::Window* window) {
|
| - aura::Window *keyboard_window = proxy_->GetKeyboardWindow();
|
| + aura::Window* keyboard_window = proxy_->GetKeyboardWindow();
|
| return (keyboard_window->GetRootWindow() == window->GetRootWindow() &&
|
| keyboard::IsKeyboardOverscrollEnabled() &&
|
| - proxy_->GetKeyboardWindow()->IsVisible() &&
|
| - keyboard_visible_);
|
| + keyboard_window->IsVisible() && keyboard_visible_);
|
| }
|
|
|
| void KeyboardController::UpdateWindowInsets(aura::Window* window) {
|
| - aura::Window *keyboard_window = proxy_->GetKeyboardWindow();
|
| + aura::Window* keyboard_window = proxy_->GetKeyboardWindow();
|
| if (window == keyboard_window)
|
| return;
|
|
|
| @@ -459,8 +458,8 @@ void KeyboardController::UpdateWindowInsets(aura::Window* window) {
|
| content::RenderWidgetHostView* view = widget->GetView();
|
| if (view && window->Contains(view->GetNativeView())) {
|
| gfx::Rect window_bounds = view->GetNativeView()->GetBoundsInScreen();
|
| - gfx::Rect intersect = gfx::IntersectRects(window_bounds,
|
| - proxy_->GetKeyboardWindow()->bounds());
|
| + gfx::Rect intersect =
|
| + gfx::IntersectRects(window_bounds, keyboard_window->bounds());
|
| int overlap = ShouldEnableInsets(window) ? intersect.height() : 0;
|
| if (overlap > 0 && overlap < window_bounds.height())
|
| view->SetInsets(gfx::Insets(0, 0, overlap, 0));
|
| @@ -471,6 +470,26 @@ void KeyboardController::UpdateWindowInsets(aura::Window* window) {
|
| }
|
| }
|
|
|
| +void KeyboardController::OnRootWindowResized(const gfx::Rect& bounds) {
|
| + // Keep the same height when window resize. It gets called when screen rotate.
|
| + if (!keyboard_container_initialized() || !proxy_->GetKeyboardWindow())
|
| + return;
|
| +
|
| + int container_height = container_->bounds().height();
|
| + if (keyboard_mode_ == FULL_WIDTH) {
|
| + container_->SetBounds(gfx::Rect(bounds.x(),
|
| + bounds.bottom() - container_height,
|
| + bounds.width(), container_height));
|
| + } else if (keyboard_mode_ == FLOATING) {
|
| + // When screen rotate, horizontally center floating virtual keyboard window
|
| + // and vertically align it to the bottom.
|
| + int container_width = container_->bounds().width();
|
| + container_->SetBounds(gfx::Rect(
|
| + bounds.x() + (bounds.width() - container_width) / 2,
|
| + bounds.bottom() - container_height, container_width, container_height));
|
| + }
|
| +}
|
| +
|
| void KeyboardController::ShowKeyboardInternal() {
|
| if (!container_.get())
|
| return;
|
| @@ -564,7 +583,7 @@ bool KeyboardController::WillHideKeyboard() const {
|
| void KeyboardController::ShowAnimationFinished() {
|
| // Notify observers after animation finished to prevent reveal desktop
|
| // background during animation.
|
| - NotifyKeyboardBoundsChanging(proxy_->GetKeyboardWindow()->bounds());
|
| + NotifyKeyboardBoundsChanging(container_->bounds());
|
| proxy_->EnsureCaretInWorkArea();
|
| }
|
|
|
|
|