platform_window_init_properties.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. // Copyright 2018 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_PLATFORM_WINDOW_PLATFORM_WINDOW_INIT_PROPERTIES_H_
  5. #define UI_PLATFORM_WINDOW_PLATFORM_WINDOW_INIT_PROPERTIES_H_
  6. #include <string>
  7. #include "base/component_export.h"
  8. #include "base/memory/raw_ptr.h"
  9. #include "build/build_config.h"
  10. #include "third_party/abseil-cpp/absl/types/optional.h"
  11. #include "third_party/skia/include/core/SkColor.h"
  12. #include "ui/base/ui_base_types.h"
  13. #include "ui/gfx/geometry/rect.h"
  14. #include "ui/gfx/native_widget_types.h"
  15. #if BUILDFLAG(IS_FUCHSIA)
  16. #include <fuchsia/element/cpp/fidl.h>
  17. #include <fuchsia/ui/composition/cpp/fidl.h>
  18. #include <fuchsia/ui/views/cpp/fidl.h>
  19. #include <lib/ui/scenic/cpp/view_ref_pair.h>
  20. #endif
  21. namespace gfx {
  22. class ImageSkia;
  23. }
  24. namespace ui {
  25. enum class PlatformWindowType {
  26. kWindow,
  27. kPopup,
  28. kMenu,
  29. kTooltip,
  30. kDrag,
  31. kBubble,
  32. };
  33. enum class PlatformWindowOpacity {
  34. kInferOpacity,
  35. kOpaqueWindow,
  36. kTranslucentWindow,
  37. };
  38. enum class PlatformWindowShadowType {
  39. kDefault,
  40. kNone,
  41. kDrop,
  42. };
  43. class WorkspaceExtensionDelegate;
  44. #if BUILDFLAG(IS_FUCHSIA)
  45. class ScenicWindowDelegate;
  46. #endif
  47. #if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
  48. class X11ExtensionDelegate;
  49. #endif
  50. // Initial properties which are passed to PlatformWindow to be initialized
  51. // with a desired set of properties.
  52. struct COMPONENT_EXPORT(PLATFORM_WINDOW) PlatformWindowInitProperties {
  53. PlatformWindowInitProperties();
  54. // Initializes properties with the specified |bounds|.
  55. explicit PlatformWindowInitProperties(const gfx::Rect& bounds);
  56. PlatformWindowInitProperties(PlatformWindowInitProperties&& props);
  57. ~PlatformWindowInitProperties();
  58. // Tells desired PlatformWindow type. It can be popup, menu or anything else.
  59. PlatformWindowType type = PlatformWindowType::kWindow;
  60. // Sets the desired initial bounds. Can be empty.
  61. gfx::Rect bounds;
  62. // Tells PlatformWindow which native widget its parent holds. It is usually
  63. // used to find a parent from internal list of PlatformWindows.
  64. gfx::AcceleratedWidget parent_widget = gfx::kNullAcceleratedWidget;
  65. // Tells the opacity type of a window. Check the comment in the
  66. // Widget::InitProperties::WindowOpacity.
  67. PlatformWindowOpacity opacity = PlatformWindowOpacity::kOpaqueWindow;
  68. #if BUILDFLAG(IS_FUCHSIA)
  69. // Scenic 3D API uses `view_token` for links, whereas Flatland
  70. // API uses `view_creation_token`. Therefore, at most one of these fields must
  71. // be set. If `allow_null_view_token_for_test` is true, they may both be
  72. // false.
  73. fuchsia::ui::views::ViewToken view_token;
  74. fuchsia::ui::views::ViewCreationToken view_creation_token;
  75. scenic::ViewRefPair view_ref_pair;
  76. // Used to coordinate window closure requests with the shell.
  77. fuchsia::element::ViewControllerPtr view_controller;
  78. // Specifies whether handling of keypress events from the system is enabled.
  79. bool enable_keyboard = false;
  80. // Specifies whether system virtual keyboard support is enabled.
  81. bool enable_virtual_keyboard = false;
  82. ScenicWindowDelegate* scenic_window_delegate = nullptr;
  83. #endif
  84. bool activatable = true;
  85. bool force_show_in_taskbar;
  86. bool keep_on_top = false;
  87. bool is_security_surface = false;
  88. bool visible_on_all_workspaces = false;
  89. bool remove_standard_frame = false;
  90. std::string workspace;
  91. ZOrderLevel z_order = ZOrderLevel::kNormal;
  92. raw_ptr<WorkspaceExtensionDelegate> workspace_extension_delegate = nullptr;
  93. PlatformWindowShadowType shadow_type = PlatformWindowShadowType::kDefault;
  94. #if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
  95. bool prefer_dark_theme = false;
  96. raw_ptr<gfx::ImageSkia> icon = nullptr;
  97. absl::optional<SkColor> background_color;
  98. // Specifies the res_name and res_class fields,
  99. // respectively, of the WM_CLASS window property. Controls window grouping
  100. // and desktop file matching in Linux window managers.
  101. std::string wm_role_name;
  102. std::string wm_class_name;
  103. std::string wm_class_class;
  104. raw_ptr<X11ExtensionDelegate> x11_extension_delegate = nullptr;
  105. // Wayland specific. Holds the application ID that is used by the window
  106. // manager to match the desktop entry and group windows.
  107. std::string wayland_app_id;
  108. // Specifies the unique session id and the restore window id.
  109. int32_t restore_session_id;
  110. absl::optional<int32_t> restore_window_id;
  111. // Specifies the source to get `restore_window_id` from.
  112. absl::optional<std::string> restore_window_id_source;
  113. #endif
  114. #if defined(USE_OZONE)
  115. // Specifies whether the current window requests key-events that matches
  116. // system shortcuts.
  117. bool inhibit_keyboard_shortcuts = false;
  118. #endif
  119. bool enable_compositing_based_throttling = false;
  120. size_t compositor_memory_limit_mb = 0;
  121. };
  122. } // namespace ui
  123. #endif // UI_PLATFORM_WINDOW_PLATFORM_WINDOW_INIT_PROPERTIES_H_