Commit 54b4f85a authored by rsadam's avatar rsadam Committed by Commit bot

Fixes moving fully occluded windows when the a11y keyboard shows.

TEST=WorkspaceLayoutManagerKeyboardTest.AdjustWindowForA11yKeyboard
BUG=407094

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

Cr-Commit-Position: refs/heads/master@{#292056}
parent 71b32fcc
...@@ -153,12 +153,13 @@ void WorkspaceLayoutManager::OnKeyboardBoundsChanging( ...@@ -153,12 +153,13 @@ void WorkspaceLayoutManager::OnKeyboardBoundsChanging(
gfx::Rect window_bounds = ScreenUtil::ConvertRectToScreen( gfx::Rect window_bounds = ScreenUtil::ConvertRectToScreen(
window_, window_,
window->GetTargetBounds()); window->GetTargetBounds());
gfx::Rect intersect = gfx::IntersectRects(window_bounds, new_bounds); int vertical_displacement =
int shift = std::min(intersect.height(), std::max(0, window_bounds.bottom() - new_bounds.y());
window->bounds().y() - work_area_in_parent_.y()); int shift = std::min(vertical_displacement,
window_bounds.y() - work_area_in_parent_.y());
if (shift > 0) { if (shift > 0) {
gfx::Point origin(window->bounds().x(), window->bounds().y() - shift); gfx::Point origin(window_bounds.x(), window_bounds.y() - shift);
SetChildBounds(window, gfx::Rect(origin, window->bounds().size())); SetChildBounds(window, gfx::Rect(origin, window_bounds.size()));
} }
} else if (window_state->HasRestoreBounds()) { } else if (window_state->HasRestoreBounds()) {
// Keyboard hidden, restore original bounds if they exist. // Keyboard hidden, restore original bounds if they exist.
......
...@@ -1139,6 +1139,21 @@ TEST_F(WorkspaceLayoutManagerKeyboardTest, AdjustWindowForA11yKeyboard) { ...@@ -1139,6 +1139,21 @@ TEST_F(WorkspaceLayoutManagerKeyboardTest, AdjustWindowForA11yKeyboard) {
HideKeyboard(); HideKeyboard();
EXPECT_EQ(small_window_bound.ToString(), window->bounds().ToString()); EXPECT_EQ(small_window_bound.ToString(), window->bounds().ToString());
gfx::Rect occluded_window_bounds(50,
keyboard_bounds.y() + keyboard_bounds.height()/2, 50,
keyboard_bounds.height()/2);
window->SetBounds(occluded_window_bounds);
EXPECT_EQ(occluded_window_bounds.ToString(),
occluded_window_bounds.ToString());
ShowKeyboard();
EXPECT_EQ(gfx::Rect(50,
keyboard_bounds.y() - keyboard_bounds.height()/2,
occluded_window_bounds.width(),
occluded_window_bounds.height()).ToString(),
window->bounds().ToString());
HideKeyboard();
EXPECT_EQ(occluded_window_bounds.ToString(), window->bounds().ToString());
Blur(&text_input_client); Blur(&text_input_client);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment