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

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

Issue 2072853002: Implement "pinned" mode in ash. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix linux build breakage Created 4 years, 6 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
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()) {
oshima 2016/06/17 10:26:53 I'd prefer to just use WmShell::IsPinned() because
hidehiko 2016/06/17 17:19:22 It looks unsafe. The order of the callbacks for On
oshima 2016/06/18 04:47:44 Can you explain how? OnPinnedStateChanged must be
hidehiko 2016/06/18 05:32:45 The trigger is an event to the WindowState, and it
oshima 2016/06/18 06:24:10 I think you should change the following say 1) Wi
hidehiko 2016/06/18 06:25:51 We cannot, now. WindowState cannot access to Scree
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);
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

Powered by Google App Engine
This is Rietveld 408576698