Commit 971b54ea authored by Avery Musbach's avatar Avery Musbach Committed by Commit Bot

split view: Adjust init/shutdown order for multi-display split view

In preparation for RootWindowController to own a SplitViewController,
the present CL arranges for the objects to be created at about the same
time, and destroyed at about the same time.

Bug: 970013
Change-Id: I0bcb60c76055124521dd3a33c4a06a299e9ccf0c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1811639
Commit-Queue: Avery Musbach <amusbach@chromium.org>
Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/heads/master@{#698631}
parent 56f49a39
......@@ -493,11 +493,6 @@ void Shell::UpdateAfterLoginStatusChange(LoginStatus status) {
root_window_controller->UpdateAfterLoginStatusChange(status);
}
void Shell::NotifySplitViewModeStarting() {
for (auto& observer : shell_observers_)
observer.OnSplitViewModeStarting();
}
void Shell::NotifySplitViewModeStarted() {
for (auto& observer : shell_observers_)
observer.OnSplitViewModeStarted();
......@@ -705,10 +700,6 @@ Shell::~Shell() {
window_cycle_controller_.reset();
overview_controller_.reset();
// |split_view_controller_| needs to be deleted after
// |overview_controller_|.
split_view_controller_.reset();
// Stop dispatching events (e.g. synthesized mouse exits from window close).
// https://crbug.com/874156
for (RootWindowController* rwc : GetAllRootWindowControllers())
......@@ -795,6 +786,10 @@ Shell::~Shell() {
// destruction of its owned RootWindowControllers relies on the value.
window_tree_host_manager_->Shutdown();
// Destroy |SplitViewController| and |RootWindowController| at about the same
// time, as we plan for |RootWindowController| to own a |SplitViewController|.
// TODO(crbug.com/970013): Actually carry out that plan.
split_view_controller_.reset();
// Depends on |focus_controller_|, so must be destroyed before.
window_tree_host_manager_.reset();
......@@ -1119,6 +1114,10 @@ void Shell::Init(
system_notification_controller_ =
std::make_unique<SystemNotificationController>();
// Create |SplitViewController| and |RootWindowController| at about the same
// time, as we plan for |RootWindowController| to own a |SplitViewController|.
// TODO(crbug.com/970013): Actually carry out that plan.
split_view_controller_ = std::make_unique<SplitViewController>();
window_tree_host_manager_->InitHosts();
// Create virtual keyboard after WindowTreeHostManager::InitHosts() since
......@@ -1147,7 +1146,6 @@ void Shell::Init(
std::make_unique<ScreenOrientationController>();
screen_layout_observer_.reset(new ScreenLayoutObserver());
sms_observer_.reset(new SmsObserver());
split_view_controller_.reset(new SplitViewController());
snap_controller_ = std::make_unique<SnapControllerImpl>();
key_accessibility_enabler_ = std::make_unique<KeyAccessibilityEnabler>();
......
......@@ -541,10 +541,6 @@ class ASH_EXPORT Shell : public SessionObserver,
// TODO(oshima): Investigate if we can merge this and |OnLoginStateChanged|.
void UpdateAfterLoginStatusChange(LoginStatus status);
// Notifies observers that split view mode is about to be started (before the
// window gets snapped and activated).
void NotifySplitViewModeStarting();
// Notifies observers that split view mode has been started.
void NotifySplitViewModeStarted();
......
......@@ -41,10 +41,6 @@ class ASH_EXPORT ShellObserver {
// Invoked when |pinned_window| enter or exit pinned mode.
virtual void OnPinnedStateChanged(aura::Window* pinned_window) {}
// Called when the split view mode is about to be started before the window
// gets snapped and activated).
virtual void OnSplitViewModeStarting() {}
// Called when the split view mode has been started.
virtual void OnSplitViewModeStarted() {}
......
......@@ -284,7 +284,6 @@ SplitViewController::SplitViewController() {
SplitViewController::~SplitViewController() {
display::Screen::GetScreen()->RemoveObserver(this);
Shell::Get()->accessibility_controller()->RemoveObserver(this);
EndSplitView();
}
......@@ -325,7 +324,6 @@ void SplitViewController::SnapWindow(aura::Window* window,
Shell::Get()->AddShellObserver(this);
Shell::Get()->overview_controller()->AddObserver(this);
Shell::Get()->activation_client()->AddObserver(this);
Shell::Get()->NotifySplitViewModeStarting();
// If there is pre-set |divider_position_|, use it. It can happen during
// tablet <-> clamshell transition or multi-user transition.
......@@ -1188,6 +1186,10 @@ void SplitViewController::OnAccessibilityStatusChanged() {
EndSplitView();
}
void SplitViewController::OnAccessibilityControllerShutdown() {
Shell::Get()->accessibility_controller()->RemoveObserver(this);
}
void SplitViewController::StartObserving(aura::Window* window) {
if (window && !window->HasObserver(this)) {
Shell::Get()->shadow_controller()->UpdateShadowForWindow(window);
......
......@@ -212,6 +212,7 @@ class ASH_EXPORT SplitViewController : public SplitViewNotifier,
// AccessibilityObserver:
void OnAccessibilityStatusChanged() override;
void OnAccessibilityControllerShutdown() override;
aura::Window* left_window() { return left_window_; }
aura::Window* right_window() { return right_window_; }
......
......@@ -113,7 +113,7 @@ BackdropController::BackdropController(aura::Window* container)
: container_(container) {
DCHECK(container_);
auto* shell = Shell::Get();
shell->AddShellObserver(this);
shell->split_view_controller()->AddObserver(this);
shell->overview_controller()->AddObserver(this);
shell->accessibility_controller()->AddObserver(this);
shell->wallpaper_controller()->AddObserver(this);
......@@ -129,7 +129,7 @@ BackdropController::~BackdropController() {
shell->wallpaper_controller()->RemoveObserver(this);
if (shell->overview_controller())
shell->overview_controller()->RemoveObserver(this);
shell->RemoveShellObserver(this);
shell->split_view_controller()->RemoveObserver(this);
// TODO(oshima): animations won't work right with mus:
// http://crbug.com/548396.
Hide(/*destroy=*/true);
......@@ -210,14 +210,6 @@ aura::Window* BackdropController::GetTopmostWindowWithBackdrop() {
return nullptr;
}
void BackdropController::OnSplitViewModeStarting() {
Shell::Get()->split_view_controller()->AddObserver(this);
}
void BackdropController::OnSplitViewModeEnded() {
Shell::Get()->split_view_controller()->RemoveObserver(this);
}
void BackdropController::OnOverviewModeStarting() {
// Don't destroy backdrops, just hide them so they don't show in the overview
// grid, but keep the widget so that it can be mirrored into the mini_desk
......
......@@ -12,7 +12,6 @@
#include "ash/public/cpp/split_view.h"
#include "ash/public/cpp/tablet_mode_observer.h"
#include "ash/public/cpp/wallpaper_controller_observer.h"
#include "ash/shell_observer.h"
#include "ash/wm/overview/overview_observer.h"
#include "base/macros.h"
#include "ui/gfx/geometry/rect.h"
......@@ -41,7 +40,6 @@ namespace ash {
// - Bottom-most snapped window in splitview,
// - Top-most activatable window if splitview is inactive.
class ASH_EXPORT BackdropController : public AccessibilityObserver,
public ShellObserver,
public OverviewObserver,
public SplitViewObserver,
public WallpaperControllerObserver,
......@@ -70,10 +68,6 @@ class ASH_EXPORT BackdropController : public AccessibilityObserver,
aura::Window* backdrop_window() { return backdrop_window_; }
// ShellObserver:
void OnSplitViewModeStarting() override;
void OnSplitViewModeEnded() override;
// OverviewObserver:
void OnOverviewModeStarting() override;
void OnOverviewModeEnding(OverviewSession* overview_session) override;
......
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