Commit 369d8230 authored by Manu Cornet's avatar Manu Cornet Committed by Commit Bot

CrOS Shelf: Unify ways of checking tablet mode

Bug: None
Change-Id: Ie5ce5db5a2dfb13f96ab370102f9f1f56782d663
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2049949Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Commit-Queue: Manu Cornet <manucornet@chromium.org>
Cr-Commit-Position: refs/heads/master@{#741094}
parent f06e3e2b
...@@ -61,17 +61,13 @@ constexpr int kScrollVelocityThreshold = 6; ...@@ -61,17 +61,13 @@ constexpr int kScrollVelocityThreshold = 6;
// this ratio. // this ratio.
constexpr float kWidthRatio = 0.8f; constexpr float kWidthRatio = 0.8f;
bool IsTabletMode() {
return Shell::Get()->tablet_mode_controller()->InTabletMode();
}
// Checks if |window| can be hidden or shown with a gesture. // Checks if |window| can be hidden or shown with a gesture.
bool CanProcessWindow(aura::Window* window, bool CanProcessWindow(aura::Window* window,
HomeLauncherGestureHandler::Mode mode) { HomeLauncherGestureHandler::Mode mode) {
if (!window) if (!window)
return false; return false;
if (!IsTabletMode()) if (!Shell::Get()->IsInTabletMode())
return false; return false;
if (!window->IsVisible() && if (!window->IsVisible() &&
...@@ -769,7 +765,7 @@ bool HomeLauncherGestureHandler::SetUpWindows(Mode mode, aura::Window* window) { ...@@ -769,7 +765,7 @@ bool HomeLauncherGestureHandler::SetUpWindows(Mode mode, aura::Window* window) {
return false; return false;
} }
if (IsTabletMode() && overview_active_on_gesture_start_ && if (Shell::Get()->IsInTabletMode() && overview_active_on_gesture_start_ &&
!split_view_active && mode == Mode::kSlideUpToShow) { !split_view_active && mode == Mode::kSlideUpToShow) {
active_window_.reset(); active_window_.reset();
return true; return true;
...@@ -936,7 +932,7 @@ bool HomeLauncherGestureHandler::OnDragEnded(const gfx::PointF& location, ...@@ -936,7 +932,7 @@ bool HomeLauncherGestureHandler::OnDragEnded(const gfx::PointF& location,
} else { } else {
// In clamshell mode, AppListView::SetIsInDrag is called explicitly so it // In clamshell mode, AppListView::SetIsInDrag is called explicitly so it
// does not need the notification from HomeLauncherGestureHandler. // does not need the notification from HomeLauncherGestureHandler.
if (IsTabletMode()) { if (Shell::Get()->IsInTabletMode()) {
HomeScreenDelegate* home_screen_delegate = GetHomeScreenDelegate(); HomeScreenDelegate* home_screen_delegate = GetHomeScreenDelegate();
DCHECK(home_screen_delegate); DCHECK(home_screen_delegate);
home_screen_delegate->OnHomeLauncherDragEnd(); home_screen_delegate->OnHomeLauncherDragEnd();
......
...@@ -34,7 +34,7 @@ constexpr base::TimeDelta kAssistantAnimationDelay = ...@@ -34,7 +34,7 @@ constexpr base::TimeDelta kAssistantAnimationDelay =
// Returns true if the button should appear activatable. // Returns true if the button should appear activatable.
bool CanActivate() { bool CanActivate() {
return Shell::Get()->tablet_mode_controller()->InTabletMode() || return Shell::Get()->IsInTabletMode() ||
!Shell::Get()->app_list_controller()->IsVisible(); !Shell::Get()->app_list_controller()->IsVisible();
} }
...@@ -178,7 +178,7 @@ void HomeButtonController::StartAssistantAnimation() { ...@@ -178,7 +178,7 @@ void HomeButtonController::StartAssistantAnimation() {
void HomeButtonController::OnAppListShown() { void HomeButtonController::OnAppListShown() {
// Do not show a highlight in tablet mode, since the home screen view is // Do not show a highlight in tablet mode, since the home screen view is
// always open in the background. // always open in the background.
if (!Shell::Get()->tablet_mode_controller()->InTabletMode()) if (!Shell::Get()->IsInTabletMode())
button_->AnimateInkDrop(views::InkDropState::ACTIVATED, nullptr); button_->AnimateInkDrop(views::InkDropState::ACTIVATED, nullptr);
is_showing_app_list_ = true; is_showing_app_list_ = true;
RootWindowController::ForWindow(button_->GetWidget()->GetNativeWindow()) RootWindowController::ForWindow(button_->GetWidget()->GetNativeWindow())
......
...@@ -114,17 +114,6 @@ int GetGestureDragThreshold() { ...@@ -114,17 +114,6 @@ int GetGestureDragThreshold() {
return ShelfConfig::Get()->button_size() / 2; return ShelfConfig::Get()->button_size() / 2;
} }
bool IsInTabletMode() {
TabletModeController* tablet_mode_controller =
Shell::Get()->tablet_mode_controller();
// TabletModeController is destructed before ScrollableShelfView.
if (!tablet_mode_controller || !tablet_mode_controller->InTabletMode())
return false;
return true;
}
} // namespace } // namespace
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
...@@ -332,7 +321,7 @@ class ScrollableShelfAnimationMetricsReporter ...@@ -332,7 +321,7 @@ class ScrollableShelfAnimationMetricsReporter
// ui::AnimationMetricsReporter: // ui::AnimationMetricsReporter:
void Report(int value) override { void Report(int value) override {
base::UmaHistogramPercentage(kAnimationSmoothnessHistogram, value); base::UmaHistogramPercentage(kAnimationSmoothnessHistogram, value);
if (IsInTabletMode()) { if (Shell::Get()->IsInTabletMode()) {
if (Shell::Get()->app_list_controller()->IsVisible()) { if (Shell::Get()->app_list_controller()->IsVisible()) {
base::UmaHistogramPercentage( base::UmaHistogramPercentage(
kAnimationSmoothnessTabletLauncherVisibleHistogram, value); kAnimationSmoothnessTabletLauncherVisibleHistogram, value);
...@@ -550,12 +539,14 @@ void ScrollableShelfView::OnFocusRingActivationChanged(bool activated) { ...@@ -550,12 +539,14 @@ void ScrollableShelfView::OnFocusRingActivationChanged(bool activated) {
if (activated) { if (activated) {
focus_ring_activated_ = true; focus_ring_activated_ = true;
SetPaneFocusAndFocusDefault(); SetPaneFocusAndFocusDefault();
if (IsInTabletMode() && chromeos::switches::ShouldShowShelfHotseat()) if (Shell::Get()->IsInTabletMode() &&
chromeos::switches::ShouldShowShelfHotseat())
GetShelf()->shelf_widget()->ForceToShowHotseat(); GetShelf()->shelf_widget()->ForceToShowHotseat();
} else { } else {
// Shows the gradient shader when the focus ring is disabled. // Shows the gradient shader when the focus ring is disabled.
focus_ring_activated_ = false; focus_ring_activated_ = false;
if (IsInTabletMode() && chromeos::switches::ShouldShowShelfHotseat()) if (Shell::Get()->IsInTabletMode() &&
chromeos::switches::ShouldShowShelfHotseat())
GetShelf()->shelf_widget()->ForceToHideHotseat(); GetShelf()->shelf_widget()->ForceToHideHotseat();
} }
...@@ -1084,7 +1075,8 @@ void ScrollableShelfView::OnShelfButtonAboutToRequestFocusFromTabTraversal( ...@@ -1084,7 +1075,8 @@ void ScrollableShelfView::OnShelfButtonAboutToRequestFocusFromTabTraversal(
ShelfWidget* shelf_widget = GetShelf()->shelf_widget(); ShelfWidget* shelf_widget = GetShelf()->shelf_widget();
// In tablet mode, when the hotseat is not extended but one of the buttons // In tablet mode, when the hotseat is not extended but one of the buttons
// gets focused, it should update the visibility of the hotseat. // gets focused, it should update the visibility of the hotseat.
if (IsInTabletMode() && chromeos::switches::ShouldShowShelfHotseat() && if (Shell::Get()->IsInTabletMode() &&
chromeos::switches::ShouldShowShelfHotseat() &&
!shelf_widget->hotseat_widget()->IsExtended()) { !shelf_widget->hotseat_widget()->IsExtended()) {
shelf_widget->shelf_layout_manager()->UpdateVisibilityState(); shelf_widget->shelf_layout_manager()->UpdateVisibilityState();
} }
...@@ -1103,7 +1095,8 @@ void ScrollableShelfView::ButtonPressed(views::Button* sender, ...@@ -1103,7 +1095,8 @@ void ScrollableShelfView::ButtonPressed(views::Button* sender,
void ScrollableShelfView::HandleAccessibleActionScrollToMakeVisible( void ScrollableShelfView::HandleAccessibleActionScrollToMakeVisible(
ShelfButton* button) { ShelfButton* button) {
if (IsInTabletMode() && chromeos::switches::ShouldShowShelfHotseat()) { if (Shell::Get()->IsInTabletMode() &&
chromeos::switches::ShouldShowShelfHotseat()) {
// Only in tablet mode with hotseat enabled, may scrollable shelf be hidden. // Only in tablet mode with hotseat enabled, may scrollable shelf be hidden.
GetShelf()->shelf_widget()->ForceToShowHotseat(); GetShelf()->shelf_widget()->ForceToShowHotseat();
} }
...@@ -1485,7 +1478,7 @@ bool ScrollableShelfView::ProcessGestureEvent(const ui::GestureEvent& event) { ...@@ -1485,7 +1478,7 @@ bool ScrollableShelfView::ProcessGestureEvent(const ui::GestureEvent& event) {
// end. // end.
if (event.type() == ui::ET_GESTURE_SCROLL_BEGIN) { if (event.type() == ui::ET_GESTURE_SCROLL_BEGIN) {
DCHECK(!presentation_time_recorder_); DCHECK(!presentation_time_recorder_);
if (IsInTabletMode()) { if (Shell::Get()->IsInTabletMode()) {
if (Shell::Get()->app_list_controller()->IsVisible()) { if (Shell::Get()->app_list_controller()->IsVisible()) {
presentation_time_recorder_ = CreatePresentationTimeHistogramRecorder( presentation_time_recorder_ = CreatePresentationTimeHistogramRecorder(
GetWidget()->GetCompositor(), GetWidget()->GetCompositor(),
...@@ -2004,8 +1997,8 @@ void ScrollableShelfView::UpdateAvailableSpace() { ...@@ -2004,8 +1997,8 @@ void ScrollableShelfView::UpdateAvailableSpace() {
gfx::Rect ScrollableShelfView::CalculateVisibleSpace( gfx::Rect ScrollableShelfView::CalculateVisibleSpace(
LayoutStrategy layout_strategy) const { LayoutStrategy layout_strategy) const {
const bool in_hotseat_tablet = const bool in_hotseat_tablet = chromeos::switches::ShouldShowShelfHotseat() &&
chromeos::switches::ShouldShowShelfHotseat() && IsInTabletMode(); Shell::Get()->IsInTabletMode();
if (layout_strategy == kNotShowArrowButtons && !in_hotseat_tablet) if (layout_strategy == kNotShowArrowButtons && !in_hotseat_tablet)
return GetAvailableLocalBounds(/*use_target_bounds=*/false); return GetAvailableLocalBounds(/*use_target_bounds=*/false);
...@@ -2040,8 +2033,8 @@ gfx::Rect ScrollableShelfView::CalculateVisibleSpace( ...@@ -2040,8 +2033,8 @@ gfx::Rect ScrollableShelfView::CalculateVisibleSpace(
gfx::Insets ScrollableShelfView::CalculateRipplePaddingInsets() const { gfx::Insets ScrollableShelfView::CalculateRipplePaddingInsets() const {
// Indicates whether it is in tablet mode with hotseat enabled. // Indicates whether it is in tablet mode with hotseat enabled.
const bool in_hotseat_tablet = const bool in_hotseat_tablet = chromeos::switches::ShouldShowShelfHotseat() &&
chromeos::switches::ShouldShowShelfHotseat() && IsInTabletMode(); Shell::Get()->IsInTabletMode();
const int ripple_padding = const int ripple_padding =
ShelfConfig::Get()->scrollable_shelf_ripple_padding(); ShelfConfig::Get()->scrollable_shelf_ripple_padding();
...@@ -2060,7 +2053,8 @@ gfx::Insets ScrollableShelfView::CalculateRipplePaddingInsets() const { ...@@ -2060,7 +2053,8 @@ gfx::Insets ScrollableShelfView::CalculateRipplePaddingInsets() const {
gfx::RoundedCornersF gfx::RoundedCornersF
ScrollableShelfView::CalculateShelfContainerRoundedCorners() const { ScrollableShelfView::CalculateShelfContainerRoundedCorners() const {
if (!chromeos::switches::ShouldShowShelfHotseat() || !IsInTabletMode()) if (!chromeos::switches::ShouldShowShelfHotseat() ||
!Shell::Get()->IsInTabletMode())
return gfx::RoundedCornersF(); return gfx::RoundedCornersF();
const bool is_horizontal_alignment = GetShelf()->IsHorizontalAlignment(); const bool is_horizontal_alignment = GetShelf()->IsHorizontalAlignment();
......
...@@ -27,12 +27,6 @@ namespace { ...@@ -27,12 +27,6 @@ namespace {
// dense shelf will be active. // dense shelf will be active.
const int kDenseShelfScreenSizeThreshold = 600; const int kDenseShelfScreenSizeThreshold = 600;
// Returns whether tablet mode is currently active.
bool IsTabletMode() {
return Shell::Get()->tablet_mode_controller() &&
Shell::Get()->tablet_mode_controller()->InTabletMode();
}
// Whether the the shelf control buttons must be shown for accessibility // Whether the the shelf control buttons must be shown for accessibility
// reasons. // reasons.
bool ShelfControlsForcedShownForAccessibility() { bool ShelfControlsForcedShownForAccessibility() {
...@@ -185,7 +179,8 @@ int ShelfConfig::system_shelf_size() const { ...@@ -185,7 +179,8 @@ int ShelfConfig::system_shelf_size() const {
} }
int ShelfConfig::hotseat_size() const { int ShelfConfig::hotseat_size() const {
if (!chromeos::switches::ShouldShowShelfHotseat() || !IsTabletMode()) { if (!chromeos::switches::ShouldShowShelfHotseat() ||
!Shell::Get()->IsInTabletMode()) {
return shelf_size(); return shelf_size();
} }
return is_dense_ ? 48 : 56; return is_dense_ ? 48 : 56;
...@@ -211,7 +206,7 @@ int ShelfConfig::control_size() const { ...@@ -211,7 +206,7 @@ int ShelfConfig::control_size() const {
if (!chromeos::switches::ShouldShowShelfHotseat()) if (!chromeos::switches::ShouldShowShelfHotseat())
return 40; return 40;
if (!IsTabletMode()) if (!Shell::Get()->IsInTabletMode())
return 36; return 36;
return is_dense_ ? 36 : 40; return is_dense_ ? 36 : 40;
...@@ -219,7 +214,7 @@ int ShelfConfig::control_size() const { ...@@ -219,7 +214,7 @@ int ShelfConfig::control_size() const {
int ShelfConfig::control_border_radius() const { int ShelfConfig::control_border_radius() const {
return (chromeos::switches::ShouldShowShelfHotseat() && is_in_app() && return (chromeos::switches::ShouldShowShelfHotseat() && is_in_app() &&
IsTabletMode()) Shell::Get()->IsInTabletMode())
? control_size() / 2 - in_app_control_button_height_inset_ ? control_size() / 2 - in_app_control_button_height_inset_
: control_size() / 2; : control_size() / 2;
} }
...@@ -230,7 +225,7 @@ int ShelfConfig::overflow_button_margin() const { ...@@ -230,7 +225,7 @@ int ShelfConfig::overflow_button_margin() const {
int ShelfConfig::control_button_edge_spacing(bool is_primary_axis_edge) const { int ShelfConfig::control_button_edge_spacing(bool is_primary_axis_edge) const {
if (is_primary_axis_edge) if (is_primary_axis_edge)
return IsTabletMode() ? 8 : 6; return Shell::Get()->IsInTabletMode() ? 8 : 6;
return (shelf_size() - control_size()) / 2; return (shelf_size() - control_size()) / 2;
} }
...@@ -265,7 +260,7 @@ void ShelfConfig::UpdateConfig(bool app_list_visible) { ...@@ -265,7 +260,7 @@ void ShelfConfig::UpdateConfig(bool app_list_visible) {
const gfx::Rect screen_size = const gfx::Rect screen_size =
display::Screen::GetScreen()->GetPrimaryDisplay().bounds(); display::Screen::GetScreen()->GetPrimaryDisplay().bounds();
const bool in_tablet_mode = IsTabletMode(); const bool in_tablet_mode = Shell::Get()->IsInTabletMode();
const bool new_is_dense = const bool new_is_dense =
chromeos::switches::ShouldShowShelfHotseat() && chromeos::switches::ShouldShowShelfHotseat() &&
(!in_tablet_mode || (!in_tablet_mode ||
...@@ -297,7 +292,7 @@ int ShelfConfig::GetShelfSize(bool ignore_in_app_state) const { ...@@ -297,7 +292,7 @@ int ShelfConfig::GetShelfSize(bool ignore_in_app_state) const {
return 56; return 56;
// In clamshell mode, the shelf always has the same size. // In clamshell mode, the shelf always has the same size.
if (!IsTabletMode()) if (!Shell::Get()->IsInTabletMode())
return 48; return 48;
if (!ignore_in_app_state && is_in_app()) if (!ignore_in_app_state && is_in_app())
...@@ -310,7 +305,8 @@ SkColor ShelfConfig::GetShelfControlButtonColor() const { ...@@ -310,7 +305,8 @@ SkColor ShelfConfig::GetShelfControlButtonColor() const {
const session_manager::SessionState session_state = const session_manager::SessionState session_state =
Shell::Get()->session_controller()->GetSessionState(); Shell::Get()->session_controller()->GetSessionState();
if (chromeos::switches::ShouldShowShelfHotseat() && IsTabletMode() && if (chromeos::switches::ShouldShowShelfHotseat() &&
Shell::Get()->IsInTabletMode() &&
session_state == session_manager::SessionState::ACTIVE) { session_state == session_manager::SessionState::ACTIVE) {
return is_in_app() ? SK_ColorTRANSPARENT : GetDefaultShelfColor(); return is_in_app() ? SK_ColorTRANSPARENT : GetDefaultShelfColor();
} else if (session_state == session_manager::SessionState::OOBE) { } else if (session_state == session_manager::SessionState::OOBE) {
...@@ -359,10 +355,10 @@ SkColor ShelfConfig::GetDefaultShelfColor() const { ...@@ -359,10 +355,10 @@ SkColor ShelfConfig::GetDefaultShelfColor() const {
AshColorProvider::BaseLayerType layer_type; AshColorProvider::BaseLayerType layer_type;
if (!chromeos::switches::ShouldShowShelfHotseat()) { if (!chromeos::switches::ShouldShowShelfHotseat()) {
layer_type = IsTabletMode() layer_type = Shell::Get()->IsInTabletMode()
? AshColorProvider::BaseLayerType::kTransparent60 ? AshColorProvider::BaseLayerType::kTransparent60
: AshColorProvider::BaseLayerType::kTransparent80; : AshColorProvider::BaseLayerType::kTransparent80;
} else if (IsTabletMode()) { } else if (Shell::Get()->IsInTabletMode()) {
layer_type = is_in_app() ? AshColorProvider::BaseLayerType::kTransparent90 layer_type = is_in_app() ? AshColorProvider::BaseLayerType::kTransparent90
: AshColorProvider::BaseLayerType::kTransparent60; : AshColorProvider::BaseLayerType::kTransparent60;
} else { } else {
...@@ -377,15 +373,16 @@ SkColor ShelfConfig::GetDefaultShelfColor() const { ...@@ -377,15 +373,16 @@ SkColor ShelfConfig::GetDefaultShelfColor() const {
int ShelfConfig::GetShelfControlButtonBlurRadius() const { int ShelfConfig::GetShelfControlButtonBlurRadius() const {
if (features::IsBackgroundBlurEnabled() && if (features::IsBackgroundBlurEnabled() &&
chromeos::switches::ShouldShowShelfHotseat() && IsTabletMode() && chromeos::switches::ShouldShowShelfHotseat() &&
!is_in_app()) { Shell::Get()->IsInTabletMode() && !is_in_app()) {
return shelf_blur_radius_; return shelf_blur_radius_;
} }
return 0; return 0;
} }
int ShelfConfig::GetAppIconEndPadding() const { int ShelfConfig::GetAppIconEndPadding() const {
return (chromeos::switches::ShouldShowShelfHotseat() && IsTabletMode()) return (chromeos::switches::ShouldShowShelfHotseat() &&
Shell::Get()->IsInTabletMode())
? app_icon_end_padding_ ? app_icon_end_padding_
: 0; : 0;
} }
......
...@@ -42,8 +42,7 @@ class ShelfControlButtonHighlightPathGenerator ...@@ -42,8 +42,7 @@ class ShelfControlButtonHighlightPathGenerator
visual_bounds.ClampToCenteredSize( visual_bounds.ClampToCenteredSize(
gfx::SizeF(shelf_config->control_size(), shelf_config->control_size())); gfx::SizeF(shelf_config->control_size(), shelf_config->control_size()));
if (chromeos::switches::ShouldShowShelfHotseat() && if (chromeos::switches::ShouldShowShelfHotseat() &&
Shell::Get()->tablet_mode_controller()->InTabletMode() && Shell::Get()->IsInTabletMode() && shelf_config->is_in_app()) {
shelf_config->is_in_app()) {
visual_bounds.Inset(0, visual_bounds.Inset(0,
shelf_config->in_app_control_button_height_inset()); shelf_config->in_app_control_button_height_inset());
} }
......
...@@ -42,7 +42,6 @@ ...@@ -42,7 +42,6 @@
#include "ash/wm/overview/overview_controller.h" #include "ash/wm/overview/overview_controller.h"
#include "ash/wm/screen_pinning_controller.h" #include "ash/wm/screen_pinning_controller.h"
#include "ash/wm/splitview/split_view_controller.h" #include "ash/wm/splitview/split_view_controller.h"
#include "ash/wm/tablet_mode/tablet_mode_controller.h"
#include "ash/wm/window_state.h" #include "ash/wm/window_state.h"
#include "ash/wm/window_util.h" #include "ash/wm/window_util.h"
#include "ash/wm/work_area_insets.h" #include "ash/wm/work_area_insets.h"
...@@ -139,15 +138,9 @@ bool IsAppListWindow(const aura::Window* window) { ...@@ -139,15 +138,9 @@ bool IsAppListWindow(const aura::Window* window) {
return parent && parent->id() == kShellWindowId_AppListContainer; return parent && parent->id() == kShellWindowId_AppListContainer;
} }
bool IsTabletModeEnabled() {
// Shell could be destroying. Shell destroys TabletModeController before
// closing all windows.
return Shell::Get()->tablet_mode_controller() &&
Shell::Get()->tablet_mode_controller()->InTabletMode();
}
bool IsHotseatEnabled() { bool IsHotseatEnabled() {
return IsTabletModeEnabled() && chromeos::switches::ShouldShowShelfHotseat(); return Shell::Get()->IsInTabletMode() &&
chromeos::switches::ShouldShowShelfHotseat();
} }
int GetOffset(int offset, bool from_touchpad) { int GetOffset(int offset, bool from_touchpad) {
...@@ -197,7 +190,7 @@ int GetShelfInset(ShelfVisibilityState visibility_state, int size) { ...@@ -197,7 +190,7 @@ int GetShelfInset(ShelfVisibilityState visibility_state, int size) {
// window. // window.
aura::Window* GetWindowForDragToHomeOrOverview( aura::Window* GetWindowForDragToHomeOrOverview(
const gfx::Point& location_in_screen) { const gfx::Point& location_in_screen) {
if (!IsTabletModeEnabled()) if (!Shell::Get()->IsInTabletMode())
return nullptr; return nullptr;
auto mru_windows = auto mru_windows =
...@@ -475,7 +468,8 @@ gfx::Rect ShelfLayoutManager::GetIdealBounds() const { ...@@ -475,7 +468,8 @@ gfx::Rect ShelfLayoutManager::GetIdealBounds() const {
} }
gfx::Rect ShelfLayoutManager::GetIdealBoundsForWorkAreaCalculation() const { gfx::Rect ShelfLayoutManager::GetIdealBoundsForWorkAreaCalculation() const {
if (!IsTabletModeEnabled() || !chromeos::switches::ShouldShowShelfHotseat() || if (!Shell::Get()->IsInTabletMode() ||
!chromeos::switches::ShouldShowShelfHotseat() ||
state_.session_state != session_manager::SessionState::ACTIVE) { state_.session_state != session_manager::SessionState::ACTIVE) {
return GetIdealBounds(); return GetIdealBounds();
} }
...@@ -787,7 +781,7 @@ ShelfBackgroundType ShelfLayoutManager::GetShelfBackgroundType() const { ...@@ -787,7 +781,7 @@ ShelfBackgroundType ShelfLayoutManager::GetShelfBackgroundType() const {
const bool in_overview = const bool in_overview =
Shell::Get()->overview_controller() && Shell::Get()->overview_controller() &&
Shell::Get()->overview_controller()->InOverviewSession(); Shell::Get()->overview_controller()->InOverviewSession();
if (IsTabletModeEnabled()) { if (Shell::Get()->IsInTabletMode()) {
if (app_list_is_visible) { if (app_list_is_visible) {
// If the home launcher is shown or mostly shown, show the home launcher // If the home launcher is shown or mostly shown, show the home launcher
// background. If it is mostly hidden, show the in-app or overview // background. If it is mostly hidden, show the in-app or overview
...@@ -819,7 +813,8 @@ ShelfBackgroundType ShelfLayoutManager::GetShelfBackgroundType() const { ...@@ -819,7 +813,8 @@ ShelfBackgroundType ShelfLayoutManager::GetShelfBackgroundType() const {
// When a window is maximized, if the auto-hide shelf is enabled and we are // When a window is maximized, if the auto-hide shelf is enabled and we are
// in clamshell mode, the shelf will keep the default transparent // in clamshell mode, the shelf will keep the default transparent
// background. // background.
if (!IsTabletModeEnabled() && state_.visibility_state == SHELF_AUTO_HIDE) if (!Shell::Get()->IsInTabletMode() &&
state_.visibility_state == SHELF_AUTO_HIDE)
return ShelfBackgroundType::kDefaultBg; return ShelfBackgroundType::kDefaultBg;
return ShelfBackgroundType::kMaximized; return ShelfBackgroundType::kMaximized;
...@@ -1583,7 +1578,7 @@ void ShelfLayoutManager::UpdateBoundsAndOpacity(bool animate) { ...@@ -1583,7 +1578,7 @@ void ShelfLayoutManager::UpdateBoundsAndOpacity(bool animate) {
bool ShelfLayoutManager::IsDraggingWindowFromTopOrCaptionArea() const { bool ShelfLayoutManager::IsDraggingWindowFromTopOrCaptionArea() const {
// Currently dragging maximized or fullscreen window from the top or the // Currently dragging maximized or fullscreen window from the top or the
// caption area is only allowed in tablet mode. // caption area is only allowed in tablet mode.
if (!IsTabletModeEnabled()) if (!Shell::Get()->IsInTabletMode())
return false; return false;
// TODO(minch): Check active window directly if removed search field // TODO(minch): Check active window directly if removed search field
...@@ -1865,7 +1860,7 @@ ShelfAutoHideState ShelfLayoutManager::CalculateAutoHideState( ...@@ -1865,7 +1860,7 @@ ShelfAutoHideState ShelfLayoutManager::CalculateAutoHideState(
if (shelf_->auto_hide_lock()) if (shelf_->auto_hide_lock())
return state_.auto_hide_state; return state_.auto_hide_state;
const bool in_tablet_mode = IsTabletModeEnabled(); const bool in_tablet_mode = Shell::Get()->IsInTabletMode();
// Don't let the shelf auto-hide when in tablet mode and Chromevox is on. // Don't let the shelf auto-hide when in tablet mode and Chromevox is on.
if (in_tablet_mode && if (in_tablet_mode &&
Shell::Get()->accessibility_controller()->spoken_feedback_enabled()) { Shell::Get()->accessibility_controller()->spoken_feedback_enabled()) {
...@@ -1937,7 +1932,7 @@ base::Optional<ShelfAutoHideState> ...@@ -1937,7 +1932,7 @@ base::Optional<ShelfAutoHideState>
ShelfLayoutManager::CalculateAutoHideStateBasedOnCursorLocation() const { ShelfLayoutManager::CalculateAutoHideStateBasedOnCursorLocation() const {
// No mouse is available in tablet mode. So there is no point to calculate // No mouse is available in tablet mode. So there is no point to calculate
// the auto-hide state by the cursor location in this scenario. // the auto-hide state by the cursor location in this scenario.
const bool in_tablet_mode = IsTabletModeEnabled(); const bool in_tablet_mode = Shell::Get()->IsInTabletMode();
if (in_tablet_mode) if (in_tablet_mode)
return base::nullopt; return base::nullopt;
...@@ -2023,7 +2018,8 @@ void ShelfLayoutManager::UpdateShelfVisibilityAfterLoginUIChange() { ...@@ -2023,7 +2018,8 @@ void ShelfLayoutManager::UpdateShelfVisibilityAfterLoginUIChange() {
float ShelfLayoutManager::ComputeTargetOpacity(const State& state) const { float ShelfLayoutManager::ComputeTargetOpacity(const State& state) const {
// The shelf should not become transparent during the animation to or from // The shelf should not become transparent during the animation to or from
// HomeLauncher. // HomeLauncher.
if (chromeos::switches::ShouldShowShelfHotseat() && IsTabletModeEnabled() && if (chromeos::switches::ShouldShowShelfHotseat() &&
Shell::Get()->IsInTabletMode() &&
Shell::Get()->app_list_controller()->home_launcher_transition_state() != Shell::Get()->app_list_controller()->home_launcher_transition_state() !=
AppListControllerImpl::HomeLauncherTransitionState::kFinished) { AppListControllerImpl::HomeLauncherTransitionState::kFinished) {
return 1.0f; return 1.0f;
...@@ -2054,7 +2050,7 @@ float ShelfLayoutManager::ComputeTargetOpacity(const State& state) const { ...@@ -2054,7 +2050,7 @@ float ShelfLayoutManager::ComputeTargetOpacity(const State& state) const {
bool ShelfLayoutManager::IsShelfHiddenForFullscreen() const { bool ShelfLayoutManager::IsShelfHiddenForFullscreen() const {
// If the non-fullscreen app list should be shown, the shelf should not be // If the non-fullscreen app list should be shown, the shelf should not be
// hidden. // hidden.
if (!IsTabletModeEnabled() && if (!Shell::Get()->IsInTabletMode() &&
Shell::Get()->app_list_controller()->GetTargetVisibility()) { Shell::Get()->app_list_controller()->GetTargetVisibility()) {
return false; return false;
} }
...@@ -2258,7 +2254,7 @@ bool ShelfLayoutManager::StartAppListDrag( ...@@ -2258,7 +2254,7 @@ bool ShelfLayoutManager::StartAppListDrag(
float scroll_y_hint) { float scroll_y_hint) {
// If the home screen is available, gesture dragging is handled by // If the home screen is available, gesture dragging is handled by
// HomeLauncherGestureHandler. // HomeLauncherGestureHandler.
if (IsTabletModeEnabled() && event_in_screen.IsGestureEvent()) if (Shell::Get()->IsInTabletMode() && event_in_screen.IsGestureEvent())
return false; return false;
// Fullscreen app list can only be dragged from bottom alignment shelf. // Fullscreen app list can only be dragged from bottom alignment shelf.
...@@ -2304,7 +2300,7 @@ bool ShelfLayoutManager::StartShelfDrag(const ui::LocatedEvent& event_in_screen, ...@@ -2304,7 +2300,7 @@ bool ShelfLayoutManager::StartShelfDrag(const ui::LocatedEvent& event_in_screen,
const gfx::Vector2dF& scroll_hint) { const gfx::Vector2dF& scroll_hint) {
// Disable the shelf dragging if the fullscreen app list is opened. // Disable the shelf dragging if the fullscreen app list is opened.
if (Shell::Get()->app_list_controller()->IsVisible() && if (Shell::Get()->app_list_controller()->IsVisible() &&
!IsTabletModeEnabled()) !Shell::Get()->IsInTabletMode())
return false; return false;
// Also disable shelf drags until the overflow shelf is closed. // Also disable shelf drags until the overflow shelf is closed.
...@@ -2430,7 +2426,8 @@ void ShelfLayoutManager::CompleteDrag(const ui::LocatedEvent& event_in_screen) { ...@@ -2430,7 +2426,8 @@ void ShelfLayoutManager::CompleteDrag(const ui::LocatedEvent& event_in_screen) {
window_drag_controller_->FinalizeDraggedWindow(); window_drag_controller_->FinalizeDraggedWindow();
// Hotseat gestures are meaningful only in tablet mode with hotseat enabled. // Hotseat gestures are meaningful only in tablet mode with hotseat enabled.
if (chromeos::switches::ShouldShowShelfHotseat() && IsTabletModeEnabled()) { if (chromeos::switches::ShouldShowShelfHotseat() &&
Shell::Get()->IsInTabletMode()) {
base::Optional<InAppShelfGestures> gesture_to_record = base::Optional<InAppShelfGestures> gesture_to_record =
CalculateHotseatGestureToRecord(window_drag_result, CalculateHotseatGestureToRecord(window_drag_result,
transitioned_from_overview_to_home, transitioned_from_overview_to_home,
...@@ -2643,7 +2640,7 @@ bool ShelfLayoutManager::MaybeStartDragWindowFromShelf( ...@@ -2643,7 +2640,7 @@ bool ShelfLayoutManager::MaybeStartDragWindowFromShelf(
const gfx::Vector2dF& scroll) { const gfx::Vector2dF& scroll) {
if (!features::IsDragFromShelfToHomeOrOverviewEnabled()) if (!features::IsDragFromShelfToHomeOrOverviewEnabled())
return false; return false;
if (!IsTabletModeEnabled()) if (!Shell::Get()->IsInTabletMode())
return false; return false;
if (drag_status_ != kDragInProgress) if (drag_status_ != kDragInProgress)
return false; return false;
......
...@@ -33,11 +33,6 @@ namespace { ...@@ -33,11 +33,6 @@ namespace {
constexpr base::TimeDelta kButtonOpacityAnimationDuration = constexpr base::TimeDelta kButtonOpacityAnimationDuration =
base::TimeDelta::FromMilliseconds(50); base::TimeDelta::FromMilliseconds(50);
bool IsTabletMode() {
return Shell::Get()->tablet_mode_controller() &&
Shell::Get()->tablet_mode_controller()->InTabletMode();
}
// Returns the bounds for the first button shown in this view (the back // Returns the bounds for the first button shown in this view (the back
// button in tablet mode, the home button otherwise). // button in tablet mode, the home button otherwise).
gfx::Rect GetFirstButtonBounds(bool is_shelf_horizontal) { gfx::Rect GetFirstButtonBounds(bool is_shelf_horizontal) {
...@@ -68,8 +63,8 @@ bool IsBackButtonShown() { ...@@ -68,8 +63,8 @@ bool IsBackButtonShown() {
if (!ShelfConfig::Get()->shelf_controls_shown()) if (!ShelfConfig::Get()->shelf_controls_shown())
return false; return false;
return chromeos::switches::ShouldShowShelfHotseat() return chromeos::switches::ShouldShowShelfHotseat()
? IsTabletMode() && ShelfConfig::Get()->is_in_app() ? Shell::Get()->IsInTabletMode() && ShelfConfig::Get()->is_in_app()
: IsTabletMode(); : Shell::Get()->IsInTabletMode();
} }
bool IsHomeButtonShown() { bool IsHomeButtonShown() {
...@@ -185,8 +180,8 @@ void ShelfNavigationWidget::Delegate::UpdateOpaqueBackground() { ...@@ -185,8 +180,8 @@ void ShelfNavigationWidget::Delegate::UpdateOpaqueBackground() {
return; return;
} }
if (chromeos::switches::ShouldShowShelfHotseat() && IsTabletMode() && if (chromeos::switches::ShouldShowShelfHotseat() &&
ShelfConfig::Get()->is_in_app()) { Shell::Get()->IsInTabletMode() && ShelfConfig::Get()->is_in_app()) {
opaque_background_.SetVisible(false); opaque_background_.SetVisible(false);
return; return;
} }
...@@ -477,7 +472,8 @@ void ShelfNavigationWidget::UpdateTargetBoundsForGesture() { ...@@ -477,7 +472,8 @@ void ShelfNavigationWidget::UpdateTargetBoundsForGesture() {
const gfx::Point shelf_origin = const gfx::Point shelf_origin =
shelf_->shelf_widget()->GetTargetBounds().origin(); shelf_->shelf_widget()->GetTargetBounds().origin();
if (shelf_->IsHorizontalAlignment()) { if (shelf_->IsHorizontalAlignment()) {
if (!IsTabletMode() || !chromeos::switches::ShouldShowShelfHotseat()) { if (!Shell::Get()->IsInTabletMode() ||
!chromeos::switches::ShouldShowShelfHotseat()) {
target_bounds_.set_y(shelf_origin.y() + target_bounds_.set_y(shelf_origin.y() +
ShelfConfig::Get()->button_spacing()); ShelfConfig::Get()->button_spacing());
} }
......
...@@ -74,11 +74,6 @@ views::View* FindFirstOrLastFocusableChild(views::View* root, ...@@ -74,11 +74,6 @@ views::View* FindFirstOrLastFocusableChild(views::View* root,
&dummy_focus_traversable, &dummy_focus_traversable_view); &dummy_focus_traversable, &dummy_focus_traversable_view);
} }
bool IsInTabletMode() {
return Shell::Get()->tablet_mode_controller() &&
Shell::Get()->tablet_mode_controller()->InTabletMode();
}
} // namespace } // namespace
// The contents view of the Shelf. In an active session, this is used to // The contents view of the Shelf. In an active session, this is used to
...@@ -304,7 +299,7 @@ void ShelfWidget::DelegateView::UpdateOpaqueBackground() { ...@@ -304,7 +299,7 @@ void ShelfWidget::DelegateView::UpdateOpaqueBackground() {
const Shelf* shelf = shelf_widget_->shelf(); const Shelf* shelf = shelf_widget_->shelf();
const ShelfBackgroundType background_type = const ShelfBackgroundType background_type =
shelf_widget_->GetBackgroundType(); shelf_widget_->GetBackgroundType();
const bool tablet_mode = IsInTabletMode(); const bool tablet_mode = Shell::Get()->IsInTabletMode();
const bool in_app = ShelfConfig::Get()->is_in_app(); const bool in_app = ShelfConfig::Get()->is_in_app();
bool show_opaque_background = bool show_opaque_background =
...@@ -350,7 +345,7 @@ void ShelfWidget::DelegateView::UpdateOpaqueBackground() { ...@@ -350,7 +345,7 @@ void ShelfWidget::DelegateView::UpdateOpaqueBackground() {
} }
void ShelfWidget::DelegateView::UpdateDragHandle() { void ShelfWidget::DelegateView::UpdateDragHandle() {
if (!IsInTabletMode() || !ShelfConfig::Get()->is_in_app() || if (!Shell::Get()->IsInTabletMode() || !ShelfConfig::Get()->is_in_app() ||
!chromeos::switches::ShouldShowShelfHotseat() || !chromeos::switches::ShouldShowShelfHotseat() ||
hide_background_for_transitions_) { hide_background_for_transitions_) {
drag_handle_->SetVisible(false); drag_handle_->SetVisible(false);
...@@ -588,7 +583,7 @@ void ShelfWidget::RegisterHotseatWidget(HotseatWidget* hotseat_widget) { ...@@ -588,7 +583,7 @@ void ShelfWidget::RegisterHotseatWidget(HotseatWidget* hotseat_widget) {
void ShelfWidget::OnTabletModeChanged() { void ShelfWidget::OnTabletModeChanged() {
// Resets |is_hotseat_forced_to_show| when leaving the tablet mode. // Resets |is_hotseat_forced_to_show| when leaving the tablet mode.
if (!IsInTabletMode()) if (!Shell::Get()->IsInTabletMode())
is_hotseat_forced_to_show_ = false; is_hotseat_forced_to_show_ = false;
} }
......
...@@ -416,6 +416,10 @@ void Shell::OnDictationEnded() { ...@@ -416,6 +416,10 @@ void Shell::OnDictationEnded() {
observer.OnDictationEnded(); observer.OnDictationEnded();
} }
bool Shell::IsInTabletMode() const {
return tablet_mode_controller()->InTabletMode();
}
bool Shell::ShouldSaveDisplaySettings() { bool Shell::ShouldSaveDisplaySettings() {
return !( return !(
screen_orientation_controller_->ignore_display_configuration_updates() || screen_orientation_controller_->ignore_display_configuration_updates() ||
......
...@@ -284,7 +284,12 @@ class ASH_EXPORT Shell : public SessionObserver, ...@@ -284,7 +284,12 @@ class ASH_EXPORT Shell : public SessionObserver,
// Called when dictation is ended. // Called when dictation is ended.
void OnDictationEnded(); void OnDictationEnded();
// Test if TabletModeWindowManager is not enabled, and if // Returns whether the device is currently in tablet mode. If the tablet
// mode controller isn't available, we assume the device is not in
// tablet mode.
bool IsInTabletMode() const;
// Tests if TabletModeWindowManager is not enabled, and if
// TabletModeController is not currently setting a display rotation. Or if // TabletModeController is not currently setting a display rotation. Or if
// the |resolution_notification_controller_| is not showing its confirmation // the |resolution_notification_controller_| is not showing its confirmation
// dialog. If true then changes to display settings can be saved. // dialog. If true then changes to display settings can be saved.
...@@ -470,7 +475,7 @@ class ASH_EXPORT Shell : public SessionObserver, ...@@ -470,7 +475,7 @@ class ASH_EXPORT Shell : public SessionObserver,
SystemTrayNotifier* system_tray_notifier() { SystemTrayNotifier* system_tray_notifier() {
return system_tray_notifier_.get(); return system_tray_notifier_.get();
} }
TabletModeController* tablet_mode_controller() { TabletModeController* tablet_mode_controller() const {
return tablet_mode_controller_.get(); return tablet_mode_controller_.get();
} }
ToastManagerImpl* toast_manager() { return toast_manager_.get(); } ToastManagerImpl* toast_manager() { return toast_manager_.get(); }
......
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