Commit a5f80c13 authored by Manu Cornet's avatar Manu Cornet Committed by Commit Bot

CrOS systray: Only trigger shelf re-layouts from systray when necessary

Bug: 1050788
Change-Id: I462618ca7f4f4486502ecbd3d89be557f6a71c7e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2057088Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Manu Cornet <manucornet@chromium.org>
Cr-Commit-Position: refs/heads/master@{#741515}
parent ffda6b98
...@@ -217,10 +217,23 @@ void StatusAreaWidgetDelegate::UpdateLayout() { ...@@ -217,10 +217,23 @@ void StatusAreaWidgetDelegate::UpdateLayout() {
} }
void StatusAreaWidgetDelegate::ChildPreferredSizeChanged(View* child) { void StatusAreaWidgetDelegate::ChildPreferredSizeChanged(View* child) {
const gfx::Size current_size = size();
const gfx::Size new_size = GetPreferredSize();
if (new_size == current_size)
return;
// Need to resize the window when trays or items are added/removed. // Need to resize the window when trays or items are added/removed.
StatusAreaWidgetDelegateAnimationSettings settings(layer()); StatusAreaWidgetDelegateAnimationSettings settings(layer());
UpdateWidgetSize(); UpdateWidgetSize();
shelf_->shelf_layout_manager()->LayoutShelf(/*animate=*/false);
// The shelf only needs a re-layout if this widget has changed size in
// the primary dimension. No re-layout is needed for changes in the cross
// dimension.
bool should_relayout_shelf = (shelf_->IsHorizontalAlignment() &&
new_size.width() != current_size.width()) ||
(!shelf_->IsHorizontalAlignment() &&
new_size.height() != current_size.height());
if (should_relayout_shelf)
shelf_->shelf_layout_manager()->LayoutShelf(/*animate=*/false);
} }
void StatusAreaWidgetDelegate::ChildVisibilityChanged(View* child) { void StatusAreaWidgetDelegate::ChildVisibilityChanged(View* child) {
......
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