Commit b92d75ce authored by Sammie Quon's avatar Sammie Quon Committed by Commit Bot

Reland "applist: Introduce HomeLauncherGestureHandler."

This is a reland of c40ba7f2. Added
a missing ASH_EXPORT which was causing ash_unittests to fail.

TBR=xiyuan@chromium.org

Original change's description:
> applist: Introduce HomeLauncherGestureHandler.
>
> Introduce swipe down gesture to homecher. This cl implements the design
> at: https://docs.google.com/document/d/1Bt5956kVDcgUz-_BTJc6M1wm5d03onBgJWE3vHQQGl0/edit#
>
> The design doc states to use a new ScopedClass but after a bit more
> thought I think that would be more difficult especially once animations
> are added.
>
> This should be behind a enabled by default flag, but I do not want to
> merge too much during code review, so I will add the flag shortly
> after this lands.
>
> Test: added tests
> Bug: 872319
> Change-Id: Ibc2dd7344fb3cdb81967b0eefb41d58d377688a3
> Reviewed-on: https://chromium-review.googlesource.com/1184326
> Commit-Queue: Sammie Quon <sammiequon@chromium.org>
> Reviewed-by: Weidong Guo <weidongg@chromium.org>
> Reviewed-by: Xiyuan Xia <xiyuan@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#585524}

Bug: 872319
Change-Id: Ic3b2320e96cb1fd770ce60a5d48818e7ee78d21c
Reviewed-on: https://chromium-review.googlesource.com/1187042Reviewed-by: default avatarSammie Quon <sammiequon@chromium.org>
Commit-Queue: Sammie Quon <sammiequon@chromium.org>
Cr-Commit-Position: refs/heads/master@{#585728}
parent e2296191
...@@ -156,6 +156,8 @@ component("ash") { ...@@ -156,6 +156,8 @@ component("ash") {
"app_list/app_list_controller_impl.cc", "app_list/app_list_controller_impl.cc",
"app_list/app_list_presenter_delegate_impl.cc", "app_list/app_list_presenter_delegate_impl.cc",
"app_list/app_list_presenter_delegate_impl.h", "app_list/app_list_presenter_delegate_impl.h",
"app_list/home_launcher_gesture_handler.cc",
"app_list/home_launcher_gesture_handler.h",
"ash_export.h", "ash_export.h",
"ash_service.cc", "ash_service.cc",
"assistant/assistant_cache_controller.cc", "assistant/assistant_cache_controller.cc",
...@@ -1695,6 +1697,7 @@ test("ash_unittests") { ...@@ -1695,6 +1697,7 @@ test("ash_unittests") {
"accessibility/touch_exploration_manager_unittest.cc", "accessibility/touch_exploration_manager_unittest.cc",
"app_launch_unittest.cc", "app_launch_unittest.cc",
"app_list/app_list_presenter_delegate_unittest.cc", "app_list/app_list_presenter_delegate_unittest.cc",
"app_list/home_launcher_gesture_handler_unittest.cc",
"app_list/model/app_list_item_list_unittest.cc", "app_list/model/app_list_item_list_unittest.cc",
"app_list/model/app_list_model_unittest.cc", "app_list/model/app_list_model_unittest.cc",
"app_list/presenter/app_list_presenter_impl_unittest.cc", "app_list/presenter/app_list_presenter_impl_unittest.cc",
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <vector> #include <vector>
#include "ash/app_list/app_list_presenter_delegate_impl.h" #include "ash/app_list/app_list_presenter_delegate_impl.h"
#include "ash/app_list/home_launcher_gesture_handler.h"
#include "ash/app_list/model/app_list_folder_item.h" #include "ash/app_list/model/app_list_folder_item.h"
#include "ash/app_list/model/app_list_item.h" #include "ash/app_list/model/app_list_item.h"
#include "ash/app_list/views/app_list_main_view.h" #include "ash/app_list/views/app_list_main_view.h"
...@@ -72,6 +73,11 @@ AppListControllerImpl::AppListControllerImpl( ...@@ -72,6 +73,11 @@ AppListControllerImpl::AppListControllerImpl(
Shell::Get()->AddShellObserver(this); Shell::Get()->AddShellObserver(this);
keyboard::KeyboardController::Get()->AddObserver(this); keyboard::KeyboardController::Get()->AddObserver(this);
if (IsHomeLauncherEnabledInTabletMode()) {
home_launcher_gesture_handler_ =
std::make_unique<HomeLauncherGestureHandler>();
}
mojom::VoiceInteractionObserverPtr ptr; mojom::VoiceInteractionObserverPtr ptr;
voice_interaction_binding_.Bind(mojo::MakeRequest(&ptr)); voice_interaction_binding_.Bind(mojo::MakeRequest(&ptr));
Shell::Get()->voice_interaction_controller()->AddObserver(std::move(ptr)); Shell::Get()->voice_interaction_controller()->AddObserver(std::move(ptr));
...@@ -517,6 +523,13 @@ void AppListControllerImpl::OnOverviewModeEnding() { ...@@ -517,6 +523,13 @@ void AppListControllerImpl::OnOverviewModeEnding() {
} }
void AppListControllerImpl::OnTabletModeStarted() { void AppListControllerImpl::OnTabletModeStarted() {
// TODO(sammiequon): Find a better way to handle events that are not in tablet
// mode than controlling the lifetime fo this object.
if (is_home_launcher_enabled_) {
home_launcher_gesture_handler_ =
std::make_unique<HomeLauncherGestureHandler>();
}
if (presenter_.GetTargetVisibility()) { if (presenter_.GetTargetVisibility()) {
DCHECK(IsVisible()); DCHECK(IsVisible());
presenter_.GetView()->OnTabletModeChanged(true); presenter_.GetView()->OnTabletModeChanged(true);
...@@ -537,6 +550,8 @@ void AppListControllerImpl::OnTabletModeStarted() { ...@@ -537,6 +550,8 @@ void AppListControllerImpl::OnTabletModeStarted() {
} }
void AppListControllerImpl::OnTabletModeEnded() { void AppListControllerImpl::OnTabletModeEnded() {
home_launcher_gesture_handler_.reset();
if (IsVisible()) if (IsVisible())
presenter_.GetView()->OnTabletModeChanged(false); presenter_.GetView()->OnTabletModeChanged(false);
......
...@@ -42,6 +42,8 @@ class AnswerCardContentsRegistry; ...@@ -42,6 +42,8 @@ class AnswerCardContentsRegistry;
namespace ash { namespace ash {
class HomeLauncherGestureHandler;
// Ash's AppListController owns the AppListModel and implements interface // Ash's AppListController owns the AppListModel and implements interface
// functions that allow Chrome to modify and observe the Shelf and AppListModel // functions that allow Chrome to modify and observe the Shelf and AppListModel
// state. // state.
...@@ -140,6 +142,9 @@ class ASH_EXPORT AppListControllerImpl ...@@ -140,6 +142,9 @@ class ASH_EXPORT AppListControllerImpl
app_list::AppListShowSource show_source, app_list::AppListShowSource show_source,
base::TimeTicks event_time_stamp); base::TimeTicks event_time_stamp);
app_list::AppListViewState GetAppListViewState(); app_list::AppListViewState GetAppListViewState();
HomeLauncherGestureHandler* home_launcher_gesture_handler() {
return home_launcher_gesture_handler_.get();
}
// app_list::AppListViewDelegate: // app_list::AppListViewDelegate:
app_list::AppListModel* GetModel() override; app_list::AppListModel* GetModel() override;
...@@ -247,6 +252,10 @@ class ASH_EXPORT AppListControllerImpl ...@@ -247,6 +252,10 @@ class ASH_EXPORT AppListControllerImpl
std::unique_ptr<app_list::AnswerCardContentsRegistry> std::unique_ptr<app_list::AnswerCardContentsRegistry>
answer_card_contents_registry_; answer_card_contents_registry_;
// Owned pointer to the object which handles gestures related to the home
// launcher.
std::unique_ptr<HomeLauncherGestureHandler> home_launcher_gesture_handler_;
// Whether the on-screen keyboard is shown. // Whether the on-screen keyboard is shown.
bool onscreen_keyboard_shown_ = false; bool onscreen_keyboard_shown_ = false;
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/app_list/home_launcher_gesture_handler.h"
#include "ash/app_list/app_list_controller_impl.h"
#include "ash/screen_util.h"
#include "ash/shell.h"
#include "ash/wm/mru_window_tracker.h"
#include "ash/wm/overview/window_selector_controller.h"
#include "ash/wm/splitview/split_view_controller.h"
#include "ash/wm/window_state.h"
#include "base/numerics/ranges.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/client/window_types.h"
#include "ui/gfx/animation/tween.h"
#include "ui/gfx/geometry/rect_f.h"
#include "ui/wm/core/transient_window_manager.h"
namespace ash {
namespace {
constexpr float kWidthInsetRatio = 0.1f;
// Given a |window|, find the transform which will move its bounds to a region
// offscreen to the top. Its destination width will be inset by a percentage,
// and its width-height ratio will remain the same.
gfx::Transform CalculateOffscreenTransform(aura::Window* window) {
gfx::RectF bounds = gfx::RectF(window->GetTargetBounds());
gfx::RectF work_area =
gfx::RectF(screen_util::GetDisplayWorkAreaBoundsInParent(window));
float inverse_aspect_ratio = work_area.height() / work_area.width();
work_area.Inset(kWidthInsetRatio * work_area.width(), 0);
work_area.set_height(work_area.width() * inverse_aspect_ratio);
work_area.set_y(-work_area.height());
gfx::Transform transform(work_area.width() / bounds.width(), 0, 0,
work_area.height() / bounds.height(),
work_area.x() - bounds.x(),
work_area.y() - bounds.y());
return transform;
}
// Given a y screen coordinate |y|, find out where it lies as a ratio in the
// work area, where the top of the work area is 0.f and the bottom is 1.f.
double GetHeightInWorkAreaAsRatio(int y, aura::Window* window) {
gfx::Rect work_area = screen_util::GetDisplayWorkAreaBoundsInParent(window);
int clamped_y = base::ClampToRange(y, work_area.y(), work_area.bottom());
double ratio =
static_cast<double>(clamped_y) / static_cast<double>(work_area.height());
return 1.0 - ratio;
}
// Helper class to perform window state changes without animations. Used to hide
// and minimize windows without having their animation interfere with the ones
// this class is in charge of.
class ScopedAnimationDisabler {
public:
explicit ScopedAnimationDisabler(aura::Window* window) : window_(window) {
needs_disable_ =
!window_->GetProperty(aura::client::kAnimationsDisabledKey);
if (needs_disable_)
window_->SetProperty(aura::client::kAnimationsDisabledKey, true);
}
~ScopedAnimationDisabler() {
if (needs_disable_)
window_->SetProperty(aura::client::kAnimationsDisabledKey, false);
}
private:
aura::Window* window_;
bool needs_disable_ = false;
DISALLOW_COPY_AND_ASSIGN(ScopedAnimationDisabler);
};
} // namespace
HomeLauncherGestureHandler::HomeLauncherGestureHandler() = default;
HomeLauncherGestureHandler::~HomeLauncherGestureHandler() = default;
void HomeLauncherGestureHandler::OnPressEvent() {
// We want the first window in the mru list, if it exists and is usable.
auto windows = Shell::Get()->mru_window_tracker()->BuildMruWindowList();
if (windows.empty() || !CanHideWindow(windows[0])) {
window_ = nullptr;
return;
}
window_ = windows[0];
window_->AddObserver(this);
windows.erase(windows.begin());
// Hide all visible windows which are behind our window so that when we
// scroll, the home launcher will be visible.
hidden_windows_.clear();
for (auto* window : windows) {
if (window->IsVisible()) {
hidden_windows_.push_back(window);
window->AddObserver(this);
ScopedAnimationDisabler disable(window);
window->Hide();
}
}
original_opacity_ = window_->layer()->opacity();
original_transform_ = window_->transform();
target_transform_ = CalculateOffscreenTransform(window_);
}
void HomeLauncherGestureHandler::OnScrollEvent(const gfx::Point& location) {
double value = GetHeightInWorkAreaAsRatio(location.y(), window_);
float opacity = gfx::Tween::FloatValueBetween(value, original_opacity_, 0.f);
window_->layer()->SetOpacity(opacity);
gfx::Transform transform = gfx::Tween::TransformValueBetween(
value, original_transform_, target_transform_);
window_->SetTransform(transform);
}
void HomeLauncherGestureHandler::OnReleaseEvent(const gfx::Point& location) {
// TODO(sammiequon): Animate the window to its final destination.
if (GetHeightInWorkAreaAsRatio(location.y(), window_) > 0.5) {
window_->layer()->SetOpacity(1.f);
window_->SetTransform(target_transform_);
// Minimize |window_| without animation. Windows in |hidden_windows_| will
// rename hidden so we can see the home launcher.
// TODO(sammiequon): Investigate if we should minimize the windows in
// |hidden_windows_|.
ScopedAnimationDisabler disable(window_);
wm::GetWindowState(window_)->Minimize();
} else {
// Reshow all windows previously hidden.
for (auto* window : hidden_windows_) {
ScopedAnimationDisabler disable(window);
window->Show();
}
window_->layer()->SetOpacity(original_opacity_);
window_->SetTransform(original_transform_);
}
for (auto* window : hidden_windows_)
window->RemoveObserver(this);
hidden_windows_.clear();
window_->RemoveObserver(this);
window_ = nullptr;
}
void HomeLauncherGestureHandler::OnWindowDestroying(aura::Window* window) {
window->RemoveObserver(this);
if (window == window_) {
for (auto* hidden_window : hidden_windows_)
hidden_window->Show();
hidden_windows_.clear();
window_ = nullptr;
return;
}
DCHECK(base::ContainsValue(hidden_windows_, window));
hidden_windows_.erase(
std::find(hidden_windows_.begin(), hidden_windows_.end(), window));
}
bool HomeLauncherGestureHandler::CanHideWindow(aura::Window* window) {
DCHECK(window);
if (!window->IsVisible())
return false;
if (!Shell::Get()->app_list_controller()->IsHomeLauncherEnabledInTabletMode())
return false;
if (Shell::Get()->split_view_controller()->IsSplitViewModeActive())
return false;
if (Shell::Get()->window_selector_controller()->IsSelecting())
return false;
if (window->type() == aura::client::WINDOW_TYPE_POPUP)
return false;
// TODO(sammiequon): Handle transient windows.
const ::wm::TransientWindowManager* manager =
::wm::TransientWindowManager::GetIfExists(window);
if (manager &&
(manager->transient_parent() || !manager->transient_children().empty())) {
return false;
}
wm::WindowState* state = wm::GetWindowState(window);
return state->CanMaximize() && state->CanResize();
}
} // namespace ash
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_APP_LIST_HOME_LAUNCHER_GESTURE_HANDLER_H_
#define ASH_APP_LIST_HOME_LAUNCHER_GESTURE_HANDLER_H_
#include "ash/ash_export.h"
#include "base/macros.h"
#include "ui/aura/window.h"
#include "ui/aura/window_observer.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/transform.h"
namespace ash {
// HomeLauncherGestureHandler makes modifications to a window's transform and
// opacity when gesture drag events are received and forwarded to it.
// Additionally hides windows which may block the home launcher. All
// modifications are either transitioned to their final state, or back to their
// initial state on release event.
class ASH_EXPORT HomeLauncherGestureHandler : aura::WindowObserver {
public:
HomeLauncherGestureHandler();
~HomeLauncherGestureHandler() override;
// Called by owner of this object when a gesture event is received. |location|
// should be in screen coordinates.
void OnPressEvent();
void OnScrollEvent(const gfx::Point& location);
void OnReleaseEvent(const gfx::Point& location);
// TODO(sammiequon): Investigate if it is needed to observe potential window
// visibility changes, if they can happen.
// aura::WindowObserver:
void OnWindowDestroying(aura::Window* window) override;
aura::Window* window() { return window_; }
private:
// Checks if |window| can be hidden or shown with a gesture.
bool CanHideWindow(aura::Window* window);
aura::Window* window_ = nullptr;
float original_opacity_;
gfx::Transform original_transform_;
gfx::Transform target_transform_;
// Stores windows which were shown behind the mru window. They need to be
// hidden so the home launcher is visible when swiping up.
std::vector<aura::Window*> hidden_windows_;
DISALLOW_COPY_AND_ASSIGN(HomeLauncherGestureHandler);
};
} // namespace ash
#endif // ASH_APP_LIST_HOME_LAUNCHER_GESTURE_HANDLER_H_
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/app_list/home_launcher_gesture_handler.h"
#include "ash/app_list/app_list_controller_impl.h"
#include "ash/shell.h"
#include "ash/test/ash_test_base.h"
#include "ash/wm/tablet_mode/tablet_mode_controller.h"
#include "ash/wm/window_state.h"
#include "ui/aura/window.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/transform.h"
#include "ui/wm/core/transient_window_manager.h"
#include "ui/wm/core/window_util.h"
namespace ash {
class HomeLauncherGestureHandlerTest : public AshTestBase {
public:
HomeLauncherGestureHandlerTest() = default;
~HomeLauncherGestureHandlerTest() override = default;
// testing::Test:
void SetUp() override {
AshTestBase::SetUp();
Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(true);
}
// Create a test window and strip it of transient relatives since this does
// not work with transient windows yet. Set the base transform to identity and
// the base opacity to opaque for easier testing.
std::unique_ptr<aura::Window> CreateNonTransientTestWindow() {
std::unique_ptr<aura::Window> window = CreateTestWindow();
::wm::TransientWindowManager* manager =
::wm::TransientWindowManager::GetOrCreate(window.get());
if (manager->transient_parent()) {
::wm::TransientWindowManager::GetOrCreate(manager->transient_parent())
->RemoveTransientChild(window.get());
}
for (auto* window : manager->transient_children())
manager->RemoveTransientChild(window);
window->SetTransform(gfx::Transform());
window->layer()->SetOpacity(1.f);
return window;
}
HomeLauncherGestureHandler* GetGestureHandler() {
return Shell::Get()->app_list_controller()->home_launcher_gesture_handler();
}
private:
DISALLOW_COPY_AND_ASSIGN(HomeLauncherGestureHandlerTest);
};
// Tests that the gesture handler is available when in tablet mode.
TEST_F(HomeLauncherGestureHandlerTest, Setup) {
EXPECT_TRUE(GetGestureHandler());
Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(false);
EXPECT_FALSE(GetGestureHandler());
}
// Tests that the gesture handler will not have a window to act on if there are
// none in the mru list.
TEST_F(HomeLauncherGestureHandlerTest, NeedsOneWindow) {
GetGestureHandler()->OnPressEvent();
EXPECT_FALSE(GetGestureHandler()->window());
auto window = CreateNonTransientTestWindow();
GetGestureHandler()->OnPressEvent();
EXPECT_TRUE(GetGestureHandler()->window());
}
// Tests that if there are other visible windows behind the most recent one,
// they get hidden on press event so that the home launcher is visible.
TEST_F(HomeLauncherGestureHandlerTest, ShowWindowsAreHidden) {
auto window1 = CreateNonTransientTestWindow();
auto window2 = CreateNonTransientTestWindow();
auto window3 = CreateNonTransientTestWindow();
ASSERT_TRUE(window1->IsVisible());
ASSERT_TRUE(window2->IsVisible());
ASSERT_TRUE(window3->IsVisible());
// Test that the most recently activated window is visible, but the others are
// not.
::wm::ActivateWindow(window1.get());
GetGestureHandler()->OnPressEvent();
EXPECT_TRUE(window1->IsVisible());
EXPECT_FALSE(window2->IsVisible());
EXPECT_FALSE(window3->IsVisible());
}
// Tests that the window transform and opacity changes as we scroll.
TEST_F(HomeLauncherGestureHandlerTest, TransformAndOpacityChangesOnScroll) {
auto window = CreateNonTransientTestWindow();
GetGestureHandler()->OnPressEvent();
ASSERT_TRUE(GetGestureHandler()->window());
// Test that on scrolling to a point on the top half of the work area, the
// window's opacity is between 0 and 0.5 and its transform has changed.
GetGestureHandler()->OnScrollEvent(gfx::Point(0, 100));
const gfx::Transform top_half_transform = window->transform();
EXPECT_NE(gfx::Transform(), top_half_transform);
EXPECT_GT(window->layer()->opacity(), 0.f);
EXPECT_LT(window->layer()->opacity(), 0.5f);
// Test that on scrolling to a point on the bottom half of the work area, the
// window's opacity is between 0.5 and 1 and its transform has changed.
GetGestureHandler()->OnScrollEvent(gfx::Point(0, 300));
EXPECT_NE(gfx::Transform(), window->transform());
EXPECT_NE(gfx::Transform(), top_half_transform);
EXPECT_GT(window->layer()->opacity(), 0.5f);
EXPECT_LT(window->layer()->opacity(), 1.f);
}
// Tests that releasing a drag at the bottom of the work area will return the
// window to its original transform and opacity.
TEST_F(HomeLauncherGestureHandlerTest, BelowHalfReleaseReturnsToOriginalState) {
UpdateDisplay("400x400");
auto window1 = CreateNonTransientTestWindow();
auto window2 = CreateNonTransientTestWindow();
auto window3 = CreateNonTransientTestWindow();
::wm::ActivateWindow(window1.get());
GetGestureHandler()->OnPressEvent();
ASSERT_TRUE(GetGestureHandler()->window());
ASSERT_FALSE(window2->IsVisible());
ASSERT_FALSE(window3->IsVisible());
// After a scroll the transform and opacity are no longer the identity and 1.
GetGestureHandler()->OnScrollEvent(gfx::Point(0, 300));
EXPECT_NE(gfx::Transform(), window1->transform());
EXPECT_NE(1.f, window1->layer()->opacity());
// Tests the transform and opacity have returned to the identity and 1.
GetGestureHandler()->OnReleaseEvent(gfx::Point(0, 300));
EXPECT_EQ(gfx::Transform(), window1->transform());
EXPECT_EQ(1.f, window1->layer()->opacity());
// The other windows return to their original visibility.
EXPECT_TRUE(window2->IsVisible());
EXPECT_TRUE(window3->IsVisible());
}
// Tests that a drag released at the top half of the work area will minimize the
// window under action.
TEST_F(HomeLauncherGestureHandlerTest, AboveHalfReleaseMinimizesWindow) {
UpdateDisplay("400x400");
auto window1 = CreateNonTransientTestWindow();
auto window2 = CreateNonTransientTestWindow();
auto window3 = CreateNonTransientTestWindow();
::wm::ActivateWindow(window1.get());
GetGestureHandler()->OnPressEvent();
ASSERT_TRUE(GetGestureHandler()->window());
ASSERT_FALSE(window2->IsVisible());
ASSERT_FALSE(window3->IsVisible());
// Test that |window1| is minimized on release.
GetGestureHandler()->OnReleaseEvent(gfx::Point(0, 100));
EXPECT_TRUE(wm::GetWindowState(window1.get())->IsMinimized());
// The rest of the windows remain invisible, to show the home launcher.
EXPECT_FALSE(window2->IsVisible());
EXPECT_FALSE(window3->IsVisible());
}
} // namespace ash
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "ash/animation/animation_change_type.h" #include "ash/animation/animation_change_type.h"
#include "ash/app_list/app_list_controller_impl.h" #include "ash/app_list/app_list_controller_impl.h"
#include "ash/app_list/home_launcher_gesture_handler.h"
#include "ash/app_list/model/app_list_view_state.h" #include "ash/app_list/model/app_list_view_state.h"
#include "ash/app_list/views/app_list_view.h" #include "ash/app_list/views/app_list_view.h"
#include "ash/public/cpp/app_list/app_list_constants.h" #include "ash/public/cpp/app_list/app_list_constants.h"
...@@ -95,6 +96,14 @@ bool IsTabletModeEnabled() { ...@@ -95,6 +96,14 @@ bool IsTabletModeEnabled() {
->IsTabletModeWindowManagerEnabled(); ->IsTabletModeWindowManagerEnabled();
} }
// TODO(sammiequon): This should be the same as IsTabletModeEnabled once home
// launcher flag is removed.
bool IsHomeLauncherEnabled() {
return Shell::Get()
->app_list_controller()
->IsHomeLauncherEnabledInTabletMode();
}
} // namespace } // namespace
// ShelfLayoutManager::UpdateShelfObserver ------------------------------------- // ShelfLayoutManager::UpdateShelfObserver -------------------------------------
...@@ -530,11 +539,8 @@ ShelfBackgroundType ShelfLayoutManager::GetShelfBackgroundType() const { ...@@ -530,11 +539,8 @@ ShelfBackgroundType ShelfLayoutManager::GetShelfBackgroundType() const {
// If the app list is active and the home launcher is not shown, hide the // If the app list is active and the home launcher is not shown, hide the
// shelf background to prevent overlap. // shelf background to prevent overlap.
if (is_app_list_visible_ && !Shell::Get() if (is_app_list_visible_ && !IsHomeLauncherEnabled())
->app_list_controller()
->IsHomeLauncherEnabledInTabletMode()) {
return SHELF_BACKGROUND_APP_LIST; return SHELF_BACKGROUND_APP_LIST;
}
if (state_.visibility_state != SHELF_AUTO_HIDE && if (state_.visibility_state != SHELF_AUTO_HIDE &&
state_.window_state == wm::WORKSPACE_WINDOW_STATE_MAXIMIZED) { state_.window_state == wm::WORKSPACE_WINDOW_STATE_MAXIMIZED) {
...@@ -980,12 +986,8 @@ ShelfAutoHideState ShelfLayoutManager::CalculateAutoHideState( ...@@ -980,12 +986,8 @@ ShelfAutoHideState ShelfLayoutManager::CalculateAutoHideState(
if (visibility_state != SHELF_AUTO_HIDE) if (visibility_state != SHELF_AUTO_HIDE)
return SHELF_AUTO_HIDE_HIDDEN; return SHELF_AUTO_HIDE_HIDDEN;
if (shelf_widget_->IsShowingAppList() && if (shelf_widget_->IsShowingAppList() && !IsHomeLauncherEnabled())
!Shell::Get()
->app_list_controller()
->IsHomeLauncherEnabledInTabletMode()) {
return SHELF_AUTO_HIDE_SHOWN; return SHELF_AUTO_HIDE_SHOWN;
}
if (shelf_widget_->status_area_widget() && if (shelf_widget_->status_area_widget() &&
shelf_widget_->status_area_widget()->ShouldShowShelf()) shelf_widget_->status_area_widget()->ShouldShowShelf())
...@@ -1172,6 +1174,16 @@ void ShelfLayoutManager::StartGestureDrag( ...@@ -1172,6 +1174,16 @@ void ShelfLayoutManager::StartGestureDrag(
launcher_above_shelf_bottom_amount_ = launcher_above_shelf_bottom_amount_ =
shelf_bounds.bottom() - gesture_in_screen.location().y(); shelf_bounds.bottom() - gesture_in_screen.location().y();
} else { } else {
HomeLauncherGestureHandler* home_launcher_handler =
Shell::Get()->app_list_controller()->home_launcher_gesture_handler();
if (home_launcher_handler) {
home_launcher_handler->OnPressEvent();
if (home_launcher_handler->window()) {
gesture_drag_status_ = GESTURE_DRAG_APPLIST_IN_PROGRESS;
return;
}
}
// Disable the shelf dragging if the fullscreen app list is opened. // Disable the shelf dragging if the fullscreen app list is opened.
if (is_app_list_visible_) { if (is_app_list_visible_) {
return; return;
...@@ -1187,6 +1199,17 @@ void ShelfLayoutManager::StartGestureDrag( ...@@ -1187,6 +1199,17 @@ void ShelfLayoutManager::StartGestureDrag(
void ShelfLayoutManager::UpdateGestureDrag( void ShelfLayoutManager::UpdateGestureDrag(
const ui::GestureEvent& gesture_in_screen) { const ui::GestureEvent& gesture_in_screen) {
HomeLauncherGestureHandler* home_launcher_handler =
Shell::Get()->app_list_controller()->home_launcher_gesture_handler();
if (home_launcher_handler) {
if (home_launcher_handler->window()) {
home_launcher_handler->OnScrollEvent(gesture_in_screen.location());
} else {
gesture_drag_status_ = GESTURE_DRAG_NONE;
}
return;
}
if (gesture_drag_status_ == GESTURE_DRAG_APPLIST_IN_PROGRESS) { if (gesture_drag_status_ == GESTURE_DRAG_APPLIST_IN_PROGRESS) {
// Dismiss the app list if the shelf changed to vertical alignment during // Dismiss the app list if the shelf changed to vertical alignment during
// dragging. // dragging.
...@@ -1270,6 +1293,16 @@ void ShelfLayoutManager::CompleteAppListDrag( ...@@ -1270,6 +1293,16 @@ void ShelfLayoutManager::CompleteAppListDrag(
if (gesture_drag_status_ == GESTURE_DRAG_NONE) if (gesture_drag_status_ == GESTURE_DRAG_NONE)
return; return;
HomeLauncherGestureHandler* home_launcher_handler =
Shell::Get()->app_list_controller()->home_launcher_gesture_handler();
if (home_launcher_handler) {
if (home_launcher_handler->window()) {
home_launcher_handler->OnReleaseEvent(gesture_in_screen.location());
}
gesture_drag_status_ = GESTURE_DRAG_NONE;
return;
}
using app_list::AppListViewState; using app_list::AppListViewState;
AppListViewState app_list_state = AppListViewState::PEEKING; AppListViewState app_list_state = AppListViewState::PEEKING;
if (gesture_in_screen.type() == ui::ET_SCROLL_FLING_START && if (gesture_in_screen.type() == ui::ET_SCROLL_FLING_START &&
...@@ -1338,11 +1371,8 @@ bool ShelfLayoutManager::CanStartFullscreenAppListDrag( ...@@ -1338,11 +1371,8 @@ bool ShelfLayoutManager::CanStartFullscreenAppListDrag(
// In overview mode, app list for tablet mode is hidden temporarily and will // In overview mode, app list for tablet mode is hidden temporarily and will
// be shown automatically after overview mode ends. So prevent opening it // be shown automatically after overview mode ends. So prevent opening it
// here. // here.
if (Shell::Get() if (IsHomeLauncherEnabled())
->app_list_controller()
->IsHomeLauncherEnabledInTabletMode()) {
return false; return false;
}
return true; return true;
} }
......
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