Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(422)

Unified Diff: ash/wm/workspace/workspace_layout_manager.cc

Issue 1841803002: Cleanup WorkspaceController and WorkspaceLayoutManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Check if the container is kShellWindowId_DefaultContainer instead. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/wm/workspace/workspace_layout_manager.h ('k') | ash/wm/workspace_controller.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/workspace/workspace_layout_manager.cc
diff --git a/ash/wm/workspace/workspace_layout_manager.cc b/ash/wm/workspace/workspace_layout_manager.cc
index fcf5cc7db40641f07315e1756dcf2d815d5882c6..c43485aab358355a80862557f37d05b9c6a2af34 100644
--- a/ash/wm/workspace/workspace_layout_manager.cc
+++ b/ash/wm/workspace/workspace_layout_manager.cc
@@ -9,8 +9,8 @@
#include "ash/root_window_controller.h"
#include "ash/screen_util.h"
#include "ash/session/session_state_delegate.h"
-#include "ash/shelf/shelf_layout_manager.h"
#include "ash/shell.h"
+#include "ash/shell_window_ids.h"
#include "ash/wm/always_on_top_controller.h"
#include "ash/wm/window_animations.h"
#include "ash/wm/window_positioner.h"
@@ -30,21 +30,19 @@
#include "ui/wm/core/window_util.h"
#include "ui/wm/public/activation_client.h"
-using aura::Window;
-
namespace ash {
WorkspaceLayoutManager::WorkspaceLayoutManager(aura::Window* window)
- : shelf_(NULL),
- window_(window),
- root_window_(window->GetRootWindow()),
+ : window_(window),
+ root_window_(window_->GetRootWindow()),
+ root_window_controller_(GetRootWindowController(root_window_)),
work_area_in_parent_(ScreenUtil::ConvertRectFromScreen(
window_,
gfx::Screen::GetScreen()
->GetDisplayNearestWindow(window_)
.work_area())),
- is_fullscreen_(GetRootWindowController(window->GetRootWindow())
- ->GetWindowForFullscreenMode() != NULL) {
+ is_fullscreen_(root_window_controller_->GetWindowForFullscreenMode() !=
+ nullptr) {
Shell::GetInstance()->activation_client()->AddObserver(this);
Shell::GetInstance()->AddShellObserver(this);
root_window_->AddObserver(this);
@@ -54,16 +52,12 @@ WorkspaceLayoutManager::WorkspaceLayoutManager(aura::Window* window)
WorkspaceLayoutManager::~WorkspaceLayoutManager() {
if (root_window_)
root_window_->RemoveObserver(this);
- for (WindowSet::const_iterator i = windows_.begin(); i != windows_.end(); ++i)
- (*i)->RemoveObserver(this);
+ for (auto* window : windows_)
+ window->RemoveObserver(this);
Shell::GetInstance()->RemoveShellObserver(this);
Shell::GetInstance()->activation_client()->RemoveObserver(this);
}
-void WorkspaceLayoutManager::SetShelf(ShelfLayoutManager* shelf) {
- shelf_ = shelf;
-}
-
void WorkspaceLayoutManager::SetMaximizeBackdropDelegate(
std::unique_ptr<WorkspaceLayoutManagerDelegate> delegate) {
backdrop_delegate_.reset(delegate.release());
@@ -72,21 +66,21 @@ void WorkspaceLayoutManager::SetMaximizeBackdropDelegate(
//////////////////////////////////////////////////////////////////////////////
// WorkspaceLayoutManager, aura::LayoutManager implementation:
-void WorkspaceLayoutManager::OnWindowAddedToLayout(Window* child) {
+void WorkspaceLayoutManager::OnWindowAddedToLayout(aura::Window* child) {
wm::WindowState* window_state = wm::GetWindowState(child);
wm::WMEvent event(wm::WM_EVENT_ADDED_TO_WORKSPACE);
window_state->OnWMEvent(&event);
windows_.insert(child);
child->AddObserver(this);
window_state->AddObserver(this);
- UpdateShelfVisibility();
+ root_window_controller_->UpdateShelfVisibility();
UpdateFullscreenState();
if (backdrop_delegate_)
backdrop_delegate_->OnWindowAddedToLayout(child);
WindowPositioner::RearrangeVisibleWindowOnShow(child);
}
-void WorkspaceLayoutManager::OnWillRemoveWindowFromLayout(Window* child) {
+void WorkspaceLayoutManager::OnWillRemoveWindowFromLayout(aura::Window* child) {
windows_.erase(child);
child->RemoveObserver(this);
wm::GetWindowState(child)->RemoveObserver(this);
@@ -95,14 +89,14 @@ void WorkspaceLayoutManager::OnWillRemoveWindowFromLayout(Window* child) {
WindowPositioner::RearrangeVisibleWindowOnHideOrRemove(child);
}
-void WorkspaceLayoutManager::OnWindowRemovedFromLayout(Window* child) {
- UpdateShelfVisibility();
+void WorkspaceLayoutManager::OnWindowRemovedFromLayout(aura::Window* child) {
+ root_window_controller_->UpdateShelfVisibility();
UpdateFullscreenState();
if (backdrop_delegate_)
backdrop_delegate_->OnWindowRemovedFromLayout(child);
}
-void WorkspaceLayoutManager::OnChildWindowVisibilityChanged(Window* child,
+void WorkspaceLayoutManager::OnChildWindowVisibilityChanged(aura::Window* child,
bool visible) {
wm::WindowState* window_state = wm::GetWindowState(child);
// Attempting to show a minimized window. Unminimize it.
@@ -114,18 +108,17 @@ void WorkspaceLayoutManager::OnChildWindowVisibilityChanged(Window* child,
else
WindowPositioner::RearrangeVisibleWindowOnHideOrRemove(child);
UpdateFullscreenState();
- UpdateShelfVisibility();
+ root_window_controller_->UpdateShelfVisibility();
if (backdrop_delegate_)
backdrop_delegate_->OnChildWindowVisibilityChanged(child, visible);
}
-void WorkspaceLayoutManager::SetChildBounds(
- Window* child,
- const gfx::Rect& requested_bounds) {
+void WorkspaceLayoutManager::SetChildBounds(aura::Window* child,
+ const gfx::Rect& requested_bounds) {
wm::WindowState* window_state = wm::GetWindowState(child);
wm::SetBoundsEvent event(wm::WM_EVENT_SET_BOUNDS, requested_bounds);
window_state->OnWMEvent(&event);
- UpdateShelfVisibility();
+ root_window_controller_->UpdateShelfVisibility();
}
//////////////////////////////////////////////////////////////////////////////
@@ -181,22 +174,18 @@ void WorkspaceLayoutManager::OnDisplayWorkAreaInsetsChanged() {
void WorkspaceLayoutManager::OnFullscreenStateChanged(
bool is_fullscreen,
aura::Window* root_window) {
- if (window_->GetRootWindow() != root_window ||
- is_fullscreen_ == is_fullscreen) {
+ if (root_window_ != root_window || is_fullscreen_ == is_fullscreen)
return;
- }
is_fullscreen_ = is_fullscreen;
- Window* fullscreen_window =
- is_fullscreen
- ? GetRootWindowController(window_->GetRootWindow())
- ->GetWindowForFullscreenMode()
- : NULL;
+ aura::Window* fullscreen_window =
+ is_fullscreen ? root_window_controller_->GetWindowForFullscreenMode()
+ : nullptr;
// Changing always on top state may change window's parent. Iterate on a copy
// of |windows_| to avoid invalidating an iterator. Since both workspace and
// always_on_top containers' layouts are managed by this class all the
// appropriate windows will be included in the iteration.
WindowSet windows(windows_);
- for (auto window : windows) {
+ for (auto* window : windows) {
wm::WindowState* window_state = wm::GetWindowState(window);
if (is_fullscreen)
window_state->DisableAlwaysOnTop(fullscreen_window);
@@ -224,11 +213,11 @@ void WorkspaceLayoutManager::OnWindowHierarchyChanged(
// the fullscreen state accordingly.
if (params.new_parent && params.new_parent->GetRootWindow() == root_window_) {
UpdateFullscreenState();
- UpdateShelfVisibility();
+ root_window_controller_->UpdateShelfVisibility();
}
}
-void WorkspaceLayoutManager::OnWindowPropertyChanged(Window* window,
+void WorkspaceLayoutManager::OnWindowPropertyChanged(aura::Window* window,
const void* key,
intptr_t old) {
if (key == aura::client::kAlwaysOnTopKey &&
@@ -239,7 +228,7 @@ void WorkspaceLayoutManager::OnWindowPropertyChanged(Window* window,
}
void WorkspaceLayoutManager::OnWindowStackingChanged(aura::Window* window) {
- UpdateShelfVisibility();
+ root_window_controller_->UpdateShelfVisibility();
UpdateFullscreenState();
if (backdrop_delegate_)
backdrop_delegate_->OnWindowStackingChanged(window);
@@ -248,13 +237,15 @@ void WorkspaceLayoutManager::OnWindowStackingChanged(aura::Window* window) {
void WorkspaceLayoutManager::OnWindowDestroying(aura::Window* window) {
if (root_window_ == window) {
root_window_->RemoveObserver(this);
- root_window_ = NULL;
+ root_window_ = nullptr;
+ root_window_controller_ = nullptr;
}
}
-void WorkspaceLayoutManager::OnWindowBoundsChanged(aura::Window* window,
- const gfx::Rect& old_bounds,
- const gfx::Rect& new_bounds) {
+void WorkspaceLayoutManager::OnWindowBoundsChanged(
+ aura::Window* window,
+ const gfx::Rect& old_bounds,
+ const gfx::Rect& new_bounds) {
if (root_window_ == window) {
const wm::WMEvent wm_event(wm::WM_EVENT_DISPLAY_BOUNDS_CHANGED);
AdjustAllWindowsBoundsForWorkAreaChange(&wm_event);
@@ -276,7 +267,7 @@ void WorkspaceLayoutManager::OnWindowActivated(
DCHECK(!window_state->IsMinimized());
}
UpdateFullscreenState();
- UpdateShelfVisibility();
+ root_window_controller_->UpdateShelfVisibility();
}
//////////////////////////////////////////////////////////////////////////////
@@ -292,7 +283,7 @@ void WorkspaceLayoutManager::OnPostWindowStateTypeChange(
UpdateFullscreenState();
}
- UpdateShelfVisibility();
+ root_window_controller_->UpdateShelfVisibility();
if (backdrop_delegate_)
backdrop_delegate_->OnPostWindowStateTypeChange(window_state, old_type);
}
@@ -321,16 +312,8 @@ void WorkspaceLayoutManager::AdjustAllWindowsBoundsForWorkAreaChange(
// We also do this when developers running Aura on a desktop manually resize
// the host window.
// We also need to do this when the work area insets changes.
- for (WindowSet::const_iterator it = windows_.begin();
- it != windows_.end();
- ++it) {
- wm::GetWindowState(*it)->OnWMEvent(event);
- }
-}
-
-void WorkspaceLayoutManager::UpdateShelfVisibility() {
- if (shelf_)
- shelf_->UpdateVisibilityState();
+ for (auto* window : windows_)
+ wm::GetWindowState(window)->OnWMEvent(event);
}
void WorkspaceLayoutManager::UpdateFullscreenState() {
@@ -339,13 +322,13 @@ void WorkspaceLayoutManager::UpdateFullscreenState() {
// only windows in the default workspace container will go fullscreen but
// this should really be tracked by the RootWindowController since
// technically any container could get a fullscreen window.
- if (!shelf_)
+ if (window_->id() != kShellWindowId_DefaultContainer)
return;
- bool is_fullscreen = GetRootWindowController(
- window_->GetRootWindow())->GetWindowForFullscreenMode() != NULL;
+ bool is_fullscreen =
+ root_window_controller_->GetWindowForFullscreenMode() != nullptr;
if (is_fullscreen != is_fullscreen_) {
- ash::Shell::GetInstance()->NotifyFullscreenStateChange(
- is_fullscreen, window_->GetRootWindow());
+ ash::Shell::GetInstance()->NotifyFullscreenStateChange(is_fullscreen,
+ root_window_);
is_fullscreen_ = is_fullscreen;
}
}
« no previous file with comments | « ash/wm/workspace/workspace_layout_manager.h ('k') | ash/wm/workspace_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698