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..12abfd19611592a4f0bc79cd6d157ceb1e393fca 100644 |
--- a/ash/wm/workspace/workspace_layout_manager.cc |
+++ b/ash/wm/workspace/workspace_layout_manager.cc |
@@ -143,15 +143,28 @@ 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()) { |
flackr
2014/08/14 19:17:58
nit: no curlies { } for single line statement.
No
Peter Wen
2014/08/15 13:44:48
Done.
It seems that workspace_layout_manager's on
|
+ 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) { |
flackr
2014/08/14 19:17:58
Should we even set restore bounds if there is no c
Peter Wen
2014/08/15 13:44:48
Yes, as that way even if the focused input area do
flackr
2014/08/20 15:02:14
Alright, sounds fine. It should be fine either way
|
+ 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(); |
} |
} |