Commit c46e474d authored by Andrew Xu's avatar Andrew Xu Committed by Commit Bot

Update hotseat target bounds earlier when flinging the hotseat up

This CL is a part of the effort to ensure that the target bounds of
the window scaling animation are the shelf icon's final bounds. See
https://crrev.com/c/1996268 for more details. This CL fixes the case 2
by accomplishing the following things:
(1) Updating the visibility state before starting the window scaling
animation. It assures that when the window scaling animation starts,
the target hotseat bounds are already set.
(2) Locking the shelf auto hide state when the back drop widget updates
since the change in back drop widget should not affect the shelf.

This CL should be landed after https://crrev.com/c/2004009 which fixes
the tests broken by this CL.

Bug: 1030819
Change-Id: Iff97f7f1731e7dec6cea36ec99cc3abbee2caa5e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2004052
Commit-Queue: Andrew Xu <andrewxu@chromium.org>
Reviewed-by: default avatarToni Baržić <tbarzic@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#735074}
parent c8dc2554
......@@ -235,35 +235,32 @@ DragWindowFromShelfController::EndDrag(const gfx::PointF& location_in_screen,
SplitViewController::SnapPosition snap_position =
GetSnapPositionOnDragEnd(location_in_screen, velocity_y);
base::Optional<ShelfWindowDragResult> window_drag_result;
window_drag_result_ = base::nullopt;
if (ShouldGoToHomeScreen(location_in_screen, velocity_y)) {
DCHECK(!in_splitview);
if (in_overview) {
overview_controller->EndOverview(
OverviewSession::EnterExitOverviewType::kFadeOutExit);
}
ScaleDownWindowAfterDrag();
window_drag_result = ShelfWindowDragResult::kGoToHomeScreen;
window_drag_result_ = ShelfWindowDragResult::kGoToHomeScreen;
} else if (ShouldRestoreToOriginalBounds(location_in_screen)) {
ScaleUpToRestoreWindowAfterDrag();
window_drag_result = ShelfWindowDragResult::kRestoreToOriginalBounds;
window_drag_result_ = ShelfWindowDragResult::kRestoreToOriginalBounds;
} else if (!in_overview) {
// if overview is not active during the entire drag process, scale down the
// dragged window to go to home screen.
ScaleDownWindowAfterDrag();
window_drag_result = ShelfWindowDragResult::kGoToHomeScreen;
window_drag_result_ = ShelfWindowDragResult::kGoToHomeScreen;
} else {
if (drop_window_in_overview)
window_drag_result = ShelfWindowDragResult::kGoToOverviewMode;
window_drag_result_ = ShelfWindowDragResult::kGoToOverviewMode;
else if (snap_position != SplitViewController::NONE)
window_drag_result = ShelfWindowDragResult::kGoToSplitviewMode;
window_drag_result_ = ShelfWindowDragResult::kGoToSplitviewMode;
// For window that may drop in overview or snap in split screen, restore its
// original backdrop mode.
window_->SetProperty(kBackdropWindowMode, original_backdrop_mode_);
}
OnDragEnded(location_in_screen, drop_window_in_overview, snap_position);
return window_drag_result;
return window_drag_result_;
}
void DragWindowFromShelfController::CancelDrag() {
......@@ -292,6 +289,29 @@ bool DragWindowFromShelfController::IsDraggedWindowAnimating() const {
return window_ && window_->layer()->GetAnimator()->is_animating();
}
void DragWindowFromShelfController::FinalizeDraggedWindow() {
if (!window_drag_result_.has_value())
return;
DCHECK(!drag_started_);
DCHECK(window_);
switch (*window_drag_result_) {
case ShelfWindowDragResult::kGoToHomeScreen:
ScaleDownWindowAfterDrag();
break;
case ShelfWindowDragResult::kRestoreToOriginalBounds:
ScaleUpToRestoreWindowAfterDrag();
break;
case ShelfWindowDragResult::kGoToOverviewMode:
case ShelfWindowDragResult::kGoToSplitviewMode:
// No action is needed.
break;
}
window_drag_result_.reset();
}
void DragWindowFromShelfController::OnWindowDestroying(aura::Window* window) {
DCHECK_EQ(window_, window);
......
......@@ -104,6 +104,12 @@ class ASH_EXPORT DragWindowFromShelfController : public aura::WindowObserver {
bool IsDraggedWindowAnimating() const;
// Performs the action on the dragged window depending on
// |window_drag_result_|, such as scaling up/down the dragged window. This
// method should be called after EndDrag() which computes
// |window_drag_result_|.
void FinalizeDraggedWindow();
// aura::WindowObserver:
void OnWindowDestroying(aura::Window* window) override;
......@@ -204,6 +210,9 @@ class ASH_EXPORT DragWindowFromShelfController : public aura::WindowObserver {
// True if overview is active and its windows are showing.
bool show_overview_windows_ = false;
// A pending action from EndDrag() to be performed in FinalizeDraggedWindow().
base::Optional<ShelfWindowDragResult> window_drag_result_;
base::ObserverList<Observer> observers_;
bool during_window_restoration_callback_ = false;
......
......@@ -65,6 +65,7 @@ class DragWindowFromShelfControllerTest : public AshTestBase {
base::Optional<float> velocity_y) {
window_drag_controller_->EndDrag(gfx::PointF(location_in_screen),
velocity_y);
window_drag_controller_->FinalizeDraggedWindow();
}
void CancelDrag() { window_drag_controller_->CancelDrag(); }
......
......@@ -2472,6 +2472,11 @@ void ShelfLayoutManager::CompleteDrag(const ui::LocatedEvent& event_in_screen) {
else
CancelDrag(window_drag_result);
// Dragged window is finalized after drag handling is completed so drag state
// does not interfere with updates on shelf state during window state changes.
if (window_drag_controller_.get())
window_drag_controller_->FinalizeDraggedWindow();
// Hotseat gestures are meaningful only in tablet mode with hotseat enabled.
if (chromeos::switches::ShouldShowShelfHotseat() && IsTabletModeEnabled()) {
base::Optional<InAppShelfGestures> gesture_to_record =
......
......@@ -14,6 +14,7 @@
#include "ash/public/cpp/shell_window_ids.h"
#include "ash/public/cpp/window_animation_types.h"
#include "ash/screen_util.h"
#include "ash/shelf/shelf.h"
#include "ash/shell.h"
#include "ash/wallpaper/wallpaper_controller_impl.h"
#include "ash/wm/always_on_top_controller.h"
......@@ -26,6 +27,7 @@
#include "base/auto_reset.h"
#include "base/memory/weak_ptr.h"
#include "chromeos/audio/chromeos_sounds.h"
#include "chromeos/constants/chromeos_switches.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/compositor/layer.h"
#include "ui/compositor/layer_animation_element.h"
......@@ -290,6 +292,13 @@ void BackdropController::UpdateBackdrop() {
if (pause_update_ || InOverviewSession())
return;
base::Optional<Shelf::ScopedAutoHideLock> auto_hide_lock;
// Updating the back drop widget should not affect the shelf's auto hide
// state.
if (chromeos::switches::ShouldShowShelfHotseat())
auto_hide_lock.emplace(ash::Shelf::ForWindow(container_));
UpdateBackdropInternal();
}
......
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