Skip to content

Commit

Permalink
Compare the adjusted bounds and current bounds
Browse files Browse the repository at this point in the history
We should use the adjusted bounds (by workspace) to compare
the current bounds. Using non adjusted resulted in re-adjusting
the bounds repeatedly, which caused the updating shelf visibility.

Bug: 895744
Change-Id: I88f467ffc050c7fe30bc427ed20bf19b784ed965
Reviewed-on: https://chromium-review.googlesource.com/c/1303408
Reviewed-by: Ahmed Fakhry <afakhry@chromium.org>
Commit-Queue: Mitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#603292}
  • Loading branch information
mitoshima authored and Commit Bot committed Oct 27, 2018
1 parent caa4b2b commit c2e341a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
18 changes: 9 additions & 9 deletions components/exo/client_controlled_shell_surface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,14 @@ void ClientControlledShellSurface::SetWidgetBounds(const gfx::Rect& bounds) {
preserve_widget_bounds_ = false;
}

if (bounds == widget_->GetWindowBoundsInScreen() &&
// Calculate a minimum window visibility required bounds.
gfx::Rect adjusted_bounds = bounds;
if (!is_display_move_pending) {
ash::wm::ClientControlledState::AdjustBoundsForMinimumWindowVisibility(
target_display.bounds(), &adjusted_bounds);
}

if (adjusted_bounds == widget_->GetWindowBoundsInScreen() &&
target_display.id() == current_display.id()) {
return;
}
Expand All @@ -778,19 +785,12 @@ void ClientControlledShellSurface::SetWidgetBounds(const gfx::Rect& bounds) {
// Move the window relative to the current display.
{
ScopedSetBoundsLocally scoped_set_bounds(this);
window->SetBounds(gfx::Rect(origin, bounds.size()));
window->SetBounds(gfx::Rect(origin, adjusted_bounds.size()));
}
UpdateSurfaceBounds();
return;
}

// Calculate a minimum window visibility required bounds.
gfx::Rect adjusted_bounds = bounds;
if (!is_display_move_pending) {
ash::wm::ClientControlledState::AdjustBoundsForMinimumWindowVisibility(
target_display.bounds(), &adjusted_bounds);
}

{
ScopedSetBoundsLocally scoped_set_bounds(this);
window->SetBoundsInScreen(adjusted_bounds, target_display);
Expand Down
7 changes: 7 additions & 0 deletions components/exo/client_controlled_shell_surface_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1768,6 +1768,13 @@ TEST_F(ClientControlledShellSurfaceTest, AdjustBoundsLocally) {
views::Widget* widget = shell_surface->GetWidget();
EXPECT_EQ(gfx::Rect(774, 0, 200, 300), widget->GetWindowBoundsInScreen());
EXPECT_EQ(gfx::Rect(774, 0, 200, 300), requested_bounds);

// Receiving the same bounds shouldn't try to update the bounds again.
requested_bounds.SetRect(0, 0, 0, 0);
shell_surface->SetGeometry(client_bounds);
surface->Commit();

EXPECT_TRUE(requested_bounds.IsEmpty());
}

TEST_F(ClientControlledShellSurfaceTest, SnappedInTabletMode) {
Expand Down

0 comments on commit c2e341a

Please sign in to comment.