window_info.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 COMPONENTS_APP_RESTORE_WINDOW_INFO_H_
  5. #define COMPONENTS_APP_RESTORE_WINDOW_INFO_H_
  6. #include "chromeos/ui/base/window_state_type.h"
  7. #include "third_party/abseil-cpp/absl/types/optional.h"
  8. #include "ui/aura/window.h"
  9. #include "ui/base/ui_base_types.h"
  10. #include "ui/gfx/geometry/rect.h"
  11. namespace app_restore {
  12. // This struct is the parameter for the interface SaveWindowInfo, to save the
  13. // window information.
  14. struct COMPONENT_EXPORT(APP_RESTORE) WindowInfo {
  15. public:
  16. // This struct is the ARC specific window info.
  17. struct ArcExtraInfo {
  18. ArcExtraInfo();
  19. ArcExtraInfo(const WindowInfo::ArcExtraInfo&);
  20. ArcExtraInfo& operator=(const WindowInfo::ArcExtraInfo&);
  21. ~ArcExtraInfo();
  22. absl::optional<gfx::Size> maximum_size;
  23. absl::optional<gfx::Size> minimum_size;
  24. absl::optional<gfx::Rect> bounds_in_root;
  25. };
  26. WindowInfo();
  27. WindowInfo(const WindowInfo&) = delete;
  28. WindowInfo& operator=(const WindowInfo&) = delete;
  29. ~WindowInfo();
  30. WindowInfo* Clone();
  31. aura::Window* window;
  32. // Index in MruWindowTracker to restore window stack. A lower index
  33. // indicates a more recently used window.
  34. absl::optional<int32_t> activation_index;
  35. // Virtual desk id.
  36. absl::optional<int32_t> desk_id;
  37. // Current bounds in screen in coordinates. If the window has restore bounds,
  38. // then this contains the restore bounds.
  39. absl::optional<gfx::Rect> current_bounds;
  40. // Window state, minimized, maximized, inactive, etc.
  41. absl::optional<chromeos::WindowStateType> window_state_type;
  42. // Show state of a window before it was minimized. Empty for non-minimized
  43. // windows.
  44. absl::optional<ui::WindowShowState> pre_minimized_show_state_type;
  45. // The snap percentage of a window, if it is snapped. For instance a snap
  46. // percentage of 75 means the window takes up three quarters of the work area.
  47. // The primary axis is determined when restoring; if it is portrait, it will
  48. // be three quarters of the height.
  49. absl::optional<uint32_t> snap_percentage;
  50. // Display id to launch an app.
  51. absl::optional<int64_t> display_id;
  52. // The title of the app window. Used for saved desks in case one of the
  53. // windows in the template is uninstalled, we can show a nice error message.
  54. // Also used for the ARC ghost window.
  55. absl::optional<std::u16string> app_title;
  56. // Extra window info of ARC app window.
  57. absl::optional<ArcExtraInfo> arc_extra_info;
  58. std::string ToString() const;
  59. };
  60. } // namespace app_restore
  61. #endif // COMPONENTS_APP_RESTORE_WINDOW_INFO_H_