Commit eb0142f4 authored by Manu Cornet's avatar Manu Cornet

CrOS Shelf: Relax constraints on what can happen during overview anim

Separate suspension of shelf visibility updates and work area
updates (the former is needed for desk transitions, the latter is
needed for overview transitions).

Bug: 1021691, 1017435, 1019531
Change-Id: Ie0bb64d931a06b2157a58afc2b1c8604ccf2d71c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1898718
Commit-Queue: Manu Cornet <manucornet@chromium.org>
Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarAlex Newcomer <newcomer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#714290}
parent ed192259
...@@ -613,12 +613,8 @@ void AppListControllerImpl::OnShellDestroying() { ...@@ -613,12 +613,8 @@ void AppListControllerImpl::OnShellDestroying() {
Shutdown(); Shutdown();
} }
void AppListControllerImpl::OnOverviewModeWillStart() { void AppListControllerImpl::OnOverviewModeStarting() {
if (IsTabletMode()) { if (IsTabletMode()) {
scoped_suspend_visibility_update_ =
std::make_unique<ShelfLayoutManager::ScopedSuspendVisibilityUpdate>(
RootWindowController::ForWindow(presenter_.GetWindow())
->GetShelfLayoutManager());
const int64_t display_id = last_visible_display_id_; const int64_t display_id = last_visible_display_id_;
OnHomeLauncherTargetPositionChanged(false /* showing */, display_id); OnHomeLauncherTargetPositionChanged(false /* showing */, display_id);
OnVisibilityWillChange(false /* visible */, display_id); OnVisibilityWillChange(false /* visible */, display_id);
...@@ -631,8 +627,6 @@ void AppListControllerImpl::OnOverviewModeStartingAnimationComplete( ...@@ -631,8 +627,6 @@ void AppListControllerImpl::OnOverviewModeStartingAnimationComplete(
bool canceled) { bool canceled) {
if (!IsTabletMode()) if (!IsTabletMode())
return; return;
if (scoped_suspend_visibility_update_)
scoped_suspend_visibility_update_.reset();
OnHomeLauncherAnimationComplete(false /* shown */, last_visible_display_id_); OnHomeLauncherAnimationComplete(false /* shown */, last_visible_display_id_);
} }
......
...@@ -232,7 +232,7 @@ class ASH_EXPORT AppListControllerImpl ...@@ -232,7 +232,7 @@ class ASH_EXPORT AppListControllerImpl
void OnShellDestroying() override; void OnShellDestroying() override;
// OverviewObserver: // OverviewObserver:
void OnOverviewModeWillStart() override; void OnOverviewModeStarting() override;
void OnOverviewModeStartingAnimationComplete(bool canceled) override; void OnOverviewModeStartingAnimationComplete(bool canceled) override;
void OnOverviewModeEnding(OverviewSession* session) override; void OnOverviewModeEnding(OverviewSession* session) override;
void OnOverviewModeEnded() override; void OnOverviewModeEnded() override;
...@@ -433,11 +433,6 @@ class ASH_EXPORT AppListControllerImpl ...@@ -433,11 +433,6 @@ class ASH_EXPORT AppListControllerImpl
// visibility animation to finish. Should only be used in tablet mode. // visibility animation to finish. Should only be used in tablet mode.
HomeLauncherAnimationCallback home_launcher_animation_callback_; HomeLauncherAnimationCallback home_launcher_animation_callback_;
// Used to prevent ShelfLayoutManager updating visibility state when overview
// is showing over the AppList.
std::unique_ptr<ShelfLayoutManager::ScopedSuspendVisibilityUpdate>
scoped_suspend_visibility_update_;
base::ObserverList<AppListControllerObserver> observers_; base::ObserverList<AppListControllerObserver> observers_;
DISALLOW_COPY_AND_ASSIGN(AppListControllerImpl); DISALLOW_COPY_AND_ASSIGN(AppListControllerImpl);
......
...@@ -663,7 +663,7 @@ void RootWindowController::MoveWindowsTo(aura::Window* dst) { ...@@ -663,7 +663,7 @@ void RootWindowController::MoveWindowsTo(aura::Window* dst) {
// Suspend unnecessary updates of the shelf visibility indefinitely since it // Suspend unnecessary updates of the shelf visibility indefinitely since it
// is going away. // is going away.
if (GetShelfLayoutManager()) if (GetShelfLayoutManager())
GetShelfLayoutManager()->SuspendVisibilityUpdate(); GetShelfLayoutManager()->SuspendVisibilityUpdateForShutdown();
// Clear the workspace controller to avoid a lot of unnecessary operations // Clear the workspace controller to avoid a lot of unnecessary operations
// when window are removed. // when window are removed.
......
This diff is collapsed.
...@@ -75,17 +75,17 @@ class ASH_EXPORT ShelfLayoutManager : public AppListControllerObserver, ...@@ -75,17 +75,17 @@ class ASH_EXPORT ShelfLayoutManager : public AppListControllerObserver,
public LocaleChangeObserver, public LocaleChangeObserver,
public DesksController::Observer { public DesksController::Observer {
public: public:
// Suspend shelf visibility update within its scope. Note that relevant // Suspend work area updates within its scope. Note that relevant
// ShelfLayoutManager must outlive this class. // ShelfLayoutManager must outlive this class.
class ScopedSuspendVisibilityUpdate { class ScopedSuspendWorkAreaUpdate {
public: public:
// |manager| is the ShelfLayoutManager whose visibility update is suspended. // |manager| is the ShelfLayoutManager whose visibility update is suspended.
explicit ScopedSuspendVisibilityUpdate(ShelfLayoutManager* manager); explicit ScopedSuspendWorkAreaUpdate(ShelfLayoutManager* manager);
~ScopedSuspendVisibilityUpdate(); ~ScopedSuspendWorkAreaUpdate();
private: private:
ShelfLayoutManager* const manager_; ShelfLayoutManager* const manager_;
DISALLOW_COPY_AND_ASSIGN(ScopedSuspendVisibilityUpdate); DISALLOW_COPY_AND_ASSIGN(ScopedSuspendWorkAreaUpdate);
}; };
ShelfLayoutManager(ShelfWidget* shelf_widget, Shelf* shelf); ShelfLayoutManager(ShelfWidget* shelf_widget, Shelf* shelf);
...@@ -163,10 +163,9 @@ class ASH_EXPORT ShelfLayoutManager : public AppListControllerObserver, ...@@ -163,10 +163,9 @@ class ASH_EXPORT ShelfLayoutManager : public AppListControllerObserver,
// Cancel the drag if the shelf is in drag progress. // Cancel the drag if the shelf is in drag progress.
void CancelDragOnShelfIfInProgress(); void CancelDragOnShelfIfInProgress();
// Suspends/resumes visibility update. Use ScopedSuspendVisibilityUpdate when // Suspends shelf visibility updates, to be used during shutdown. Since there
// possible to ensure there are balanced calls. // is no balanced "resume" public API, the suspension will be indefinite.
void SuspendVisibilityUpdate(); void SuspendVisibilityUpdateForShutdown();
void ResumeVisiblityUpdate();
// Called when ShelfItems are interacted with in the shelf. // Called when ShelfItems are interacted with in the shelf.
void OnShelfItemSelected(ShelfAction action); void OnShelfItemSelected(ShelfAction action);
...@@ -186,6 +185,7 @@ class ASH_EXPORT ShelfLayoutManager : public AppListControllerObserver, ...@@ -186,6 +185,7 @@ class ASH_EXPORT ShelfLayoutManager : public AppListControllerObserver,
SplitViewController::State state) override; SplitViewController::State state) override;
// OverviewObserver: // OverviewObserver:
void OnOverviewModeWillStart() override;
void OnOverviewModeStarting() override; void OnOverviewModeStarting() override;
void OnOverviewModeStartingAnimationComplete(bool canceled) override; void OnOverviewModeStartingAnimationComplete(bool canceled) override;
void OnOverviewModeEnding(OverviewSession* overview_session) override; void OnOverviewModeEnding(OverviewSession* overview_session) override;
...@@ -366,6 +366,10 @@ class ASH_EXPORT ShelfLayoutManager : public AppListControllerObserver, ...@@ -366,6 +366,10 @@ class ASH_EXPORT ShelfLayoutManager : public AppListControllerObserver,
session_manager::SessionState session_state; session_manager::SessionState session_state;
}; };
// Suspends/resumes work area updates.
void SuspendWorkAreaUpdate();
void ResumeWorkAreaUpdate();
// Sets the visibility of the shelf to |state|. // Sets the visibility of the shelf to |state|.
void SetState(ShelfVisibilityState visibility_state); void SetState(ShelfVisibilityState visibility_state);
...@@ -530,10 +534,14 @@ class ASH_EXPORT ShelfLayoutManager : public AppListControllerObserver, ...@@ -530,10 +534,14 @@ class ASH_EXPORT ShelfLayoutManager : public AppListControllerObserver,
ShelfWidget* shelf_widget_; ShelfWidget* shelf_widget_;
Shelf* shelf_; Shelf* shelf_;
// Count of pending visibility update suspensions. Skip updating shelf // Count of pending visibility update suspensions. Skip updating the shelf
// visibility state if it is greater than 0. // visibility state if it is greater than 0.
int suspend_visibility_update_ = 0; int suspend_visibility_update_ = 0;
// Count of pending work area update suspensions. Skip updating the work
// area if it is greater than 0.
int suspend_work_area_update_ = 0;
base::OneShotTimer auto_hide_timer_; base::OneShotTimer auto_hide_timer_;
// Whether the mouse was over the shelf when the auto hide timer started. // Whether the mouse was over the shelf when the auto hide timer started.
...@@ -571,6 +579,10 @@ class ASH_EXPORT ShelfLayoutManager : public AppListControllerObserver, ...@@ -571,6 +579,10 @@ class ASH_EXPORT ShelfLayoutManager : public AppListControllerObserver,
// detects that the background has been interacted with. // detects that the background has been interacted with.
bool should_hide_hotseat_ = false; bool should_hide_hotseat_ = false;
// Whether the overview mode is about to start. This becomes false again
// once the overview mode has actually started.
bool overview_mode_will_start_ = false;
// Tracks the amount of the drag. The value is only valid when // Tracks the amount of the drag. The value is only valid when
// |drag_status_| is set to kDragInProgress. // |drag_status_| is set to kDragInProgress.
float drag_amount_ = 0.f; float drag_amount_ = 0.f;
...@@ -630,12 +642,12 @@ class ASH_EXPORT ShelfLayoutManager : public AppListControllerObserver, ...@@ -630,12 +642,12 @@ class ASH_EXPORT ShelfLayoutManager : public AppListControllerObserver,
// state. // state.
bool is_auto_hide_state_locked_ = false; bool is_auto_hide_state_locked_ = false;
// An optional ScopedSuspendVisibilityUpdate that gets created when suspend // An optional ScopedSuspendWorkAreaUpdate that gets created when suspend
// visibility update is requested for overview and resets when overview no // visibility update is requested for overview and resets when overview no
// longer needs it. It is used because OnOverviewModeStarting() and // longer needs it. It is used because OnOverviewModeStarting() and
// OnOverviewModeStartingAnimationComplete() calls are not balanced. // OnOverviewModeStartingAnimationComplete() calls are not balanced.
base::Optional<ScopedSuspendVisibilityUpdate> base::Optional<ScopedSuspendWorkAreaUpdate>
overview_suspend_visibility_update_; overview_suspend_work_area_update_;
// The window drag controller that will be used when a window can be dragged // The window drag controller that will be used when a window can be dragged
// up from shelf to homescreen, overview or splitview. // up from shelf to homescreen, overview or splitview.
......
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