Commit e5526488 authored by Ana Salazar's avatar Ana Salazar Committed by Commit Bot

Cros: Extend the hotseat when keyboard focused

In tablet mode, when try to keyboard focus the in-app hotseat, it gets
focused but remains hidden.
This change:
- Force the hotseat to be extended in a similar way as when it gets
Chromevox focused.
- Hides the hotseat when it loses focus, unless it was manually
extended.

Bug: 1020308
Change-Id: Ie1f6ae1b91c9bd21e27552de42cf195dbf113b69
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1918642Reviewed-by: default avatarManu Cornet <manucornet@chromium.org>
Commit-Queue: Ana Salazar <anasalazar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#715741}
parent 1b344f50
......@@ -469,9 +469,13 @@ void ScrollableShelfView::OnFocusRingActivationChanged(bool activated) {
if (activated) {
focus_ring_activated_ = true;
SetPaneFocusAndFocusDefault();
if (IsInTabletMode() && chromeos::switches::ShouldShowShelfHotseat())
GetShelf()->shelf_widget()->ForceToShowHotseat();
} else {
// Shows the gradient shader when the focus ring is disabled.
focus_ring_activated_ = false;
if (IsInTabletMode() && chromeos::switches::ShouldShowShelfHotseat())
GetShelf()->shelf_widget()->ForceToHideHotseat();
}
// Not needs to update the gradient areas. Returns early.
......
......@@ -37,6 +37,7 @@
#include "ash/shelf/home_button.h"
#include "ash/shelf/shelf.h"
#include "ash/shelf/shelf_controller.h"
#include "ash/shelf/shelf_focus_cycler.h"
#include "ash/shelf/shelf_layout_manager_observer.h"
#include "ash/shelf/shelf_metrics.h"
#include "ash/shelf/shelf_navigation_widget.h"
......@@ -4575,6 +4576,38 @@ TEST_F(HotseatShelfLayoutManagerTest,
EXPECT_FALSE(GetShelfWidget()->GetOpaqueBackground()->visible());
}
// Tests that closing a window which was opened prior to entering tablet mode
// results in a kShown hotseat.
TEST_F(HotseatShelfLayoutManagerTest, ExtendHotseatIfFocusedWithKeyboard) {
TabletModeControllerTestApi().EnterTabletMode();
std::unique_ptr<aura::Window> window =
AshTestBase::CreateTestWindow(gfx::Rect(0, 0, 400, 400));
wm::ActivateWindow(window.get());
ASSERT_EQ(HotseatState::kHidden, GetShelfLayoutManager()->hotseat_state());
// Focus the shelf. Hotseat should now show extended.
GetPrimaryShelf()->shelf_focus_cycler()->FocusShelf(false /* last_element */);
EXPECT_EQ(HotseatState::kExtended, GetShelfLayoutManager()->hotseat_state());
// Focus the navigation widget. Hotseat should now hide, as it was
// automatically extended by focusing it.
GetPrimaryShelf()->shelf_focus_cycler()->FocusNavigation(
false /* last_element */);
EXPECT_EQ(HotseatState::kHidden, GetShelfLayoutManager()->hotseat_state());
// Now swipe up to show the shelf and then focus it with the keyboard. Hotseat
// should keep extended.
SwipeUpOnShelf();
GetPrimaryShelf()->shelf_focus_cycler()->FocusShelf(false /* last_element */);
EXPECT_EQ(HotseatState::kExtended, GetShelfLayoutManager()->hotseat_state());
// Now focus the navigation widget again. Hotseat should remain shown, as it
// was manually extended.
GetPrimaryShelf()->shelf_focus_cycler()->FocusNavigation(
false /* last_element */);
EXPECT_EQ(HotseatState::kExtended, GetShelfLayoutManager()->hotseat_state());
}
class ShelfLayoutManagerWindowDraggingTest : public ShelfLayoutManagerTestBase {
public:
ShelfLayoutManagerWindowDraggingTest() = default;
......
......@@ -443,6 +443,14 @@ ui::Layer* ShelfWidget::GetAnimatingBackground() {
return delegate_view_->animating_background();
}
void ShelfWidget::ForceToHideHotseat() {
if (!is_hotseat_forced_to_show_)
return;
is_hotseat_forced_to_show_ = false;
shelf_layout_manager_->UpdateVisibilityState();
}
ShelfWidget::ShelfWidget(Shelf* shelf)
: shelf_(shelf),
background_animator_(shelf_, Shell::Get()->wallpaper_controller()),
......
......@@ -133,6 +133,7 @@ class ASH_EXPORT ShelfWidget : public views::Widget,
gfx::Rect* hit_test_rect_touch);
void ForceToShowHotseat();
void ForceToHideHotseat();
bool is_hotseat_forced_to_show() const { return is_hotseat_forced_to_show_; }
......
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