display_highlight_controller.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright 2020 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. #ifndef ASH_DISPLAY_DISPLAY_HIGHLIGHT_CONTROLLER_H_
  5. #define ASH_DISPLAY_DISPLAY_HIGHLIGHT_CONTROLLER_H_
  6. #include "ash/ash_export.h"
  7. #include "ash/display/window_tree_host_manager.h"
  8. #include "ash/public/cpp/session/session_observer.h"
  9. #include "ui/views/widget/widget.h"
  10. namespace ash {
  11. // DisplayHighlightController manages which display should render display
  12. // identification highlights. Highlights are translucent blue rectangles on the
  13. // edges of a display.
  14. // TODO(1091497): Consider combining DisplayHighlightController and
  15. // DisplayAlignmentController.
  16. class ASH_EXPORT DisplayHighlightController
  17. : public WindowTreeHostManager::Observer,
  18. public SessionObserver {
  19. public:
  20. DisplayHighlightController();
  21. ~DisplayHighlightController() override;
  22. // Sets the display to render the highlights on. To remove a currently-active
  23. // highlight, pass display::kInvalidDisplayId as |display_id|.
  24. void SetHighlightedDisplay(int64_t display_id);
  25. views::Widget* GetWidgetForTesting() { return highlight_widget_.get(); }
  26. private:
  27. // WindowTreeHostManager::Observer:
  28. void OnDisplayConfigurationChanged() override;
  29. void OnDisplaysInitialized() override;
  30. // SessionObserver:
  31. void OnLockStateChanged(bool locked) override;
  32. // Updates |highlight_| with new selected display.
  33. void UpdateDisplayIdentificationHighlight();
  34. // Widget used to render a blue highlight on the border of the specified
  35. // display.
  36. std::unique_ptr<views::Widget> highlight_widget_;
  37. int64_t selected_display_id_ = display::kInvalidDisplayId;
  38. // Tracks if the screen is locked in order to remove the highlight when screen
  39. // locks and show it when it unlocks.
  40. bool is_locked_;
  41. };
  42. } // namespace ash
  43. #endif // ASH_DISPLAY_DISPLAY_HIGHLIGHT_CONTROLLER_H_