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

applist: Allow swiping up on shelf to show applist when autohide.

Test: manual
Bug: 881483, 891366
Change-Id: I88c5d7a5d41f7ef4013c84debf5c4e963f891d21
Reviewed-on: https://chromium-review.googlesource.com/c/1279356
Commit-Queue: Sammie Quon <sammiequon@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#599778}
parent e89d87c7
......@@ -729,7 +729,8 @@ bool AppListControllerImpl::ProcessHomeLauncherGesture(
return home_launcher_gesture_handler_->OnScrollEvent(
screen_location, event->details().scroll_y());
case ui::ET_GESTURE_END:
return home_launcher_gesture_handler_->OnReleaseEvent(screen_location);
return home_launcher_gesture_handler_->OnReleaseEvent(
screen_location, /*out_dragged_down=*/nullptr);
default:
break;
}
......
......@@ -58,10 +58,6 @@ bool CanProcessWindow(aura::Window* window,
if (!window)
return false;
// Window should not be fullscreen as we do not allow swiping up when auto
// hide for shelf.
DCHECK(!wm::GetWindowState(window)->IsFullscreen());
if (!window->IsVisible() &&
mode == HomeLauncherGestureHandler::Mode::kSlideUpToShow) {
return false;
......@@ -208,6 +204,7 @@ bool HomeLauncherGestureHandler::OnPressEvent(Mode mode,
return false;
mode_ = mode;
initial_event_location_ = location;
last_event_location_ = base::make_optional(location);
UpdateWindows(0.0, /*animate=*/false);
......@@ -221,17 +218,29 @@ bool HomeLauncherGestureHandler::OnScrollEvent(const gfx::Point& location,
last_event_location_ = base::make_optional(location);
last_scroll_y_ = scroll_y;
if (mode_ == Mode::kSlideUpToShow &&
(*last_event_location_ - initial_event_location_).y() > 0) {
UpdateWindows(0.0, /*animate=*/false);
return true;
}
DCHECK(display_.is_valid());
UpdateWindows(GetHeightInWorkAreaAsRatio(location, display_.work_area()),
/*animate=*/false);
return true;
}
bool HomeLauncherGestureHandler::OnReleaseEvent(const gfx::Point& location) {
bool HomeLauncherGestureHandler::OnReleaseEvent(const gfx::Point& location,
bool* out_dragged_down) {
if (!IsDragInProgress())
return false;
last_event_location_ = base::make_optional(location);
if (out_dragged_down) {
DCHECK_EQ(mode_, Mode::kSlideUpToShow);
*out_dragged_down =
(*last_event_location_ - initial_event_location_).y() > 0;
}
AnimateToFinalState();
return true;
}
......
......@@ -53,7 +53,7 @@ class ASH_EXPORT HomeLauncherGestureHandler : aura::WindowObserver,
// was not processed.
bool OnPressEvent(Mode mode, const gfx::Point& location);
bool OnScrollEvent(const gfx::Point& location, float scroll_y);
bool OnReleaseEvent(const gfx::Point& location);
bool OnReleaseEvent(const gfx::Point& location, bool* out_dragged_down);
// Cancel a current drag and animates the items to their final state based on
// |last_event_location_|.
......@@ -155,6 +155,8 @@ class ASH_EXPORT HomeLauncherGestureHandler : aura::WindowObserver,
// hidden so the home launcher is visible when swiping up.
std::vector<aura::Window*> hidden_windows_;
gfx::Point initial_event_location_;
// Tracks the location of the last received event in screen coordinates. Empty
// if there is currently no window being processed.
base::Optional<gfx::Point> last_event_location_;
......
......@@ -1212,7 +1212,7 @@ void ShelfLayoutManager::StartGestureDrag(
} else {
HomeLauncherGestureHandler* home_launcher_handler =
Shell::Get()->app_list_controller()->home_launcher_gesture_handler();
if (home_launcher_handler && visibility_state() == SHELF_VISIBLE &&
if (home_launcher_handler && IsVisible() &&
home_launcher_handler->OnPressEvent(
HomeLauncherGestureHandler::Mode::kSlideUpToShow,
gesture_in_screen.location())) {
......@@ -1237,7 +1237,7 @@ void ShelfLayoutManager::UpdateGestureDrag(
const ui::GestureEvent& gesture_in_screen) {
HomeLauncherGestureHandler* home_launcher_handler =
Shell::Get()->app_list_controller()->home_launcher_gesture_handler();
if (home_launcher_handler && visibility_state() == SHELF_VISIBLE &&
if (home_launcher_handler && IsVisible() &&
home_launcher_handler->OnScrollEvent(
gesture_in_screen.location(),
gesture_in_screen.details().scroll_y())) {
......@@ -1301,8 +1301,16 @@ void ShelfLayoutManager::CompleteAppListDrag(
HomeLauncherGestureHandler* home_launcher_handler =
Shell::Get()->app_list_controller()->home_launcher_gesture_handler();
if (home_launcher_handler && visibility_state() == SHELF_VISIBLE &&
home_launcher_handler->OnReleaseEvent(gesture_in_screen.location())) {
bool dragged_down;
if (home_launcher_handler && IsVisible() &&
home_launcher_handler->OnReleaseEvent(gesture_in_screen.location(),
&dragged_down)) {
if (dragged_down && visibility_state() == SHELF_AUTO_HIDE) {
DCHECK_EQ(SHELF_AUTO_HIDE_SHOWN, gesture_drag_auto_hide_state_);
gesture_drag_auto_hide_state_ = SHELF_AUTO_HIDE_HIDDEN;
gesture_drag_status_ = GESTURE_DRAG_COMPLETE_IN_PROGRESS;
UpdateVisibilityState();
}
gesture_drag_status_ = GESTURE_DRAG_NONE;
return;
}
......
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