| Index: ash/wm/workspace/workspace_layout_manager.cc
|
| diff --git a/ash/wm/workspace/workspace_layout_manager.cc b/ash/wm/workspace/workspace_layout_manager.cc
|
| index 71f4b969f7f61c6e531651528bdfb3c45a6512e4..68fabb50f7cb58a4557ec0cd316eb7dc9184e65d 100644
|
| --- a/ash/wm/workspace/workspace_layout_manager.cc
|
| +++ b/ash/wm/workspace/workspace_layout_manager.cc
|
| @@ -143,15 +143,27 @@ void WorkspaceLayoutManager::OnKeyboardBoundsChanging(
|
| aura::Window *window = text_input_client->GetAttachedWindow();
|
| if (!window || !window_->Contains(window))
|
| return;
|
| - gfx::Rect window_bounds = ScreenUtil::ConvertRectToScreen(
|
| - window_,
|
| - window->GetTargetBounds());
|
| - gfx::Rect intersect = gfx::IntersectRects(window_bounds, new_bounds);
|
| - int shift = std::min(intersect.height(),
|
| - window->bounds().y() - work_area_in_parent_.y());
|
| - if (shift > 0) {
|
| - gfx::Point origin(window->bounds().x(), window->bounds().y() - shift);
|
| - SetChildBounds(window, gfx::Rect(origin, window->bounds().size()));
|
| + aura::Window *toplevel_window = window->GetToplevelWindow();
|
| + wm::WindowState* toplevel_window_state = wm::GetWindowState(toplevel_window);
|
| + if (!new_bounds.IsEmpty()) {
|
| + // Store existing bounds to be restored before resizing for keyboard if it
|
| + // is not already stored.
|
| + if (!toplevel_window_state->HasRestoreBounds())
|
| + toplevel_window_state->SaveCurrentBoundsForRestore();
|
| +
|
| + gfx::Rect window_bounds = ScreenUtil::ConvertRectToScreen(
|
| + window_,
|
| + window->GetTargetBounds());
|
| + gfx::Rect intersect = gfx::IntersectRects(window_bounds, new_bounds);
|
| + int shift = std::min(intersect.height(),
|
| + window->bounds().y() - work_area_in_parent_.y());
|
| + if (shift > 0) {
|
| + gfx::Point origin(window->bounds().x(), window->bounds().y() - shift);
|
| + SetChildBounds(window, gfx::Rect(origin, window->bounds().size()));
|
| + }
|
| + } else if (toplevel_window_state->HasRestoreBounds()) {
|
| + // Keyboard hidden, restore original bounds if they exist.
|
| + toplevel_window_state->SetAndClearRestoreBounds();
|
| }
|
| }
|
|
|
|
|