unified_desktop_utils.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // Copyright 2017 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 UI_DISPLAY_UNIFIED_DESKTOP_UTILS_H_
  5. #define UI_DISPLAY_UNIFIED_DESKTOP_UTILS_H_
  6. #include <vector>
  7. #include "ui/display/display_export.h"
  8. #include "ui/display/display_layout.h"
  9. namespace display {
  10. // Defines a display position in the unified display matrix.
  11. enum class DisplayPositionInUnifiedMatrix {
  12. kTopLeft,
  13. kTopRight,
  14. kBottomLeft,
  15. };
  16. // Type of the matrix that represents the display layout in Unified Desktop
  17. // mode. The ID of a display is placed in a cell in the matrix where that
  18. // display is desired to be placed in the actual layout.
  19. using UnifiedDesktopLayoutMatrix = std::vector<std::vector<int64_t>>;
  20. // Validates that:
  21. // - The matrix is not empty.
  22. // - There are no holes (empty display IDs) in the matrix.
  23. // - All matrix rows have equal non-zero widths.
  24. bool DISPLAY_EXPORT ValidateMatrix(const UnifiedDesktopLayoutMatrix& matrix);
  25. // Validates that the given display |layout| is convertable to a valid Unified
  26. // Desktop layout matrix. If yes, then the matrix will be built and filled in
  27. // |out_matrix| and true is returned. False is returned and |out_matrix| will be
  28. // unchanged.
  29. //
  30. // Rules of a valid Unified Desktop layout:
  31. // - All IDs in the |layout|'s |primary_id| and |placement_list| must exist in
  32. // the display |ids_list|.
  33. // - There is a placement for each display in the |ids_list| except the primary
  34. // display.
  35. // - The primary display must be the root.
  36. // - There is a path from each display to the root display with no cycles.
  37. // - No placement offsets are allowed.
  38. // - The |layout|'s |placement_list| is not required to be sorted.
  39. // - A display can only have at most one child on either of its sides.
  40. // - Layouts that specify a display grid must be complete; i.e. no empty holes
  41. // in the grid.
  42. bool DISPLAY_EXPORT
  43. BuildUnifiedDesktopMatrix(const DisplayIdList& ids_list,
  44. const DisplayLayout& layout,
  45. UnifiedDesktopLayoutMatrix* out_matrix);
  46. } // namespace display
  47. #endif // UI_DISPLAY_UNIFIED_DESKTOP_UTILS_H_