Commit d54b5c6f authored by Toni Barzic's avatar Toni Barzic Committed by Commit Bot

Avoid resetting app list state when bounds shouldn't change

When on screen keyboard state changes, AppListView was calling SetState
to ensure the current bounds match the current state. This does more
work than necessary - for example closes the active folder if it exists,
and it should be avoided if possible. This changes the logic to reset
the state only if the target bounds change.

BUG=1020754

Change-Id: I8a393b5d88a37cee8f5369c68492304589c45274
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1896304Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Toni Baržić <tbarzic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#712168}
parent 818b7809
...@@ -1187,6 +1187,21 @@ void AppListView::MaybeCreateAccessibilityEvent( ...@@ -1187,6 +1187,21 @@ void AppListView::MaybeCreateAccessibilityEvent(
announcement_view_->NotifyAccessibilityEvent(ax::mojom::Event::kAlert, true); announcement_view_->NotifyAccessibilityEvent(ax::mojom::Event::kAlert, true);
} }
void AppListView::EnsureWidgetBoundsMatchCurrentState() {
const gfx::Rect new_target_bounds =
GetPreferredWidgetBoundsForState(app_list_state_);
aura::Window* window = GetWidget()->GetNativeView();
if (new_target_bounds == window->GetTargetBounds())
return;
// Set the widget size to fit the new display metrics.
GetWidget()->GetNativeView()->SetBounds(new_target_bounds);
// Update the widget bounds to accomodate the new work
// area.
SetState(app_list_state_);
}
int AppListView::GetRemainingBoundsAnimationDistance() const { int AppListView::GetRemainingBoundsAnimationDistance() const {
return GetWidget()->GetLayer()->transform().To2dTranslation().y(); return GetWidget()->GetLayer()->transform().To2dTranslation().y();
} }
...@@ -2120,7 +2135,7 @@ void AppListView::OnScreenKeyboardShown(bool shown) { ...@@ -2120,7 +2135,7 @@ void AppListView::OnScreenKeyboardShown(bool shown) {
// sure app list bounds match the current app list view state. // sure app list bounds match the current app list view state.
GetWidget()->GetNativeView()->ClearProperty( GetWidget()->GetNativeView()->ClearProperty(
wm::kVirtualKeyboardRestoreBoundsKey); wm::kVirtualKeyboardRestoreBoundsKey);
SetState(app_list_state_); EnsureWidgetBoundsMatchCurrentState();
} }
} }
...@@ -2138,18 +2153,7 @@ bool AppListView::CloseKeyboardIfVisible() { ...@@ -2138,18 +2153,7 @@ bool AppListView::CloseKeyboardIfVisible() {
} }
void AppListView::OnParentWindowBoundsChanged() { void AppListView::OnParentWindowBoundsChanged() {
const gfx::Rect new_target_bounds = EnsureWidgetBoundsMatchCurrentState();
GetPreferredWidgetBoundsForState(app_list_state_);
aura::Window* window = GetWidget()->GetNativeView();
if (new_target_bounds == window->GetTargetBounds())
return;
// Set the widget size to fit the new display metrics.
GetWidget()->GetNativeView()->SetBounds(new_target_bounds);
// Update the widget bounds to accomodate the new work
// area.
SetState(app_list_state_);
} }
float AppListView::GetAppListBackgroundOpacityDuringDragging() { float AppListView::GetAppListBackgroundOpacityDuringDragging() {
......
...@@ -425,6 +425,11 @@ class APP_LIST_EXPORT AppListView : public views::WidgetDelegateView, ...@@ -425,6 +425,11 @@ class APP_LIST_EXPORT AppListView : public views::WidgetDelegateView,
// Creates an Accessibility Event if the state transition warrants one. // Creates an Accessibility Event if the state transition warrants one.
void MaybeCreateAccessibilityEvent(ash::AppListViewState new_state); void MaybeCreateAccessibilityEvent(ash::AppListViewState new_state);
// Ensures that the app list widget bounds are set to the preferred bounds for
// the current app list view state - intended to be called when the
// display bounds available to the app list view change.
void EnsureWidgetBoundsMatchCurrentState();
// Returns the remaining vertical distance for the bounds movement // Returns the remaining vertical distance for the bounds movement
// animation. // animation.
int GetRemainingBoundsAnimationDistance() const; int GetRemainingBoundsAnimationDistance() const;
......
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