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

Unified Diff: ash/common/shelf/shelf_window_watcher.cc

Issue 2618333004: Add ShelfWindowWatcher support for pre-existing windows. (Closed)
Patch Set: Address comments. Created 3 years, 11 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 | « no previous file | ash/common/shelf/shelf_window_watcher_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/common/shelf/shelf_window_watcher.cc
diff --git a/ash/common/shelf/shelf_window_watcher.cc b/ash/common/shelf/shelf_window_watcher.cc
index b4087c29f599ce7722de355cdd2e80497d0e747b..0fd654bcb015d78aff9de3c5d2c3e5844758d792 100644
--- a/ash/common/shelf/shelf_window_watcher.cc
+++ b/ash/common/shelf/shelf_window_watcher.cc
@@ -118,13 +118,8 @@ ShelfWindowWatcher::ShelfWindowWatcher(ShelfModel* model)
observed_container_windows_(&container_window_observer_),
observed_user_windows_(&user_window_observer_) {
WmShell::Get()->AddActivationObserver(this);
- for (WmWindow* root : WmShell::Get()->GetAllRootWindows()) {
- observed_container_windows_.Add(
- root->GetChildByShellWindowId(kShellWindowId_DefaultContainer));
- observed_container_windows_.Add(
- root->GetChildByShellWindowId(kShellWindowId_PanelContainer));
- }
-
+ for (const auto& display : display::Screen::GetScreen()->GetAllDisplays())
+ OnDisplayAdded(display);
display::Screen::GetScreen()->AddObserver(this);
}
@@ -218,16 +213,22 @@ void ShelfWindowWatcher::OnWindowActivated(WmWindow* gained_active,
void ShelfWindowWatcher::OnDisplayAdded(const display::Display& new_display) {
WmWindow* root = WmShell::Get()->GetRootWindowForDisplayId(new_display.id());
- // When the primary root window's display get removed, the existing root
- // window is taken over by the new display and the observer is already set.
+ // When the primary root window's display is removed, the existing root window
+ // is taken over by the new display, and the observer is already set.
WmWindow* default_container =
root->GetChildByShellWindowId(kShellWindowId_DefaultContainer);
- if (!observed_container_windows_.IsObserving(default_container))
+ if (!observed_container_windows_.IsObserving(default_container)) {
+ for (WmWindow* window : default_container->GetChildren())
+ OnUserWindowAdded(window);
observed_container_windows_.Add(default_container);
+ }
WmWindow* panel_container =
root->GetChildByShellWindowId(kShellWindowId_PanelContainer);
- if (!observed_container_windows_.IsObserving(panel_container))
+ if (!observed_container_windows_.IsObserving(panel_container)) {
+ for (WmWindow* window : panel_container->GetChildren())
+ OnUserWindowAdded(window);
observed_container_windows_.Add(panel_container);
+ }
}
void ShelfWindowWatcher::OnDisplayRemoved(const display::Display& old_display) {
« no previous file with comments | « no previous file | ash/common/shelf/shelf_window_watcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698