Commit 1f6fd36b authored by Sammie Quon's avatar Sammie Quon Committed by Commit Bot

overview: Grid bounds should respect the auto hidden shelf.

Adds an inset when the shelf is auto hidden because we want the grid to
be centered as if the shelf is fully visible.

Test: ash_unittests WindowSelectorTest.GridBounds
Bug: 908679, 908982
Change-Id: Ibccfb0bab70d68a463c3325fa8ca3b7912d0dc65
Reviewed-on: https://chromium-review.googlesource.com/c/1354355Reviewed-by: default avatarXiaoqian Dai <xdai@chromium.org>
Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Commit-Queue: Sammie Quon <sammiequon@chromium.org>
Cr-Commit-Position: refs/heads/master@{#612859}
parent 56a58d7d
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "ash/resources/vector_icons/vector_icons.h" #include "ash/resources/vector_icons/vector_icons.h"
#include "ash/screen_util.h" #include "ash/screen_util.h"
#include "ash/shelf/shelf.h" #include "ash/shelf/shelf.h"
#include "ash/shelf/shelf_constants.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/strings/grit/ash_strings.h" #include "ash/strings/grit/ash_strings.h"
#include "ash/wm/mru_window_tracker.h" #include "ash/wm/mru_window_tracker.h"
...@@ -139,8 +140,31 @@ gfx::Rect GetGridBoundsInScreen(aura::Window* root_window, ...@@ -139,8 +140,31 @@ gfx::Rect GetGridBoundsInScreen(aura::Window* root_window,
bool divider_changed) { bool divider_changed) {
SplitViewController* split_view_controller = SplitViewController* split_view_controller =
Shell::Get()->split_view_controller(); Shell::Get()->split_view_controller();
const gfx::Rect work_area = gfx::Rect work_area =
split_view_controller->GetDisplayWorkAreaBoundsInScreen(root_window); split_view_controller->GetDisplayWorkAreaBoundsInScreen(root_window);
// If the shelf is in auto hide, overview will force it to be in auto hide
// shown, but we want to place the thumbnails as if the shelf was shown, so
// manually update the work area.
if (Shelf::ForWindow(root_window)->GetVisibilityState() == SHELF_AUTO_HIDE) {
const int inset = kShelfSize;
switch (Shelf::ForWindow(root_window)->alignment()) {
case SHELF_ALIGNMENT_BOTTOM:
case SHELF_ALIGNMENT_BOTTOM_LOCKED:
work_area.Inset(0, 0, 0, inset);
break;
case SHELF_ALIGNMENT_LEFT:
work_area.Inset(inset, 0, 0, 0);
break;
case SHELF_ALIGNMENT_RIGHT:
work_area.Inset(0, 0, inset, 0);
break;
default:
NOTREACHED();
break;
}
}
if (!split_view_controller->IsSplitViewModeActive()) if (!split_view_controller->IsSplitViewModeActive())
return work_area; return work_area;
......
...@@ -3101,6 +3101,43 @@ TEST_F(WindowSelectorTest, DraggingFromTopAnimation) { ...@@ -3101,6 +3101,43 @@ TEST_F(WindowSelectorTest, DraggingFromTopAnimation) {
window_selector()->enter_exit_overview_type()); window_selector()->enter_exit_overview_type());
} }
// Tests the grid bounds are as expected with different shelf auto hide
// behaviors and alignments.
TEST_F(WindowSelectorTest, GridBounds) {
UpdateDisplay("600x600");
const gfx::Rect bounds(200, 200);
std::unique_ptr<aura::Window> window(CreateWindow(bounds));
Shelf* shelf = GetPrimaryShelf();
shelf->SetAlignment(SHELF_ALIGNMENT_BOTTOM);
shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
// Test that with the bottom shelf, the grid should take up the entire display
// minus the shelf area on the bottom regardless of auto hide behavior.
ToggleOverview();
EXPECT_EQ(gfx::Rect(0, 0, 600, 544), GetGridBounds());
ToggleOverview();
shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
ToggleOverview();
EXPECT_EQ(gfx::Rect(0, 0, 600, 544), GetGridBounds());
ToggleOverview();
// Test that with the right shelf, the grid should take up the entire display
// minus the shelf area on the right regardless of auto hide behavior.
shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT);
shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
ToggleOverview();
EXPECT_EQ(gfx::Rect(0, 0, 544, 600), GetGridBounds());
ToggleOverview();
shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
ToggleOverview();
EXPECT_EQ(gfx::Rect(0, 0, 544, 600), GetGridBounds());
ToggleOverview();
}
class SplitViewWindowSelectorTest : public WindowSelectorTest { class SplitViewWindowSelectorTest : public WindowSelectorTest {
public: public:
SplitViewWindowSelectorTest() = default; SplitViewWindowSelectorTest() = default;
......
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