cros_display_config.mojom 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. // Copyright 2022 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. module crosapi.mojom;
  5. import "ui/gfx/geometry/mojom/geometry.mojom";
  6. import "ui/display/mojom/display.mojom";
  7. // This API is used for communication between Settings WebUI and Ash C++ code.
  8. // All points, bounds, and insets are in display pixels unless otherwise
  9. // sepcified.
  10. // SetDisplayLayoutInfo or SetDisplayProperties result.
  11. [Stable, Extensible]
  12. enum DisplayConfigResult {
  13. // CrosDisplayConfigController method call was successful.
  14. [Default] kSuccess = 0,
  15. // Operation is not supported.
  16. kInvalidOperationError,
  17. // Input display ID represents an invalid display.
  18. kInvalidDisplayIdError,
  19. // Unified desktop mode is disabled.
  20. kUnifiedNotEnabledError,
  21. // Input property for operation is out of range. E.g. display zoom factor,
  22. // bounds origin or overscan.
  23. kPropertyValueOutOfRangeError,
  24. // Operation is not supported for internal displays.
  25. kNotSupportedOnInternalDisplayError,
  26. // Negative values are not supportet for the operation.
  27. kNegativeValueError,
  28. // Setting the display mode failed.
  29. kSetDisplayModeError,
  30. // Invalid display layout error.
  31. kInvalidDisplayLayoutError,
  32. // Mode requires multiple displays.
  33. kSingleDisplayError,
  34. // Mirror mode source ID is invalid.
  35. kMirrorModeSourceIdError,
  36. // Mirror mode destination ID is invalid.
  37. kMirrorModeDestIdError,
  38. // Calibration is not available (e.g. no external touch screen device).
  39. kCalibrationNotAvailableError,
  40. // Calibration was not started.
  41. kCalibrationNotStartedError,
  42. // Touch calibration is already active.
  43. kCalibrationInProgressError,
  44. // Invalid input data for calibration.
  45. kCalibrationInvalidDataError,
  46. // Calibration procedure failed.
  47. kCalibrationFailedError,
  48. };
  49. // Describes how the displays are laid out.
  50. [Stable, Extensible]
  51. enum DisplayLayoutMode {
  52. // In normal mode displays are laid out as described by
  53. // DisplayLayoutInfo.layouts.
  54. [Default] kNormal = 0,
  55. // In unified desktop mode, a single desktop will be stretched across all
  56. // available displays.
  57. kUnified,
  58. // In mirrored mode, the display defined by DisplayLayoutInfo.mirrorSourceId
  59. // will be mirrored in the displays defined by
  60. // DisplayLayoutInfo.mirrorDestinationIds, or in all other displays if
  61. // mirrorDestinationIds is empty.
  62. kMirrored
  63. };
  64. // Describes a display edge.
  65. [Stable, Extensible]
  66. enum DisplayLayoutPosition {
  67. [Default] kTop = 0,
  68. kRight,
  69. kBottom,
  70. kLeft
  71. };
  72. // Describes an overscan or touch calibration operation.
  73. [Stable, Extensible]
  74. enum DisplayConfigOperation {
  75. // Start a calibration procedure.
  76. [Default] kStart = 0,
  77. // Adjusts the current overscan insets for a display.
  78. kAdjust,
  79. // Resets the overscan insets for a display to the last saved value.
  80. kReset,
  81. // Finish calibration procedure. Save current values and hide the overlay.
  82. kComplete,
  83. // Displays the native touch calibration.
  84. kShowNative,
  85. };
  86. // Describes who initiated configuration change.
  87. [Stable, Extensible]
  88. enum DisplayConfigSource {
  89. // Display configuration change was requested by the user.
  90. [Default] kUser = 0,
  91. // Display configuration change was requested by the policy.
  92. // Don't show notifications to confirm/revert the change.
  93. kPolicy
  94. };
  95. // Describes the options the DisplayConfigProperties.rotation and
  96. // DisplayUnitInfo.rotation_options can be set to.
  97. [Stable, Extensible]
  98. enum DisplayRotationOptions {
  99. // In physical tablet state, enables auto-rotation and clears the user
  100. // rotation lock. Otherwise, it behaves the same as kZeroDegrees.
  101. [Default] kAutoRotate = 0,
  102. // In physical tablet state, Sets the user rotation lock to 0 degrees.
  103. // Otherwise, it sets the display rotation to 0.
  104. kZeroDegrees,
  105. // In physical tablet state, Sets the user rotation lock to 90 degrees.
  106. // Otherwise, it sets the display rotation 90.
  107. k90Degrees,
  108. // In physical tablet state, Sets the user rotation lock to 180 degrees.
  109. // Otherwise, it sets the display rotation 180.
  110. k180Degrees,
  111. // In physical tablet state, Sets the user rotation lock to 270 degrees.
  112. // Otherwise, it sets the display rotation 270.
  113. k270Degrees,
  114. };
  115. // Defines a pair of display + touch points used for touch calibration.
  116. [Stable]
  117. struct TouchCalibrationPair {
  118. // The coordinates of the display point.
  119. gfx.mojom.Point display_point@0;
  120. // The coordinates of the touch point corresponding to the display point.
  121. gfx.mojom.Point touch_point@1;
  122. };
  123. // Defines the data required for touch calibration.
  124. [Stable]
  125. struct TouchCalibration {
  126. // Must contain exactly four pairs of touch calibration points.
  127. array<TouchCalibrationPair> pairs@0;
  128. // Width and height of the display area when the touch calibration was
  129. // performed.
  130. gfx.mojom.Size bounds@1;
  131. };
  132. // Defines the layout of a single display.
  133. [Stable]
  134. struct DisplayLayout {
  135. // The unique identifier of the display.
  136. string id@0;
  137. // The unique identifier of the parent display. Empty for the root display.
  138. string parent_id@1;
  139. // The edge of the display that is shared with the parent display. Ignored for
  140. // the root display.
  141. DisplayLayoutPosition position@2;
  142. // The offset of the display along the connected edge. 0 indicates that
  143. // the topmost or leftmost corner is aligned.
  144. int32 offset@3;
  145. };
  146. // Defines the layout mode and details.
  147. [Stable]
  148. struct DisplayLayoutInfo {
  149. // The layout mode to use, see DisplayLayoutMode for details.
  150. DisplayLayoutMode layout_mode@0;
  151. // Ignored if If layout_mode is not kMirrored. Otherwise, if provided,
  152. // specifies the unique identifier of the source display for mirroring. If
  153. // not provided, mirror_destination_ids will be ignored and default ('normal')
  154. // mirrored mode will be enabled.
  155. string? mirror_source_id@1;
  156. // Ignored if layout_mode is not kMirrored. Otherwise, if provided, specifies
  157. // the unique identifiers of the displays to mirror the source display. If not
  158. // provided or empty, all displays will mirror the source display.
  159. array<string>? mirror_destination_ids@2;
  160. // An array of layouts describing a directed graph of displays. Required if
  161. // layout_mode is kNormal or kMirrored and not all displays are mirrored
  162. // ('mixed' mode). Ignored if layout_mode is kUnified.
  163. array<DisplayLayout>? layouts@3;
  164. };
  165. // EDID extracted parameters. Field description refers to "VESA ENHANCED
  166. // EXTENDED DISPLAY IDENTIFICATION DATA STANDARD (Defines EDID Structure
  167. // Version 1, Revision 4)" Release A, Revision 2 September 25, 2006.
  168. // https://www.vesa.org/vesa-standards
  169. [Stable]
  170. struct Edid {
  171. // Three character manufacturer code, Sec. 3.4.1 page 21.
  172. string manufacturer_id@0;
  173. // Two byte manufacturer-assigned code, Sec. 3.4.2 page 21.
  174. string product_id@1;
  175. // Year of manufacture. Sec. 3.4.4 page 22.
  176. int32 year_of_manufacture@2;
  177. };
  178. // Struct wrapper so that the property can be optional.
  179. [Stable]
  180. struct DisplayRotation {
  181. DisplayRotationOptions rotation@0;
  182. };
  183. // Defines the properties for a display mode, i.e. a valid size and scale.
  184. [Stable]
  185. struct DisplayMode {
  186. // The display mode size in device independent (user visible) pixels.
  187. gfx.mojom.Size size@0;
  188. // The display mode size in native pixels.
  189. gfx.mojom.Size size_in_native_pixels@1;
  190. // The display mode device scale factor.
  191. double device_scale_factor@2;
  192. // The display mode refresh rate in hertz.
  193. double refresh_rate@3;
  194. // True if the mode is the display's native mode.
  195. bool is_native@4;
  196. // True if the mode is interlaced.
  197. bool is_interlaced@5;
  198. };
  199. // Defines the properties of an individual display, returned by
  200. // GetDisplayLayoutInfo.
  201. [Stable]
  202. struct DisplayUnitInfo {
  203. // The unique identifier of the display.
  204. string id@0;
  205. // The user-friendly name (e.g. "Acme LCD monitor").
  206. string name@1;
  207. // EDID properties when available.
  208. Edid? edid@2;
  209. // True if this is the primary display.
  210. bool is_primary@3;
  211. // True if this is an internal display.
  212. bool is_internal@4;
  213. // True if this display is enabled.
  214. bool is_enabled@5;
  215. // True if auto-rotation is allowed. It happens when the device is in a
  216. // physical tablet state or kSupportsClamshellAutoRotation is set.
  217. bool is_auto_rotation_allowed@6;
  218. // True if this display has a touch input device associated with it.
  219. bool has_touch_support@7;
  220. // True if this display has an accelerometer associated with it.
  221. bool has_accelerometer_support@8;
  222. // The number of pixels per inch along the x-axis.
  223. double dpi_x@9;
  224. // The number of pixels per inch along the y-axis.
  225. double dpi_y@10;
  226. // The display rotation options.
  227. DisplayRotationOptions rotation_options@11;
  228. // The display's logical bounds.
  229. gfx.mojom.Rect bounds@12;
  230. // The display's ovserscan insets within its screen's bounds.
  231. gfx.mojom.Insets overscan@13;
  232. // The usable work area of the display within the display bounds. Excludes
  233. // areas of the display reserved for the OS, e.g. the taskbar and launcher.
  234. gfx.mojom.Rect work_area@14;
  235. // The index of the selected display mode.
  236. int32 selected_display_mode_index@15;
  237. // The list of available display modes.
  238. array<DisplayMode> available_display_modes@16;
  239. // The ratio between the display's current and default zoom. i.e. 1.0 is
  240. // is equivalent to 100% zoom, and value 1.5 is equivalent to 150% zoom.
  241. double display_zoom_factor@17;
  242. // The list of allowed zoom factor values for the display.
  243. array<double> available_display_zoom_factors@18;
  244. };
  245. // Properties for configuring an individual display, used in
  246. // SetDisplayProperties.
  247. [Stable]
  248. struct DisplayConfigProperties {
  249. // If true, makes the display primary. No-op if set to false.
  250. bool set_primary@0;
  251. // If provided, sets the display's overscan insets to the provided value.
  252. // Note: overscan values may not be negative or larger than a half of the
  253. // screen's size. Overscan cannot be changed on the internal monitor.
  254. gfx.mojom.Insets? overscan@1;
  255. // If provided updates the display's rotation, or if the auto-rotation is
  256. // allowed in the device, it can be used to set or clear the user rotation
  257. // lock, enabling or disabling auto-rotation.
  258. DisplayRotation? rotation@2;
  259. // If provided, updates the display's logical bounds origin. Note: when
  260. // updating the display origin, some constraints will be applied. so the final
  261. // bounds origin may be different than the one set. The actual bounds will be
  262. // reflected in DisplayUnitInfo. Cannot be changed on the primary display (or
  263. // if set_primary is true).
  264. gfx.mojom.Point? bounds_origin@3;
  265. // If non zero, updates the zoom associated with the display. This zoom
  266. // performs relayout and repaint thus resulting in a better quality zoom than
  267. // just performing a pixel by pixel stretch enlargement.
  268. double display_zoom_factor@4;
  269. // Optional DisplayMode properties to set. This should match one of the
  270. // modes listed in DisplayUnitInfo.available_display_modes. Other custom
  271. // modes may or may not be valid.
  272. DisplayMode? display_mode@5;
  273. };
  274. // Interface for configuring displays in Chrome OS. Currently this is
  275. // implemented in Ash through classes owned by ash::Shell, but the interface
  276. // should not have any Ash specific dependencies.
  277. [Stable, Uuid="a172cdb1-c97f-4a53-9ac9-6b96c18da099"]
  278. interface CrosDisplayConfigController {
  279. // Observers are notified when the display layout or any display properties
  280. // change.
  281. AddObserver@0(pending_associated_remote<CrosDisplayConfigObserver> observer);
  282. // Returns the display layout info, including the list of layouts.
  283. GetDisplayLayoutInfo@1() => (DisplayLayoutInfo info);
  284. // Sets the layout mode, mirroring, and layouts. Returns kSuccess if the
  285. // layout is valid or an error value otherwise.
  286. SetDisplayLayoutInfo@2(DisplayLayoutInfo info) =>
  287. (DisplayConfigResult result);
  288. // Returns the properties for all displays. If |single_unified| is true, a
  289. // single display will be returned if the display layout is in unifed mode.
  290. GetDisplayUnitInfoList@3(bool single_unified) =>
  291. (array<DisplayUnitInfo> info_list);
  292. // Sets |properties| for individual display with identifier |id|. |source|
  293. // should describe who initiated the change. Returns Success if the properties
  294. // are valid or an error value otherwise.
  295. SetDisplayProperties@4(string id,
  296. DisplayConfigProperties properties,
  297. DisplayConfigSource source) =>
  298. (DisplayConfigResult result);
  299. // Enables or disables unified desktop mode. If the current display mode is
  300. // kMirrored the mode will not be changed, if it is kNormal then the mode will
  301. // be set to kUnified.
  302. SetUnifiedDesktopEnabled@5(bool enabled);
  303. // Starts, updates, completes, or resets overscan calibration for the display
  304. // with identifier |display_id|. If |op| is kAdjust, |delta| describes the
  305. // amount to change the overscan value. Runs the callback after performing the
  306. // operation or on error.
  307. OverscanCalibration@6(string display_id,
  308. DisplayConfigOperation op,
  309. gfx.mojom.Insets? delta) => (DisplayConfigResult result);
  310. // Starts, completes, or resets touch calibration for the display with
  311. // identifier |display_id|. If |op| is kShowNative shows the native
  312. // calibration UI. Runs the callback after performing the operation or on
  313. // error.
  314. TouchCalibration@7(string display_id,
  315. DisplayConfigOperation op,
  316. TouchCalibration? calibration) =>
  317. (DisplayConfigResult result);
  318. // Sets |id| of display to render identification highlight on. Invalid |id|
  319. // turns identification highlight off.
  320. HighlightDisplay@8(int64 id);
  321. // Updates preview indicators with change in position of display being dragged
  322. // in display layouts section of the display settings page. |display_id| is
  323. // the ID of the display being dragged. |delta_x| and |delta_y| are the change
  324. // in position of the dragged display since DragDisplayDelta() was last
  325. // called. |display_id| remains the same while the drag is in progress, once
  326. // the display is dropped, the new layout is applied, updating the display
  327. // configuration.
  328. DragDisplayDelta@9(int64 display_id, int32 delta_x, int32 delta_y);
  329. };
  330. // Interface for clients needing to be informed when the display configuration
  331. // changes.
  332. [Stable, Uuid="61eda0c8-63dc-49eb-ad43-02acfd48d4f5"]
  333. interface CrosDisplayConfigObserver {
  334. // Called any time the display configuration changes.
  335. OnDisplayConfigChanged@0();
  336. };