Commit 5b4e72c6 authored by jonross's avatar jonross Committed by Commit bot

Have Notifications appear over docked windows

Update AshPopupAlignmentDelegate calculations of its work area.

When windows are docked this reduces the work area for windows.
AshPopupAlignmentDelegate uses the work area to determine the positioning of
notifications. Update this calculation to include the docked region.

TEST=AshPopupAlignmentDelegateTest.DockedWindow
BUG=284574

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

Cr-Commit-Position: refs/heads/master@{#329486}
parent f8682c06
......@@ -859,6 +859,9 @@ void ShelfLayoutManager::CalculateTargetBounds(
gfx::Rect(0, 0,
shelf_width - status_size.width(),
target_bounds->shelf_bounds_in_root.height()));
non_shelf_bounds_ = available_bounds;
non_shelf_bounds_.Subtract(target_bounds->shelf_bounds_in_root);
}
void ShelfLayoutManager::UpdateTargetBoundsForGesture(
......
......@@ -121,6 +121,9 @@ class ASH_EXPORT ShelfLayoutManager
// Returns the docked area bounds.
const gfx::Rect& dock_bounds() const { return dock_bounds_; }
// Returns the bounds within the root window not occupied by the shelf.
const gfx::Rect& non_shelf_bounds() const { return non_shelf_bounds_; }
// Stops any animations and sets the bounds of the shelf and status
// widgets.
void LayoutShelf();
......@@ -399,6 +402,9 @@ class ASH_EXPORT ShelfLayoutManager
// The bounds of the dock.
gfx::Rect dock_bounds_;
// The bounds within the root window not occupied by the shelf.
gfx::Rect non_shelf_bounds_;
// The show hide animation duration override or 0 for default.
int duration_override_in_ms_;
......
......@@ -55,7 +55,7 @@ void AshPopupAlignmentDelegate::StartObserving(gfx::Screen* screen,
screen->AddObserver(this);
Shell::GetInstance()->AddShellObserver(this);
if (system_tray_height_ > 0)
UpdateWorkArea(display, shelf_->auto_hide_state());
UpdateWorkArea();
}
void AshPopupAlignmentDelegate::SetSystemTrayHeight(int height) {
......@@ -134,39 +134,19 @@ gfx::Display AshPopupAlignmentDelegate::GetCurrentDisplay() const {
shelf_->shelf_widget()->GetNativeView());
}
void AshPopupAlignmentDelegate::UpdateWorkArea(const gfx::Display& display,
ShelfAutoHideState new_state) {
work_area_ = display.work_area();
if (Shell::GetInstance()->display_manager()->IsInUnifiedMode()) {
gfx::Rect bounds = ScreenUtil::GetShelfDisplayBoundsInScreen(
shelf_->shelf_widget()->GetNativeView());
work_area_.Intersect(bounds);
}
int width = 0;
if (shelf_ && (shelf_->visibility_state() == SHELF_AUTO_HIDE) &&
new_state == SHELF_AUTO_HIDE_SHOWN) {
// Since the work_area is already reduced by kAutoHideSize, the inset width
// should be just the difference.
width = kShelfSize - ShelfLayoutManager::kAutoHideSize;
}
work_area_.Inset(shelf_->SelectValueForShelfAlignment(
gfx::Insets(0, 0, width, 0),
gfx::Insets(0, width, 0, 0),
gfx::Insets(0, 0, 0, width),
gfx::Insets(width, 0, 0, 0)));
void AshPopupAlignmentDelegate::UpdateWorkArea() {
work_area_ = shelf_->non_shelf_bounds();
DoUpdateIfPossible();
}
void AshPopupAlignmentDelegate::OnDisplayWorkAreaInsetsChanged() {
UpdateShelf();
UpdateWorkArea(GetCurrentDisplay(), shelf_->auto_hide_state());
UpdateWorkArea();
}
void AshPopupAlignmentDelegate::OnAutoHideStateChanged(
ShelfAutoHideState new_state) {
UpdateWorkArea(GetCurrentDisplay(), new_state);
UpdateWorkArea();
}
void AshPopupAlignmentDelegate::OnDisplayAdded(
......@@ -182,7 +162,7 @@ void AshPopupAlignmentDelegate::OnDisplayMetricsChanged(
uint32_t metrics) {
UpdateShelf();
if (shelf_ && GetCurrentDisplay().id() == display.id())
UpdateWorkArea(display, shelf_->auto_hide_state());
UpdateWorkArea();
}
} // namespace ash
......@@ -70,8 +70,7 @@ class ASH_EXPORT AshPopupAlignmentDelegate
gfx::Display GetCurrentDisplay() const;
// Compute the new work area.
void UpdateWorkArea(const gfx::Display& display,
ShelfAutoHideState new_state);
void UpdateWorkArea();
// Overridden from ShellObserver:
void OnDisplayWorkAreaInsetsChanged() override;
......
......@@ -170,6 +170,19 @@ TEST_F(AshPopupAlignmentDelegateTest, DockedWindow) {
kShellWindowId_DockedContainer);
docked_container->AddChild(window.get());
// Left-side dock should not affect popup alignment
EXPECT_EQ(origin_x, alignment_delegate()->GetToastOriginX(toast_size));
EXPECT_EQ(baseline, alignment_delegate()->GetBaseLine());
EXPECT_FALSE(alignment_delegate()->IsTopDown());
EXPECT_FALSE(alignment_delegate()->IsFromLeft());
// Force dock to right-side
Shell::GetInstance()->SetShelfAlignment(SHELF_ALIGNMENT_LEFT,
Shell::GetPrimaryRootWindow());
Shell::GetInstance()->SetShelfAlignment(SHELF_ALIGNMENT_BOTTOM,
Shell::GetPrimaryRootWindow());
// Right-side dock should not affect popup alignment
EXPECT_EQ(origin_x, alignment_delegate()->GetToastOriginX(toast_size));
EXPECT_EQ(baseline, alignment_delegate()->GetBaseLine());
EXPECT_FALSE(alignment_delegate()->IsTopDown());
......
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