[go: nahoru, domu]

Do not show shelf nor system tray on secondary displays in lock and login states.

Add logic to hide shelf on secondary display to ShelfWidget.
Add logic to hide system tray on secondary screen to
LoginScreenController.

Set hide state for shelf on secondary display in
ShelfLayoutManager::UpdateVisibilityState(). Otherwise system tray will
be displayed on secondary display despite calls from
LoginScreenController.

Bug: 796239
Change-Id: I941507860e2b4800a1f396ff3e8d6bdf09d95fda
Reviewed-on: https://chromium-review.googlesource.com/885581
Reviewed-by: James Cook <jamescook@chromium.org>
Reviewed-by: Jacob Dufault <jdufault@chromium.org>
Commit-Queue: Aga Wronska <agawronska@chromium.org>
Cr-Commit-Position: refs/heads/master@{#532445}
diff --git a/ash/login/login_screen_controller.cc b/ash/login/login_screen_controller.cc
index 36d3b94..c6b278f4 100644
--- a/ash/login/login_screen_controller.cc
+++ b/ash/login/login_screen_controller.cc
@@ -34,11 +34,29 @@
   return key.GetSecret();
 }
 
-void SetSystemTrayVisibility(bool visible) {
-  auto* status_area =
-      Shell::GetPrimaryRootWindowController()->GetStatusAreaWidget();
-  if (status_area)
-    status_area->SetSystemTrayVisibility(visible);
+enum class SystemTrayVisibility {
+  kNone,     // Tray not visible anywhere.
+  kPrimary,  // Tray visible only on primary display.
+  kAll,      // Tray visible on all displays.
+};
+
+void SetSystemTrayVisibility(SystemTrayVisibility visibility) {
+  RootWindowController* primary_window_controller =
+      Shell::GetPrimaryRootWindowController();
+  for (RootWindowController* window_controller :
+       Shell::GetAllRootWindowControllers()) {
+    StatusAreaWidget* status_area = window_controller->GetStatusAreaWidget();
+    if (!status_area)
+      continue;
+    if (window_controller == primary_window_controller) {
+      status_area->SetSystemTrayVisibility(
+          visibility == SystemTrayVisibility::kPrimary ||
+          visibility == SystemTrayVisibility::kAll);
+    } else {
+      status_area->SetSystemTrayVisibility(visibility ==
+                                           SystemTrayVisibility::kAll);
+    }
+  }
 }
 
 }  // namespace
@@ -71,7 +89,7 @@
 void LoginScreenController::ShowLockScreen(ShowLockScreenCallback on_shown) {
   ash::LockScreen::Show(ash::LockScreen::ScreenType::kLock);
   std::move(on_shown).Run(true);
-  SetSystemTrayVisibility(true);
+  SetSystemTrayVisibility(SystemTrayVisibility::kPrimary);
 }
 
 void LoginScreenController::ShowLoginScreen(ShowLoginScreenCallback on_shown) {
@@ -85,7 +103,7 @@
   // TODO(jdufault): rename ash::LockScreen to ash::LoginScreen.
   ash::LockScreen::Show(ash::LockScreen::ScreenType::kLogin);
   std::move(on_shown).Run(true);
-  SetSystemTrayVisibility(true);
+  SetSystemTrayVisibility(SystemTrayVisibility::kPrimary);
 }
 
 void LoginScreenController::ShowErrorMessage(int32_t login_attempts,