Commit a961ddbf authored by Weidong Guo's avatar Weidong Guo Committed by Commit Bot

Fix home launcher not shown issue

Background:
There are several corner cases that home launcher is not shown:
1. Drag app list from shelf, meanwhile switch to tablet mode.
2. Drag app list to shelf after being opened, meanwhile switch to tablet
   mode.
3. Close app list and, during the close animation, switch to tablet
   mode.

Changes:
1. Ignore drag event from both shelf or app list and reset dragging
   state when tablet mode is on.
2. Immediately stop close animation before reshow app list when tablet
   mode is on.

Bug: 872072,871923
Change-Id: I5bd7dae242d84e2f0a82839693fbd36930f8e613
Reviewed-on: https://chromium-review.googlesource.com/1167658Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Weidong Guo <weidongg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#581688}
parent 65bdc77c
...@@ -412,12 +412,18 @@ void AppListControllerImpl::Show(int64_t display_id, ...@@ -412,12 +412,18 @@ void AppListControllerImpl::Show(int64_t display_id,
void AppListControllerImpl::UpdateYPositionAndOpacity( void AppListControllerImpl::UpdateYPositionAndOpacity(
int y_position_in_screen, int y_position_in_screen,
float background_opacity) { float background_opacity) {
// Avoid changing app list opacity and position when homecher is enabled.
if (IsHomeLauncherEnabledInTabletMode())
return;
presenter_.UpdateYPositionAndOpacity(y_position_in_screen, presenter_.UpdateYPositionAndOpacity(y_position_in_screen,
background_opacity); background_opacity);
} }
void AppListControllerImpl::EndDragFromShelf( void AppListControllerImpl::EndDragFromShelf(
app_list::AppListViewState app_list_state) { app_list::AppListViewState app_list_state) {
// Avoid dragging app list when homecher is enabled.
if (IsHomeLauncherEnabledInTabletMode())
return;
presenter_.EndDragFromShelf(app_list_state); presenter_.EndDragFromShelf(app_list_state);
} }
...@@ -461,8 +467,14 @@ void AppListControllerImpl::OnOverviewModeEnding() { ...@@ -461,8 +467,14 @@ void AppListControllerImpl::OnOverviewModeEnding() {
void AppListControllerImpl::OnTabletModeStarted() { void AppListControllerImpl::OnTabletModeStarted() {
if (IsVisible()) { if (IsVisible()) {
presenter_.GetView()->OnTabletModeChanged(true); if (!presenter_.is_animating_to_close()) {
return; presenter_.GetView()->OnTabletModeChanged(true);
return;
}
// The launcher is running close animation, so close it immediately before
// reshow the launcher in tablet mode.
presenter_.GetView()->GetWidget()->CloseNow();
} }
if (!is_home_launcher_enabled_ || !display::Display::HasInternalDisplay()) if (!is_home_launcher_enabled_ || !display::Display::HasInternalDisplay())
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "ash/app_list/views/app_list_main_view.h" #include "ash/app_list/views/app_list_main_view.h"
#include "ash/app_list/views/app_list_view.h" #include "ash/app_list/views/app_list_view.h"
#include "ash/app_list/views/search_box_view.h" #include "ash/app_list/views/search_box_view.h"
#include "ash/public/cpp/app_list/app_list_config.h"
#include "ash/public/cpp/app_list/app_list_features.h" #include "ash/public/cpp/app_list/app_list_features.h"
#include "ash/public/cpp/app_list/app_list_switches.h" #include "ash/public/cpp/app_list/app_list_switches.h"
#include "ash/public/cpp/ash_switches.h" #include "ash/public/cpp/ash_switches.h"
...@@ -1491,4 +1492,82 @@ TEST_F(AppListPresenterDelegateHomeLauncherTest, WallpaperContextMenu) { ...@@ -1491,4 +1492,82 @@ TEST_F(AppListPresenterDelegateHomeLauncherTest, WallpaperContextMenu) {
EXPECT_FALSE(root_window_controller->IsContextMenuShown()); EXPECT_FALSE(root_window_controller->IsContextMenuShown());
} }
// Tests app list visibility when switching to tablet mode during dragging from
// shelf.
TEST_F(AppListPresenterDelegateHomeLauncherTest,
SwitchToTabletModeDuringDraggingFromShelf) {
UpdateDisplay("1080x900");
GetAppListTestHelper()->CheckVisibility(false);
// Drag from the shelf to show the app list.
ui::test::EventGenerator* generator = GetEventGenerator();
const int x = 540;
const int closed_y = 890;
const int fullscreen_y = 0;
generator->MoveTouch(gfx::Point(x, closed_y));
generator->PressTouch();
generator->MoveTouch(gfx::Point(x, fullscreen_y));
GetAppListTestHelper()->CheckVisibility(true);
// Drag to shelf to close app list.
generator->MoveTouch(gfx::Point(x, closed_y));
generator->ReleaseTouch();
GetAppListTestHelper()->WaitUntilIdle();
GetAppListTestHelper()->CheckVisibility(false);
// Drag from the shelf to show the app list.
generator->MoveTouch(gfx::Point(x, closed_y));
generator->PressTouch();
generator->MoveTouch(gfx::Point(x, fullscreen_y));
GetAppListTestHelper()->CheckVisibility(true);
// Switch to tablet mode.
EnableTabletMode(true);
GetAppListTestHelper()->CheckVisibility(true);
// Drag to shelf to try to close app list.
generator->MoveTouch(gfx::Point(x, closed_y));
generator->ReleaseTouch();
GetAppListTestHelper()->WaitUntilIdle();
GetAppListTestHelper()->CheckVisibility(true);
}
// Tests app list visibility when switching to tablet mode during dragging to
// close app list.
TEST_F(AppListPresenterDelegateHomeLauncherTest,
SwitchToTabletModeDuringDraggingToClose) {
UpdateDisplay("1080x900");
// Open app list.
GetAppListTestHelper()->ShowAndRunLoop(GetPrimaryDisplayId());
GetAppListTestHelper()->CheckVisibility(true);
// Drag to shelf to close app list.
ui::test::EventGenerator* generator = GetEventGenerator();
const int x = 540;
const int peeking_height =
900 - app_list::AppListConfig::instance().peeking_app_list_height();
const int closed_y = 890;
generator->MoveTouch(gfx::Point(x, peeking_height));
generator->PressTouch();
generator->MoveTouch(gfx::Point(x, closed_y));
generator->ReleaseTouch();
GetAppListTestHelper()->WaitUntilIdle();
GetAppListTestHelper()->CheckVisibility(false);
// Open app list.
GetAppListTestHelper()->ShowAndRunLoop(GetPrimaryDisplayId());
GetAppListTestHelper()->CheckVisibility(true);
// Drag to shelf to close app list, meanwhile switch to tablet mode.
generator->MoveTouch(gfx::Point(x, peeking_height));
generator->PressTouch();
generator->MoveTouch(gfx::Point(x, peeking_height + 10));
EnableTabletMode(true);
generator->MoveTouch(gfx::Point(x, closed_y));
generator->ReleaseTouch();
GetAppListTestHelper()->WaitUntilIdle();
GetAppListTestHelper()->CheckVisibility(true);
}
} // namespace ash } // namespace ash
...@@ -253,6 +253,7 @@ void AppListPresenterImpl::ScheduleAnimation() { ...@@ -253,6 +253,7 @@ void AppListPresenterImpl::ScheduleAnimation() {
gfx::Transform transform; gfx::Transform transform;
transform.Translate(-offset.x(), -offset.y()); transform.Translate(-offset.x(), -offset.y());
layer->SetTransform(transform); layer->SetTransform(transform);
is_animating_to_close_ = true;
{ {
ui::ScopedLayerAnimationSettings animation(layer->GetAnimator()); ui::ScopedLayerAnimationSettings animation(layer->GetAnimator());
...@@ -318,10 +319,12 @@ void AppListPresenterImpl::OnWindowFocused(aura::Window* gained_focus, ...@@ -318,10 +319,12 @@ void AppListPresenterImpl::OnWindowFocused(aura::Window* gained_focus,
// AppListPresenterImpl, ui::ImplicitAnimationObserver implementation: // AppListPresenterImpl, ui::ImplicitAnimationObserver implementation:
void AppListPresenterImpl::OnImplicitAnimationsCompleted() { void AppListPresenterImpl::OnImplicitAnimationsCompleted() {
if (is_visible_) if (is_visible_) {
view_->GetWidget()->Activate(); view_->GetWidget()->Activate();
else } else {
view_->GetWidget()->Close(); view_->GetWidget()->Close();
is_animating_to_close_ = false;
}
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
......
...@@ -84,6 +84,8 @@ class APP_LIST_PRESENTER_EXPORT AppListPresenterImpl ...@@ -84,6 +84,8 @@ class APP_LIST_PRESENTER_EXPORT AppListPresenterImpl
// Passes a MouseWheelEvent from the shelf to the AppListView. // Passes a MouseWheelEvent from the shelf to the AppListView.
void ProcessMouseWheelOffset(int y_scroll_offset); void ProcessMouseWheelOffset(int y_scroll_offset);
bool is_animating_to_close() const { return is_animating_to_close_; }
private: private:
// Sets the app list view and attempts to show it. // Sets the app list view and attempts to show it.
void SetView(AppListView* view); void SetView(AppListView* view);
...@@ -151,6 +153,9 @@ class APP_LIST_PRESENTER_EXPORT AppListPresenterImpl ...@@ -151,6 +153,9 @@ class APP_LIST_PRESENTER_EXPORT AppListPresenterImpl
bool last_visible_ = false; bool last_visible_ = false;
int64_t last_display_id_ = display::kInvalidDisplayId; int64_t last_display_id_ = display::kInvalidDisplayId;
// True if app list is running close animation.
bool is_animating_to_close_ = false;
DISALLOW_COPY_AND_ASSIGN(AppListPresenterImpl); DISALLOW_COPY_AND_ASSIGN(AppListPresenterImpl);
}; };
......
...@@ -1024,7 +1024,8 @@ void AppListView::OnGestureEvent(ui::GestureEvent* event) { ...@@ -1024,7 +1024,8 @@ void AppListView::OnGestureEvent(ui::GestureEvent* event) {
event->SetHandled(); event->SetHandled();
break; break;
case ui::ET_GESTURE_SCROLL_UPDATE: case ui::ET_GESTURE_SCROLL_UPDATE:
if (is_side_shelf_) // Avoid scrolling events for the app list in tablet mode.
if (is_side_shelf_ || IsHomeLauncherEnabledInTabletMode())
return; return;
SetIsInDrag(true); SetIsInDrag(true);
last_fling_velocity_ = event->details().scroll_y(); last_fling_velocity_ = event->details().scroll_y();
...@@ -1034,7 +1035,8 @@ void AppListView::OnGestureEvent(ui::GestureEvent* event) { ...@@ -1034,7 +1035,8 @@ void AppListView::OnGestureEvent(ui::GestureEvent* event) {
case ui::ET_GESTURE_END: case ui::ET_GESTURE_END:
if (!is_in_drag_) if (!is_in_drag_)
break; break;
if (is_side_shelf_) // Avoid scrolling events for the app list in tablet mode.
if (is_side_shelf_ || IsHomeLauncherEnabledInTabletMode())
return; return;
SetIsInDrag(false); SetIsInDrag(false);
EndDrag(event->location()); EndDrag(event->location());
...@@ -1115,6 +1117,18 @@ void AppListView::OnTabletModeChanged(bool started) { ...@@ -1115,6 +1117,18 @@ void AppListView::OnTabletModeChanged(bool started) {
return; return;
} }
if (is_in_drag_) {
SetIsInDrag(false);
DraggingLayout();
}
// Set fullscreen state. When current state is fullscreen, we still need to
// set it again because app list may be in dragging.
SetState(app_list_state_ == AppListViewState::HALF ||
app_list_state_ == AppListViewState::FULLSCREEN_SEARCH
? AppListViewState::FULLSCREEN_SEARCH
: AppListViewState::FULLSCREEN_ALL_APPS);
// Put app list window in corresponding container based on whether the // Put app list window in corresponding container based on whether the
// tablet mode is enabled. // tablet mode is enabled.
aura::Window* window = GetWidget()->GetNativeWindow(); aura::Window* window = GetWidget()->GetNativeWindow();
...@@ -1131,6 +1145,8 @@ void AppListView::OnTabletModeChanged(bool started) { ...@@ -1131,6 +1145,8 @@ void AppListView::OnTabletModeChanged(bool started) {
// Update background blur. // Update background blur.
if (is_background_blur_enabled_) if (is_background_blur_enabled_)
app_list_background_shield_->layer()->SetBackgroundBlur(0); app_list_background_shield_->layer()->SetBackgroundBlur(0);
return;
} }
if (is_tablet_mode_ && !is_fullscreen()) { if (is_tablet_mode_ && !is_fullscreen()) {
......
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