immersive_context_ash.cc 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright 2016 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "ash/wm/immersive_context_ash.h"
  5. #include "ash/shelf/shelf.h"
  6. #include "ash/shell.h"
  7. #include "ash/wm/window_state.h"
  8. #include "ash/wm/window_util.h"
  9. #include "chromeos/ui/frame/immersive/immersive_fullscreen_controller.h"
  10. #include "ui/display/screen.h"
  11. #include "ui/views/widget/widget.h"
  12. namespace ash {
  13. using ::chromeos::ImmersiveFullscreenController;
  14. ImmersiveContextAsh::ImmersiveContextAsh() = default;
  15. ImmersiveContextAsh::~ImmersiveContextAsh() = default;
  16. void ImmersiveContextAsh::OnEnteringOrExitingImmersive(
  17. ImmersiveFullscreenController* controller,
  18. bool entering) {
  19. aura::Window* window = controller->widget()->GetNativeWindow();
  20. WindowState* window_state = WindowState::Get(window);
  21. // Auto hide the shelf in immersive fullscreen instead of hiding it.
  22. window_state->SetHideShelfWhenFullscreen(!entering);
  23. for (aura::Window* root_window : Shell::GetAllRootWindows())
  24. Shelf::ForWindow(root_window)->UpdateVisibilityState();
  25. }
  26. gfx::Rect ImmersiveContextAsh::GetDisplayBoundsInScreen(views::Widget* widget) {
  27. display::Display display =
  28. display::Screen::GetScreen()->GetDisplayNearestWindow(
  29. widget->GetNativeWindow());
  30. return display.bounds();
  31. }
  32. bool ImmersiveContextAsh::DoesAnyWindowHaveCapture() {
  33. return window_util::GetCaptureWindow() != nullptr;
  34. }
  35. } // namespace ash