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..c55c711ff691582d806384eea6d9230a38dc6e29 100644 |
--- a/ash/wm/workspace/workspace_layout_manager.cc |
+++ b/ash/wm/workspace/workspace_layout_manager.cc |
@@ -143,15 +143,25 @@ 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.height() > 0) { |
flackr
2014/08/14 18:20:55
nit: Use !new_bounds.IsEmpty()
Can't this get call
Peter Wen
2014/08/14 19:13:31
Done. Added HasRestoreBounds guard.
@kevers - Is
|
+ // Store existing bounds to be restored before resizing for keyboard. |
+ 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(); |
} |
} |