Chromium Code Reviews| Index: ash/common/wm/workspace/workspace_layout_manager.cc |
| diff --git a/ash/common/wm/workspace/workspace_layout_manager.cc b/ash/common/wm/workspace/workspace_layout_manager.cc |
| index 7304c365400127795ec93771b85c74c9447bf77f..8c8caabd3e17cae908683cf6b5ed6736dc55122e 100644 |
| --- a/ash/common/wm/workspace/workspace_layout_manager.cc |
| +++ b/ash/common/wm/workspace/workspace_layout_manager.cc |
| @@ -33,7 +33,8 @@ WorkspaceLayoutManager::WorkspaceLayoutManager( |
| shell_(window_->GetShell()), |
| delegate_(std::move(delegate)), |
| work_area_in_parent_(wm::GetDisplayWorkAreaBounds(window_)), |
| - is_fullscreen_(wm::GetWindowForFullscreenMode(window) != nullptr) { |
| + is_fullscreen_(wm::GetWindowForFullscreenMode(window) != nullptr), |
| + is_pinned_(WmShell::Get()->IsPinned()) { |
| shell_->AddActivationObserver(this); |
| root_window_->AddObserver(this); |
| root_window_controller_->AddObserver(this); |
| @@ -44,8 +45,11 @@ WorkspaceLayoutManager::WorkspaceLayoutManager( |
| WorkspaceLayoutManager::~WorkspaceLayoutManager() { |
| if (root_window_) |
| root_window_->RemoveObserver(this); |
| - for (WmWindow* window : windows_) |
| + for (WmWindow* window : windows_) { |
| + wm::WindowState* window_state = window->GetWindowState(); |
| + window_state->RemoveObserver(this); |
|
hidehiko
2016/06/16 19:53:09
Note: this is a bug fix of the existing code.
|
| window->RemoveObserver(this); |
| + } |
| root_window_->GetRootWindowController()->RemoveObserver(this); |
| shell_->RemoveActivationObserver(this); |
| } |
| @@ -173,20 +177,17 @@ void WorkspaceLayoutManager::OnFullscreenStateChanged(bool is_fullscreen) { |
| if (is_fullscreen_ == is_fullscreen) |
| return; |
| + bool was_always_on_top_allowed = !is_fullscreen_ && !is_pinned_; |
| is_fullscreen_ = is_fullscreen; |
| - WmWindow* fullscreen_window = |
| - is_fullscreen ? wm::GetWindowForFullscreenMode(window_) : 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) { |
| - wm::WindowState* window_state = window->GetWindowState(); |
| - if (is_fullscreen) |
| - window_state->DisableAlwaysOnTop(fullscreen_window); |
| - else |
| - window_state->RestoreAlwaysOnTop(); |
| + bool is_always_on_top_allowed = !is_fullscreen_ && !is_pinned_; |
| + if (is_always_on_top_allowed != was_always_on_top_allowed) { |
| + // In this pass, if is_always_on_top_allowed is false, then fullscreen |
| + // window should be found. It is because; the situation only happens |
| + // when was_always_on_top_allowed is true, so (is_fullscreen, is_pinned) |
| + // is changed from (false, false) to (true, false). |
| + UpdateAlwaysOnTop(is_always_on_top_allowed |
| + ? nullptr |
| + : wm::GetWindowForFullscreenMode(window_)); |
| } |
| } |
| @@ -284,6 +285,22 @@ void WorkspaceLayoutManager::OnPostWindowStateTypeChange( |
| } |
| ////////////////////////////////////////////////////////////////////////////// |
| +// WorkspaceLayoutManager, ShellObserver implementation: |
| + |
| +void WorkspaceLayoutManager::OnPinnedStateChanged(WmWindow* pinned_window) { |
| + bool is_pinned = pinned_window->GetWindowState()->IsPinned(); |
| + if (is_pinned_ == is_pinned) |
| + return; |
| + |
| + bool was_always_on_top_allowed = !is_fullscreen_ && !is_pinned_; |
| + is_pinned_ = is_pinned; |
| + bool is_always_on_top_allowed = !is_fullscreen_ && !is_pinned_; |
| + if (is_always_on_top_allowed != was_always_on_top_allowed) { |
| + UpdateAlwaysOnTop(is_always_on_top_allowed ? nullptr : pinned_window); |
| + } |
| +} |
| + |
| +////////////////////////////////////////////////////////////////////////////// |
| // WorkspaceLayoutManager, private: |
| void WorkspaceLayoutManager::AdjustAllWindowsBoundsForWorkAreaChange( |
| @@ -329,4 +346,19 @@ void WorkspaceLayoutManager::UpdateFullscreenState() { |
| } |
| } |
| +void WorkspaceLayoutManager::UpdateAlwaysOnTop(WmWindow* window_on_top) { |
| + // 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) { |
| + wm::WindowState* window_state = window->GetWindowState(); |
| + if (window_on_top) |
| + window_state->DisableAlwaysOnTop(window_on_top); |
| + else |
| + window_state->RestoreAlwaysOnTop(); |
| + } |
| +} |
| + |
| } // namespace ash |